add_symbols_versioning
authorLLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Tue, 25 Apr 2017 17:46:34 +0000 (17:46 +0000)
committerSylvestre Ledru <sylvestre@debian.org>
Tue, 25 Apr 2017 17:46:34 +0000 (17:46 +0000)
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.8 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 <rebecca_palmer@zoho.com>
Author: Lisandro Damían Nicanor Pérez Meyer <lisandro@debian.org>
Bug-Debian: https://bugs.debian.org/848368

Gbp-Pq: Name add_symbols_versioning.patch

cmake/modules/AddLLVM.cmake
tools/llvm-shlib/CMakeLists.txt
tools/llvm-shlib/simple_version_script.map [new file with mode: 0644]

index a829751eca8f4d645d5a6f982ed9e0cd961aec07..c67cf64eaf7ac2fa64af958293169afb0b40d7df 100644 (file)
@@ -74,7 +74,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_3.8 {" > ${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}
index 87658019022dc7c33870e628c81c35aa3179c105..2b1a7c624aaff651a0656c487e3691385c547c53 100644 (file)
@@ -44,7 +44,7 @@ set_property(TARGET LLVM PROPERTY VERSION "1") # Append .1 to SONAME
 list(REMOVE_DUPLICATES LIB_NAMES)
 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "GNU" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "kFreeBSD") # 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 (file)
index 0000000..2b62f3c
--- /dev/null
@@ -0,0 +1 @@
+LLVM_3.8 { global: *; };