randombit / botan

Cryptography Toolkit
https://botan.randombit.net
BSD 2-Clause "Simplified" License
2.59k stars 568 forks source link

Build failure caused by incorrect library paths order when using LDFLAGS #2847

Closed tenzap closed 2 years ago

tenzap commented 3 years ago

Hello,

I believe there is still an equivalent problem to https://github.com/randombit/botan/issues/2496

In my case, instead of having the -L/opt/local/lib set through --with-external-libdir, it is set through LDFLAGS

and -L/opt/local/lib comes before -L.

This leads to the same kind of problem when an older version of botan is already installed on the system on which a newer version is compiled:

Typically:

:info:build /opt/local/bin/clang++-mp-9.0 -fstack-protector -pthread -stdlib=libc++ build/obj/cli/argon2.o build/obj/cli/asn1.o build/obj/cli/bcrypt.o build/obj/cli/cc_enc.o build/obj/cli/cli.o build/obj/cli/cli_rng.o build/obj/cli/codec.o build/obj/cli/compress.o build/obj/cli/encryption.o build/obj/cli/entropy.o build/obj/cli/hash.o build/obj/cli/hmac.o build/obj/cli/main.o build/obj/cli/math.o build/obj/cli/pbkdf.o build/obj/cli/pk_crypt.o build/obj/cli/psk.o build/obj/cli/pubkey.o build/obj/cli/roughtime.o build/obj/cli/sandbox.o build/obj/cli/speed.o build/obj/cli/timing_tests.o build/obj/cli/tls_client.o build/obj/cli/tls_http_server.o build/obj/cli/tls_proxy.o build/obj/cli/tls_server.o build/obj/cli/tls_utils.o build/obj/cli/tss.o build/obj/cli/utils.o build/obj/cli/x509.o -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -L. -lbotan-2 -lbz2 -lcrypto -ldl -llzma -lsqlite3 -lz  -o botan
:info:build Undefined symbols for architecture x86_64:
:info:build   "Botan::Stateful_RNG::add_entropy(unsigned char const*, unsigned long)", referenced from:
:info:build       Botan_CLI::cli_make_rng(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in cli_rng.o
:info:build   "Botan::newhope_poly::~newhope_poly()", referenced from:

This is with 2.18.2 that I'm trying to build on macports

reneme commented 3 years ago

Thanks for pointing that out! I suggested a patch that should solve this. It is based on the latest master but should apply to 2.18.2 as well. Could you try whether this fixes your issue?

tenzap commented 3 years ago

Compilation finishes successfully with that patch on 2.18.2 and -L. comes before the others

reneme commented 2 years ago

I opened a PR to backport #2848 .