diff --git a/pkgs/development/compilers/llvm/common/clang/default.nix b/pkgs/development/compilers/llvm/common/clang/default.nix index c855562acc128..289bd2df5de76 100644 --- a/pkgs/development/compilers/llvm/common/clang/default.nix +++ b/pkgs/development/compilers/llvm/common/clang/default.nix @@ -81,7 +81,7 @@ let (cd tools && ln -s ../../clang-tools-extra extra) '' + lib.optionalString (lib.versionOlder release_version "13") '' substituteInPlace tools/extra/clangd/quality/CompletionModel.cmake \ - --replace ' ''${CMAKE_SOURCE_DIR}/../clang-tools-extra' ' ''${CMAKE_SOURCE_DIR}/tools/extra' + --replace-fail ' ''${CMAKE_SOURCE_DIR}/../clang-tools-extra' ' ''${CMAKE_SOURCE_DIR}/tools/extra' '' + lib.optionalString stdenv.hostPlatform.isMusl '' sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp @@ -104,12 +104,12 @@ let moveToOutput "lib/libclang-cpp.*" "$lib" '' + (if lib.versionOlder release_version "15" then '' substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ - --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ - --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." + --replace-fail "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ + --replace-fail "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." '' else '' substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \ - --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ - --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." + --replace-fail "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ + --replace-fail "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." '') + '' '' + (if lib.versionOlder release_version "15" then '' diff --git a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix index 457c68555d11f..839aadfbae14b 100644 --- a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix @@ -148,22 +148,22 @@ stdenv.mkDerivation { postPatch = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' substituteInPlace cmake/builtin-config-ix.cmake \ - --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' + --replace-fail 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' '' + lib.optionalString (!haveLibc) ((lib.optionalString (lib.versions.major release_version == "18") '' substituteInPlace lib/builtins/aarch64/sme-libc-routines.c \ - --replace "" "" + --replace-fail "" "" '') + '' substituteInPlace lib/builtins/int_util.c \ - --replace "#include " "" + --replace-fail "#include " "" '' + (lib.optionalString (!stdenv.hostPlatform.isFreeBSD) # On FreeBSD, assert/static_assert are macros and allowing them to be implicitly declared causes link errors. # see description above for why we're nuking assert.h normally but that doesn't work here. # instead, we add the freebsd.include dependency explicitly '' substituteInPlace lib/builtins/clear_cache.c \ - --replace "#include " "" + --replace-fail "#include " "" substituteInPlace lib/builtins/cpu_model${lib.optionalString (lib.versionAtLeast release_version "18") "/x86"}.c \ - --replace "#include " "" + --replace-fail "#include " "" '')) + lib.optionalString (lib.versionAtLeast release_version "13" && lib.versionOlder release_version "14") '' # https://github.com/llvm/llvm-project/blob/llvmorg-14.0.6/libcxx/utils/merge_archives.py # Seems to only be used in v13 though it's present in v12 and v14, and dropped in v15. diff --git a/pkgs/development/compilers/llvm/common/libclc.nix b/pkgs/development/compilers/llvm/common/libclc.nix index d20e6877019b1..32a33f43c9984 100644 --- a/pkgs/development/compilers/llvm/common/libclc.nix +++ b/pkgs/development/compilers/llvm/common/libclc.nix @@ -63,20 +63,20 @@ stdenv.mkDerivation rec { postPatch = lib.optionalString (lib.versionOlder release_version "19") '' substituteInPlace CMakeLists.txt \ - --replace 'find_program( LLVM_CLANG clang PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ + --replace-fail 'find_program( LLVM_CLANG clang PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ 'find_program( LLVM_CLANG clang PATHS "${buildLlvmTools.clang.cc}/bin" NO_DEFAULT_PATH )' \ - --replace 'find_program( LLVM_AS llvm-as PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ + --replace-fail 'find_program( LLVM_AS llvm-as PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ 'find_program( LLVM_AS llvm-as PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \ - --replace 'find_program( LLVM_LINK llvm-link PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ + --replace-fail 'find_program( LLVM_LINK llvm-link PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ 'find_program( LLVM_LINK llvm-link PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \ - --replace 'find_program( LLVM_OPT opt PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ + --replace-fail 'find_program( LLVM_OPT opt PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ 'find_program( LLVM_OPT opt PATHS "${buildLlvmTools.llvm}/bin" NO_DEFAULT_PATH )' \ - --replace 'find_program( LLVM_SPIRV llvm-spirv PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ + --replace-fail 'find_program( LLVM_SPIRV llvm-spirv PATHS ''${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )' \ 'find_program( LLVM_SPIRV llvm-spirv PATHS "${spirv-llvm-translator}/bin" NO_DEFAULT_PATH )' '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' substituteInPlace CMakeLists.txt \ - --replace 'COMMAND prepare_builtins' 'COMMAND ${buildLlvmTools.libclc.dev}/bin/prepare_builtins' + --replace-fail 'COMMAND prepare_builtins' 'COMMAND ${buildLlvmTools.libclc.dev}/bin/prepare_builtins' ''; nativeBuildInputs = diff --git a/pkgs/development/compilers/llvm/common/lld/default.nix b/pkgs/development/compilers/llvm/common/lld/default.nix index 8257971c29cc8..5df98f720fce9 100644 --- a/pkgs/development/compilers/llvm/common/lld/default.nix +++ b/pkgs/development/compilers/llvm/common/lld/default.nix @@ -30,7 +30,7 @@ let '') else src; postPatch = lib.optionalString (lib.versionOlder release_version "14") '' - substituteInPlace MachO/CMakeLists.txt --replace \ + substituteInPlace MachO/CMakeLists.txt --replace-fail \ '(''${LLVM_MAIN_SRC_DIR}/' '(../' ''; in diff --git a/pkgs/development/compilers/llvm/common/llvm/default.nix b/pkgs/development/compilers/llvm/common/llvm/default.nix index 1b90522a4ebfd..aae640c4d92fd 100644 --- a/pkgs/development/compilers/llvm/common/llvm/default.nix +++ b/pkgs/development/compilers/llvm/common/llvm/default.nix @@ -139,8 +139,8 @@ stdenv.mkDerivation (finalAttrs: { postPatch = optionalString stdenv.hostPlatform.isDarwin ('' substituteInPlace cmake/modules/AddLLVM.cmake \ - --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ - --replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' "" + --replace-fail 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ + --replace-fail 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' "" '' + # As of LLVM 15, marked as XFAIL on arm64 macOS but lit doesn't seem to pick # this up: https://github.com/llvm/llvm-project/blob/c344d97a125b18f8fed0a64aace73c49a870e079/llvm/test/MC/ELF/cfi-version.ll#L7 @@ -152,10 +152,10 @@ stdenv.mkDerivation (finalAttrs: { # and thus fails under the sandbox: (if lib.versionAtLeast release_version "16" then '' substituteInPlace unittests/TargetParser/Host.cpp \ - --replace '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers" }" + --replace-fail '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers" }" '' else '' substituteInPlace unittests/Support/Host.cpp \ - --replace '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers" }" + --replace-fail '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers" }" '') + # This test tries to call the intrinsics `@llvm.roundeven.f32` and # `@llvm.roundeven.f64` which seem to (incorrectly?) lower to `roundevenf` @@ -169,25 +169,25 @@ stdenv.mkDerivation (finalAttrs: { # pass there? optionalString (lib.versionAtLeast release_version "16") '' substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \ - --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ - --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" + --replace-fail "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ + --replace-fail "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" '' + # fails when run in sandbox optionalString (!stdenv.hostPlatform.isx86 && lib.versionAtLeast release_version "18") '' substituteInPlace unittests/Support/VirtualFileSystemTest.cpp \ - --replace "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure" + --replace-fail "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure" ''))) + # dup of above patch with different conditions optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86 && lib.versionAtLeast release_version "15") (optionalString (lib.versionOlder release_version "16") '' substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \ - --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ - --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" + --replace-fail "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ + --replace-fail "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" '' + # fails when run in sandbox ((optionalString (lib.versionAtLeast release_version "18") '' substituteInPlace unittests/Support/VirtualFileSystemTest.cpp \ - --replace "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure" + --replace-fail "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure" '') + # This test fails on darwin x86_64 because `sw_vers` reports a different # macOS version than what LLVM finds by reading @@ -219,10 +219,10 @@ stdenv.mkDerivation (finalAttrs: { # TODO(@rrbutani): fix/follow-up (if lib.versionAtLeast release_version "16" then '' substituteInPlace unittests/TargetParser/Host.cpp \ - --replace "getMacOSHostVersion" "DISABLED_getMacOSHostVersion" + --replace-fail "getMacOSHostVersion" "DISABLED_getMacOSHostVersion" '' else '' substituteInPlace unittests/Support/Host.cpp \ - --replace "getMacOSHostVersion" "DISABLED_getMacOSHostVersion" + --replace-fail "getMacOSHostVersion" "DISABLED_getMacOSHostVersion" '') + # This test fails with a `dysmutil` crash; have not yet dug into what's # going on here (TODO(@rrbutani)). @@ -232,10 +232,10 @@ stdenv.mkDerivation (finalAttrs: { # FileSystem permissions tests fail with various special bits '' substituteInPlace unittests/Support/CMakeLists.txt \ - --replace "Path.cpp" "" + --replace-fail "Path.cpp" "" rm unittests/Support/Path.cpp substituteInPlace unittests/IR/CMakeLists.txt \ - --replace "PassBuilderCallbacksTest.cpp" "" + --replace-fail "PassBuilderCallbacksTest.cpp" "" rm unittests/IR/PassBuilderCallbacksTest.cpp '' + lib.optionalString (lib.versionAtLeast release_version "13") '' rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test @@ -258,7 +258,7 @@ stdenv.mkDerivation (finalAttrs: { optionalString stdenv.hostPlatform.isMusl '' patch -p1 -i ${./TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ - --replace "add_subdirectory(DynamicLibrary)" "" + --replace-fail "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp rm test/CodeGen/AArch64/wineh4.mir '' + optionalString stdenv.hostPlatform.isAarch32 '' @@ -308,8 +308,8 @@ stdenv.mkDerivation (finalAttrs: { ; do echo "PATCH: $f" substituteInPlace $f \ - --replace 'Starting llvm::' 'Starting {{.*}}' \ - --replace 'Finished llvm::' 'Finished {{.*}}' + --replace-fail 'Starting llvm::' 'Starting {{.*}}' \ + --replace-fail 'Finished llvm::' 'Finished {{.*}}' done '' + # gcc-13 fix @@ -423,14 +423,13 @@ stdenv.mkDerivation (finalAttrs: { mv $out/share/opt-viewer $python/share/opt-viewer moveToOutput "bin/llvm-config*" "$dev" substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ - --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \ - --replace "$out/bin/llvm-config" "$dev/bin/llvm-config" + --replace-fail "$out/bin/llvm-config" "$dev/bin/llvm-config" '' + (if lib.versionOlder release_version "15" then '' substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \ - --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}'"$lib"'")' + --replace-fail 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}'"$lib"'")' '' else '' substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \ - --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "'"$lib"'")' + --replace-fail 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "'"$lib"'")' '') + optionalString (stdenv.hostPlatform.isDarwin && enableSharedLibraries && lib.versionOlder release_version "18") '' ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib