Skip to content

Commit 49c0111

Browse files
authored
Statically link LLVM in gandiva (#6280)
Actually hides the llvm*/LLVM* symbols and avoids conflict with other libraries which do not hide them.
1 parent e723710 commit 49c0111

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

arrow.sh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,22 @@ case $ARCHITECTURE in
4343
_LLVM*
4444
__ZN4llvm*
4545
__ZNK4llvm*
46+
__ZTIN4llvm*
47+
__ZTSN4llvm*
48+
__ZTVN4llvm*
49+
__ZTVSt*N4llvm*
50+
__ZTTN4llvm*
51+
__ZGVN4llvm*
4652
EOF
4753
CMAKE_SHARED_LINKER_FLAGS="-Wl,-unexported_symbols_list,$PWD/no-llvm-symbols.txt"
4854
;;
49-
*) SONAME=so ;;
55+
*)
56+
SONAME=so
57+
# Symbols coming from the static libraries we link (LLVM in particular) must
58+
# not end up in the dynamic symbol table, or they interpose the LLVM shipped
59+
# with the GPU drivers.
60+
CMAKE_SHARED_LINKER_FLAGS="-Wl,--exclude-libs,ALL"
61+
;;
5062
esac
5163

5264
# Downloaded by CMake, built, and linked statically (not needed at runtime):
@@ -71,8 +83,19 @@ case $ARCHITECTURE in
7183
;;
7284
*)
7385
CLANG_EXECUTABLE="${CLANG_ROOT}/bin-safe/clang"
74-
# this patches version script to hide llvm symbols in gandiva library
75-
sed -i.deleteme '/^[[:space:]]*extern/ a \ \ \ \ \ \ llvm*; LLVM*;' "./src_tmp/cpp/src/gandiva/symbols.map"
86+
# Patch the version script to hide llvm symbols in the gandiva library, so
87+
# they cannot interpose the LLVM shipped with the GPU drivers. The patterns
88+
# inside the extern "C++" block match the *demangled* name, which covers the
89+
# llvm:: functions but not typeinfo / vtable / VTT / guard variables. The
90+
# latter are added as *mangled* patterns at top level (single leading
91+
# underscore on ELF): _ZTI (typeinfo), _ZTS (typeinfo name), _ZTV (vtable),
92+
# _ZTT (VTT), _ZGV (guard variable). _ZTVSt*N4llvm* also hides vtables for
93+
# std:: types instantiated on an llvm type (mangled _ZTVSt..., which the
94+
# _ZTVN4llvm* pattern does not match).
95+
sed -i.deleteme \
96+
-e '/^[[:space:]]*local:/ a \ \ \ \ \ \ _ZN4llvm*; _ZNK4llvm*; _ZTIN4llvm*; _ZTSN4llvm*; _ZTVN4llvm*; _ZTVSt*N4llvm*; _ZTTN4llvm*; _ZGVN4llvm*;' \
97+
-e '/^[[:space:]]*extern/ a \ \ \ \ \ \ llvm*; LLVM*;' \
98+
"./src_tmp/cpp/src/gandiva/symbols.map"
7699
;;
77100
esac
78101

@@ -117,6 +140,7 @@ cmake ./src_tmp/cpp
117140
-DCMAKE_INSTALL_PREFIX="$INSTALLROOT" \
118141
-DARROW_TENSORFLOW=ON \
119142
-DARROW_GANDIVA=ON \
143+
-DARROW_LLVM_USE_SHARED=OFF \
120144
-DARROW_COMPUTE=ON \
121145
-DARROW_DATASET=ON \
122146
-DARROW_FILESYSTEM=ON \

0 commit comments

Comments
 (0)