Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

llvmPackages: Clean up in a few ways

Changed files
+146 -166
pkgs
development
compilers
llvm
common
+5 -5
pkgs/development/compilers/llvm/common/clang/default.nix
··· 57 57 ]; 58 58 59 59 cmakeFlags = 60 - (lib.optionals (lib.versionAtLeast release_version "15") [ 61 - "-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang" 62 - ]) 63 - ++ [ 60 + [ 61 + "-DCMAKE_INSTALL_PACKAGEDIR=${placeholder "dev"}/lib/" 64 62 "-DCLANGD_BUILD_XPC=OFF" 65 63 "-DLLVM_ENABLE_RTTI=ON" 64 + (lib.cmakeBool "LLVM_INCLUDE_TESTS" finalAttrs.doCheck) 66 65 ] 67 - ++ lib.optionals (lib.versionAtLeast release_version "17") [ "-DLLVM_INCLUDE_TESTS=OFF" ] 68 66 ++ lib.optionals enableManpages [ 69 67 "-DCLANG_INCLUDE_DOCS=ON" 70 68 "-DLLVM_ENABLE_SPHINX=ON" ··· 183 181 cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin 184 182 '' 185 183 ); 184 + 185 + doCheck = false; 186 186 187 187 passthru = 188 188 {
+141 -161
pkgs/development/compilers/llvm/common/llvm/default.nix
··· 107 107 in 108 108 109 109 stdenv.mkDerivation ( 110 - rec { 110 + finalAttrs: 111 + { 111 112 inherit pname version; 112 113 113 114 src = src'; ··· 145 146 ) ncurses) 146 147 ++ [ zlib ]; 147 148 149 + nativeCheckInputs = 150 + lib.optional (lib.versionAtLeast release_version "13") which 151 + ++ lib.optional (stdenv.isDarwin && lib.versionAtLeast release_version "15") sysctl; 152 + 148 153 postPatch = 149 - optionalString stdenv.isDarwin ( 154 + '' 155 + patchShebangs test/BugPoint/compile-custom.ll.py 156 + '' 157 + + 158 + # FileSystem permissions tests fail with various special bits 159 + '' 160 + substituteInPlace unittests/Support/CMakeLists.txt \ 161 + --replace "Path.cpp" "" 162 + rm unittests/Support/Path.cpp 163 + substituteInPlace unittests/IR/CMakeLists.txt \ 164 + --replace "PassBuilderCallbacksTest.cpp" "" 165 + rm unittests/IR/PassBuilderCallbacksTest.cpp 166 + '' 167 + + 168 + # timing-based tests are trouble 169 + '' 170 + rm utils/lit/tests/googletest-timeout.py 171 + '' 172 + + 173 + # FileSystem permissions tests fail with various special bits 174 + '' 175 + substituteInPlace unittests/Support/CMakeLists.txt \ 176 + --replace "Path.cpp" "" 177 + rm unittests/Support/Path.cpp 178 + substituteInPlace unittests/IR/CMakeLists.txt \ 179 + --replace "PassBuilderCallbacksTest.cpp" "" 180 + rm unittests/IR/PassBuilderCallbacksTest.cpp 181 + '' 182 + + optionalString stdenv.isDarwin ( 150 183 '' 151 184 substituteInPlace cmake/modules/AddLLVM.cmake \ 152 185 --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ ··· 155 188 + 156 189 # As of LLVM 15, marked as XFAIL on arm64 macOS but lit doesn't seem to pick 157 190 # this up: https://github.com/llvm/llvm-project/blob/c344d97a125b18f8fed0a64aace73c49a870e079/llvm/test/MC/ELF/cfi-version.ll#L7 158 - (optionalString (lib.versionAtLeast release_version "15") ( 191 + optionalString (lib.versionAtLeast release_version "15") ( 159 192 '' 160 193 rm test/MC/ELF/cfi-version.ll 161 194 ··· 164 197 # This test tries to call `sw_vers` by absolute path (`/usr/bin/sw_vers`) 165 198 # and thus fails under the sandbox: 166 199 ( 167 - if lib.versionAtLeast release_version "16" then 168 - '' 169 - substituteInPlace unittests/TargetParser/Host.cpp \ 170 - --replace '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers"}" 171 - '' 172 - else 173 - '' 174 - substituteInPlace unittests/Support/Host.cpp \ 175 - --replace '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers"}" 176 - '' 200 + let 201 + file = 202 + if lib.versionAtLeast release_version "16" then 203 + "unittests/TargetParser/Host.cpp" 204 + else 205 + "unittests/Support/Host.cpp"; 206 + in 207 + '' 208 + substituteInPlace ${file} \ 209 + --replace \ 210 + '/usr/bin/sw_vers' \ 211 + "${builtins.toString darwin.DarwinTools + "/bin/sw_vers"}" 212 + '' 177 213 ) 178 - + 179 - # This test tries to call the intrinsics `@llvm.roundeven.f32` and 180 - # `@llvm.roundeven.f64` which seem to (incorrectly?) lower to `roundevenf` 181 - # and `roundeven` on macOS and FreeBSD. 214 + 215 + + optionalString stdenv.hostPlatform.isAarch64 ( 216 + # This test fails on darwin x86_64 because `sw_vers` reports a different 217 + # macOS version than what LLVM finds by reading 218 + # `/System/Library/CoreServices/SystemVersion.plist` (which is passed into 219 + # the sandbox on macOS). 220 + # 221 + # The `sw_vers` provided by nixpkgs reports the macOS version associated 222 + # with the `CoreFoundation` framework with which it was built. Because 223 + # nixpkgs pins the SDK for `aarch64-darwin` and `x86_64-darwin` what 224 + # `sw_vers` reports is not guaranteed to match the macOS version of the host 225 + # that's building this derivation. 226 + # 227 + # Astute readers will note that we only _patch_ this test on aarch64-darwin 228 + # (to use the nixpkgs provided `sw_vers`) instead of disabling it outright. 229 + # So why does this test pass on aarch64? 182 230 # 183 - # However these functions are glibc specific so the test fails: 184 - # - https://www.gnu.org/software/gnulib/manual/html_node/roundevenf.html 185 - # - https://www.gnu.org/software/gnulib/manual/html_node/roundeven.html 231 + # Well, it seems that `sw_vers` on aarch64 actually links against the _host_ 232 + # CoreFoundation framework instead of the nixpkgs provided one. 186 233 # 187 - # TODO(@rrbutani): this seems to run fine on `aarch64-darwin`, why does it 188 - # pass there? 189 - optionalString (lib.versionAtLeast release_version "16") '' 190 - substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \ 191 - --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ 192 - --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" 193 - '' 194 - + 195 - # fails when run in sandbox 196 - optionalString (!stdenv.hostPlatform.isx86 && lib.versionAtLeast release_version "18") '' 197 - substituteInPlace unittests/Support/VirtualFileSystemTest.cpp \ 198 - --replace "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure" 199 - '' 200 - )) 201 - ) 202 - + 203 - # dup of above patch with different conditions 204 - optionalString 205 - (stdenv.isDarwin && stdenv.hostPlatform.isx86 && lib.versionAtLeast release_version "15") 206 - ( 207 - optionalString (lib.versionOlder release_version "16") '' 208 - substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \ 209 - --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ 210 - --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" 211 - 212 - '' 213 - + 214 - # fails when run in sandbox 234 + # Not entirely sure what the right fix is here. I'm assuming aarch64 235 + # `sw_vers` doesn't intentionally link against the host `CoreFoundation` 236 + # (still digging into how this ends up happening, will follow up) but that 237 + # aside I think the more pertinent question is: should we be patching LLVM's 238 + # macOS version detection logic to use `sw_vers` instead of reading host 239 + # paths? This *is* a way in which details about builder machines can creep 240 + # into the artifacts that are produced, affecting reproducibility, but it's 241 + # not clear to me when/where/for what this even gets used in LLVM. 242 + # 243 + # TODO(@rrbutani): fix/follow-up 215 244 ( 216 - (optionalString (lib.versionAtLeast release_version "18") '' 217 - substituteInPlace unittests/Support/VirtualFileSystemTest.cpp \ 218 - --replace "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure" 219 - '') 220 - + 221 - # This test fails on darwin x86_64 because `sw_vers` reports a different 222 - # macOS version than what LLVM finds by reading 223 - # `/System/Library/CoreServices/SystemVersion.plist` (which is passed into 224 - # the sandbox on macOS). 225 - # 226 - # The `sw_vers` provided by nixpkgs reports the macOS version associated 227 - # with the `CoreFoundation` framework with which it was built. Because 228 - # nixpkgs pins the SDK for `aarch64-darwin` and `x86_64-darwin` what 229 - # `sw_vers` reports is not guaranteed to match the macOS version of the host 230 - # that's building this derivation. 231 - # 232 - # Astute readers will note that we only _patch_ this test on aarch64-darwin 233 - # (to use the nixpkgs provided `sw_vers`) instead of disabling it outright. 234 - # So why does this test pass on aarch64? 235 - # 236 - # Well, it seems that `sw_vers` on aarch64 actually links against the _host_ 237 - # CoreFoundation framework instead of the nixpkgs provided one. 238 - # 239 - # Not entirely sure what the right fix is here. I'm assuming aarch64 240 - # `sw_vers` doesn't intentionally link against the host `CoreFoundation` 241 - # (still digging into how this ends up happening, will follow up) but that 242 - # aside I think the more pertinent question is: should we be patching LLVM's 243 - # macOS version detection logic to use `sw_vers` instead of reading host 244 - # paths? This *is* a way in which details about builder machines can creep 245 - # into the artifacts that are produced, affecting reproducibility, but it's 246 - # not clear to me when/where/for what this even gets used in LLVM. 247 - # 248 - # TODO(@rrbutani): fix/follow-up 249 - ( 245 + let 246 + file = 250 247 if lib.versionAtLeast release_version "16" then 251 - '' 252 - substituteInPlace unittests/TargetParser/Host.cpp \ 253 - --replace "getMacOSHostVersion" "DISABLED_getMacOSHostVersion" 254 - '' 248 + "unittests/TargetParser/Host.cpp" 255 249 else 256 - '' 257 - substituteInPlace unittests/Support/Host.cpp \ 258 - --replace "getMacOSHostVersion" "DISABLED_getMacOSHostVersion" 259 - '' 260 - ) 261 - + 262 - # This test fails with a `dysmutil` crash; have not yet dug into what's 263 - # going on here (TODO(@rrbutani)). 264 - '' 265 - rm test/tools/dsymutil/ARM/obfuscated.test 266 - '' 250 + "unittests/Support/Host.cpp"; 251 + in 252 + '' 253 + substituteInPlace ${file} \ 254 + --replace "getMacOSHostVersion" "DISABLED_getMacOSHostVersion" 255 + '' 267 256 ) 257 + + 258 + # This test fails with a `dysmutil` crash; have not yet dug into what's 259 + # going on here (TODO(@rrbutani)). 260 + '' 261 + rm test/tools/dsymutil/ARM/obfuscated.test 262 + '' 263 + ) 268 264 ) 269 - + 270 - # FileSystem permissions tests fail with various special bits 271 - '' 272 - substituteInPlace unittests/Support/CMakeLists.txt \ 273 - --replace "Path.cpp" "" 274 - rm unittests/Support/Path.cpp 275 - substituteInPlace unittests/IR/CMakeLists.txt \ 276 - --replace "PassBuilderCallbacksTest.cpp" "" 277 - rm unittests/IR/PassBuilderCallbacksTest.cpp 278 - '' 265 + + 266 + # This test tries to call the intrinsics `@llvm.roundeven.f32` and 267 + # `@llvm.roundeven.f64` which seem to (incorrectly?) lower to `roundevenf` 268 + # and `roundeven` on macOS and FreeBSD. 269 + # 270 + # However these functions are glibc specific so the test fails: 271 + # - https://www.gnu.org/software/gnulib/manual/html_node/roundevenf.html 272 + # - https://www.gnu.org/software/gnulib/manual/html_node/roundeven.html 273 + # 274 + # TODO(@rrbutani): this seems to run fine on `aarch64-darwin`, why does it 275 + # pass there? 276 + optionalString (lib.versionAtLeast release_version "16") '' 277 + substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \ 278 + --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ 279 + --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" 280 + '' 281 + + 282 + # fails when run in sandbox 283 + optionalString (!stdenv.hostPlatform.isx86 && lib.versionAtLeast release_version "18") '' 284 + substituteInPlace unittests/Support/VirtualFileSystemTest.cpp \ 285 + --replace "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure" 286 + '' 287 + ) 279 288 + lib.optionalString (lib.versionAtLeast release_version "13") '' 280 289 rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test 281 290 '' ··· 290 299 '' 291 300 rm test/tools/llvm-objcopy/ELF/strip-preserve-atime.test 292 301 '' 293 - + lib.optionalString (lib.versionOlder release_version "17") '' 294 - 295 - '' 302 + + 303 + # valgrind unhappy with musl or glibc, but fails w/musl only 304 + optionalString stdenv.hostPlatform.isMusl '' 305 + patch -p1 -i ${./TLI-musl.patch} 306 + substituteInPlace unittests/Support/CMakeLists.txt \ 307 + --replace "add_subdirectory(DynamicLibrary)" "" 308 + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp 309 + rm test/CodeGen/AArch64/wineh4.mir 310 + '' 296 311 ) 297 - + 298 - # timing-based tests are trouble 299 - lib.optionalString 300 - (lib.versionAtLeast release_version "15" && lib.versionOlder release_version "17") 301 - '' 302 - rm utils/lit/tests/googletest-timeout.py 303 - '' 304 - + 305 - # valgrind unhappy with musl or glibc, but fails w/musl only 306 - optionalString stdenv.hostPlatform.isMusl '' 307 - patch -p1 -i ${./TLI-musl.patch} 308 - substituteInPlace unittests/Support/CMakeLists.txt \ 309 - --replace "add_subdirectory(DynamicLibrary)" "" 310 - rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp 311 - rm test/CodeGen/AArch64/wineh4.mir 312 - '' 313 312 + optionalString stdenv.hostPlatform.isAarch32 '' 314 313 # skip failing X86 test cases on 32-bit ARM 315 314 rm test/DebugInfo/X86/convert-debugloc.ll ··· 333 332 rm test/tools/llvm-libtool-darwin/L-and-l.test 334 333 rm test/ExecutionEngine/Interpreter/intrinsics.ll 335 334 '' 336 - + '' 337 - patchShebangs test/BugPoint/compile-custom.ll.py 338 - '' 339 335 + 340 336 # Tweak tests to ignore namespace part of type to support 341 337 # gcc-12: https://gcc.gnu.org/PR103598. ··· 343 339 # CHECK-NEXT: Starting llvm::Function pass manager run. 344 340 # to: 345 341 # CHECK-NEXT: Starting {{.*}}Function pass manager run. 346 - (lib.optionalString (lib.versionOlder release_version "13") ( 342 + lib.optionalString (lib.versionOlder release_version "13") ( 347 343 '' 348 344 for f in \ 349 345 test/Other/new-pass-manager.ll \ ··· 372 368 sed -i '/#include <string>/i#include <cstdint>' \ 373 369 include/llvm/DebugInfo/Symbolize/DIPrinter.h 374 370 '' 375 - )); 371 + ); 376 372 377 373 # Workaround for configure flags that need to have spaces 378 - preConfigure = 379 - if lib.versionAtLeast release_version "15" then 380 - '' 381 - cmakeFlagsArray+=( 382 - -DLLVM_LIT_ARGS="-svj''${NIX_BUILD_CORES} --no-progress-bar" 383 - ) 384 - '' 385 - else 386 - '' 387 - cmakeFlagsArray+=( 388 - -DLLVM_LIT_ARGS='-svj''${NIX_BUILD_CORES} --no-progress-bar' 389 - ) 390 - ''; 374 + preConfigure = '' 375 + cmakeFlagsArray+=( 376 + -DLLVM_LIT_ARGS='-svj''${NIX_BUILD_CORES} --no-progress-bar' 377 + ) 378 + ''; 391 379 392 380 # E.g. mesa.drivers use the build-id as a cache key (see #93946): 393 381 LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; ··· 404 392 # 405 393 # Some flags don't need to be repassed because LLVM already does so (like 406 394 # CMAKE_BUILD_TYPE), others are irrelevant to the result. 407 - flagsForLlvmConfig = 408 - ( 409 - if lib.versionOlder release_version "15" then 410 - [ "-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/" ] 411 - else 412 - [ "-DLLVM_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/llvm" ] 413 - ) 414 - ++ [ "-DLLVM_ENABLE_RTTI=ON" ] 415 - ++ optionals enableSharedLibraries [ "-DLLVM_LINK_LLVM_DYLIB=ON" ]; 395 + flagsForLlvmConfig = [ 396 + "-DLLVM_ENABLE_RTTI=ON" 397 + (lib.cmakeBool "LLVM_LINK_LLVM_DYLIB" enableSharedLibraries) 398 + (lib.optional (lib.versionOlder release_version "15") "-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/") 399 + ]; 416 400 in 417 401 flagsForLlvmConfig 418 402 ++ [ 403 + "-DCMAKE_INSTALL_PACKAGEDIR=${placeholder "dev"}/lib/" 419 404 "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc 420 - "-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}" 405 + (lib.cmakeBool "LLVM_INCLUDE_TESTS" finalAttrs.doCheck) 406 + (lib.cmakeBool "LLVM_BUILD_TESTS" finalAttrs.doCheck) 421 407 "-DLLVM_ENABLE_FFI=ON" 422 408 "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" 423 409 "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" 424 410 "-DLLVM_ENABLE_DUMP=ON" 425 411 (lib.cmakeBool "LLVM_ENABLE_TERMINFO" enableTerminfo) 426 412 ] 427 - ++ optionals (!doCheck) [ "-DLLVM_INCLUDE_TESTS=OFF" ] 428 413 ++ optionals stdenv.hostPlatform.isStatic [ 429 414 # Disables building of shared libs, -fPIC is still injected by cc-wrapper 430 415 "-DLLVM_ENABLE_PIC=OFF" ··· 450 435 ++ 451 436 optionals 452 437 ( 453 - (stdenv.hostPlatform != stdenv.buildPlatform) 438 + stdenv.hostPlatform != stdenv.buildPlatform 454 439 && !(stdenv.buildPlatform.canExecute stdenv.hostPlatform) 455 440 ) 456 441 [ ··· 603 588 unpackFile $polly_src 604 589 mv polly-* $sourceRoot/tools/polly 605 590 ''; 606 - } 607 - // lib.optionalAttrs (lib.versionAtLeast release_version "13") { 608 - nativeCheckInputs = [ 609 - which 610 - ] ++ lib.optional (stdenv.isDarwin && lib.versionAtLeast release_version "15") sysctl; 611 591 } 612 592 // lib.optionalAttrs (lib.versionOlder release_version "15") { 613 593 # hacky fix: created binaries need to be run before installation