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

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

Closed
jtmcx opened this issue Mar 22, 2020 · 1 comment · Fixed by #83180
Closed
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: darwin Running or building packages on Darwin

Comments

@jtmcx
Copy link

jtmcx commented Mar 22, 2020

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 :)

@jtmcx jtmcx added the 0.kind: bug Something is broken label Mar 22, 2020
@veprbl veprbl added 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: darwin Running or building packages on Darwin labels Mar 22, 2020
@matthewbauer
Copy link
Member

This is caused by #77632. Related to #80754

@vcunat vcunat closed this as completed in b0b0a06 Jun 10, 2020
Gabriella439 pushed a commit to awakesecurity/nixpkgs that referenced this issue May 1, 2021
We can’t set this for cross-compiling since we use the GNU linker.
Instead, set these flags only when targetPlatform is macOS.

Fixes NixOS#80754

Fixes NixOS#83141
Gabriella439 pushed a commit to awakesecurity/nixpkgs that referenced this issue May 3, 2021
We can’t set this for cross-compiling since we use the GNU linker.
Instead, set these flags only when targetPlatform is macOS.

Fixes NixOS#80754

Fixes NixOS#83141
Gabriella439 pushed a commit to awakesecurity/nixpkgs that referenced this issue May 6, 2021
We can’t set this for cross-compiling since we use the GNU linker.
Instead, set these flags only when targetPlatform is macOS.

Fixes NixOS#80754

Fixes NixOS#83141
rvem pushed a commit to serokell/nixpkgs that referenced this issue Nov 8, 2022
We can’t set this for cross-compiling since we use the GNU linker.
Instead, set these flags only when targetPlatform is macOS.

Fixes NixOS#80754

Fixes NixOS#83141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants