You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Cabal unconditionally invokes pkg-config --libs when collecting arguments, which is not sufficient for certain static linking scenarios:
When statically linking, it should use pkg-config --static --libs instead.
To Reproduce
Download hw-kafka-client and change its extra-libraries: rdkafka to pkgconfig-depends: rdkafka.
Create a package with build-depends: hw-kafka-client, use a cabal.project file to have the test package use your local hw-kafka-client and attempt to build it using a musl64 cross-toolchain (easiest to use haskell.nix for this). Expect to see unresolved symbol errors of the form:
/nix/store/b07pcb91l2q1iasnqj74bajikd43b714-rdkafka-1.6.0-x86_64-unknown-linux-musl/lib/librdkafka.a(rdkafka_ssl.o):function rd_kafka_ssl_ctx_init: error: undefined reference to 'OpenSSL_version_num'
(The failure can be worked around with extra-libraries: rdkafka ssl crypto z.)
Cause of failure:
The linker command line mentions -lrdkafka but not -lssl -lcrypto, which are required by objects in librdkafka.a.
rdkafka.pc correctly lists the -lssl etc in Libs.private.
Reading between the lines of the pkg-config manual, the Libs.private are only added when statically linking. You can confirm this by running pkg-config --static --libs rdkafka and pkg-config --libs rdkafka and comparing their output.
Cabal only ever invokes pkg-config --libs as far as I can tell (see link at top of issue), so the musl64 build fails.
A package that has build-depends: hw-kafka-client will not statically link (using musl64 cross-toolchain from haskell.nix) due to missing -lssl and -lcrypto on the linker command-line.
Expected behavior
Additional flags for static linking should make their way through to the linker command line, and the program should build without errors.
The text was updated successfully, but these errors were encountered:
Attached is a minimal reproduction case. unpack the tarball, cd into example and run the shell script - it will download a copy of hw-kafka-client and change it to use pkgconfig-depends. Then run nix-build and you'll see the linker errors I'm talking about. Make sure to set up the IOHK nix cache first.
Describe the bug
Cabal unconditionally invokes
pkg-config --libs
when collecting arguments, which is not sufficient for certain static linking scenarios:cabal/Cabal/src/Distribution/Simple/Configure.hs
Line 1640 in 00a2351
When statically linking, it should use
pkg-config --static --libs
instead.To Reproduce
hw-kafka-client
and change itsextra-libraries: rdkafka
topkgconfig-depends: rdkafka
.build-depends: hw-kafka-client
, use acabal.project
file to have the test package use your localhw-kafka-client
and attempt to build it using a musl64 cross-toolchain (easiest to usehaskell.nix
for this). Expect to see unresolved symbol errors of the form:(The failure can be worked around with
extra-libraries: rdkafka ssl crypto z
.)Cause of failure:
-lrdkafka
but not-lssl -lcrypto
, which are required by objects inlibrdkafka.a
.rdkafka.pc
correctly lists the-lssl
etc inLibs.private
.pkg-config
manual, theLibs.private
are only added when statically linking. You can confirm this by runningpkg-config --static --libs rdkafka
andpkg-config --libs rdkafka
and comparing their output.pkg-config --libs
as far as I can tell (see link at top of issue), so the musl64 build fails.A package that has
build-depends: hw-kafka-client
will not statically link (usingmusl64
cross-toolchain fromhaskell.nix
) due to missing-lssl
and-lcrypto
on the linker command-line.Expected behavior
Additional flags for static linking should make their way through to the linker command line, and the program should build without errors.
The text was updated successfully, but these errors were encountered: