mold icon indicating copy to clipboard operation
mold copied to clipboard

mold: error: undefined symbol: OPENSSL_ia32cap_P

Open psiddire opened this issue 1 year ago • 7 comments
trafficstars

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?

psiddire avatar Jul 22 '24 20:07 psiddire

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.

rui314 avatar Jul 22 '24 21:07 rui314

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

psiddire avatar Jul 23 '24 17:07 psiddire

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"

BenWhetton avatar Sep 11 '24 13:09 BenWhetton

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

rui314 avatar Sep 12 '24 01:09 rui314

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.

rui314 avatar Sep 12 '24 02:09 rui314

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

BenWhetton avatar Sep 12 '24 14:09 BenWhetton

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 [email protected]. I'll delete the file from my machine after debugging.

rui314 avatar Sep 13 '24 03:09 rui314

I can't be sure my environment is exactly the same as last time I checked, but I think this is fixed in the latest release. Amazing job solving it! Thanks :pray:

BenWhetton avatar Nov 28 '24 14:11 BenWhetton