Skip to content

Commit 0c8ff69

Browse files
committed
Add support for FreeBSD's LD_32_LIBRARY_PATH
Summary: Because the dynamic linker for 32-bit executables on 64-bit FreeBSD uses the environment variable `LD_32_LIBRARY_PATH` instead of `LD_LIBRARY_PATH` to find needed dynamic libraries, running the 32-bit parts of the dynamic ASan tests will fail with errors similar to: ``` ld-elf32.so.1: Shared object "libclang_rt.asan-i386.so" not found, required by "Asan-i386-inline-Dynamic-Test" ``` This adds support for setting up `LD_32_LIBRARY_PATH` for the unit and regression tests. It will likely also require a minor change to the `TestingConfig` class in `llvm/utils/lit/lit`. Reviewers: emaste, kcc, rnk, arichardson Reviewed By: arichardson Subscribers: kubamracek, krytarowski, fedor.sergeev, delcypher, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D65772 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@368516 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 85b494a commit 0c8ff69

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

test/asan/Unit/lit.site.cfg.py.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@LIT_SITE_CFG_IN_HEADER@
22

33
import os
4+
import platform
45

56
# Load common config for all compiler-rt unit tests.
67
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
@@ -10,6 +11,11 @@ def push_ld_library_path(config, new_path):
1011
(new_path, config.environment.get('LD_LIBRARY_PATH', '')))
1112
config.environment['LD_LIBRARY_PATH'] = new_ld_library_path
1213

14+
if platform.system() == 'FreeBSD':
15+
new_ld_32_library_path = os.path.pathsep.join(
16+
(new_path, config.environment.get('LD_32_LIBRARY_PATH', '')))
17+
config.environment['LD_32_LIBRARY_PATH'] = new_ld_32_library_path
18+
1319
# Setup config name.
1420
config.name = 'AddressSanitizer-Unit'
1521

test/asan/lit.cfg.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ def push_dynamic_library_lookup_path(config, new_path):
3636
(new_path, config.environment.get(dynamic_library_lookup_var, '')))
3737
config.environment[dynamic_library_lookup_var] = new_ld_library_path
3838

39+
if platform.system() == 'FreeBSD':
40+
dynamic_library_lookup_var = 'LD_32_LIBRARY_PATH'
41+
new_ld_32_library_path = os.path.pathsep.join(
42+
(new_path, config.environment.get(dynamic_library_lookup_var, '')))
43+
config.environment[dynamic_library_lookup_var] = new_ld_32_library_path
44+
3945
# Setup config name.
4046
config.name = 'AddressSanitizer' + config.name_suffix
4147

@@ -111,7 +117,7 @@ def build_invocation(compile_flags):
111117
config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) )
112118
config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) )
113119
if config.asan_dynamic:
114-
if config.host_os in ['Linux', 'NetBSD', 'SunOS']:
120+
if config.host_os in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
115121
shared_libasan_path = os.path.join(config.compiler_rt_libdir, "libclang_rt.asan{}.so".format(config.target_suffix))
116122
elif config.host_os == 'Darwin':
117123
shared_libasan_path = os.path.join(config.compiler_rt_libdir, 'libclang_rt.asan_{}_dynamic.dylib'.format(config.apple_platform))

test/xray/Unit/lit.site.cfg.py.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@LIT_SITE_CFG_IN_HEADER@
22

33
import os
4+
import platform
45

56
# Load common config for all compiler-rt unit tests.
67
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
@@ -22,3 +23,10 @@ if 'LD_LIBRARY_PATH' in os.environ:
2223
config.environment['LD_LIBRARY_PATH'] = libdirs
2324
else:
2425
config.environment['LD_LIBRARY_PATH'] = config.llvm_lib_dir
26+
27+
if platform.system() == 'FreeBSD':
28+
if 'LD_32_LIBRARY_PATH' in os.environ:
29+
libdirs = os.path.pathsep.join((config.llvm_lib_dir, os.environ['LD_32_LIBRARY_PATH']))
30+
config.environment['LD_32_LIBRARY_PATH'] = libdirs
31+
else:
32+
config.environment['LD_32_LIBRARY_PATH'] = config.llvm_lib_dir

0 commit comments

Comments
 (0)