Closed
Description
Problem
When I call with inlined env values, everything works fine :
LD_LIBRARY_PATH='/path/to/dynamic/lib' RUSTFLAGS='-L /path/to/dynamic/lib -L locallibdir -ldynamiclib -lstaticlib' cargo run
But when I migrate to Cargo.toml
, it fails :
// Cargo.toml
...
[build]
rustflags = "-L /path/to/dynamic/lib -L locallibdir -ldynamiclib -lstaticlib"
...
$ LD_LIBRARY_PATH='/opt/santesocial/fsv/1.40.13/lib' cargo run
// Error
...
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
...
Looks like these issues, somehow
- the .cargo/config.toml rustflags did not passed to the compiler #12794
- Cargo doesn't pass RUSTFLAGS "-L native=/path" to linker commands with -lffi #4452
Steps
No response
Possible Solution(s)
No response
Notes
I've check for other config which could override my Cargo.toml, but didn't find anything :
$ env | grep RUSTFLAGS
// Nothing
$ cargo +nightly -Z unstable-options config get --show-origin
# The following environment variables may affect the loaded values.
# CARGO_HOME=/home/user/.cargo
$ ls -la /home/user/.cargo
total 184
drwxr-xr-x. 1 user user 174 6 juil. 01:07 .
drwx------. 1 user user 1190 6 juil. 00:29 ..
drwxr-xr-x. 1 user user 324 3 juil. 19:15 bin
-rw-r--r--. 1 user user 1404 3 juil. 19:15 .crates2.json
-rw-r--r--. 1 user user 309 3 juil. 19:15 .crates.toml
-rw-r--r--. 1 user user 300 29 juin 23:13 env
-rw-r--r--. 1 user user 172032 6 juil. 01:07 .global-cache
-rw-r--r--. 1 user user 0 24 juin 21:25 .package-cache
-rw-r--r--. 1 user user 0 24 juin 21:25 .package-cache-mutate
drwxr-xr-x. 1 user user 50 24 juin 21:29 registry
And here are the logs of a build :
$ LD_LIBRARY_PATH='/path/to/dynamic/lib' cargo build -vv &> build.log
Version
cargo 1.79.0 (ffa9cf99a 2024-06-03)
release: 1.79.0
commit-hash: ffa9cf99a594e59032757403d4c780b46dc2c43a
commit-date: 2024-06-03
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w 11 Sep 2023
os: Fedora 39.0.0 [64-bit]