-
Notifications
You must be signed in to change notification settings - Fork 270
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
Compilation fails on Mac M1 #283
Comments
Can you include more information? So this is on Mac M1? What were you doing when this message came up? Can you include the entire log? What's your rust version? Can you compile other Rust code? (see https://blog.rust-lang.org/2020/11/27/Rustup-1.23.0.html ) |
secp256k1 = {version = "0.20.1", features = ["std", "recovery"] } It is in Mac M1.
It build successfully , and I can compile other Rust code:
It is ok! But i run a test: cargo test --package xxxxx_crypto --lib -- xxxx::xxx::xxxx --exact --nocapture'
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-arch" "arm64"
"-L" "/Users/xxxx/.rustup/toolchains/stable-aarch64-apple-darwin....
...
...
= note: ld: in /Users/xxxx/Desktop/xxxxx/target/debug/deps/libsecp256k1_sys-83373f8ecea41938.rlib(secp256k1.o), archive member 'secp256k1.o' with length 195816 is not mach-o or llvm bitcode for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
error: could not compile `xxxx_crypto` |
hmmmm, that won't be easy to debug without an actual mac M1 (are there VMs/qemus of it?)
|
The three tests are interesting but in the end I suspect the problem needs to be fixed in |
New versions of |
Indeed, but I wonder how important this is on MacOS (e.g., we arrived at 1.29 specifically because we were looking at Debian versions...) |
We arrived at 1.29 because this is mrustc's target. But I agree, this probably doesn't matter for users of OS X because they are already running scads of completely closed-source software. |
Oh right. But yeah, it's probably not as important on Mac as it is on Linux. |
It's not possible to build wasm32 target on M1 right now too:
env:
Code: https://github.com/fanatid/rust-secp256k1/tree/wasm-example-m1 Full output with `-vv`
|
I have the same compilation error on a 2015 Macbook Pro on Catalina 10.15. So this may not be an M1-specific issue |
Are you also targetting webassembly? can you show the output of the compilation? FWIWI I just ran |
Unfortunately I changed my rustup config and now cannot reproduce the |
FWIW, I believe Apple clang does not support wasm targets and produces this message; using Homebrew clang ( Note that it's possible to run the x86_64 toolchain on M1:
This still gives me |
See #254. You will also need to override the archiver that is being used ( |
I don't have an M1 chip, I'm running BigSur 11.6 and I get this error. I've tried everything on this thread, but I still get the For context, I've installed
Versioning outputs:
|
I am getting these two errors ( |
I get the same error at first, then I get true path: which llvm-ar
/opt/homebrew/opt/llvm/bin/llvm-ar
which clang
/opt/homebrew/opt/llvm/bin/clang But after I set both, I failed too: AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang cargo build --release --target wasm32-unknown-unknown run cargo clean first will make compile success: cargo clean
AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang cargo build --release --target wasm32-unknown-unknown |
@aewc worked for me. Thanks! |
Thanks @aewc. That worked for me, too. |
If it helps, this pr produces there error with a Nix flake so that should hopefully be reproducible. |
For others, you can also add AR and CC to your path on mac like this without having to include it in the cargo build command:
restart your terminal after adding these to |
☝️ This worked for me, thanks! For new readers, in case you don't want to add those variables to your shell environment, you can also add it to the cargo build environment, either in the [env]
AR = "/opt/homebrew/opt/llvm/bin/llvm-ar"
CC = "/opt/homebrew/opt/llvm/bin/clang" |
While trying to run I got the following errors: RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown So it is file name collision warning... Still getting this again: The bin target And this is the Colliding filename: /Users/emlanis/examples/EVM-encrypt-decrypt/secret_network/target/wasm32-unknown-unknown/release/secret_encryption.wasm And it is saying the targets should have unique names. And this is the suggestion: After that, I still encountered other error messages such as: error: failed to run custom build command for Caused by: So this is basically a secp256k1-sys error. I need help sorting it out. See more output info for that error: TARGET = Some("wasm32-unknown-unknown") --- stderr This is the finally error message I received: error occurred: Failed to find tool. Is Obviously a clang error. I'm stuck at this stage towards compiling a contract and I desperately need help sorting it out. Note that I tried all the solutions above without success. I'm using MacBook Air 2020 MacOs Sonoma 14.2.1 |
@emlanis I'm not really convinced the duplicate is related to this library. Can you try compiling |
That's an interesting take from you. I'm now left with the 'secp256k1' error only. So this is what I got returned after trying to compile again: " error: failed to select a version for the package failed to select a version for Is there anyway you can help sort this out finally? |
secp256k1-sys 0.1is from 2019, before we figured out how best to handle linking issues with multiple versions of libsecp (and possibly before we had compiler support for our actual solution). The latest version is 0.9.2. I'm afraid if you're going to use ancient versions from near the start of this project, we won't be able to help you. |
So what do you think I should do in order to move past this bug? |
Upgrade the library, obviously. |
= note: ld: in /Users/XXX/Desktop/xxxxx/target/debug/deps/libsecp256k1_sys-83373f8ecea41938.rlib(secp256k1.o), archive member 'secp256k1.o' with length 195816 is not mach-o or llvm bitcode for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The text was updated successfully, but these errors were encountered: