Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add handling of the removal of std::unary_function in C++17 #334

Merged
18 changes: 16 additions & 2 deletions var/spack/repos/builtin/packages/boost/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ def libs(self):
"14",
# C++17 is not supported by Boost < 1.63.0.
conditional("17", when="@1.63.0:"),
# C++20/2a is not support by Boost < 1.73.0
# C++20/2a is not supported by Boost < 1.73.0
conditional("2a", when="@1.73.0:"),
conditional("20", when="@1.77.0:"),
conditional("23", when="@1.79.0:"),
conditional("26", when="@1.79.0:"),
),
multi=False,
description="Use the specified C++ standard when building.",
Expand Down Expand Up @@ -587,10 +590,10 @@ def determine_b2_options(self, spec, options):
cxxflags = []

# Deal with C++ standard.
cxxstd = spec.variants["cxxstd"].value
if spec.satisfies("@1.66:"):
options.append("cxxstd={0}".format(spec.variants["cxxstd"].value))
else: # Add to cxxflags for older Boost.
cxxstd = spec.variants["cxxstd"].value
flag = getattr(self.compiler, "cxx{0}_flag".format(cxxstd))
if flag:
cxxflags.append(flag)
Expand All @@ -604,6 +607,17 @@ def determine_b2_options(self, spec, options):
if not spec.satisfies("@:1.70 %intel"):
cxxflags.append("-DBOOST_PARAMETER_DISABLE_PERFECT_FORWARDING")

# std::unary_function was removed in C++17 so need to set the following
# flag for building boost
if (
(cxxstd == "17")
or (cxxstd == "2a")
or (cxxstd == "20")
or (cxxstd == "23")
or (cxxstd == "26")
):
cxxflags.append("-DBOOST_NO_CXX98_FUNCTION_BASE")

# clang is not officially supported for pre-compiled headers
# and at least in clang 3.9 still fails to build
# https://www.boost.org/build/doc/html/bbv2/reference/precompiled_headers.html
Expand Down