Closed miakizz closed 1 year ago
Hi @nkizz Thanks for the report. The problem relates to the build of tinycbor which uses its own build system that we can't easily control. I think what we'll do is point anyone else who hits this problem to this issue since it contains the resolution.
ld: warning: ignoring file lib/libtinycbor.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
says the file starts with !<arch>\n/
. What does file
say it is? That doesn't appear to be a Mach-O archive, which I think should start with 0xFEEDFACF
, so I'm not sure what's going on.
The archive contains .o files which file
report as Mach-O 64-bit object arm64
. I think it is simply the case that binutils is not compatible with the Apple host toolchain (e.g. Apple clang) so the right solution is to make sure binutils is not on path.
brew emits a warning when installing binutils:
==> Caveats
binutils is keg-only, which means it was not symlinked into /opt/homebrew,
because it shadows the host toolchain.
If you need to have binutils first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/binutils/bin:$PATH"' >> /Users/perl/.bash_profile
For compilers to find binutils you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/binutils/lib"
export CPPFLAGS="-I/opt/homebrew/opt/binutils/include"
Running
cargo install c2rust
fails on my M1 Mac with the following error:Inspired by https://stackoverflow.com/a/74159799, I ran
brew uninstall binutils
, and c2rust installed without any errors. I would dig into a fix, but I'm not exactly sure which ld is being used where. Maybe just explicitly using the system ld would be good? Or throwing an error if it detects the bintools package is installed.Thanks!