-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
llvmPackages_15.llvm: run the tests on macOS
there are a few parts to this: - adding darwin specific check deps - working around referencing LLVM dylibs during the checkPhase in a way that supports darwin + previously we just set `$LD_LIBRARY_PATH` and/or made some strategic symlinks + now we have LLVM's `lit` config set the appropriate env vars as needed (as is done for other LLVM subprojects) + in retrospect switching to `installCheckPhase` might have been the better move.. - patching `lit` to deal with `$DYLD_LIBRARY_PATH` being purged for new "protected" processes more details within.
- Loading branch information
Showing
4 changed files
with
180 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
pkgs/development/compilers/llvm/15/llvm/lit-shell-script-runner-set-dyld-library-path.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py | ||
index 0242e0b75af3..d732011306f7 100644 | ||
--- a/utils/lit/lit/TestRunner.py | ||
+++ b/utils/lit/lit/TestRunner.py | ||
@@ -1029,6 +1029,12 @@ def executeScript(test, litConfig, tmpBase, commands, cwd): | ||
f.write('@echo off\n') | ||
f.write('\n@if %ERRORLEVEL% NEQ 0 EXIT\n'.join(commands)) | ||
else: | ||
+ # This env var is *purged* when invoking subprocesses so we have to | ||
+ # manually set it from within the bash script in order for the commands | ||
+ # in run lines to see this var: | ||
+ if "DYLD_LIBRARY_PATH" in test.config.environment: | ||
+ f.write(f'export DYLD_LIBRARY_PATH="{test.config.environment["DYLD_LIBRARY_PATH"]}"\n') | ||
+ | ||
for i, ln in enumerate(commands): | ||
match = re.match(kPdbgRegex, ln) | ||
if match: | ||
@@ -1363,7 +1369,7 @@ def applySubstitutions(script, substitutions, conditions={}, | ||
return processed | ||
|
||
process = processLine if recursion_limit is None else processLineToFixedPoint | ||
- | ||
+ | ||
return [unescapePercents(process(ln)) for ln in script] | ||
|
||
|
79 changes: 79 additions & 0 deletions
79
pkgs/development/compilers/llvm/15/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
diff --git a/test/Unit/lit.cfg.py b/test/Unit/lit.cfg.py | ||
index 81e8dc04acea..479ff95681e2 100644 | ||
--- a/test/Unit/lit.cfg.py | ||
+++ b/test/Unit/lit.cfg.py | ||
@@ -3,6 +3,7 @@ | ||
# Configuration file for the 'lit' test runner. | ||
|
||
import os | ||
+import platform | ||
import subprocess | ||
|
||
import lit.formats | ||
@@ -55,3 +56,26 @@ if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir): | ||
# Win32 may use %SYSTEMDRIVE% during file system shell operations, so propogate. | ||
if sys.platform == 'win32' and 'SYSTEMDRIVE' in os.environ: | ||
config.environment['SYSTEMDRIVE'] = os.environ['SYSTEMDRIVE'] | ||
+ | ||
+# Add the LLVM dynamic libs to the platform-specific loader search path env var: | ||
+# | ||
+# TODO: this is copied from `clang`'s `lit.cfg.py`; should unify.. | ||
+def find_shlibpath_var(): | ||
+ if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'OpenBSD', 'SunOS']: | ||
+ yield 'LD_LIBRARY_PATH' | ||
+ elif platform.system() == 'Darwin': | ||
+ yield 'DYLD_LIBRARY_PATH' | ||
+ elif platform.system() == 'Windows': | ||
+ yield 'PATH' | ||
+ elif platform.system() == 'AIX': | ||
+ yield 'LIBPATH' | ||
+ | ||
+for shlibpath_var in find_shlibpath_var(): | ||
+ shlibpath = os.path.pathsep.join( | ||
+ (config.shlibdir, | ||
+ 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())) | ||
diff --git a/test/lit.cfg.py b/test/lit.cfg.py | ||
index 75a38b4c5dad..856fc75c9d74 100644 | ||
--- a/test/lit.cfg.py | ||
+++ b/test/lit.cfg.py | ||
@@ -42,6 +42,26 @@ llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True) | ||
llvm_config.with_system_environment( | ||
['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP']) | ||
|
||
+# Add the LLVM dynamic libs to the platform-specific loader search path env var: | ||
+# | ||
+# TODO: this is copied from `clang`'s `lit.cfg.py`; should unify.. | ||
+def find_shlibpath_var(): | ||
+ if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'OpenBSD', 'SunOS']: | ||
+ yield 'LD_LIBRARY_PATH' | ||
+ elif platform.system() == 'Darwin': | ||
+ yield 'DYLD_LIBRARY_PATH' | ||
+ elif platform.system() == 'Windows': | ||
+ yield 'PATH' | ||
+ elif platform.system() == 'AIX': | ||
+ yield 'LIBPATH' | ||
+ | ||
+for shlibpath_var in find_shlibpath_var(): | ||
+ shlibpath = config.llvm_shlib_dir | ||
+ llvm_config.with_environment(shlibpath_var, shlibpath, append_path = True) | ||
+ break | ||
+else: | ||
+ lit_config.warning("unable to inject shared library path on '{}'" | ||
+ .format(platform.system())) | ||
|
||
# Set up OCAMLPATH to include newly built OCaml libraries. | ||
top_ocaml_lib = os.path.join(config.llvm_lib_dir, 'ocaml') | ||
@@ -318,7 +338,7 @@ def have_cxx_shared_library(): | ||
|
||
try: | ||
readobj_cmd = subprocess.Popen( | ||
- [readobj_exe, '--needed-libs', readobj_exe], stdout=subprocess.PIPE) | ||
+ [readobj_exe, '--needed-libs', readobj_exe], stdout=subprocess.PIPE, env=config.environment) | ||
except OSError: | ||
print('could not exec llvm-readobj') | ||
return False |
24 changes: 24 additions & 0 deletions
24
pkgs/development/compilers/llvm/15/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/tools/polly/test/lit.cfg b/tools/polly/test/lit.cfg | ||
index 41e3a589c61e..09f3b17498b0 100644 | ||
--- a/tools/polly/test/lit.cfg | ||
+++ b/tools/polly/test/lit.cfg | ||
@@ -36,9 +36,17 @@ base_paths = [config.llvm_tools_dir, config.environment['PATH']] | ||
path = os.path.pathsep.join(base_paths + config.extra_paths) | ||
config.environment['PATH'] = path | ||
|
||
+# (Copied from polly/test/Unit/lit.cfg) | ||
+if platform.system() == 'Darwin': | ||
+ shlibpath_var = 'DYLD_LIBRARY_PATH' | ||
+elif platform.system() == 'Windows': | ||
+ shlibpath_var = 'PATH' | ||
+else: | ||
+ shlibpath_var = 'LD_LIBRARY_PATH' | ||
+ | ||
path = os.path.pathsep.join((config.llvm_libs_dir, | ||
- config.environment.get('LD_LIBRARY_PATH',''))) | ||
-config.environment['LD_LIBRARY_PATH'] = path | ||
+ config.environment.get(shlibpath_var,''))) | ||
+config.environment[shlibpath_var] = path | ||
|
||
llvm_config.use_default_substitutions() | ||
|