summaryrefslogtreecommitdiff
path: root/sys-devel/clang/files/5.0.2/0002-test-Fix-clang-test-for-FreeBSD-and-NetBSD.patch
blob: 1751a4f479f0f94134148a33cc4de97ead6e4cf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From 4650c277d616e5d297baf28682eb792e2e0144b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Sun, 1 Apr 2018 23:20:56 +0200
Subject: [PATCH] [test] Fix clang-test for FreeBSD and NetBSD

Lit tries to inject the shared library paths, but no action is taken
when platform.system() is not recognized, results in an environment
variable with an empty name, which is illegal.

The patch fixes this mechanism for FreeBSD and NetBSD, and gives an
warning on other platforms, so that the latecomers don't have to spend
time on debugging lit.

Thanks Zhihao Yuan for the patch!

Differential Revision: https://reviews.llvm.org/D39162

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316411 91177308-0d34-0410-b5e6-96231b3b80d8

(rebased for release_50 branch)
---
 test/Unit/lit.cfg | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/test/Unit/lit.cfg b/test/Unit/lit.cfg
index 90eb2ac604..2cabf4bba1 100644
--- a/test/Unit/lit.cfg
+++ b/test/Unit/lit.cfg
@@ -87,24 +87,23 @@ if config.test_exec_root is None:
     lit_config.load_config(config, site_cfg)
     raise SystemExit
 
-shlibpath_var = ''
-if platform.system() == 'Linux':
-    shlibpath_var = 'LD_LIBRARY_PATH'
-elif platform.system() == 'Darwin':
-    shlibpath_var = 'DYLD_LIBRARY_PATH'
-elif platform.system() == 'Windows':
-    shlibpath_var = 'PATH'
-
-# in stand-alone builds, shlibdir is clang's build tree
-# while llvm_libs_dir is installed LLVM (and possibly older clang)
-llvm_shlib_dir = getattr(config, 'shlibdir', None)
-if not llvm_shlib_dir:
-    lit_config.fatal('No shlibdir set!')
-# Point the dynamic loader at dynamic libraries in 'lib'.
-llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
-if not llvm_libs_dir:
-    lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
-                                 config.environment.get(shlibpath_var,'')))
-
-config.environment[shlibpath_var] = shlibpath
+def find_shlibpath_var():
+    if platform.system() in ['Linux', 'FreeBSD', 'NetBSD']:
+        yield 'LD_LIBRARY_PATH'
+    elif platform.system() == 'Darwin':
+        yield 'DYLD_LIBRARY_PATH'
+    elif platform.system() == 'Windows':
+        yield 'PATH'
+
+for shlibpath_var in find_shlibpath_var():
+    # in stand-alone builds, shlibdir is clang's build tree
+    # while llvm_libs_dir is installed LLVM (and possibly older clang)
+    shlibpath = os.path.pathsep.join(
+        (config.shlibdir,
+         config.llvm_libs_dir,
+         config.environment.get(shlibpath_var, '')))
+    config.environment[shlibpath_var] = shlibpath
+    break
+else:
+    lit_config.warning("unable to inject shared library path on '{}'"
+                       .format(platform.system()))
-- 
2.17.0.rc2