Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build.rustflags config ignored, while inlines RUSTFLAGS works #14199

Closed
Nabellaleen opened this issue Jul 5, 2024 · 4 comments
Closed

build.rustflags config ignored, while inlines RUSTFLAGS works #14199

Nabellaleen opened this issue Jul 5, 2024 · 4 comments
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@Nabellaleen
Copy link

Nabellaleen commented Jul 5, 2024

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

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

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]
@Nabellaleen Nabellaleen added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jul 5, 2024
@weihanglo
Copy link
Member

In the log file:

warning: unused manifest key: build

[build] is a table for the Cargo configuration, which is usually a file at <package-root>/.cargo/config.toml. Could you check that?

@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Jul 6, 2024
@Nabellaleen
Copy link
Author

Nothing like that :/

$ find / -type f -name "config.toml" 2>/dev/null
/home/user/Projects/Utils/mage/site/config.toml
/home/user/Projects/Utils/mage/site/themes/learn/exampleSite/config.toml
/home/user/go/pkg/mod/github.com/magefile/mage@v1.15.0/site/config.toml
/home/user/go/pkg/mod/github.com/magefile/mage@v1.15.0/site/themes/learn/exampleSite/config.toml
/home/user/go/pkg/mod/github.com/!three!dots!labs/watermill@v1.3.5/docs/config.toml
/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/create-tauri-app-4.0.1/.cargo/config.toml
/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/console-0.15.8/.cargo/config.toml
/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tiny-skia-0.11.4/.cargo/config.toml
/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dialoguer-0.11.0/.cargo/config.toml
/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytemuck-1.16.1/.cargo/config.toml
/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cfg-expr-0.15.8/.cargo/config.toml
/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.40.1/.cargo/config.toml
/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wry-0.41.0/.cargo/config.toml
/etc/containerd/config.toml

And indeed, this warning is interesting : it appears only when I add the [build] table with the rustflags entry in my Cargo.toml

@Nabellaleen
Copy link
Author

Doh ... I get it.

Indeed, it's a confusion from me (and many others, it seems ^^) that this cargo config NEED to be in a .cargo/config.toml file and not in the Cargo.toml (even if its name let suppose it ... XD)

Why is there a separate file config.toml and this is not in the Manifest ?

@weihanglo
Copy link
Member

See below issues for relevant discussions:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

2 participants