Skip to content

Failed to build Rust programs on darwin #254104

Closed

Description

@jaudiger

Describe the bug

Since a recent upgrade, cc tool from LLVM suite, fails to build simple program. I cannot even invoke it with a simple command such as: clang --version:

[user@system:~]$ clang --version
mktemp: illegal option -- -
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix

Steps To Reproduce

To reproduce with cargo, but it can be reproduced without it as shown in the description.

  1. cargo init foo
  2. cd foo
  3. cargo build

Expected behavior

The program should build.

Additional context

cargo build   
   Compiling foo v0.1.0 (/Users/jaudiger/Downloads/test/foo)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jaudiger/development/scripts:/Users/jaudiger/development/scripts/ioterop/alaska:/nix/store/dfgwfxmkvsz4lvnsc1pr5wsrrj1p9p41-devenv-profile/bin:/Users/jaudiger/.config/carapace/bin:/Users/jaudiger/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/etc/profiles/per-user/jaudiger/bin:/run/current-system/sw/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin:/Users/jaudiger/Development/git-repositories/jaudiger/iowa-rs/.devenv/state/cargo-install/bin:/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/bin" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "arm64" "/var/folders/2p/ffp4lc_n1z3b08fcr0c8x0cw0000gn/T/nix-shell.XXXXXX.UmuyNXXk/rustcioDcXQ/symbols.o" "/Users/jaudiger/Downloads/test/foo/target/debug/deps/foo-81ff2ee467938130.1jh3lrjcj17s958y.rcgu.o" "/Users/jaudiger/Downloads/test/foo/target/debug/deps/foo-81ff2ee467938130.2xr33ct7iud5m2gv.rcgu.o" "/Users/jaudiger/Downloads/test/foo/target/debug/deps/foo-81ff2ee467938130.2xyzgcivkf9qkaqv.rcgu.o" "/Users/jaudiger/Downloads/test/foo/target/debug/deps/foo-81ff2ee467938130.3e08yhzy1ox6qalc.rcgu.o" "/Users/jaudiger/Downloads/test/foo/target/debug/deps/foo-81ff2ee467938130.5c1ulshnxmkalya4.rcgu.o" "/Users/jaudiger/Downloads/test/foo/target/debug/deps/foo-81ff2ee467938130.ahmtt8pmg7y1c7o.rcgu.o" "/Users/jaudiger/Downloads/test/foo/target/debug/deps/foo-81ff2ee467938130.2n1nhu2hh32pqpfd.rcgu.o" "-L" "/Users/jaudiger/Downloads/test/foo/target/debug/deps" "-F" "/nix/store/dfgwfxmkvsz4lvnsc1pr5wsrrj1p9p41-devenv-profile/Library/Frameworks" "-L" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libstd-ea564c277a9775e7.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-c304a3a182c52105.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libobject-0da73a32c086f64c.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-556ad8b38e2b6326.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-57143c50a93b3a9f.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libgimli-adc2359764c1f3f9.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-2d8358e39b89a642.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-d0d09b18e41baa81.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-39f4403a59eee8ff.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-ecdabbd76e51f43d.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libminiz_oxide-aa17e9989b8bb446.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libadler-f43598e54d974a89.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libunwind-ea359c2001d296ca.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-d6ca6b2b6de59e80.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/liblibc-675c3823e7b08979.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/liballoc-b138f6381e7b42de.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-54a048c441247cd0.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libcore-1dcac5a329c19f30.rlib" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-9a5dde18cc747729.rlib" "-lSystem" "-lc" "-lm" "-L" "/nix/store/vd6jzf0m9kprxyd95lkd2h3gy73sq90a-rustc-1.72.0/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/jaudiger/Downloads/test/foo/target/debug/deps/foo-81ff2ee467938130" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: mktemp: illegal option -- -
          usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
                 mktemp [-d] [-q] [-u] -t prefix 
          

error: could not compile `foo` (bin "foo") due to previous error

Notify maintainers

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 22.6.0, macOS 13.5.2`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.16.1`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Activity

  1. added
    0.kind: bug
    on Sep 8, 2023
  2. n8henrie commented on Sep 13, 2023

    @n8henrie
    Contributor

    Working fine here:

    $ nix shell nixpkgs/master#cargo --command bash -c 'cargo init foo; cd foo; cargo build; cargo run'
         Created binary (application) package
       Compiling foo v0.1.0 (/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.mgZlD11pdm/foo)
        Finished dev [unoptimized + debuginfo] target(s) in 0.30s
        Finished dev [unoptimized + debuginfo] target(s) in 0.00s
         Running `target/debug/foo`
    Hello, world!
    $ nix-info -m
     - system: `"aarch64-darwin"`
     - host os: `Darwin 22.6.0, macOS 13.5.2`
     - multi-user?: `yes`
     - sandbox: `no`
     - version: `nix-env (Nix) 2.13.5`
     - channels(n8henrie): `""`
     - channels(root): `""`
     - nixpkgs: `/nix/store/iybmq7v6fkj5kdm2zdvx35j4h9vjihfq-source`
  3. jaudiger commented on Sep 13, 2023

    @jaudiger
    ContributorAuthor

    I resolved the aforementioned issue by using the mktemp package from Nix. It seems there is a compatibility issue with the mktemp package from MacOS. An option seems to be use by a tool, and this option does not exist in the version of the package exposed by MacOS. If I'm using the one from Nix, I'm now able to build Rust programs.

  4. n8henrie commented on Sep 13, 2023

    @n8henrie
    Contributor

    Good deal, so sounds like this issue can be closed?

  5. jaudiger commented on Sep 13, 2023

    @jaudiger
    ContributorAuthor

    I'll close it, even if I'm concerned about how I encountered this issue at the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions