Skip to content

llvmPackages_18: init#296284

Merged
5 commits merged intoNixOS:masterfrom
ExpidusOS:feat/llvm-18
Mar 28, 2024
Merged

llvmPackages_18: init#296284
5 commits merged intoNixOS:masterfrom
ExpidusOS:feat/llvm-18

Conversation

@RossComputerGuy
Copy link
Member

@RossComputerGuy RossComputerGuy commented Mar 16, 2024

Description of changes

Closes #293866

Adding LLVM 18 to Nixpkgs, opening as a draft while I work on this.

Things done

  • Update patches
  • Test if working
  • 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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 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.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

PR #292043 which is currently in staging-next made changes to the LLVMs specifically, merging libcxxabi into libcxx.

Please start with a LLVM which has those changes when copying all the files into llvm/18

thanks.

@RossComputerGuy
Copy link
Member Author

@a-n-n-a-l-e-e Alright, I'll rebase this with that. I didn't see that since I'm at NixCon NA and there's WiFi issues here lol.

@RossComputerGuy RossComputerGuy force-pushed the feat/llvm-18 branch 2 times, most recently from 36b2de6 to bd9409f Compare March 16, 2024 01:25
@ghost
Copy link

ghost commented Mar 16, 2024

are these files copied from llvm_git or llvm_17? looks like llvm_17.

@ghost
Copy link

ghost commented Mar 16, 2024

@a-n-n-a-l-e-e Alright, I'll rebase this with that. I didn't see that since I'm at NixCon NA and there's WiFi issues here lol.

you might want to be on staging-next and then rebase to master once it merges into master because c++ code will not compile with this toolchain on master currently.

@RossComputerGuy
Copy link
Member Author

@a-n-n-a-l-e-e Yes it is copied from 17, I couldn't pull almost anything at NixCon NA but now that I'm back home, I can do that. I'll trying to do that here in a bit.

@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: haskell General-purpose, statically typed, purely functional programming language 8.has: documentation This PR adds or changes documentation 8.has: changelog This PR adds or changes release notes 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: emacs Text editor 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 6.topic: policy discussion Discuss policies to work in and around Nixpkgs 6.topic: golang Go is a high-level general purpose programming language that is statically typed and compiled. 6.topic: vim Advanced text editor 6.topic: ocaml OCaml is a general-purpose, high-level, multi-paradigm programming language. 6.topic: stdenv Standard environment 6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab labels Mar 17, 2024
@github-actions github-actions bot removed 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: haskell General-purpose, statically typed, purely functional programming language labels Mar 17, 2024
@ghost
Copy link

ghost commented Mar 25, 2024

I think that leaving libunwind as a separate component is a mistake as it is no longer supported. i think it should be combined into libcxx as it is coupled to libcxxabi i believe. have to look at this a little more tho.

I'll look into this tonight.

so i think standalone libunwind is fine libcxx just errors when LIBCXXABI_USE_LLVM_UNWINDER=ON using an external libunwind. we could try to just specify libunwind as the system unwinder, that's what we did with libcxxabi but resulted in using the wrong linker flags on darwin, but looking over the cmake files it seems less of an issue for libunwind.

so the change in libcxx/default.nix would be.
diff --git a/pkgs/development/compilers/llvm/18/libcxx/default.nix b/pkgs/development/compilers/llvm/18/libcxx/default.nix
index a865c27f4845..a071bcbf1e20 100644
--- a/pkgs/development/compilers/llvm/18/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/18/libcxx/default.nix
@@ -1,5 +1,5 @@
 { lib, stdenv, llvm_meta
-, monorepoSrc, runCommand, fetchpatch
+, monorepoSrc, runCommand
 , cmake, lndir, ninja, python3, fixDarwinDylibNames, version
 , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
 , libcxxrt, libunwind
@@ -19,10 +19,10 @@ let
   # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
   useLLVM = stdenv.hostPlatform.useLLVM or false;
 
-  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ lib.optionals (lib.versionAtLeast version "18" && !(useLLVM && !stdenv.hostPlatform.isWasm)) [
+  cxxabiCMakeFlags = [
     "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind"
   ] ++ lib.optionals stdenv.hostPlatform.isWasm [
     "-DLIBCXXABI_ENABLE_THREADS=OFF"
     "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
@@ -86,18 +86,6 @@ stdenv.mkDerivation rec {
   patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
     # https://github.com/llvm/llvm-project/issues/64226
     ./0001-darwin-10.12-mbstate_t-fix.patch
-  ] ++ lib.optionals (cxxabi == null && lib.versionAtLeast version "18") [
-    # Allow building libcxxabi alone when using LLVM unwinder
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/77610dd10454e87bb387040d2b51100a17ac5755.patch";
-      revert = true;
-      hash = "sha256-jFbC3vBY3nKfjknJ7UzaPyoy0iSYdD3+jUmOFeOaVcA=";
-    })
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/48e5b5ea92674ded69b998cf35724d9012c0f57d.patch";
-      revert = true;
-      hash = "sha256-WN63L4T3GxVozPZb6kx21AgNe4rwwSUOeeryIGsvQYY=";
-    })
   ];
 
   postPatch = ''

