diff --git a/var/spack/repos/builtin/packages/boost/package.py b/var/spack/repos/builtin/packages/boost/package.py index d6d0bef13d3c66..67bebe454ec5d8 100644 --- a/var/spack/repos/builtin/packages/boost/package.py +++ b/var/spack/repos/builtin/packages/boost/package.py @@ -590,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) @@ -607,6 +607,12 @@ 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