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