Skip to content

use C++ compiler for linking, replaces -lstdc++ #10663

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

Closed
wants to merge 4 commits into from

Conversation

MaxKellermann
Copy link
Contributor

If at least one source is C++, ask the C++ compiler to link the executable instead of manually adding -lstdc++. The C++ compiler knows best which C++ standard library needs to be used. This is more robust, and allows non-GNU standard libraries such as libc++.

Merge lots of duplicate code from sapi/*/config.m4.  All
Darwin-specific cases have been eliminated there.
@MaxKellermann
Copy link
Contributor Author

This is a possible fix for #10641 (comment) (sanitizers currently broken with C++)

If at least one source is C++, ask the C++ compiler to link the
executable instead of manually adding `-lstdc++`.  The C++ compiler
knows best which C++ standard library needs to be used.  This is more
robust, and allows non-GNU standard libraries such as libc++.
Without this, the sanitizers are disabled on C++ sources.
@MaxKellermann
Copy link
Contributor Author

MaxKellermann commented Feb 22, 2023

macOS failure due to a bug in this PR
ASAN failure due to bug in configure.ac (see my php-internals thread). Trying to work around this by adding sanitizer flags to CXXFLAGS (cherry-picked from #10641)

@devnexen
Copy link
Member

Looks correct changes to me but prefer to double check with someone more accustomed to

@devnexen devnexen requested a review from iluuu1994 February 28, 2023 18:37
@iluuu1994
Copy link
Member

I don't know much about C++ or the linker, so I'm probably not the right guy to review this one.

@MaxKellermann MaxKellermann deleted the link_cxx branch March 7, 2023 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants