This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Make check_linker_flags operate via linker flags
ClosedPublic

Authored by smeenai on Oct 30 2017, 1:50 PM.

Details

Summary

check_linker_flags currently sets the *compiler* flags (via
CMAKE_REQUIRED_FLAGS), and thus implicitly relies on cmake's default
behavior of passing the compiler flags to the linker. This breaks when
cmake's build rules have been altered to not pollute the link line with
compiler flags (which can be desirable for build cleanliness). Instead,
set CMAKE_EXE_LINKER_FLAGS explicitly and use CMP0056 to ensure the
linker flags are passed along. Additionally, since we're inside a
function, we can just alter the variable directly (as the alteration
will be limited to the scope of the function) rather than saving and
restoring the old value.

Diff Detail

Repository
rL LLVM

Event Timeline

smeenai created this revision.Oct 30 2017, 1:50 PM
compnerd edited edge metadata.Oct 30 2017, 5:36 PM

LG if none of the subtree projects are negatively impacted by this.

CMakeLists.txt
20 ↗(On Diff #120884)

Since this impacts all try_compile, can you ensure that libc++ in tree builds are not impacted by this change?

compnerd accepted this revision.Oct 30 2017, 5:36 PM
This revision is now accepted and ready to land.Oct 30 2017, 5:36 PM
smeenai added inline comments.Oct 30 2017, 6:30 PM
CMakeLists.txt
20 ↗(On Diff #120884)

I confirmed that clang, LLD and libc++ all build correctly after this change.

This revision was automatically updated to reflect the committed changes.