Skip to content

llvmPackages: sed -i 's/--replace /--replace-fail /g'#356120

Merged
RossComputerGuy merged 1 commit intoNixOS:stagingfrom
pwaller:nixpkgs-replace-fail
Dec 17, 2024
Merged

llvmPackages: sed -i 's/--replace /--replace-fail /g'#356120
RossComputerGuy merged 1 commit intoNixOS:stagingfrom
pwaller:nixpkgs-replace-fail

Conversation

@pwaller
Copy link
Contributor

@pwaller pwaller commented Nov 15, 2024

Rationale: --replace is deprecated and emits warnings. If these
replacements fail it is probably better to know about it early
than the alternative of letting them silently fail
and discover some distal brokenness.

The following was removed as it has no matches in the output, at least no x86_64-linux.

    substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
      --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \

Signed-off-by: Peter Waller [email protected]

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label Nov 15, 2024
@pwaller
Copy link
Contributor Author

pwaller commented Nov 16, 2024

This found something.

substituteStream() in derivation llvm-18.1.8: ERROR: pattern \$\{_IMPORT_PREFIX\}/lib/lib doesn't match anything in file '/nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/lib/cmake/llvm/LLVMExports-release.cmake'
error: builder for '/nix/store/h33lrkhshp6bsvc5jpc3hj2vhq2q2z3d-llvm-18.1.8.drv' failed with exit code 1;
       last 10 log lines:
       > -- Installing: /nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/include/llvm/IR/IntrinsicsAArch64.h
       > -- Installing: /nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/include/llvm/IR/IntrinsicsNVPTX.h
       > -- Installing: /nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/include/llvm/IR/IntrinsicsMips.h
       > -- Installing: /nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/include/llvm/IR/IntrinsicsRISCV.h
       > -- Installing: /nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/include/llvm/IR/IntrinsicsHexagon.h
       > -- Installing: /nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/include/llvm/IR/IntrinsicEnums.inc
       > -- Installing: /nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/include/llvm/IR/IntrinsicsR600.h
       > -- Installing: /nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/lib/cmake/llvm/LLVMConfigExtensions.cmake
       > Moving /nix/store/5lmqdjyb191n4gy0zik1cxqlilmvn6zq-llvm-18.1.8/bin/llvm-config to /nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/bin/llvm-config
       > substituteStream() in derivation llvm-18.1.8: ERROR: pattern \$\{_IMPORT_PREFIX\}/lib/lib doesn't match anything in file '/nix/store/7jc77afrqsszz1frmxrcmwf0ka8j6wzx-llvm-18.1.8-dev/lib/cmake/llvm/LLVMExports-release.cmake'
       For full logs, run 'nix-store -l /nix/store/h33lrkhshp6bsvc5jpc3hj2vhq2q2z3d-llvm-18.1.8.drv'.

This commit introduced a subtle error in the replacement.

7869d16#diff-0cdba49d4ff4923a2e1d9368cc63521811510568ce3e73699fc76157fc9bb57dL143-R157

