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

Upgrading to new openssl-sys crate fails to link for Lua module #72

Closed
chipsenkbeil opened this issue Oct 22, 2021 · 5 comments
Closed
Labels
help wanted Extra attention is needed

Comments

@chipsenkbeil
Copy link
Owner

See example here: https://github.com/chipsenkbeil/sample-cdylib-wezterm-ssh
A working version (maybe?) is here: https://github.com/chipsenkbeil/sample-cdylib-wezterm-ssh/tree/WorkingVersion

I'm not sure why having wezterm be an indirect dependency and the main library also being a member versus having a top-level consumer of the library would fix this. It may be a false positive as Rust could be filtering out some of the code.

Failure

During linking, I see this on Intel and M1 Macs:

   Compiling main-lib v0.1.0 (/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/main-lib)
     Running `rustc --crate-name main_lib --edition=2018 main-lib/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type cdylib --emit=dep-info,link -C opt-level=z -Clto -C codegen-units=1 -C metadata=702ba97a81d567ca --out-dir /Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/deps -L dependency=/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/deps --extern helper_lib=/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/deps/libhelper_lib-e6ab167d0119fbeb.rlib --extern mlua=/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/deps/libmlua-e3ea2a11946416a7.rlib -C link-arg=-undefined -C link-arg=dynamic_lookup -L native=/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/openssl-sys-9f63f7f8648ac00a/out/openssl-build/install/lib -L native=/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/openssl-sys-9f63f7f8648ac00a/out/openssl-build/install/lib -L native=/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/libssh-rs-sys-3cdd6e33e90fc2f0/out -Lnative=/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/libssh2-sys-0184ac85c61617d0/out/build`
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "-arch" "x86_64" "-L" "/Users/chipsenkbeil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/deps/main_lib.main_lib.6fwq71c4-cgu.0.rcgu.o" "-o" "/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/deps/libmain_lib.dylib" "-Wl,-exported_symbols_list,/var/folders/fm/5_7nb1k97tqgxf4n03_2kj780000gn/T/rustcbNtGQH/list" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs" "-L" "/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/deps" "-L" "/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/openssl-sys-9f63f7f8648ac00a/out/openssl-build/install/lib" "-L" "/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/openssl-sys-9f63f7f8648ac00a/out/openssl-build/install/lib" "-L" "/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/libssh-rs-sys-3cdd6e33e90fc2f0/out" "-L" "/Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/libssh2-sys-0184ac85c61617d0/out/build""-L" "/Users/chipsenkbeil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/var/folders/fm/5_7nb1k97tqgxf4n03_2kj780000gn/T/rustcbNtGQH/liblibssh2_sys-bd9b1e21d051066b.rlib" "/var/folders/fm/5_7nb1k97tqgxf4n03_2kj780000gn/T/rustcbNtGQH/libopenssl_sys-c28c6e425d8aa49c.rlib" "/var/folders/fm/5_7nb1k97tqgxf4n03_2kj780000gn/T/rustcbNtGQH/liblibssh_rs_sys-46abeff4fe401922.rlib" "/Users/chipsenkbeil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-160a7dd17f2dc334.rlib" "-lz""-lc" "-liconv" "-lssl" "-lcrypto" "-lz" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-undefined" "dynamic_lookup"
  = note: ld: warning: duplicate symbol '_BIO_ADDR_family' in:
              /var/folders/fm/5_7nb1k97tqgxf4n03_2kj780000gn/T/rustcbNtGQH/libopenssl_sys-c28c6e425d8aa49c.rlib(libcrypto-lib-bio_addr.o)
              /Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/openssl-sys-9f63f7f8648ac00a/out/openssl-build/install/lib/libcrypto.a(libcrypto-lib-bio_addr.o)
          ld: warning: duplicate symbol '_BIO_ADDRINFO_family' in:
              /var/folders/fm/5_7nb1k97tqgxf4n03_2kj780000gn/T/rustcbNtGQH/libopenssl_sys-c28c6e425d8aa49c.rlib(libcrypto-lib-bio_addr.o)
              /Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/openssl-sys-9f63f7f8648ac00a/out/openssl-build/install/lib/libcrypto.a(libcrypto-lib-bio_addr.o)

          ......... (bunch more warnings about duplicate symbols)

          ld: warning: duplicate symbol '_ossl_property_free' in:
              /var/folders/fm/5_7nb1k97tqgxf4n03_2kj780000gn/T/rustcbNtGQH/libopenssl_sys-c28c6e425d8aa49c.rlib(libcrypto-lib-property_parse.o)
              /Users/chipsenkbeil/projects/sample-cdylib-wezterm-ssh/target/release/build/openssl-sys-9f63f7f8648ac00a/out/openssl-build/install/lib/libcrypto.a(libcrypto-lib-property_parse.o)
          ld: reference to symbol (which has not been assigned an address) _ossl_property_parse_init in '_context_init' from /var/folders/fm/5_7nb1k97tqgxf4n03_2kj780000gn/T/rustcbNtGQH/libopenssl_sys-c28c6e425d8aa49c.rlib(libcrypto-lib-context.o) for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
@chipsenkbeil chipsenkbeil added the help wanted Extra attention is needed label Oct 22, 2021
@chipsenkbeil chipsenkbeil added this to the 1.0 milestone Oct 22, 2021
@chipsenkbeil
Copy link
Owner Author

chipsenkbeil commented Oct 22, 2021

Maybe I can statically link it per https://stackoverflow.com/questions/49263452/how-do-i-statically-link-the-openssl-sys-crate-into-a-shared-library

We're using an rlib already, so I'm pretty sure a static link to libopenssl_sys is being attempted.

@chipsenkbeil
Copy link
Owner Author

cc @wez regarding this one to move convo out from element.

@chipsenkbeil
Copy link
Owner Author

This is an apparent bug on M1, but described solution doesn't fix it for me: rust-lang/rust#90342

Should verify this works on other non-M1 platforms.

@chipsenkbeil
Copy link
Owner Author

Resolved by 050bb34.

@github-actions
Copy link

github-actions bot commented Jul 8, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant