Skip to content

riscv64-none-elf-ld fails with "unrecognised emulation mode: acosx_version_min" on macOS #83141

@jtmcx

Description

@jtmcx

Describe the bug
When trying to use the riscv64-none-elf toolchain to cross compile on macOS (10.15.1), the linker (riscv64-none-elf-ld) fails with error: unrecognised emulation mode: acosx_version_min.

To Reproduce

  1. Create a shell.nix file with the following:
let crossPkgs = import <nixpkgs> {
  crossSystem = (import <nixpkgs/lib>).systems.examples.riscv64-embedded;
}; in crossPkgs.mkShell { }
  1. Run $ nix-shell, and wait for the cross compiler derivations to build.
  2. Once the toolchain is built, run [nix-shell]$ riscv64-none-elf-ld

Expected behavior
I expect the linker to output ld: no object files specified (or something similar).

Instead, I'm seeing the following output:

/nix/store/8apl30x7n9i8gm3dwsqsl1kcr80ab5zl-riscv64-none-elf-binutils-2.31.1/bin/riscv64-none-elf-ld: unrecognised emulation mode: acosx_version_min
Supported emulations: elf64lriscv elf32lriscv

Additional context
I suspect that there is something going on where the native macOS linker (/usr/bin/ld) is being invoked under the hood. I ran some analysis with dtruss, but couldn't find anything definitive.

Note that this error occurs no matter what flags are passed -- including riscv64-none-elf-ld --version.

Metadata

  • system: "x86_64-darwin"
  • host os: Darwin 19.0.0, macOS 10.15.1
  • multi-user?: no
  • sandbox: no
  • version: nix-env (Nix) 2.3.3
  • channels: "nixpkgs-20.09pre216412.04d6123309f"
  • nixpkgs: /Users/johnmurphy/.nix-defexpr/channels/nixpkgs

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
  - stdenv.cross
# a list of nixos modules affected by the problem
module:

I'm not too sure who the maintainer is, or how the cross compiling setup works. (I'm fairly new to nix). Any help here would be greatly appreciated! Thank you :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: cross-compilationBuilding packages on a different platform than they will be used on6.topic: darwinRunning or building packages on Darwin

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions