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

fixing definition of CXX11_ABI for gcc-like #10165

Merged
merged 3 commits into from
Dec 14, 2021

Conversation

memsharded
Copy link
Member

Changelog: Bugfix: Fix the definition of D_GLIBCXX_USE_CXX11_ABI in gcc-like compilers for CMakeToolchain and AutotoolsToolchain. Define it only to D_GLIBCXX_USE_CXX11_ABI=0 for new compilers, assuming that the default is alread 1.
Docs: Omit

Address conan-io/conan-center-index#8389

Lets see if something breaks, need to add tests.

elif libcxx == "libstdc++":

if compiler in ['clang', 'apple-clang', 'gcc']:
if libcxx == "libstdc++":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets be aware that from https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

Using the default configuration options for GCC the default value of the macro is 1 which causes the new ABI to be active, so to use the old ABI you must explicitly define the macro to 0 before including any library headers. (Be aware that some GNU/Linux distributions configure GCC 5 differently so that the default value of the macro is 0 and users must define it to 1 to enable the new ABI.)

So if we go this way, users from those distros will need to customize the CMakeToolchain, something like this:

def generate(self):
    tc = CMakeToolchain(self)
    tc.blocks["libcxx"].values["glibcxx"] = "1" if self.settings.libcxx == "libstdc++11" else "0"
    tc.generate()

There were requests to eliminate the default GLIBCXX_USE_CXX11_ABI=1, as it was raising some warnings (undefined in some compilers, but not errors), so it seems there is no perfect solution for 100% of users.

@memsharded memsharded added this to the 1.43.1 milestone Dec 13, 2021
Copy link
Contributor

@lasote lasote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a test with the generate you suggest in case someone uses a custom distro. Also, we have to document this default.

@memsharded
Copy link
Member Author

I would add a test with the generate you suggest in case someone uses a custom distro. Also, we have to document this default.

I have added tests for both CMakeToolchain and AutotoolsToolchain, probably needs to be added to Meson, but I see no trace of libcxx there, so that would need more time.

I have also added a new conf tools.gnu:define_libcxx11_abi, as it seems it would be very inconvenient for users of ConanCenter recipes, if they don't want to fork and modify those recipes, for example. What do you think?

Copy link
Contributor

@lasote lasote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Could be merged

@memsharded memsharded marked this pull request as ready for review December 14, 2021 10:38
@memsharded memsharded merged commit d0e2897 into conan-io:release/1.43 Dec 14, 2021
@memsharded memsharded deleted the hotfix/cxx11_abi branch December 14, 2021 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants