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

cargo-watch build failure on aarch64-darwin #146349

Closed
samuela opened this issue Nov 17, 2021 · 14 comments
Closed

cargo-watch build failure on aarch64-darwin #146349

samuela opened this issue Nov 17, 2021 · 14 comments
Labels
0.kind: build failure A package fails to build 6.topic: darwin Running or building packages on Darwin 6.topic: rust

Comments

@samuela
Copy link
Member

samuela commented Nov 17, 2021

Describe the bug

The cargo-watch package fails to build on aarch64-darwin. This appears to be related to a failure running the build script for the crate mac-notification-sys.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Try building cargo-watch on aarch64-darwin.
  2. Observe failure.

Expected behavior

The package to build.

Screenshots

n/a

Additional context

See https://gist.github.com/samuela/64da4e242830cd92054121030828a691 for the complete build log.

Notify maintainers

@xrelkd @ivan

Metadata

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

nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 21.1.0, macOS 12.0.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.4`
 - channels(samuelainsworth): `"darwin, home-manager, nixpkgs-21.11pre330734.5cb226a06c4"`
 - channels(root): `"nixpkgs-21.11pre330734.5cb226a06c4"`
 - nixpkgs: `/Users/samuelainsworth/.nix-defexpr/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: cargo-watch
# a list of nixos modules affected by the problem
module:
@samuela samuela added the 0.kind: bug Something is broken label Nov 17, 2021
@samuela
Copy link
Member Author

samuela commented Nov 17, 2021

Installing via cargo install cargo-watch does work OTOH.

@Artturin
Copy link
Member

CoreFoundation and Foundation need to be added to the buildInputs

@Artturin Artturin added 0.kind: build failure A package fails to build 6.topic: darwin Running or building packages on Darwin and removed 0.kind: bug Something is broken labels Nov 17, 2021
@samuela
Copy link
Member Author

samuela commented Nov 17, 2021

buildInputs = lib.optionals stdenv.isDarwin [ CoreServices Foundation libiconv ];

Foundation is already in buildInputs. I just tried adding CoreFoundation as well but that didn't seem to make any difference.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/cant-build-tauri-app-on-macos-with-rust-installed-via-nix/16895/6

@rpearce
Copy link
Contributor

rpearce commented Jan 16, 2022

Ran into this, too, but cargo install cargo-watch also doesn't seem to work (in nix)

warning: In file included from objc/notify.m:1:
warning: objc/notify.h:1:9: fatal error: 'Foundation/Foundation.h' file not found
warning: #import <Foundation/Foundation.h>
warning:         ^~~~~~~~~~~~~~~~~~~~~~~~~
warning: 1 error generated.

error: failed to run custom build command for `mac-notification-sys v0.3.0`

Looks a lot like 78f07d0 but is also reported on mac-notification-sys here: h4llow3En/mac-notification-sys#28

@nigelgbanks
Copy link

nigelgbanks commented Jan 22, 2022

cargo install cargo-watch works for me I'm using github:oxalica/rust-overlay with rust-bin.stable.latest.default.

cargo --version 
cargo 1.58.0 (7f08ace4f 2021-11-24)

uname -a
Darwin macbook 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64

nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 21.2.0, macOS 12.1`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4`
 - channels(root): `"nixpkgs-22.05pre346778.1caf78f4bf5"`
 - nixpkgs: `/etc/nixpkgs`
# I use flakes so the channels(root) here can be ignored I'm on nixpkgs-21.11-darwin 2c9afd35b57f22dc69803972df147b7a331ee596

Building via nix however, fails.

error: failed to run custom build command for `mac-notification-sys v0.3.0`

Caused by:
  process didn't exit successfully: `/private/tmp/nix-build-cargo-watch-8.1.1.drv-0/source/target/release/build/mac-notification-sys-35a1d46b2ce92018/build-scri
  --- stdout
  TARGET = Some("aarch64-apple-darwin")
  OPT_LEVEL = Some("3")
  HOST = Some("aarch64-apple-darwin")
  CC_aarch64-apple-darwin = Some("/nix/store/7sfdssd4p5c6gh5dr2j1fy06fxky195q-clang-wrapper-11.1.0/bin/cc")
  CFLAGS_aarch64-apple-darwin = None
  CFLAGS_aarch64_apple_darwin = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = None
  running: "/nix/store/7sfdssd4p5c6gh5dr2j1fy06fxky195q-clang-wrapper-11.1.0/bin/cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-fmo
  cargo:warning=error: unable to open output file '/homeless-shelter/.cache/clang/ModuleCache/34TQMRHFQU7QU/Foundation-20C0ANTXDRONG.pcm': 'No such file or dire
  cargo:warning=In file included from objc/notify.m:1:
  cargo:warning=objc/notify.h:1:9: fatal error: could not build module 'Foundation'
  cargo:warning=#import <Foundation/Foundation.h>
  cargo:warning= ~~~~~~~^
  cargo:warning=error: unable to open output file '/homeless-shelter/.cache/clang/ModuleCache/34TQMRHFQU7QU/ObjectiveC-3KPV63CE69HU8.pcm': 'No such file or dire
  cargo:warning=error: unable to open output file '/homeless-shelter/.cache/clang/ModuleCache/34TQMRHFQU7QU/CoreServices-2ZSMMJ1VHU9R1.pcm': 'No such file or di
  cargo:warning=4 errors generated.
  exit status: 1

  --- stderr


  error occurred: Command "/nix/store/7sfdssd4p5c6gh5dr2j1fy06fxky195q-clang-wrapper-11.1.0/bin/cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch


warning: build failed, waiting for other jobs to finish...
error: build failed

These files exist on my disk just not in nix:

/System/Volumes/Data/private/var/folders/xj/2g_69j1504vgc597y35p3r7h00009d/C/clang/ModuleCache/34TQMRHFQU7QU/ObjectiveC-3KPV63CE69HU8.pcm
/private/var/folders/xj/2g_69j1504vgc597y35p3r7h00009d/C/clang/ModuleCache/34TQMRHFQU7QU/ObjectiveC-3KPV63CE69HU8.pcm

@rpearce
Copy link
Contributor

rpearce commented Mar 13, 2022

In lieu of not being able to use cargo-watch on an M1 through nix, I've now got all this running through Docker and the nixos/nix image, but it ain't pretty yet and isn't ready for sharing. I might even go so far as to just put my whole dev environment in this eventually.

@Artturin
Copy link
Member

@NixOS/darwin-maintainers

@uri-canva
Copy link
Contributor

Same underlying issue: #160876.

@uri-canva
Copy link
Contributor

Issue opened for a possible root cause: #163052

@schickling
Copy link

Is there any progress on this issue or any known workarounds?

@toonn
Copy link
Contributor

toonn commented Sep 5, 2022

@schickling, @tjni is still chipping away at #163052, latest findings in #185569.

@tjni
Copy link
Contributor

tjni commented Oct 12, 2022

Fix for this is now in master, so I'm going to close this issue. It should be on nixpkgs-unstable soon if not already.

@tjni tjni closed this as completed Oct 12, 2022
@schickling
Copy link

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure A package fails to build 6.topic: darwin Running or building packages on Darwin 6.topic: rust
Projects
None yet
Development

No branches or pull requests

10 participants