-
Notifications
You must be signed in to change notification settings - Fork 450
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
Support a convention for specifying more paths to toolchain binaries #82
Comments
Interestingly, AFAICT cargo does not expose the values of |
Yeah currently Cargo doesn't expose It's probably worth at least doing some parsing of |
That depends on the user. I think you can specify the linker just by giving the name, in case it is in your environment PATH. Personally I don't have it in the path and just gave the full (absolute) location to the file, which would be enough to get the directory, as all the different tools can find in the same directory as the linker. But even if the user doesn't give the full path, we should be able to get the directory of the executable on all development OS's, no? I know on Unix based systems it's possible with tools like |
I just noticed that |
@jdub certainly! I hadn't heard of those before but if they're commonly in use I'd love to have support for them. |
I might stick to
|
Ok sounds good to me! |
FYI, cargo exposes the linker configuration in the |
It looks like cargo will pass the environment variable TARGET to build scripts https://doc.rust-lang.org/cargo/reference/environment-variables.html Also of note are HOST and NUM_JOBS |
And also RUSTC_LINKER, which does what it says |
Could we also have TARGET_LD and LD distinguished? I'm cross-compiling from one x86_64-unknown-linux-gnu to a different x86_64-unknown-linux-gnu TARGET_CC and CC might work for compiling, to distinguish between build scripts and the cross-compiled binaries/libs, but the same linker is being used to build the build scripts as is being used to link the cross-compiled binaries, and so the build scripts won't run. I've had to set this script as my:
|
Can you expound on how the two targets differ? Also: I don't think this is the right place to ask this question. This is about the |
Different compilers, different libc, and ultimately to run against a different kernel. target binaries fail to run in the host environment due to linker problems. Those tickets you referred to also seem relevant, I'm not sure which (or both?) would need adjusting. |
I think that these reports all cover my use case thoroughly:
but I think this one really is the point: |
Maybe the target-applies-to-host and/or host-config feature is what is needed here? You should be able to override the host linker explicitly when using stable toolchains by setting this in your env:
Setting |
Thank you so much @jameshilliard, these touch the point so well, particularly host-config, and the tip to also apply to current stable is very gratefully received. I am surprised that these don't both have the same value, is that a mistake? :
For stable, if I set the env as described, do I override the host linker explicitly by setting HOST_LD or HOST_CC, or by using a host.* section in config.toml as explained in host-config ? EDIT: I see your example here - thanks: https://github.com/buildroot/buildroot/blob/2022.11-rc1/package/pkg-cargo.mk#L26-L47 |
Should be correct, see:
You can set this if you need a specific host linker:
|
Currently cargo supports setting
linker
andar
in a config file, which is useful but is not always sufficient for cross-compiling crates that build native libraries.While cross-compiling Servo I found that I had to specify quite a few extra tools to get everything to compile:
https://gist.github.com/luser/a33e5070d1c55a7d2c46fe763a9d1543#file-servo-cross-mac-L59
This was mostly because various crates used different build systems for building native libraries--autotools, cmake, etc. I think it'd be useful if the gcc crate supported a convention for specifying more tools in
.cargo/config
so that common crates for building native libraries (likecmake
) could use that support to drive their builds.Specifically, I think it would be useful if it allowed at least setting cc, cxx, ranlib, and exposed those values through its API.
The text was updated successfully, but these errors were encountered: