Skip to content

cc <file> -o /dev/null fails on aarch64-darwin #154203

Open

Description

@abathur

I noticed OfBorg failing to build oil-dev on aarch64-darwin.

It's failing on a ~sanity-check Oil's configure script is performing. I think I've successfully boiled the failing check down to a nix-shell oneliner that works on x86_64-darwin but fails on aarch64-darwin as below:

$ nix-shell -p stdenv --command 'cc -o /dev/null -x c <(echo "int main(void){ return 0; }"); echo $?'
libc++abi: terminating with uncaught exception of type SigTool::NotAMachOFileException: std::exception
/nix/store/r2pg5y3iyvsdx996iqynm4b414blbwpc-post-link-sign-hook: line 2: 95193 Abort trap: 6           CODESIGN_ALLOCATE=codesign_allocate /nix/store/pil07xvm57xbiczfqqj0cmrycwimapr5-sigtool-0.1.2/bin/codesign -f -s - "$linkerOutput"
clang-11: error: linker command failed with exit code 134 (use -v to see invocation)
134

I'm not really familiar with anything at this level, but dropping -o /dev/null causes the invocation to work, and it seems plausible that the post-link-sign-hook trying to codesign /dev/null could cause trouble.

I don't know what the appropriate fix is, but I see where /dev/null would get picked up and set to $linkerOutput:

# Determine linkerOutput
prev=
for p in \
${extraBefore+"${extraBefore[@]}"} \
${params+"${params[@]}"} \
${extraAfter+"${extraAfter[@]}"}
do
case "$prev" in
-o)
# Informational for post-link-hook
linkerOutput="$p"
;;
*)
;;
esac
prev="$p"
done

@thefloweringash

Activity

  1. added
    0.kind: bug
    on Jan 9, 2022
  2. added
    6.topic: darwin
    on Jan 9, 2022
  3. abathur commented on Jan 16, 2022

    @abathur
    MemberAuthor

    I've talked to @thefloweringash in matrix a bit (starting here), but we haven't quite unpicked this. I'm going to go ahead and work around it for my case, so I'll try to document what we've got so far.

    1. The less-hacky way to fix this is probably updating cctools-port, since it looks like they've made progress on signing (especially the now-merged Use sigtool's codesign binary to sign in install_name_tool and strip tpoechtrager/cctools-port#114)

    2. But, it seems like the SDK version is biting us again a bit on making this jump. I start seeing missing symbol failures for open_memstream (on x86_64-darwin, at least) from tpoechtrager/cctools-port@86cf74f

    3. It looks like they attempted to address this problem in Support macos<10.13 by disabling some diagnostics tpoechtrager/cctools-port#111, but my attempt to build still fails after this. I don't have a good grasp of the feature-checking API here and how it interacts with my system version and the SDK version nixpkgs is using, but here's what Andrew thought:

      IIUC, the availability stuff works like this: symbols are tagged with availability ranges, symbols that might not be available according to the compile-time -mmacos-version-min are weakly linked, applications must check at runtime (old way: symbol value is null, new: way via __builtin_available). So after 111, it can run on macos 10.12 if built with an sdk that is 10.13 or newer. to build with 10.12, we can probably #define HAVE_OPENMEMSTREAM_RUNTIME 0. it gets a little further but fails on DISPATCH_APPLY_AUTO which is also new in 10.13.

    4. Andrew has some WIP towards this end already, visible in master...thefloweringash:cctools-update

  4. tanshihaj commented on May 17, 2022

    @tanshihaj
    Contributor
  5. stephank commented on Aug 8, 2022

    @stephank
    Contributor

    I found this issue while trying a cctools upgrade myself. The PR for that is here: #185656

    1. The less-hacky way to fix this is probably updating cctools-port, since it looks like they've made progress on signing (especially the now-merged Use sigtool's codesign binary to sign in install_name_tool and strip tpoechtrager/cctools-port#114)

    Unfortunately, this change causes segfaults when using strip on non-binaries, which Nix does a lot. So the upgrade I did is up to the commit right before it. I didn't attempt a fix, only left a comment there.

    1. Andrew has some WIP towards this end already, visible in master...thefloweringash:cctools-update

    I read over this before starting. Would've saved some time. 🤦‍♂️ Good thing we ended up doing much of the same.

  6. added
    2.status: stale
    on Jul 3, 2025
  7. smancill commented on Sep 27, 2026

    @smancill
    Contributor

    It should have been fixed long ago:

    $ nix-shell -p stdenv --command 'cc -o /dev/null -x c <(echo "int main(void){ return 0; }"); echo $?'
    0
  8. removed
    2.status: stale
    on Sep 27, 2026
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: bug6.topic: darwin

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions