Skip to content

llvmPackages_15: init at 15.0.7#194634

Merged
wegank merged 30 commits intoNixOS:masterfrom
rrbutani:feature/llvm-15
Jan 28, 2023
Merged

llvmPackages_15: init at 15.0.7#194634
wegank merged 30 commits intoNixOS:masterfrom
rrbutani:feature/llvm-15

Conversation

@rrbutani
Copy link
Copy Markdown
Contributor

@rrbutani rrbutani commented Oct 5, 2022

Note
Further work is being tracked in #213033


Description of changes

The commit messages in this PR have more details but at a high level this PR contains a few different kinds of changes:

  • introduces llvmPackages_15
  • switching to using clang from this package set to bootstrap libcxx, sidestepping some of the issues we've seen with older LLVM package sets
  • switches to ninja where possible
  • re-enables Polly by default
  • enables the LLVM tests on macOS (x86_64 and aarch64)
  • miscellaneous fixes (lldb, manpages) and updates (LLVM license, dropping some flags we don't need anymore)
  • mostly mechanical changes to make it easier to override the monorepo source used in the package set (the last two commits)

TODOs:

Checks:

  • llvmPackages_15.*
  • passthru tests
  • test cross / use as a cross compiler with this script
    • only focusing on this passing eval successfully for now
      • i.e.:
        • nix path-info --file ./test.nix --derivation
        • nix path-info --file ./test.nix --derivation --arg systems '[ "aarch64-darwin" "x86_64-darwin" ]' --arg testStdenvPackages '[]'
    • and checking that the following don't regress:
      • pkgsCross.x86_64-freebsd.boost (with llvmPackages = llvmPackages_15)
        • i.e. nix build --expr '(import ./. { system = "x86_64-linux"; overlays = [(f: p: { llvmPackages = f.llvmPackages_15; })]; }).pkgsCross.x86_64-freebsd.boost'
        • this is currently broken in libcxx
  • rdeps with nixpkgs-review
    • not applicable since we're not bumping llvmPackages_latest

Closes #191132.

Things done
  • Built on platform(s)
    • x86_64-linux
    • i686-linux
    • aarch64-linux
    • armv7l-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 22.11 Release Notes (or backporting 22.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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Oct 5, 2022
@ofborg ofborg bot requested review from 7c6f434c, dtzWill, lovek323 and primeos October 5, 2022 18:45
@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: 1001-2500 This PR causes many rebuilds on Darwin and should most likely 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: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. labels Oct 5, 2022
@ofborg ofborg bot added 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. and removed 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely 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: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. labels Oct 5, 2022
@zowoq zowoq mentioned this pull request Oct 6, 2022
13 tasks
@rrbutani rrbutani force-pushed the feature/llvm-15 branch 2 times, most recently from 79aa175 to 8484b4d Compare October 7, 2022 20:39
@rrbutani
Copy link
Copy Markdown
Contributor Author

rrbutani commented Oct 7, 2022

With ab9d3df, libcxx-abi (and the rest of llvmPackages_15) builds fine on aarch64-linux as well as x86_64-linux. Darwin is now hitting an unrelated issue in compiler-rt; I'll tackle that next.

After that:

@rrbutani rrbutani mentioned this pull request Oct 7, 2022
13 tasks
@rrbutani
Copy link
Copy Markdown
Contributor Author

rrbutani commented Oct 7, 2022

Fixed one compiler-rt build issue, hit another one.

compiler-rt's build now attempts to detect whether the ld used automatically does codesigning, based on version. Our cctools ld is too old for this but postLinkSignHook handles codesigning for us, regardless.

Unfortunately there doesn't seem to be a way to communicate this to the compiler-rt build machinery. In the interest of avoiding making another patch, I tried to add sigtool to the derivation and just let the compiler-rt build sign some dylibs twice but unfortunately compiler-rt's build uses --sign instead of -s which the sigtool in nixpkgs has not been updated to support.

I opened a PR for this (#194994) but given that sigtool has many transitive deps and that that PR is likely to trigger many rebuilds I think it's probably faster to just add a compiler-rt patch.

@rrbutani
Copy link
Copy Markdown
Contributor Author

rrbutani commented Oct 7, 2022

With 974ea1c this now builds on aarch64-darwin.

Testing x86_64-darwin now; hopefully it Just Works 🤞.


Update: lldb fails to build on x86_64-darwin; it's failing on #include <bsm/audit_session.h> and CPU_SUBTYPE_ARM64E not being present in mach/machine.h 😕

<bsm/audit_session.h>

This isn't an issue on aarch64-darwin because we use a newer SDK there:

apple_sdk = if stdenv.hostPlatform.isAarch64 then apple_sdk_11_0 else apple_sdk_10_12;

This is the change in upstream causing the issue: llvm/llvm-project@b945b62

lldb appears to only use AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS from audit_session.h which, worst case, would be easy to stub or patch out.

Fortunately, this header is available in the macOS 10.12 SDK (i.e. nixpkgs.darwin.apple_sdk.sdk.dev). Is it okay for me to depend on this header? This was the only precedent in nixpkgs I could find:

install -Dm444 "${lib.getDev apple_sdk.sdk}"/include/libproc.h "$out"/include/libproc.h

CPU_SUBTYPE_ARM64E

For CPU_SUBTYPE_ARM64E I am not sure why we're just hitting this issue now; it appears to have been added in LLVM 13? llvm/llvm-project@479b672

Edit: oh, of course; lldb is marked as broken for LLVM 13 and 14:

broken = stdenv.isDarwin; # error: use of undeclared identifier 'CPU_SUBTYPE_ARM64E'

It's not marked as broken in llvmPackages_git but I'm willing to bet that has the same issue.


Fixed in 040efed and opened #195013 to fix lldb 14 and lldb 13 on macOS x86_64.

rrbutani and others added 7 commits January 27, 2023 13:29
Details within but ultimately there isn't a satisfying resolution for
any of the three test failures we were seeing and all three deserve
further exploration.

For the `sw_vers` macOS version issue in particular, it's possible to
observe the nixpkgs provided `CoreFoundation` vs system `CoreFoundation`
for `x86_64` and `aarch64` like so (on a host running macOS `13.0.1`):

```console
$ nix-shell -p darwin.DarwinTools --system aarch64-darwin --command "sw_vers"
ProductName:    macOS
ProductVersion: 13.0.1
BuildVersion:   22A400

$ nix-shell -p darwin.DarwinTools --system x86_64-darwin --command "sw_vers"
ProductName:    Mac OS X
ProductVersion: 10.16
BuildVersion:   22A400
```

Where `/System/Library/CoreServices/SystemVersion.plist` has:
```console
$ cat /System/Library/CoreServices/SystemVersion.plist | grep ProductVersion
-A 1
	<key>ProductVersion</key>
	<string>13.0.1</string>
```

Further:
```console
$ nix-shell -p darwin.DarwinTools --system aarch64-darwin --command 'otool -L $(which sw_vers)'
/nix/store/nb2q33ak2zif49ndcpc6m823z0vhmy8y-DarwinTools-1/bin/sw_vers:
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

$ nix-shell -p darwin.DarwinTools --system x86_64-darwin --command 'otool -L $(which sw_vers)'
/nix/store/88v4kjvgwl71byfpvd0baviiq7l5appc-DarwinTools-1/bin/sw_vers:
	@rpath/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1454.90.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
```

For the `x86_64` `sw_vers` binary we can see rpath:
```console
$ nix-shell -p darwin.DarwinTools --system x86_64-darwin --command 'otool -l $(which sw_vers)' | grep LC_RPATH -A 2 -B 1
Load command 13
          cmd LC_RPATH
      cmdsize 120
         path /nix/store/zvr4wypbgskhhw9cawfn7mmxfa75nh8f-swift-corefoundation-unstable-2018-09-14/Library/Frameworks (offset 12)
```

And we can confirm that the nixpkgs provided `CoreFoundation` is what
ultimately gets loaded:
```console
$ nix-shell -p darwin.DarwinTools --system x86_64-darwin --command 'DYLD_PRINT_LIBRARIES=1 sw_vers'
dyld[16215]: <no uuid> /nix/store/88v4kjvgwl71byfpvd0baviiq7l5appc-DarwinTools-1/bin/sw_vers
dyld[16215]: <no uuid> /nix/store/zvr4wypbgskhhw9cawfn7mmxfa75nh8f-swift-corefoundation-unstable-2018-09-14/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld[16215]: <no uuid> /nix/store/xd2a4xh8kdwq0j67hzgw720npdw5hzkk-ICU-66108/lib/libicucore.A.dylib
<snipped>
```

```bash
nix-diff \
    $(nix path-info nixpkgs#legacyPackages.aarch64-darwin.darwin.DarwinTools --derivation) \
    $(nix path-info nixpkgs#legacyPackages.x86_64-darwin.darwin.DarwinTools --derivation)
```
doesn't show any _obvious_ discrepancies
see this thread for context: NixOS#194634 (comment)

Co-authored-by: misuzu <bakalolka@gmail.com>
…lation

The two scenarios described within where splicing doesn't handle
selecting the right package for us are observable in the following
(nix repl session):
```
> np = import <nixpkgs> { system = "x86_64-linux"; crossSystem = { config = "aarch64-linux"; }; }

> np.__splicedPackages.hello ? __spliced
true

> np.__splicedPackages.python3Packages.psutil ? __spliced
true

> np.__splicedPackages.python3.pkgs.psutil ? __spliced
false

> (np.__splicedPackages.python3.withPackages (ps: with ps; [psutil])) ? __spliced
false
```

See: NixOS#211340
the tests still don't all pass so `doCheck` is still disabled
@rrbutani
Copy link
Copy Markdown
Contributor Author

rrbutani commented Jan 27, 2023

Apologies for the delay, again.

I couldn't reproduce #193636 (the test case in #151879 passes and I don't see the extra header dirs on macOS or Linux) so I think this PR is pretty much ready.

I'm waiting on builds to finish for:

  • aarch64-linux
  • aarch64-darwin
  • x86_64-linux
  • x86_64-darwin
  • i686-linux
  • armv7l-linux
    • building on a Pi so this will take me a while; if anyone has access to a machine capable of running 32-bit ARM code (like the nix community aarch64 build box) and is willing to test building the package set it'd be much appreciated!

Additionally, I'm testing that:

  • the packages in this script eval (cross compiling LLVM + using LLVM as a cross-compiler)
    • with the exception of using LLVM as a cross-compiler on darwin which runs into infinite recursion issues that I haven't been able to get to the bottom of
    • i.e.:
      • nix path-info --file ./test.nix --derivation
      • nix path-info --file ./test.nix --derivation --arg systems '[ "aarch64-darwin" "x86_64-darwin" ]' --arg testStdenvPackages '[]'
  • pkgsCross.x86_64-freebsd.boost builds from an x86_64-linux host where llvmPackages has been overridden to point to llvmPackages_15
    • this builds as of llvmPackages: use libcxxrt on FreeBSD #211230 and I want to make sure I replicated those changes correctly
    • i.e. nix build --expr '(import ./. { system = "x86_64-linux"; overlays = [(f: p: { llvmPackages = f.llvmPackages_15; })]; }).pkgsCross.x86_64-freebsd.boost'
    • this is currently stuck, http://anoncvs.netbsd.org seems to be down?
      • trying: anoncvs.fr.NetBSD.org
      • nevermind, this was just firewall/proxy stuff
    • this is currently broken in libcxx; investigating..
  • pkgsStatic.llvmPackages_15 on x86_64-linux
    • about half of this is currently broken..

I've opened a tracking issue for the follow-up work to this PR: #213033; I'll fill in that issue and open a (draft, contingent on this PR getting merged) follow-up PR bumping llvmPackages_latest on staging later today.

@msm-code
Copy link
Copy Markdown
Contributor

msm-code commented Jan 27, 2023

@rrbutani

Is there a reason for this pull request to be a draft?

It is a bit complicated, complex and it still does not compile all tier-1 architectures.

I believe this PR is ready to be reviewed. Can you remove the draft status? I understand that it's not 100% completed, but it's close enough (I believe, based on my undestanding of this thread).

Personally I really want this PR to be merged (in my case because of Zig), and I know many people IRL that feel similar. Since almost all issues are resolved, I believe it shouldn't be a draft (for example, #209536 is not a draft).

@wegank
Copy link
Copy Markdown
Member

wegank commented Jan 27, 2023

@rrbutani

Is there a reason for this pull request to be a draft?

It is a bit complicated, complex and it still does not compile all tier-1 architectures.

I believe this PR is ready to be reviewed. Can you remove the draft status? I understand that it's not 100% completed, but it's close enough (I believe, based on my undestanding of this thread).

Personally I really want this PR to be merged (in my case because of Zig), and I know many people IRL that feel similar. Since almost all issues are resolved, I believe it shouldn't be a draft (for example, #209536 is not a draft).

For Zig, I think we need assistance from the darwin maintainers, since (last time I tried) I ran into errors in rrbutani's #191152, and even applying the fix there didn't help (?).

this is in preparation for the next commit which exposes the release
information and monorepo source as overridable args (which makes it
easier for users to use their own LLVM in nixpkgs)

this commit only adds a check in the `llvm` package's postConfigure that
makes sure the LLVM source provided matches the version we were given;
the actual machinery (functionally just a cosmetic change; causes no
rebuilds) is in the next commit
…s overridable args

this makes it easier for users to use their own LLVM in nixpkgs
@LunNova
Copy link
Copy Markdown
Member

LunNova commented Jan 28, 2023

Result of nixpkgs-review pr 194634 run on x86_64-linux 1

25 packages built:
  • clang-tools_15
  • clang_15 (llvmPackages_15.clang ,llvmPackages_15.libstdcxxClang)
  • lld_15 (llvmPackages_15.lld)
  • lldb_15 (llvmPackages_15.lldb)
  • llvmPackages_15.bintools
  • llvmPackages_15.bintools-unwrapped
  • llvmPackages_15.bintoolsNoLibc
  • llvmPackages_15.clang-manpages
  • llvmPackages_15.libclang (llvmPackages_15.clang-unwrapped)
  • llvmPackages_15.clangNoCompilerRt
  • llvmPackages_15.clangNoCompilerRtWithLibc
  • llvmPackages_15.clangNoLibc
  • llvmPackages_15.clangNoLibcxx
  • llvmPackages_15.clangUseLLVM
  • llvmPackages_15.compiler-rt (llvmPackages_15.compiler-rt-libc ,llvmPackages_15.compiler-rt-no-libc)
  • llvmPackages_15.libcxx
  • llvmPackages_15.libcxxClang
  • llvmPackages_15.libcxxStdenv
  • llvmPackages_15.libcxxabi
  • llvm_15 (llvmPackages_15.llvm)
  • llvmPackages_15.libunwind
  • llvmPackages_15.lldb-manpages
  • llvmPackages_15.llvm-manpages
  • llvmPackages_15.openmp
  • llvmPackages_15.stdenv

@strager
Copy link
Copy Markdown
Contributor

strager commented Jan 28, 2023

wegank said:

I think I'll merge it if Zig builds on my (slow) aarch64-linux machine.

I built the following packages on my Linux AArch64 machine. They all built successfully at commit d231d18 + my two Zig patches (#210324):

30 packages built:
cargo-lambda
cargo-zigbuild
clang-tools_15
clang_15
clipbuzz
lld_15
lldb_15
llvmPackages_15.bintools
llvmPackages_15.bintools-unwrapped
llvmPackages_15.bintoolsNoLibc
llvmPackages_15.clang-manpages
llvmPackages_15.libclang
llvmPackages_15.clangNoCompilerRt
llvmPackages_15.clangNoCompilerRtWithLibc
llvmPackages_15.clangNoLibc
llvmPackages_15.clangNoLibcxx
llvmPackages_15.clangUseLLVM
llvmPackages_15.compiler-rt
llvmPackages_15.libcxx
llvmPackages_15.libcxxClang
llvmPackages_15.libcxxStdenv
llvmPackages_15.libcxxabi
llvmPackages_15.llvm
llvmPackages_15.libunwind
llvmPackages_15.lldb-manpages
llvmPackages_15.llvm-manpages
llvmPackages_15.openmp
llvmPackages_15.stdenv
zig
zig_0_9

Linux ubuntu-linux-22-04-desktop 5.15.0-41-generic #44-Ubuntu SMP Thu Jun 23 11:20:13 UTC 2022 aarch64 GNU/Linux

@wegank
Copy link
Copy Markdown
Member

wegank commented Jan 28, 2023

Also built Zig 0.10.1 on top of f80ac84 with the two PRs applied:

$ nix-build -A zig
/nix/store/g9kixfg3cy0nxpv19z8b4i8dbn8zbsxb-zig-0.10.1

@rrbutani Thank you for your hard work!

@github-actions
Copy link
Copy Markdown
Contributor

Successfully created backport PR for release-22.11:

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request: add llvmPackages_15