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

Abseil is built against C++17, but should be built against the lowest supported C++ standard instead #133007

Closed
4 tasks done
adamnovak opened this issue Jun 6, 2023 · 1 comment
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age

Comments

@adamnovak
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

N/A

Verification

  • My "brew doctor output" says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

I would like Homebrew to ship Abseil built with the lowest supported C++ standard, because the Abseil 20230125.3 release as packaged by Homebrew seems to have broken my builds.

What happened (include all command output)?

Right now, Homebrew's Abseil is built via CMake against C++17:

system "cmake", "-S", ".", "-B", "build",
"-DCMAKE_INSTALL_RPATH=#{rpath}",
"-DCMAKE_CXX_STANDARD=17",
"-DBUILD_SHARED_LIBS=ON",
"-DABSL_PROPAGATE_CXX_STD=ON",
*std_cmake_args

As of abseil/abseil-cpp@308bbf3, released in https://github.com/abseil/abseil-cpp/releases/tag/20230125.3, Abseil installed through CMake no longer looks at the current compiler settings in the builds of dependent projects, but consults its own installed absl/base/options.h to see what features it was built with. This is so that the Abseil headers in the dependent's build try to link against the Abseil features that are actually in the built library, and not the features that would be in it if it were built for the C++ standard currently in use.

This means that Abseil is now forward-compatible: Abseil built for C++<17 can be used in an application built for C++>=17. So af74e52 is no longer needed and much of https://discourse.brew.sh/t/abseil-and-c-revision/8641 is no longer true. But it also means that cases where you could get away with including the Abseil headers when Abseil was built with a newer C++ standard and your application is built with an older C++ standard are now caught at compile time, when the Abseil headers reach for stuff not in your application's C++ standard because they saw it during the Abseil build.

So right now, Homebrew shipping Abseil 20230125.3 built with C++17 means any user code that has a dependency or transitive dependency on Abseil needs to itself be built with C++17 or newer. Protobuf has a dependency on Abseil, so any user code with a dependency on Protobuf has to be built with C++17 or newer.

I am lazy and want to support older compilers, and I don't want to upgrade my Protobuf-using project to build on C++17.

What did you expect to happen?

Abseil should be built against the lowest C++ version that Abseil itself supports. As of Abseil 20230125.3, the Abseil headers are clever enough to remember that the Abseil library artifacts were built with an old C++ standard, and will link correctly against them even if included on a newer C++ standard.

Step-by-step reproduction instructions (by running brew commands)

N/A
@adamnovak adamnovak added the bug Reproducible Homebrew/homebrew-core bug label Jun 6, 2023
adamnovak added a commit to adamnovak/homebrew-core that referenced this issue Jun 6, 2023
This will fix Homebrew#133007 and undoes Homebrew#62803 since Abseil 20230125.3 shouldn't need
it.

I'd add a test for user code with C++17 and Abseil with C++14, but then I
wouldn't be able to get rid of the fails with GCC 5 annotation.
@carlocab
Copy link
Member

carlocab commented Jun 6, 2023

You already have an open pull request at #133008, so I'm closing this in favour of that.

For future reference: the output of brew config and brew doctor is required for all issues opened at this repository, regardless of the perceived relevance of this information.

@carlocab carlocab closed this as completed Jun 6, 2023
@github-actions github-actions bot added the outdated PR was locked due to age label Jul 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age
Projects
None yet
Development

No branches or pull requests

2 participants