Closed pnehrer closed 3 years ago
@benesch do you think this is a viable approach? Any pointers would be greatly appreciated!
Hey, sorry for the delay! I'm not opposed to adding more search prefixes in principle, though I'm not sure DEP_SASL2_ROOT
is the right name for the environment variable to control that behavior. The DEP
prefix is to me indicates the magic Cargo variables that get passed around.
We could follow the OpenSSL crate here I suppose and use SASL2_DIR
as the name of the environment variable.
Better yet, I'd love to make librdkafka just support compilation in the musl builder out of the box. What were the errors you were seeing?
Was it this?
= note: /usr/bin/ld: /workdir/target/x86_64-unknown-linux-musl/debug/deps/libsasl2_sys-04250f7405343342.rlib(dnsglue.o): undefined reference to symbol '__res_ninit@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libc.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Yes, I believe that was the error.
Ah, ok, it's because the musl builder isn't setting CC
to musl-gcc
and autoconf can't guess that it's supposed to use "musl-gcc" either. If you set CC
and CXX
before invoking cargo
, I bet things will just work out of the box for you with the gssapi-vendored
feature:
docker run ekidd/rust-musl-builder:nightly-2020-11-19 env CC=musl-gcc CXX=musl-g++ cargo build
Hmmm I now get different errors:
= note: /usr/bin/ld: /home/rust/src/target/debug/deps/liblibgit2_sys-38ef062e5795b808.rlib(attr.o): relocation R_X86_64_32 against `.rodata.__func__.10182' can not be used when making a PIE object; recompile with -fPIC
Thank you for the fix in #24, that should work for me!
You bet! Just published as v0.1.13 to crates.io.
= note: /usr/bin/ld: /home/rust/src/target/debug/deps/liblibgit2_sys-38ef062e5795b808.rlib(attr.o): relocation R_X86_64_32 against `.rodata.__func__.10182' can not be used when making a PIE object; recompile with -fPIC
For what it's worth, this is an issue with libgit2, it looks like, not libsasl2. libgit2 might need a stanza like this in its build script:
I wonder if it would be possible to support custom libsasl2 installation prefix, in addition to
/usr
and/usr/local
.My use-case: I need to build rdkafka against x86_64-unknown-linux-musl in Docker using rust-musl-builder. In order to support this, I first build libsasl2, then indicate that I want librdkafka to link libsasl2 statically at the given install path:
Note that the vendored build using
gssapi-vendored
seems to fail to link, so I use this: