Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure: swift for aarch64 #295322

Closed
natsukium opened this issue Mar 12, 2024 · 4 comments · Fixed by #296082 or #301103
Closed

Build failure: swift for aarch64 #295322

natsukium opened this issue Mar 12, 2024 · 4 comments · Fixed by #296082 or #301103

Comments

@natsukium
Copy link
Member

Since #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 #291901 (comment)

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 👍 reaction to issues you find important.

@ghost ghost mentioned this issue Mar 15, 2024
13 tasks
@ghost ghost closed this as completed in #296082 Mar 17, 2024
YorikSar added a commit to YorikSar/nixpkgs that referenced this issue Mar 18, 2024
Use the same stdenv and clang as part of it as Swift uses. Leverages
workaround from NixOS#296082 for
the issue NixOS#295322.
@ghost
Copy link

ghost commented Mar 18, 2024

#296082 (comment) states that this only fixed the swift build but all downstream packages are still broken. re-opening.

@ghost ghost reopened this Mar 18, 2024
@YorikSar
Copy link
Contributor

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
Copy link
Member Author

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;

domenkozar pushed a commit to cachix/devenv-nixpkgs that referenced this issue Mar 18, 2024
swiftc uses cc-wrapper which sets the -march flag on some systems which
breaks the build. This change adds a flag, disableMarch, to cc-wrapper
which disables using the -march flag.
NixOS/nixpkgs#295322
@afh
Copy link
Member

afh commented Mar 28, 2024

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

@squirmy squirmy mentioned this issue Apr 1, 2024
@ghost ghost closed this as completed in #301103 Apr 3, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants