-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Setting rustflags does not work with --target #9743
Comments
Thanks for the report! Can you provide some more information, such as the project, or a minimal reproduction? Can you run with the Just FYI, there are various ways flags will be ignored. When passing |
Sure, and thanks for the quick reply! I can trigger this by adding a dependency on Cargo.toml: [package]
name = "foo"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = "1" Cargo.lock: # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "foo"
version = "0.1.0"
dependencies = [
"serde",
]
[[package]]
name = "serde"
version = "1.0.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" src/main.rs: fn main() {
println!("Hello, world!");
} Running |
I'm actually a little confused. I can't find a single mention of EDIT: maybe it comes from |
Note: not only |
Ah, yea, Cargo should only extend |
No, I don't have that it seems: $ ls /usr/lib/libiconv.dylib
ls: /usr/lib/libiconv.dylib: No such file or directory I worked around the problem by setting How can I tell cargo (as opposed to telling the linker directly with |
I'm a little curious, do you happen to know why libiconv is missing? Which version of macOS are you using, and which platform (is it an m1/arm mac)? |
Yea, I looked it up, and in macOS 11, they switched to having a hidden cache of shared libraries (62986286). Another thing that looks fishy is that your error message says |
Ok as mentioned I did not install the Xcode suite. I have a custom clang build, that's probably why it displays Is By the way, thanks a lot for taking the time here! |
Cargo doesn't deal with linking; rustc controls that process. It assumes that |
I'm going to close, at it sounds like the issue here is using a custom clang that does not know about the hidden library cache in macOS 11. You'll probably need to provide iconv somehow in the search page so that it can be found, or use the xcode clang. |
Problem
It looks like
cargo
ignores the rustflags set by environment variables (RUSTFLAGS
andCARGO_TARGET_X86_64_APPLE_DARWIN_RUSTFLAGS
andCARGO_BUILD_RUSTFLAGS
) when given--target
. For instance, in a build linked against-liconv
,cargo build
succeeds when given the proper linker arguments, whereascargo build --target <my actual target>
doesn't:If this is the expected behavior, how do I set the linker flags?
Notes
From the Compilation Options page, I understand that this "makes Cargo run in a different mode where the target artifacts are placed in a separate directory". However, as I understand it, this should only impact where the target artifacts are placed, not how the configuration is read.
Output of
cargo version
:The text was updated successfully, but these errors were encountered: