diff options
author | Dan Liew <dan@su-root.co.uk> | 2018-08-13 12:59:38 +0000 |
---|---|---|
committer | Dan Liew <dan@su-root.co.uk> | 2018-08-13 12:59:38 +0000 |
commit | a4214b789d3fa94f71514ecbbcc1eaf66a6f8357 (patch) | |
tree | 473409bd26f3f50680eed1bf85bf6a90653e8927 /cmake/Modules | |
parent | 6ede64d9baec14360789964f76630744aefdc6e2 (diff) |
[CMake] Fix bug in `add_weak_symbols()` function.
Previously the the `weak_symbols.txt` files could be modified and the
build system wouldn't update the link flags automatically. Instead the
developer had to know to reconfigure CMake manually.
This is now fixed by telling CMake that the file being used to
read weak symbols from is a configure-time dependency.
Differential Revision: https://reviews.llvm.org/D50059
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@339559 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/Modules')
-rw-r--r-- | cmake/Modules/SanitizerUtils.cmake | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake index b6312426c..8fe4baae4 100644 --- a/cmake/Modules/SanitizerUtils.cmake +++ b/cmake/Modules/SanitizerUtils.cmake @@ -51,7 +51,15 @@ endmacro() # This function is only used on Darwin, where undefined symbols must be specified # in the linker invocation. function(add_weak_symbols libname link_flags) - file(STRINGS "${COMPILER_RT_SOURCE_DIR}/lib/${libname}/weak_symbols.txt" WEAK_SYMBOLS) + set(weak_symbols_file "${COMPILER_RT_SOURCE_DIR}/lib/${libname}/weak_symbols.txt") + file(STRINGS "${weak_symbols_file}" WEAK_SYMBOLS) + # Add this file as a configure-time dependency so that changes to this + # file trigger a re-configure. This is necessary so that `${link_flags}` + # is changed when appropriate. + set_property( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + APPEND + PROPERTY CMAKE_CONFIGURE_DEPENDS "${weak_symbols_file}") set(local_link_flags ${${link_flags}}) foreach(SYMBOL ${WEAK_SYMBOLS}) set(local_link_flags ${local_link_flags} -Wl,-U,${SYMBOL}) |