@RossComputerGuy
Copy link
Member Author

I think that leaving libunwind as a separate component is a mistake as it is no longer supported. i think it should be combined into libcxx as it is coupled to libcxxabi i believe. have to look at this a little more tho.

I'll look into this tonight.

so i think standalone libunwind is fine libcxx just errors when LIBCXXABI_USE_LLVM_UNWINDER=ON using an external libunwind. we could try to just specify libunwind as the system unwinder, that's what we did with libcxxabi but resulted in using the wrong linker flags on darwin, but looking over the cmake files it seems less of an issue for libunwind.
so the change in libcxx/default.nix would be.

diff --git a/pkgs/development/compilers/llvm/18/libcxx/default.nix b/pkgs/development/compilers/llvm/18/libcxx/default.nix
index a865c27f4845..a071bcbf1e20 100644
--- a/pkgs/development/compilers/llvm/18/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/18/libcxx/default.nix
@@ -1,5 +1,5 @@
 { lib, stdenv, llvm_meta
-, monorepoSrc, runCommand, fetchpatch
+, monorepoSrc, runCommand
 , cmake, lndir, ninja, python3, fixDarwinDylibNames, version
 , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
 , libcxxrt, libunwind
@@ -19,10 +19,10 @@ let
   # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
   useLLVM = stdenv.hostPlatform.useLLVM or false;
 
-  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ lib.optionals (lib.versionAtLeast version "18" && !(useLLVM && !stdenv.hostPlatform.isWasm)) [
+  cxxabiCMakeFlags = [
     "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind"
   ] ++ lib.optionals stdenv.hostPlatform.isWasm [
     "-DLIBCXXABI_ENABLE_THREADS=OFF"
     "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
@@ -86,18 +86,6 @@ stdenv.mkDerivation rec {
   patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
     # https://github.com/llvm/llvm-project/issues/64226
     ./0001-darwin-10.12-mbstate_t-fix.patch
-  ] ++ lib.optionals (cxxabi == null && lib.versionAtLeast version "18") [
-    # Allow building libcxxabi alone when using LLVM unwinder
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/77610dd10454e87bb387040d2b51100a17ac5755.patch";
-      revert = true;
-      hash = "sha256-jFbC3vBY3nKfjknJ7UzaPyoy0iSYdD3+jUmOFeOaVcA=";
-    })
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/48e5b5ea92674ded69b998cf35724d9012c0f57d.patch";
-      revert = true;
-      hash = "sha256-WN63L4T3GxVozPZb6kx21AgNe4rwwSUOeeryIGsvQYY=";
-    })
   ];
 
   postPatch = ''

Alright, I've implemented this

@RossComputerGuy
Copy link
Member Author

Just fixed a conflict.

@ghost
Copy link

ghost commented Mar 26, 2024

the libunwind change in libcxx looks like it got reverted on the last update.

@theoparis
Copy link
Contributor

I think once MLIR is added, these options should be enabled by default, with vulkan being optional.

-DMLIR_ENABLE_VULKAN_RUNNER=ON \
-DMLIR_ENABLE_SPIRV_CPU_RUNNER=ON \
-DMLIR_ENABLE_EXECUTION_ENGINE=ON \

@RossComputerGuy
Copy link
Member Author

the libunwind change in libcxx looks like it got reverted on the last update.

It looks to be present still. It was only needed for git.

@ghost
Copy link

ghost commented Mar 27, 2024

the libunwind change in libcxx looks like it got reverted on the last update.

It looks to be present still. It was only needed for git.

it should be in both. 18 is reverting two commits to make libunwind work the old way.

@RossComputerGuy
Copy link
Member Author

the libunwind change in libcxx looks like it got reverted on the last update.

It looks to be present still. It was only needed for git.

it should be in both. 18 is reverting two commits to make libunwind work the old way.

Alright, done.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

diffed changes against llvm17. looks good. missing one patch in lld but perhaps it was already incorporated upstream.

Copy link

Choose a reason for hiding this comment

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

compared to llvm17 this is missing ./add-table-base.patch. is it no longer needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe so

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

ok. diffed 18 against git. looks good except for libcxx/default.nix.

git/libcxx/default.nix is not correct and should be refreshed from the one from 18/libcxx/default.nix

also noticed that 18/libcxx/default.nix is missing a flag (comment inline) so that should be added as well.

Works after changing `git/default.nix` to use `gitRelease` instead of `officialRelease`

Wont update the version attr

```
, gitRelease ? {
    version = "15.0.0";
    rev = "a5640968f2f7485b2aa4919f5fa68fd8f23e2d1f";
    rev-version = "unstable-2022-26-07";
    sha256 = "1sh5xihdfdn2hp7ds3lkaq1bfrl4alj36gl1aidmhlw65p5rdvl7";
  }

```
@RossComputerGuy
Copy link
Member Author

Added @Artturin's update-git.py commit as they stated on Matrix.

@ghost ghost merged commit 6fb20db into NixOS:master Mar 28, 2024
@RossComputerGuy RossComputerGuy deleted the feat/llvm-18 branch March 28, 2024 14:22
@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 27, 2024
This pull request was closed.
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 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package request: llvmPackages_18

6 participants