This is an archive of the discontinued LLVM Phabricator instance.

Add -Wl,-color-diagnostics if a linker supports the option.
ClosedPublic

Authored by ruiu on Dec 22 2016, 12:25 AM.

Event Timeline

ruiu updated this revision to Diff 82311.Dec 22 2016, 12:25 AM
ruiu retitled this revision from to Add -Wl,-color-diagnostics if a linker supports the option..
ruiu updated this object.
ruiu added a reviewer: thakis.
ruiu added a subscriber: llvm-commits.
inglorion added inline comments.
llvm/cmake/modules/HandleLLVMOptions.cmake
592

Why not check_cxx_compiler_flag("-Wl,-color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS), analogous with check_c_compiler_flag below for -fno-function-sections? Would that allow us to avoid the dance with saving CMAKE_REQUIRED_FLAGS and restoring it to its old value?

ruiu added inline comments.Jan 3 2017, 4:49 PM
llvm/cmake/modules/HandleLLVMOptions.cmake
592

check_c_compiler_flags doesn't seem to link the result. It just compiles. So it cannot be used for testing -Wl,-something flags.

inglorion added inline comments.Jan 4 2017, 1:21 PM
llvm/cmake/modules/HandleLLVMOptions.cmake
592

To clarify, I meant using check_cxx_compiler_flag (as you're doing), but passing the flag as the first argument, rather than by setting it in CMAKE_REQUIRED_FLAGS. Are you saying that passing the flag into check_cxx_compiler_flag() does not result in linking, but setting it in CMAKE_REQUIRED_FLAGS and passing an empty string to check_cxx_compiler_flag() does?

ruiu updated this revision to Diff 83766.Jan 9 2017, 7:01 PM
  • Updated as per Bob's comment.
inglorion accepted this revision.Jan 11 2017, 12:58 PM
inglorion added a reviewer: inglorion.

Thanks! lgtm.

This revision is now accepted and ready to land.Jan 11 2017, 12:58 PM
ruiu updated this revision to Diff 84015.Jan 11 2017, 1:20 PM
ruiu edited edge metadata.

I had to revert to the previous version because check_cxx_compiler_flag
didn't actually work. check_cxx_compiler_flag doesn't seem to link, but
just compiles, so the previous check of -Wl,-color-diagnostics always
succeeded.

Alright, well, if the more elegant way doesn't work, let's ship the way that does work.

ruiu updated this revision to Diff 84030.Jan 11 2017, 2:58 PM
  • factor out the new code as a new function.

Looks good, thanks! This is ready to go.

This revision was automatically updated to reflect the committed changes.