From d268d6d5c52137f668dcc13d38e5f64776299f9c Mon Sep 17 00:00:00 2001 From: LLVM Packaging Team Date: Wed, 18 Oct 2017 15:37:25 +0100 Subject: [PATCH] add_symbols_versioning MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch adds a very simple linker script to version the lib's symbols and thus trying to avoid crashes if an application loads two different LLVM versions (as long as they do not share data between them). Note that we deliberately *don't* make LLVM_3.9 depend on LLVM_3.8: they're incompatible and the whole point of this patch is to tell the linker that. Author: Rebecca N. Palmer Author: Lisandro Damían Nicanor Pérez Meyer Bug-Debian: https://bugs.debian.org/848368 Gbp-Pq: Name add_symbols_versioning.patch --- cmake/modules/AddLLVM.cmake | 2 +- tools/llvm-shlib/CMakeLists.txt | 2 +- tools/llvm-shlib/simple_version_script.map | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 tools/llvm-shlib/simple_version_script.map diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index cb4171c9b..182486a9a 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -82,7 +82,7 @@ function(add_llvm_symbol_exports target_name export_file) set(native_export_file "${target_name}.exports") # FIXME: Don't write the "local:" line on OpenBSD. add_custom_command(OUTPUT ${native_export_file} - COMMAND echo "{" > ${native_export_file} + COMMAND echo "LLVM_4.0 {" > ${native_export_file} COMMAND grep -q "[[:alnum:]]" ${export_file} && echo " global:" >> ${native_export_file} || : COMMAND sed -e "s/$/;/" -e "s/^/ /" < ${export_file} >> ${native_export_file} COMMAND echo " local: *;" >> ${native_export_file} diff --git a/tools/llvm-shlib/CMakeLists.txt b/tools/llvm-shlib/CMakeLists.txt index 73b3a37b9..559ae270f 100644 --- a/tools/llvm-shlib/CMakeLists.txt +++ b/tools/llvm-shlib/CMakeLists.txt @@ -40,7 +40,7 @@ set_property(TARGET LLVM PROPERTY VERSION "1") # Append .1 to SONAME list(REMOVE_DUPLICATES LIB_NAMES) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR MINGW) # FIXME: It should be "GNU ld for elf" # GNU ld doesn't resolve symbols in the version script. - set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive) + set(LIB_NAMES -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") set(LIB_NAMES -Wl,-all_load ${LIB_NAMES}) endif() diff --git a/tools/llvm-shlib/simple_version_script.map b/tools/llvm-shlib/simple_version_script.map new file mode 100644 index 000000000..816fb3c98 --- /dev/null +++ b/tools/llvm-shlib/simple_version_script.map @@ -0,0 +1 @@ +LLVM_4.0 { global: *; }; -- 2.30.2