@@ -134,20 +152,19 @@ in stdenv.mkDerivation (rec {
-    substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
-      --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
+    substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
+      --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \

Looks like a second 'lib/' was retained unintentionally.

At least in llvm 18, the text "_IMPORT_PREFIX" doesn't appear, so I'm inclined to drop it.

@pwaller
Copy link
Contributor Author

pwaller commented Nov 16, 2024

Looks as though cmake has been changing it's behaviour in this area, it might not be needed anymore.
Kitware/CMake@70f36de

@pwaller pwaller force-pushed the nixpkgs-replace-fail branch from 5923ac4 to 00af4e9 Compare November 16, 2024 13:53
@ofborg ofborg bot added the 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. label Nov 17, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Nov 17, 2024
@pwaller pwaller marked this pull request as ready for review November 17, 2024 16:27
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Dec 10, 2024
Rationale: --replace is deprecated and emits warnings. If these
replacements fail it is probably better to know about it early and come
up with better fixes than the alternative of letting them silently fail
and discover some distal brokenness.

Signed-off-by: Peter Waller <[email protected]>
@pwaller pwaller force-pushed the nixpkgs-replace-fail branch from 00af4e9 to 269fdda Compare December 15, 2024 16:20
@pwaller
Copy link
Contributor Author

pwaller commented Dec 15, 2024

Rebased onto staging. One month ping. Switching this over did find some residual problems.

(also cc @emilazy who I discussed this with at some point).

@github-actions github-actions bot removed 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. labels Dec 15, 2024
Copy link
Member

@RossComputerGuy RossComputerGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 15, 2024
@ofborg ofborg bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Dec 16, 2024
@ofborg ofborg bot requested a review from RossComputerGuy December 16, 2024 01:10
@ofborg ofborg bot added the 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. label Dec 16, 2024
@ofborg ofborg bot added the 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. label Dec 16, 2024
@wegank wegank added the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. label Dec 16, 2024
@RossComputerGuy RossComputerGuy merged commit df8af49 into NixOS:staging Dec 17, 2024
@trofi
Copy link
Contributor

trofi commented Dec 17, 2024

Bisect says that 269fdda llvmPackages: sed -i 's/--replace /--replace-fail /g' broke clang_19 build in staging on x86_64-linux as:

$ nix build --no-link -f. clang_19
...
-- Installing: /nix/store/1l960hr653g85260iy49bs1vx32kndpi-clang-19.1.5/bin/hmaptool
'/nix/store/1l960hr653g85260iy49bs1vx32kndpi-clang-19.1.5/bin/cpp' -> '/nix/store/1l960hr653g85260iy49bs1vx32kndpi-clan
g-19.1.5/bin/clang'
substituteStream() in derivation clang-19.1.5: ERROR: pattern \$\{_IMPORT_PREFIX\}/lib/libclang. doesn't match anything
 in file '/nix/store/2b1vk96rbzibqcyjj3s6yvbqknxy6c50-clang-19.1.5-dev/lib/cmake/clang/ClangTargets-release.cmake'

@pwaller
Copy link
Contributor Author

pwaller commented Dec 17, 2024

Thanks for spotting. If necessary please revert or apply obvious patches, we can revisit later, but I'm not going to do so immediately. I'm afk so can't easily do so now.

@philiptaron
Copy link
Contributor

I've made an attempted fix in #366029. I'm doing a build of the clangs now to see if it's resolved it beyond clang 19.

@paparodeo
Copy link
Contributor

also has an issue building at least llvm-19 on darwin

llvm> substituteStream() in derivation llvm-19.1.6: ERROR: pattern set\(_install_rpath\ \"@loader_path/../\$\{CMAKE_INSTALL_LIBDIR\}\$\{LLVM_LIBDIR_SUFFIX\}\"\ \$\{extra_libdir\}\) doesn't match anything in f
ile 'cmake/modules/AddLLVM.cmake'

@paparodeo
Copy link
Contributor

also has an issue building at least llvm-19 on darwin

llvm> substituteStream() in derivation llvm-19.1.6: ERROR: pattern set\(_install_rpath\ \"@loader_path/../\$\{CMAKE_INSTALL_LIBDIR\}\$\{LLVM_LIBDIR_SUFFIX\}\"\ \$\{extra_libdir\}\) doesn't match anything in f
ile 'cmake/modules/AddLLVM.cmake'

doesn't match with llvm-19 or llvm-12
https://github.com/llvm/llvm-project/blob/release/12.x/llvm/cmake/modules/AddLLVM.cmake

@paparodeo paparodeo mentioned this pull request Dec 18, 2024
13 tasks
@pwaller pwaller deleted the nixpkgs-replace-fail branch December 21, 2024 10:04
pwaller added a commit to pwaller/nixpkgs that referenced this pull request Dec 21, 2024
…l.cmake

Fix up NixOS#356120 for clang 12. The failing replacement target was removed
between llvm 12.0.0 and 12.0.1.

Ref: NixOS#348568 (comment)
Ref: llvm/llvm-project@3be5dbb
Signed-off-by: Peter Waller <[email protected]>
@pwaller
Copy link
Contributor Author

pwaller commented Dec 21, 2024

Fix for LLVM 12: #367056

pwaller added a commit to pwaller/nixpkgs that referenced this pull request Dec 21, 2024
The target replacement is failing after NixOS#356120.

Currently my analysis is that it must be a vestigial replacement, if it
was failing recently and the darwin build was nonetheless happy.

I'm not a darwin user so can't easily test.

Signed-off-by: Peter Waller <[email protected]>
@pwaller
Copy link
Contributor Author

pwaller commented Dec 21, 2024

@paparodeo: Potential fix for the issue you mentioned: #367059
Apologies, I'm not a darwin user so can't easily test.

@paparodeo
Copy link
Contributor

@paparodeo: Potential fix for the issue you mentioned: #367059 Apologies, I'm not a darwin user so can't easily test.

sorry, forgot to mention that I fixed in 71d262c and it is merged into staging

@pwaller
Copy link
Contributor Author

pwaller commented Dec 21, 2024

I missed that only because it was in a PR which looked merely like a package bump, and my staging branch was only just behind. Just got a bit unlucky, thanks for fixing anyway!

alyssais pushed a commit that referenced this pull request Dec 22, 2024
…l.cmake

Fix up #356120 for clang 12. The failing replacement target was removed
between llvm 12.0.0 and 12.0.1.

Ref: #348568 (comment)
Ref: llvm/llvm-project@3be5dbb
Signed-off-by: Peter Waller <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants