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

Cant compile crate-type cdylib on macOS #1628

Closed
codenutt opened this issue Aug 21, 2023 · 3 comments
Closed

Cant compile crate-type cdylib on macOS #1628

codenutt opened this issue Aug 21, 2023 · 3 comments

Comments

@codenutt
Copy link

codenutt commented Aug 21, 2023

I'm trying to build a project with a crate-type of lib, staticlib, cdylib on macOS. The project is blank, just importing and referencing ring. If I remove cdylib, it works fine.

System
macOS Ventura 13.4, M1
rustc 1.71.1 (eb26296b5 2023-08-03)

Main error:

ld: in /Users/codenutt/code/t/target/debug/deps/libring-08f7f88fe5c951d4.rlib(aesv8-armx-ios64.o), building for macOS, but linking in object file built for iOS Simulator, file '/Users/codenutt/code/t/target/debug/deps/libring-08f7f88fe5c951d4.rlib' for architecture arm64

Full error:

     Running `/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name t --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=108 --crate-type lib --crate-type staticlib --crate-type cdylib --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=df8c44a3f1f87b60 --out-dir /Users/codenutt/code/t/target/debug/deps -C incremental=/Users/codenutt/code/t/target/debug/incremental -L dependency=/Users/codenutt/code/t/target/debug/deps --extern cc=/Users/codenutt/code/t/target/debug/deps/libcc-3ca6462b9cd63bea.rlib --extern ring=/Users/codenutt/code/t/target/debug/deps/libring-08f7f88fe5c951d4.rlib -L native=/Users/codenutt/code/t/target/debug/build/ring-f5b2ebe489d1f21d/out`
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/Users/codenutt/.nvm/versions/node/v18.16.0/bin:/opt/homebrew/opt/openssl@3/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/codenutt/.nvm/versions/node/v18.16.0/bin:/opt/homebrew/opt/openssl@3/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/codenutt/.cargo/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/codenutt/Library/Android/sdk/emulator:/Users/codenutt/Library/Android/sdk/platform-tools:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/codenutt/Library/Android/sdk/emulator:/Users/codenutt/Library/Android/sdk/platform-tools" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-Wl,-exported_symbols_list,/var/folders/61/rsg0bvwd6z3bqrk475p2yn280000gn/T/rustcd83NNr/list" "-arch" "arm64" "/var/folders/61/rsg0bvwd6z3bqrk475p2yn280000gn/T/rustcd83NNr/symbols.o" "/Users/codenutt/code/t/target/debug/deps/t.1qnx6rzacf9ej64y.rcgu.o" "/Users/codenutt/code/t/target/debug/deps/t.vkouhutn1ed6763.rcgu.o" "-L" "/Users/codenutt/code/t/target/debug/deps" "-L" "/Users/codenutt/code/t/target/debug/build/ring-f5b2ebe489d1f21d/out" "-L" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/codenutt/code/t/target/debug/deps/libring-08f7f88fe5c951d4.rlib" "/Users/codenutt/code/t/target/debug/deps/libuntrusted-f69d54bc56e49cb6.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-7bed9c9534a4783f.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-f456041915a03f76.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libobject-75e72c3f3eda5e08.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-7ef5de4921915240.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-149c01b62f8a4ec5.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgimli-aa054eddcbd6d258.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-b3ef24dd1ab36f55.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-6170fd3ad3878cfb.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-af8917bc99df4867.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-b8c30b83a6ae9cd5.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libminiz_oxide-605f098102fff522.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libadler-54c9ff9352f5dccb.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-205575322fd87867.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-a3bb5dbcd821cc67.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-a58cb74e27442406.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-424a32f341952313.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-c04c718cd4c414fe.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-a072ee74c7a13846.rlib" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-6dcfe245e3c1f496.rlib" "-framework" "Security" "-lSystem" "-lc" "-lm" "-L" "/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/codenutt/code/t/target/debug/deps/libt.dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs"
  = note: ld: in /Users/codenutt/code/t/target/debug/deps/libring-08f7f88fe5c951d4.rlib(aesv8-armx-ios64.o), building for macOS, but linking in object file built for iOS Simulator, file '/Users/codenutt/code/t/target/debug/deps/libring-08f7f88fe5c951d4.rlib' for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile `t` (lib) due to previous error

Caused by:
  process didn't exit successfully: `/Users/codenutt/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name t --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=108 --crate-type lib --crate-type staticlib --crate-type cdylib --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=df8c44a3f1f87b60 --out-dir /Users/codenutt/code/t/target/debug/deps -C incremental=/Users/codenutt/code/t/target/debug/incremental -L dependency=/Users/codenutt/code/t/target/debug/deps --extern cc=/Users/codenutt/code/t/target/debug/deps/libcc-3ca6462b9cd63bea.rlib --extern ring=/Users/codenutt/code/t/target/debug/deps/libring-08f7f88fe5c951d4.rlib -L native=/Users/codenutt/code/t/target/debug/build/ring-f5b2ebe489d1f21d/out` (exit status: 1)
@briansmith
Copy link
Owner

I think you'd be more likely to find somebody to help you with this if you posted a link to a GitHub Repo that allows somebody to git clone and cargo build to reproduce this.

@tonylazarew
Copy link

FWIW this seems to be fixed by rust-lang/cc-rs#848.

@briansmith
Copy link
Owner

Thanks for reporting back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants