···11+{ lib, stdenv, llvm_meta
22+, pkgsBuildBuild
33+, monorepoSrc
44+, runCommand
55+, fetchpatch
66+, cmake
77+, darwin
88+, ninja
99+, python3
1010+, python3Packages
1111+, libffi
1212+# TODO: Gold plugin on LLVM16 has a severe memory corruption bug: https://github.com/llvm/llvm-project/issues/61350.
1313+, enableGoldPlugin ? false
1414+, libbfd
1515+, libpfm
1616+, libxml2
1717+, ncurses
1818+, version
1919+, release_version
2020+, zlib
2121+, which
2222+, sysctl
2323+, buildLlvmTools
2424+, debugVersion ? false
2525+, doCheck ? (!stdenv.isx86_32 /* TODO: why */) && (!stdenv.hostPlatform.isMusl)
2626+ && (stdenv.hostPlatform == stdenv.buildPlatform)
2727+, enableManpages ? false
2828+, enableSharedLibraries ? !stdenv.hostPlatform.isStatic
2929+, enablePFM ? stdenv.isLinux /* PFM only supports Linux */
3030+ # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
3131+ # broken for the armv7l builder
3232+ && !stdenv.hostPlatform.isAarch
3333+, enablePolly ? true
3434+} @args:
3535+3636+let
3737+ inherit (lib) optional optionals optionalString;
3838+3939+ # Used when creating a version-suffixed symlink of libLLVM.dylib
4040+ shortVersion = with lib;
4141+ concatStringsSep "." (take 1 (splitString "." release_version));
4242+4343+ # Ordinarily we would just the `doCheck` and `checkDeps` functionality
4444+ # `mkDerivation` gives us to manage our test dependencies (instead of breaking
4545+ # out `doCheck` as a package level attribute).
4646+ #
4747+ # Unfortunately `lit` does not forward `$PYTHONPATH` to children processes, in
4848+ # particular the children it uses to do feature detection.
4949+ #
5050+ # This means that python deps we add to `checkDeps` (which the python
5151+ # interpreter is made aware of via `$PYTHONPATH` – populated by the python
5252+ # setup hook) are not picked up by `lit` which causes it to skip tests.
5353+ #
5454+ # Adding `python3.withPackages (ps: [ ... ])` to `checkDeps` also doesn't work
5555+ # because this package is shadowed in `$PATH` by the regular `python3`
5656+ # package.
5757+ #
5858+ # So, we "manually" assemble one python derivation for the package to depend
5959+ # on, taking into account whether checks are enabled or not:
6060+ python = if doCheck then
6161+ # Note that we _explicitly_ ask for a python interpreter for our host
6262+ # platform here; the splicing that would ordinarily take care of this for
6363+ # us does not seem to work once we use `withPackages`.
6464+ let
6565+ checkDeps = ps: with ps; [ psutil ];
6666+ in pkgsBuildBuild.targetPackages.python3.withPackages checkDeps
6767+ else python3;
6868+6969+in
7070+ assert (lib.assertMsg (!enableGoldPlugin) "Gold plugin cannot be enabled on LLVM16 due to a upstream issue: https://github.com/llvm/llvm-project/issues/61350");
7171+ stdenv.mkDerivation (rec {
7272+ pname = "llvm";
7373+ inherit version;
7474+7575+ src = runCommand "${pname}-src-${version}" {} (''
7676+ mkdir -p "$out"
7777+ cp -r ${monorepoSrc}/cmake "$out"
7878+ cp -r ${monorepoSrc}/${pname} "$out"
7979+ cp -r ${monorepoSrc}/third-party "$out"
8080+ '' + lib.optionalString enablePolly ''
8181+ chmod u+w "$out/${pname}/tools"
8282+ cp -r ${monorepoSrc}/polly "$out/${pname}/tools"
8383+ '');
8484+8585+ sourceRoot = "${src.name}/${pname}";
8686+8787+ outputs = [ "out" "lib" "dev" "python" ];
8888+8989+ nativeBuildInputs = [ cmake ninja python ]
9090+ ++ optionals enableManpages [
9191+ # Note: we intentionally use `python3Packages` instead of `python3.pkgs`;
9292+ # splicing does *not* work with the latter. (TODO: fix)
9393+ python3Packages.sphinx python3Packages.recommonmark
9494+ ];
9595+9696+ buildInputs = [ libxml2 libffi ]
9797+ ++ optional enablePFM libpfm; # exegesis
9898+9999+ propagatedBuildInputs = [ ncurses zlib ];
100100+101101+ nativeCheckInputs = [
102102+ which
103103+ ] ++ lib.optional stdenv.isDarwin sysctl;
104104+105105+ patches = [
106106+ ./gnu-install-dirs.patch
107107+108108+ # Running the tests involves invoking binaries (like `opt`) that depend on
109109+ # the LLVM dylibs and reference them by absolute install path (i.e. their
110110+ # nix store path).
111111+ #
112112+ # Because we have not yet run the install phase (we're running these tests
113113+ # as part of `checkPhase` instead of `installCheckPhase`) these absolute
114114+ # paths do not exist yet; to work around this we point the loader (`ld` on
115115+ # unix, `dyld` on macOS) at the `lib` directory which will later become this
116116+ # package's `lib` output.
117117+ #
118118+ # Previously we would just set `LD_LIBRARY_PATH` to include the build `lib`
119119+ # dir but:
120120+ # - this doesn't generalize well to other platforms; `lit` doesn't forward
121121+ # `DYLD_LIBRARY_PATH` (macOS):
122122+ # + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26
123123+ # - even if `lit` forwarded this env var, we actually cannot set
124124+ # `DYLD_LIBRARY_PATH` in the child processes `lit` launches because
125125+ # `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for
126126+ # "protected processes" (i.e. the python interpreter that runs `lit`):
127127+ # https://stackoverflow.com/a/35570229
128128+ # - other LLVM subprojects deal with this issue by having their `lit`
129129+ # configuration set these env vars for us; it makes sense to do the same
130130+ # for LLVM:
131131+ # + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31
132132+ #
133133+ # !!! TODO: look into upstreaming this patch
134134+ ./llvm-lit-cfg-add-libs-to-dylib-path.patch
135135+136136+ # `lit` has a mode where it executes run lines as a shell script which is
137137+ # constructs; this is problematic for macOS because it means that there's
138138+ # another process in between `lit` and the binaries being tested. As noted
139139+ # above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our
140140+ # tests fail with dyld errors.
141141+ #
142142+ # To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when
143143+ # present in the test configuration.
144144+ #
145145+ # It's not clear to me why this isn't an issue for LLVM developers running
146146+ # on macOS (nothing about this _seems_ nix specific)..
147147+ ./lit-shell-script-runner-set-dyld-library-path.patch
148148+ ] ++ lib.optionals enablePolly [
149149+ ./gnu-install-dirs-polly.patch
150150+151151+ # Just like the `llvm-lit-cfg` patch, but for `polly`.
152152+ ./polly-lit-cfg-add-libs-to-dylib-path.patch
153153+ ];
154154+155155+ postPatch = optionalString stdenv.isDarwin ''
156156+ substituteInPlace cmake/modules/AddLLVM.cmake \
157157+ --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
158158+ --replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' ""
159159+160160+ # As of LLVM 15, marked as XFAIL on arm64 macOS but lit doesn't seem to pick
161161+ # this up: https://github.com/llvm/llvm-project/blob/c344d97a125b18f8fed0a64aace73c49a870e079/llvm/test/MC/ELF/cfi-version.ll#L7
162162+ rm test/MC/ELF/cfi-version.ll
163163+164164+ # This test tries to call `sw_vers` by absolute path (`/usr/bin/sw_vers`)
165165+ # and thus fails under the sandbox:
166166+ substituteInPlace unittests/Support/Host.cpp \
167167+ --replace '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers" }"
168168+ '' + optionalString (stdenv.isDarwin && stdenv.hostPlatform.isx86) ''
169169+ # This test tries to call the intrinsics `@llvm.roundeven.f32` and
170170+ # `@llvm.roundeven.f64` which seem to (incorrectly?) lower to `roundevenf`
171171+ # and `roundeven` on x86_64 macOS.
172172+ #
173173+ # However these functions are glibc specific so the test fails:
174174+ # - https://www.gnu.org/software/gnulib/manual/html_node/roundevenf.html
175175+ # - https://www.gnu.org/software/gnulib/manual/html_node/roundeven.html
176176+ #
177177+ # TODO(@rrbutani): this seems to run fine on `aarch64-darwin`, why does it
178178+ # pass there?
179179+ substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \
180180+ --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \
181181+ --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" ""
182182+183183+ # This test fails on darwin x86_64 because `sw_vers` reports a different
184184+ # macOS version than what LLVM finds by reading
185185+ # `/System/Library/CoreServices/SystemVersion.plist` (which is passed into
186186+ # the sandbox on macOS).
187187+ #
188188+ # The `sw_vers` provided by nixpkgs reports the macOS version associated
189189+ # with the `CoreFoundation` framework with which it was built. Because
190190+ # nixpkgs pins the SDK for `aarch64-darwin` and `x86_64-darwin` what
191191+ # `sw_vers` reports is not guaranteed to match the macOS version of the host
192192+ # that's building this derivation.
193193+ #
194194+ # Astute readers will note that we only _patch_ this test on aarch64-darwin
195195+ # (to use the nixpkgs provided `sw_vers`) instead of disabling it outright.
196196+ # So why does this test pass on aarch64?
197197+ #
198198+ # Well, it seems that `sw_vers` on aarch64 actually links against the _host_
199199+ # CoreFoundation framework instead of the nixpkgs provided one.
200200+ #
201201+ # Not entirely sure what the right fix is here. I'm assuming aarch64
202202+ # `sw_vers` doesn't intentionally link against the host `CoreFoundation`
203203+ # (still digging into how this ends up happening, will follow up) but that
204204+ # aside I think the more pertinent question is: should we be patching LLVM's
205205+ # macOS version detection logic to use `sw_vers` instead of reading host
206206+ # paths? This *is* a way in which details about builder machines can creep
207207+ # into the artifacts that are produced, affecting reproducibility, but it's
208208+ # not clear to me when/where/for what this even gets used in LLVM.
209209+ #
210210+ # TODO(@rrbutani): fix/follow-up
211211+ substituteInPlace unittests/Support/Host.cpp \
212212+ --replace "getMacOSHostVersion" "DISABLED_getMacOSHostVersion"
213213+214214+ # This test fails with a `dysmutil` crash; have not yet dug into what's
215215+ # going on here (TODO(@rrbutani)).
216216+ rm test/tools/dsymutil/ARM/obfuscated.test
217217+ '' + ''
218218+ # FileSystem permissions tests fail with various special bits
219219+ substituteInPlace unittests/Support/CMakeLists.txt \
220220+ --replace "Path.cpp" ""
221221+ rm unittests/Support/Path.cpp
222222+ substituteInPlace unittests/IR/CMakeLists.txt \
223223+ --replace "PassBuilderCallbacksTest.cpp" ""
224224+ rm unittests/IR/PassBuilderCallbacksTest.cpp
225225+ rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test
226226+ '' + optionalString stdenv.hostPlatform.isMusl ''
227227+ patch -p1 -i ${../../TLI-musl.patch}
228228+ substituteInPlace unittests/Support/CMakeLists.txt \
229229+ --replace "add_subdirectory(DynamicLibrary)" ""
230230+ rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
231231+ # valgrind unhappy with musl or glibc, but fails w/musl only
232232+ rm test/CodeGen/AArch64/wineh4.mir
233233+ '' + optionalString stdenv.hostPlatform.isAarch32 ''
234234+ # skip failing X86 test cases on 32-bit ARM
235235+ rm test/DebugInfo/X86/convert-debugloc.ll
236236+ rm test/DebugInfo/X86/convert-inlined.ll
237237+ rm test/DebugInfo/X86/convert-linked.ll
238238+ rm test/tools/dsymutil/X86/op-convert.test
239239+ rm test/tools/gold/X86/split-dwarf.ll
240240+ rm test/tools/llvm-dwarfdump/X86/prettyprint_types.s
241241+ rm test/tools/llvm-dwarfdump/X86/simplified-template-names.s
242242+243243+ # !!! Note: these tests are removed in LLVM 16.
244244+ #
245245+ # See here for context: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999790443
246246+ rm test/CodeGen/RISCV/rv32zbp.ll
247247+ rm test/CodeGen/RISCV/rv64zbp.ll
248248+ '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") ''
249249+ # Seems to require certain floating point hardware (NEON?)
250250+ rm test/ExecutionEngine/frem.ll
251251+ '' + ''
252252+ patchShebangs test/BugPoint/compile-custom.ll.py
253253+ '';
254254+255255+ preConfigure = ''
256256+ # Workaround for configure flags that need to have spaces
257257+ cmakeFlagsArray+=(
258258+ -DLLVM_LIT_ARGS="-svj''${NIX_BUILD_CORES} --no-progress-bar"
259259+ )
260260+ '';
261261+262262+ # Defensive check: some paths (that we make symlinks to) depend on the release
263263+ # version, for example:
264264+ # - https://github.com/llvm/llvm-project/blob/406bde9a15136254f2b10d9ef3a42033b3cb1b16/clang/lib/Headers/CMakeLists.txt#L185
265265+ #
266266+ # So we want to sure that the version in the source matches the release
267267+ # version we were given.
268268+ #
269269+ # We do this check here, in the LLVM build, because it happens early.
270270+ postConfigure = let
271271+ v = lib.versions;
272272+ major = v.major release_version;
273273+ minor = v.minor release_version;
274274+ patch = v.patch release_version;
275275+ in ''
276276+ # $1: part, $2: expected
277277+ check_version() {
278278+ part="''${1^^}"
279279+ part="$(cat include/llvm/Config/llvm-config.h | grep "#define LLVM_VERSION_''${part} " | cut -d' ' -f3)"
280280+281281+ if [[ "$part" != "$2" ]]; then
282282+ echo >&2 \
283283+ "mismatch in the $1 version! we have version ${release_version}" \
284284+ "and expected the $1 version to be '$2'; the source has '$part' instead"
285285+ exit 3
286286+ fi
287287+ }
288288+289289+ check_version major ${major}
290290+ check_version minor ${minor}
291291+ check_version patch ${patch}
292292+ '';
293293+294294+ # E.g. mesa.drivers use the build-id as a cache key (see #93946):
295295+ LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1";
296296+297297+ cmakeFlags = with stdenv; let
298298+ # These flags influence llvm-config's BuildVariables.inc in addition to the
299299+ # general build. We need to make sure these are also passed via
300300+ # CROSS_TOOLCHAIN_FLAGS_NATIVE when cross-compiling or llvm-config-native
301301+ # will return different results from the cross llvm-config.
302302+ #
303303+ # Some flags don't need to be repassed because LLVM already does so (like
304304+ # CMAKE_BUILD_TYPE), others are irrelevant to the result.
305305+ flagsForLlvmConfig = [
306306+ "-DLLVM_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/llvm"
307307+ "-DLLVM_ENABLE_RTTI=ON"
308308+ ] ++ optionals enableSharedLibraries [
309309+ "-DLLVM_LINK_LLVM_DYLIB=ON"
310310+ ];
311311+ in flagsForLlvmConfig ++ [
312312+ "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
313313+ "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
314314+ "-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}"
315315+ "-DLLVM_ENABLE_FFI=ON"
316316+ "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
317317+ "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
318318+ "-DLLVM_ENABLE_DUMP=ON"
319319+ ] ++ optionals stdenv.hostPlatform.isStatic [
320320+ # Disables building of shared libs, -fPIC is still injected by cc-wrapper
321321+ "-DLLVM_ENABLE_PIC=OFF"
322322+ "-DLLVM_BUILD_STATIC=ON"
323323+ "-DLLVM_LINK_LLVM_DYLIB=off"
324324+ # libxml2 needs to be disabled because the LLVM build system ignores its .la
325325+ # file and doesn't link zlib as well.
326326+ # https://github.com/ClangBuiltLinux/tc-build/issues/150#issuecomment-845418812
327327+ "-DLLVM_ENABLE_LIBXML2=OFF"
328328+ ] ++ optionals enableManpages [
329329+ "-DLLVM_BUILD_DOCS=ON"
330330+ "-DLLVM_ENABLE_SPHINX=ON"
331331+ "-DSPHINX_OUTPUT_MAN=ON"
332332+ "-DSPHINX_OUTPUT_HTML=OFF"
333333+ "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
334334+ ] ++ optionals (false) [
335335+ "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
336336+ ] ++ optionals isDarwin [
337337+ "-DLLVM_ENABLE_LIBCXX=ON"
338338+ "-DCAN_TARGET_i386=false"
339339+ ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
340340+ "-DCMAKE_CROSSCOMPILING=True"
341341+ "-DLLVM_TABLEGEN=${buildLlvmTools.llvm}/bin/llvm-tblgen"
342342+ (
343343+ let
344344+ nativeCC = pkgsBuildBuild.targetPackages.stdenv.cc;
345345+ nativeBintools = nativeCC.bintools.bintools;
346346+ nativeToolchainFlags = [
347347+ "-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
348348+ "-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
349349+ "-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
350350+ "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
351351+ "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
352352+ ];
353353+ # We need to repass the custom GNUInstallDirs values, otherwise CMake
354354+ # will choose them for us, leading to wrong results in llvm-config-native
355355+ nativeInstallFlags = [
356356+ "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
357357+ "-DCMAKE_INSTALL_BINDIR=${placeholder "out"}/bin"
358358+ "-DCMAKE_INSTALL_INCLUDEDIR=${placeholder "dev"}/include"
359359+ "-DCMAKE_INSTALL_LIBDIR=${placeholder "lib"}/lib"
360360+ "-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "lib"}/libexec"
361361+ ];
362362+ in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list="
363363+ + lib.concatStringsSep ";" (lib.concatLists [
364364+ flagsForLlvmConfig
365365+ nativeToolchainFlags
366366+ nativeInstallFlags
367367+ ])
368368+ )
369369+ ];
370370+371371+ postInstall = ''
372372+ mkdir -p $python/share
373373+ mv $out/share/opt-viewer $python/share/opt-viewer
374374+ moveToOutput "bin/llvm-config*" "$dev"
375375+ substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
376376+ --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \
377377+ --replace "$out/bin/llvm-config" "$dev/bin/llvm-config"
378378+ substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \
379379+ --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "'"$lib"'")'
380380+ ''
381381+ + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
382382+ ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
383383+ ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
384384+ ''
385385+ + optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
386386+ cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native
387387+ '';
388388+389389+ inherit doCheck;
390390+391391+ checkTarget = "check-all";
392392+393393+ # For the update script:
394394+ passthru.monorepoSrc = monorepoSrc;
395395+396396+ requiredSystemFeatures = [ "big-parallel" ];
397397+ meta = llvm_meta // {
398398+ homepage = "https://llvm.org/";
399399+ description = "A collection of modular and reusable compiler and toolchain technologies";
400400+ longDescription = ''
401401+ The LLVM Project is a collection of modular and reusable compiler and
402402+ toolchain technologies. Despite its name, LLVM has little to do with
403403+ traditional virtual machines. The name "LLVM" itself is not an acronym; it
404404+ is the full name of the project.
405405+ LLVM began as a research project at the University of Illinois, with the
406406+ goal of providing a modern, SSA-based compilation strategy capable of
407407+ supporting both static and dynamic compilation of arbitrary programming
408408+ languages. Since then, LLVM has grown to be an umbrella project consisting
409409+ of a number of subprojects, many of which are being used in production by
410410+ a wide variety of commercial and open source projects as well as being
411411+ widely used in academic research. Code in the LLVM project is licensed
412412+ under the "Apache 2.0 License with LLVM exceptions".
413413+ '';
414414+ };
415415+} // lib.optionalAttrs enableManpages {
416416+ pname = "llvm-manpages";
417417+418418+ propagatedBuildInputs = [];
419419+420420+ ninjaFlags = [ "docs-llvm-man" ];
421421+ installTargets = [ "install-docs-llvm-man" ];
422422+423423+ postPatch = null;
424424+ postInstall = null;
425425+426426+ outputs = [ "out" ];
427427+428428+ doCheck = false;
429429+430430+ meta = llvm_meta // {
431431+ description = "man pages for LLVM ${version}";
432432+ };
433433+})
···11+diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
22+index 0242e0b75af3..d732011306f7 100644
33+--- a/utils/lit/lit/TestRunner.py
44++++ b/utils/lit/lit/TestRunner.py
55+@@ -1029,6 +1029,12 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
66+ f.write('@echo off\n')
77+ f.write('\n@if %ERRORLEVEL% NEQ 0 EXIT\n'.join(commands))
88+ else:
99++ # This env var is *purged* when invoking subprocesses so we have to
1010++ # manually set it from within the bash script in order for the commands
1111++ # in run lines to see this var:
1212++ if "DYLD_LIBRARY_PATH" in test.config.environment:
1313++ f.write(f'export DYLD_LIBRARY_PATH="{test.config.environment["DYLD_LIBRARY_PATH"]}"\n')
1414++
1515+ for i, ln in enumerate(commands):
1616+ match = re.match(kPdbgRegex, ln)
1717+ if match: