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

mold: error: undefined symbol: OPENSSL_ia32cap_P #1315

Open
psiddire opened this issue Jul 22, 2024 · 7 comments
Open

mold: error: undefined symbol: OPENSSL_ia32cap_P #1315

psiddire opened this issue Jul 22, 2024 · 7 comments

Comments

@psiddire
Copy link

Setup
Machine - SUSE Linux Enterprise Server version 12.
GCC - 12.3.0
cmake - 3.25.1

As I do not have root permissions, I installed mold in a local directory and added it to the path.
I ran the build with mold -run make install

It ran fine for the most part, but received the following error:
mold: error: undefined symbol: OPENSSL_ia32cap_P

This is because I am using OpenSSL in one of the source files:
openssl - 1.1.1g

The error mentions that the above symbol is referenced in the following file: openssl/openssl-1.1.1g/openssl-64bit-release-static-gcc-8.2.0/lib/libcrypto.a(cryptlib.o):(OPENSSL_cpuid_setup)

I did not receive this error when I used the default linker, so I know that it works.

Seems to be an issue with mold. Is there a bypass or a workaround for this?

@rui314
Copy link
Owner

rui314 commented Jul 22, 2024

We need more information about your issue to see what went wrong. Is your program open-source? I need to reproduce the issue locally to debug it.

@psiddire
Copy link
Author

Unfortunately it is not open-source. I'll try to create a small test case and share with you.

@BenWhetton
Copy link

I'm also having this problem. The project is doing something questionable IMO, but gold is able to link it no problem. The project depends on a closed-source commercially licensed library which bundles a number of its own dependencies as shared libraries, openssl among them. The project also uses vcpkg to depend on openssl directly from source. My guess is that the project's code which uses openssl directly is statically linking to the openssl from vcpkg, and the closed source libs are dynamically linking to the bundled openssl, so it "works" ok, but mold doesn't like it for some reason.
I haven't been able to reproduce the issue without the commercially licensed library yet, so I can't share a repro, unfortunately.

A little googling led me to this stackoverflow question which contains a possible clue: "What is your link command? OPENSSL_ia32cap_P has public visibility in libcrypto.a. However, it is private in libcrypto.so"

@rui314
Copy link
Owner

rui314 commented Sep 12, 2024

@BenWhetton Can you upload your libcrypt.so and libcrypto.a?

@rui314
Copy link
Owner

rui314 commented Sep 12, 2024

Also please try to run the final link command with -Wl,-y,OPENSSL_ia32cap_P and copy-n-paste the output here. It allows you to see who defines that symbol in your link command.

@BenWhetton
Copy link

Thanks for getting back to me so quickly! I think the relevant lines in the linker output are:

trace-symbol: vcpkg_installed/x64-linux/debug/lib/libcrypto.a(libcrypto-lib-x86_64cpuid.o): definition of OPENSSL_ia32cap_P
trace-symbol: <redacted_commercial_closed_source_lib>.so: definition of OPENSSL_ia32cap_P

And the libcrypto files:
libcrypto.zip

@rui314
Copy link
Owner

rui314 commented Sep 13, 2024

I think I need a copy of that closed-source .so file. If you can, can you upload it to some secret URL and share it with me via email? My email is rui314@gmail.com. I'll delete the file from my machine after debugging.

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