This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Provide options for toggling on and off various runtime libraries.
Needs ReviewPublic

Authored by beanz on Jan 21 2016, 1:53 PM.

Details

Reviewers
samsonov
Summary

Trying this again after I had to back it out due to bot failures.

I believe the bot failrues were the result of the interception library getting picked up in places it shouldn't have been. This is fixed by adding the REQUIRES_INTERCEPTION list. Original code review (http://reviews.llvm.org/D14846).

Rather than having to add new "experimental" options each time someone wants to work on bringing a sanitizer to a new platform, this patch makes options for all of them.

The default values for the options are set by the platform checks that would have enabled them, but they can be overridden on or off.

Diff Detail

Event Timeline

beanz updated this revision to Diff 45591.Jan 21 2016, 1:53 PM
beanz retitled this revision from to [CMake] Provide options for toggling on and off various runtime libraries..
beanz updated this object.
beanz added a reviewer: samsonov.
beanz added a subscriber: llvm-commits.
samsonov added inline comments.Jan 21 2016, 2:33 PM
cmake/config-ix.cmake
630

I think you should do the same for "stats" library. It's not a part of sanitizer_common, it uses sanitizer_common. So, this
should be smth. like

if (OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows")
  list(APPEND DEFAULT_RUNTIMES stats)
  list(APPEND REQUIRES_COMMON stats)
endif()

and remove adding stats below from "SHOULD_BUILD_COMMON".

646

I don't fully understand how it works: you seem to add "ubsan" to COMPILER_RT_RUNTIMES_TO_BUILD always if you need sanitizer_common, which will lead to COMPILER_RT_HAS_UBSAN being true in that case. That's not true: e.g. if UBSAN_SUPPORTED_ARCH is empty you don't need to create UBSan runtime, or execute UBSan tests.

beanz added inline comments.Jan 21 2016, 2:48 PM
cmake/config-ix.cmake
630

I can make that change.

Additional explanation in my next comment.

646

I had based this on the if(COMPILER_RT_HAS_SANITIZER_COMMON) block that exists in lib/CMakeLists.txt today.

The complication is that some of these libraries (like ubsan and lsan) produce object libs even if you're not actually building the sanitizer, and those object libraries get used all over the place without checking to make sure the corresponding sanitizer is supported.

I probably need to re-think how to handle those. If you have suggestions I'd appreciate them, but I'll head back to the drawing board.

beanz updated this revision to Diff 45701.Jan 22 2016, 10:37 AM

Changed handling of lsan and ubsan to generate object libraries without building the actual runtimes.

samsonov added inline comments.Jan 22 2016, 4:21 PM
cmake/config-ix.cmake
655

Hm, do you need to remove/update this now?

lib/CMakeLists.txt
17

Looks like you have to pepper these check_list_contains code around the CMakeLists.txt now. WDYT of generating them in a single place
in config-ix.cmake, and using them as is?

foreach(runtime ${COMPILER_RT_RUNTIMES_TO_BUILD})
  string(TOUPPER ${runtime} runtime_toupper)
  set(COMPILER_RT_HAS_${runtime_toupper} True)
endforeach()

?