This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Perform configuration checks with -nodefaultlibs
ClosedPublic

Authored by smeenai on Aug 24 2016, 3:44 PM.

Details

Summary

We're compiling libc++ with -nodefaultlibs, so we should also pass this
option during the configuration checks to ensure those checks are
consistent with the actual build.

The primary motivation here is to ease cross-compilation against a
non-standard set of C++ libraries. Previously, the configuration checks
would attempt to link against the standard C++ libraries, which would
cause link failures when cross-compiling, even though the actual library
link would go through correctly (because of the use of -nodefaultlibs
and explicitly specifying any needed libraries). This is more correct
even ignoring the motivation, however.

This redoes D23791 but fixes the configuration errors in sanitizer
builds by disabling the sanitizers for the configuration checks.

Test Plan:

  • check-libcxx passes on OS X 10.11
  • check-libcxx passes on Ubuntu 16.04
  • libcxx configures correctly on Ubuntu 16.04 with LLVM_USE_SANITIZER Address, Memory, Thread, and Undefined

Did some additional testing on CentOS 7 against trunk clang:

  • check-libcxx passes with -DLLVM_USE_SANITIZER=Address
  • check-libcxx passes with -DLLVM_USE_SANITIZER=Memory
  • check-libcxx passes with -DLLVM_USE_SANITIZER=MemoryWithOrigins
  • check-libcxx passes with -DLLVM_USE_SANITIZER=Thread
  • check-libcxx with -DLLVM_USE_SANITIZER=Undefined has 24 unexpected failures both with and without this diff. Seems to be related to LLVM bug 19302, except I don't know why it's passing on the buildbots and failing locally. I can reproduce the failures on Ubuntu 16.04

Diff Detail

Event Timeline

smeenai updated this revision to Diff 69180.Aug 24 2016, 3:44 PM
smeenai retitled this revision from to [libc++] Perform configuration checks with -nodefaultlibs.
smeenai updated this object.
smeenai added reviewers: EricWF, compnerd.
smeenai added subscribers: cfe-commits, kastiglione.
compnerd added inline comments.Aug 26 2016, 8:03 AM
cmake/config-ix.cmake
18

Can we not use CMAKE_SHARED_LINKER_FLAGS instead of CMAKE_REQUIRED_LIBRARIES? It is slightly misleading.

smeenai added inline comments.Aug 26 2016, 11:52 AM
cmake/config-ix.cmake
18

That would pollute everything building a shared library, whereas this limits it to only configuration checks. I know it's misleading, but I view it similar to how target_link_libraries is also used for specifying linker flags.

Speaking of pollution though, my REQUIRED_* changes in this file will end up affecting other projects for non-standalone builds, correct? What's the best way to limit this to be libc++-only?

smeenai updated this object.Aug 26 2016, 2:44 PM
smeenai added reviewers: beanz, mclow.lists.
smeenai marked an inline comment as done.Aug 29 2016, 11:48 AM
smeenai added inline comments.
cmake/config-ix.cmake
18

Never mind. cmake automatically limits variables to the scope of the current directory, so this shouldn't pollute anything outside of libc++.

This should be good to review.

EricWF added inline comments.Aug 29 2016, 12:04 PM
cmake/config-ix.cmake
18

CMAKE_REQUIRED_LIBRARIES should still only really be used for libraries. I think CMAKE_REQUIRED_FLAGS would be a better place to put this, if not CMAKE_SHARED_LINKER_FLAGS.

smeenai added inline comments.Aug 29 2016, 1:00 PM
cmake/config-ix.cmake
18

I'm fine moving it to CMAKE_REQUIRED_FLAGS. Lemme make that change and test it out and then re-upload it.

smeenai planned changes to this revision.Aug 29 2016, 1:01 PM
smeenai updated this revision to Diff 69607.Aug 29 2016, 1:35 PM

Putting -nodefaultlibs in CMAKE_REQUIRED_FLAGS

smeenai marked an inline comment as done.Aug 29 2016, 1:37 PM
EricWF accepted this revision.Aug 29 2016, 1:53 PM
EricWF edited edge metadata.
This revision is now accepted and ready to land.Aug 29 2016, 1:53 PM
compnerd closed this revision.Aug 29 2016, 2:42 PM
compnerd edited edge metadata.

SVN r280015