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

Build is broken on Apple Clang 15 due to boost 1.79 #4978

Closed
jmarrec opened this issue Sep 22, 2023 · 3 comments · Fixed by #4984
Closed

Build is broken on Apple Clang 15 due to boost 1.79 #4978

jmarrec opened this issue Sep 22, 2023 · 3 comments · Fixed by #4984

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented Sep 22, 2023

Issue overview

My M1 updated Xcode while I was working. Could compile fine, then 30 minutes later I couldn't anymore.

This is due to the removal of the std::unary_function from the stdlib. https://github.com/boostorg/container_hash/blob/355603c0c2a56013d7e44f3a0952004f4f280b39/include/boost/container_hash/hash.hpp#L132

std::unary_function was deprecated in C++11 and removed in C++17, so this is just Apple Clang finally complying with the standard.
https://en.cppreference.com/w/cpp/utility/functional/unary_function

This was fixed in boost 1.81 by this commit: boostorg/container_hash@4e11c85

Current Behavior

/Users/julien/.conan/data/boost/1.79.0/_/_/package/1d4cf74eec610dd689c30a2588eba75912388924/include/boost/container_hash/hash.hpp:132:33: error: no template named 'unary_function' in namespace 'std'; did you mean '__unary_function'?
        struct hash_base : std::unary_function<T, std::size_t> {};
                           ~~~~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/unary_function.h:46:1: note: '__unary_function' declared here
using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>;

Expected Behavior

Steps to Reproduce

Compile with Apple Clang 15

Possible Solution

  • Workaround is to define BOOST_NO_CXX98_FUNCTION_BASE.
  • Fix is to upgrade to boost 1.81+, latest on conan center is 1.83.

image

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version): Mac OS, Apple Clang 15
  • Version of OpenStudio (if using an intermediate build, include SHA): develop
@jmarrec
Copy link
Collaborator Author

jmarrec commented Sep 25, 2023

BOOST_NO_CXX98_FUNCTION_BASE doesn't work.

@jmarrec
Copy link
Collaborator Author

jmarrec commented Sep 25, 2023

Updating to Boost 1.83, lots of deprecated errors due to filesystem.

@jmarrec
Copy link
Collaborator Author

jmarrec commented Sep 27, 2023

Ok, either of these works:

add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
  if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0))
    add_definitions(-DBOOST_NO_CXX98_FUNCTION_BASE)
    add_definitions(-D_HAS_AUTO_PTR_ETC=0)
  endif()

jmarrec added a commit that referenced this issue Sep 27, 2023
…ng/apple clang alike

Xcode removed auto_ptr before 10.1 (not sure when)

Xcode 15: removed unary/binary_function:
* https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes
* unary_function and binary_function are no longer provided in C++17 and newer Standard modes. They can be re-enabled with _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION.
jmarrec added a commit that referenced this issue Sep 27, 2023
Fix #4978 - adjust definitions for boost 1.79 to work with modern clang/apple clang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant