NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.06k stars 14.1k forks source link

Build failure: swift for aarch64 #295322

Closed natsukium closed 7 months ago

natsukium commented 8 months ago

Since https://github.com/NixOS/nixpkgs/pull/291901 was merged into the master, swift cannot be built on aarch64.

Steps To Reproduce

Steps to reproduce the behavior:

nix build github:NixOS/nixpkgs/0dd6aae052b3748d761c93efa16b49c02f8a14e4#swift

Build log

Run Build Command(s): /nix/store/40wywa8y2nsgws1lwj7nhmkbbsx1arq4-ninja-1.11.1/bin/ninja -v cmTC_809f1
[1/1] : && /private/tmp/nix-build-swift-5.8.drv-0/build/swift/bin/swiftc -j 8 -num-threads 8 -emit-executable -o cmTC_809f1 -emit-dependencies  -output-file-map CMakeFiles/cmTC_809f1.dir//output-file-map.json  /tmp/nix-build-swift-5.8.drv-0/build/swift-concurrency-backdeploy/CMakeFiles/CMakeScratch/TryCompile-DsXkpX/main.swift    && :
FAILED: cmTC_809f1 CMakeFiles/cmTC_809f1.dir/main.swift.o 
: && /private/tmp/nix-build-swift-5.8.drv-0/build/swift/bin/swiftc -j 8 -num-threads 8 -emit-executable -o cmTC_809f1 -emit-dependencies  -output-file-map CMakeFiles/cmTC_809f1.dir//output-file-map.json  /tmp/nix-build-swift-5.8.drv-0/build/swift-concurrency-backdeploy/CMakeFiles/CMakeScratch/TryCompile-DsXkpX/main.swift    && :
<unknown>:0: error: unknown argument: '-march=armv8.3-a+crypto+sha2+aes+crc+fp16+lse+simd+ras+rdm+rcpc'
ninja: build stopped: subcommand failed.

https://hydra.nixos.org/build/252498280 https://hydra.nixos.org/build/252595108

Additional context

reported in https://github.com/NixOS/nixpkgs/pull/291901#issuecomment-1976557559

I'm not familiar with swift or clang, but I'm using the following overlay as a workaround until it's fixed.

self: super: {
  swiftPackages = super.swiftPackages // {
    clang = super.swiftPackages.clang.overrideAttrs (oldAttrs: {
      postFixup =
        (oldAttrs.postFixup or "")
        + ''
          sed -i "s/'-march=.*'//g" $out/nix-support/add-local-cc-cflags-before.sh
        '';
    });
  };
};

Notify maintainers

@dtzWill @trepetti @dduan @Trundle @stephank

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.3.0, macOS 14.3.1`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/store/8ny3r3jvj17ljzc89h9rpfr56a7nyn8c-source`

Add a :+1: reaction to issues you find important.

ghost commented 7 months ago

https://github.com/NixOS/nixpkgs/pull/296082#issuecomment-2003578574 states that this only fixed the swift build but all downstream packages are still broken. re-opening.

YorikSar commented 7 months ago

all downstream packages are still broken

Actually, it seems only dark-mode-notify is broken, others seem fine. Probably because it uses Cocoa or disables sandbox. I don't know for sure.

natsukium commented 7 months ago

I noticed that my personal package does not build either. Maybe it's because of swift itself or swiftpm?

https://github.com/natsukium/nur-packages/blob/a6cdb433c05da1535707d91247701dae91402763/pkgs/bclm/default.nix

❯ nom build .#bclm
this derivation will be built:
  /nix/store/5fydm8ymavd5xf6kzaf8pzp7c1vyzixj-bclm-0.1.0.drv
bclm> building '/nix/store/5fydm8ymavd5xf6kzaf8pzp7c1vyzixj-bclm-0.1.0.drv'
bclm> Running phase: unpackPhase
bclm> unpacking source archive /nix/store/flpabhsb1drhc20hlbxy0gdz0nfiy7wn-source
bclm> source root is source
bclm> Running phase: patchPhase
bclm> Running phase: updateAutotoolsGnuConfigScriptsPhase
bclm> Running phase: configurePhase
bclm> Running phase: buildPhase
bclm> build flags: -j 8 -c release
bclm> TSCUtility/Triple.swift:215: Fatal error: Failed to parse target info (malformed).
bclm> Raw compiler output: 
bclm> /nix/store/ghp1m1i27yyqfys8i6ilpcq7mrpy7848-swiftpm-5.8/nix-support/setup-hook: line 2: 63542 Trace/BPT trap: 5       TERM=dumb swift-build "${flagsArray[@]}"
error: builder for '/nix/store/5fydm8ymavd5xf6kzaf8pzp7c1vyzixj-bclm-0.1.0.drv' failed with exit code 133;
afh commented 7 months ago

The above open PR seems to run into the same issue…