With this option one can set the default library to use if no -stdlib= is provided on compiler invocation (currently hard coded libstdc++ which remains default)
Also add explicit option -stdlib=libstdc++ to tests that require it and would fail when you choose libc++.
Details
Diff Detail
Event Timeline
Is it correct to assume that all the test case changes are needed just to make the tests pass if you set CLANG_DEFAULT_CXX_STDLIB=libc++?
I'm not really comfortable approving this patch because I've made all of one or two changes ever to the driver, but I can try to pester someone else to take a gander. It doesn't look particularly invasive to me.
One comment inline.
lib/Driver/ToolChain.cpp | ||
---|---|---|
561–564 | There are two cases where this line would get hit: (1) If the stdlib arg is an invalid library, it falls through here after printing the diagnostic Can you add a configure-time or compile time check to catch case 2? |
The direction here generally seems fine to me.
lib/Driver/ToolChain.cpp | ||
---|---|---|
549–550 | On Darwin, this default will be clobbered by the code in Darwin::TranslateArgs in ToolChains.cpp. On MIPS, this override will take no effect because GetCXXStdlibType is overridden. Perhaps we could instead default CLANG_DEFAULT_CXX_STDLIB to "", and let the tool chain pick the default if it's neither specified at configure time nor on the command line. |
Address reviewers' comments:
- check for valid CLANG_DEFAULT_CXX_STDLIB
- generalize for Darwin and Bitrig by introducing GetDefaultCXXStdlibType
- fallback to CLANG_DEFAULT_CXX_STDLIB if user choice is incorrect
Yes, most of the tests check for the correct libstdc++ include paths which are not met with libc++.
lib/Driver/ToolChain.cpp | ||
---|---|---|
549–550 | I have moved the behaviour from Darwin::TranslateArgs to Darwin::GetDefaultCXXStdlibType and added this method for Bitrig as well (which was straightforward). MIPS only allows libc++ so there is nothing the user can choose from... I would have also liked to implement this for FreeBSD and NetBSD but their default library is dependent on the system version. While this wouldn't be a problem and could be implemented in GetDefaultCXXStdlibType, this would still be overriden by CLANG_DEFAULT_CXX_STDLIB which unfortunately fails the tests in test/Driver/{freebsd.c,netbsd.c}. Is it ok to leave this for now? |
Everything about this looks reasonable to me.
Can you commit the test changes in a separate commit before committing the other changes? That way if something goes wrong the diff for the meat of the patch is a small diff.
On Darwin, this default will be clobbered by the code in Darwin::TranslateArgs in ToolChains.cpp. On MIPS, this override will take no effect because GetCXXStdlibType is overridden.
Perhaps we could instead default CLANG_DEFAULT_CXX_STDLIB to "", and let the tool chain pick the default if it's neither specified at configure time nor on the command line.