-
Notifications
You must be signed in to change notification settings - Fork 479
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
Archiver for musl is not ar
when in Docker image for a different architecture
#1399
Comments
It might be that |
This is kind of the expected behaviour, we check if you're cross-compiling, and attempt to use an archiver more suited for that task: Line 3288 in fcf940e
The reason you're seeing something different on your local machine might be because you have |
Or actually, I think we choose Lines 3301 to 3302 in fcf940e
|
Why do the |
But then I have two questions:
I thought that too at first, but Lines 3551 to 3558 in 15fe112
The archiver is something other than
I don't. But to be clear, I'm more confused about the difference between the
No; they don't exist in those Docker images, which is why the build fails when I don't add
As mentioned above and in the Stack Overflow answer, they don't exist in the Docker container. |
@madsmtm just to clarify, are you able to reproduce the behavior in Docker using the instructions I gave in that GitHub repository?
|
Lines 3301 to 3302 in fcf940e
This check is for cross compilation, it seems that we are not doing cross compilation here but rather just changing HOST by using different docker image Is that correct? |
I suspect that maybe the docker image comes with environment vsriables set for AR, because I can't find any musl- in our code, however checking the dockerfile didn't find any Maybe you can run |
Huh. But that's the entire reason for that check?
Didn't yet, I don't have Docker installed locally, and it's kind of a hazzle so I was hoping to do without.
See |
If you could provide the output of |
Sure thing! Similar to before, I ran this command first:
Here are the outputs when running on my M1 MacBook:
And here they are when running on my x86 Linux machine:
As you can see, all the |
Correct, I think! Because passing |
Thanks for the output, that is indeed weird. I'm out of time for today, but I'll take a look during the weekend (if @NobodyXu doesn't get to it first ;)).
Yeah, we're still cross-compiling here. |
While it's technically a cross compilation, cc-rs cannot detect it as rustc host has been changed with the target. |
@NobodyXu hmm... I'm not sure I quite understand, could you explain? Cross-compilation just means the target and host are different, and they are different in this case because one is |
And all those |
Oh sorry I got confused😂so you are compiling musl on glibc env, yes that's always cross compilation |
@NobodyXu yes, that works! But I still don't understand how this bug happened in the first place; why does the |
I suspect this is an implementation difference. If you check the PR, the only thing I've added is the exit Before the PR we just check if spawning the process is alright, afterwards we also check exit status of the process spawned. So if If it looks for the binary after spawning the process then it does not work. This might be the difference between fork + exec and vfork + exec, vfork requires the binary to be located before spawning. @samestep you can try using strace to find out if fork or vfork is used |
When I use
cc
natively on Linux or macOS,cc::Build::get_archiver
always returnsar
when I'm building for either x86 musl or ARM musl. However, when I try to do the same build in arust
Docker image, and the--platform
is not my native platform, it sometimes attempts other names for the archiver program (likemusl-ar
oraarch64-linux-musl-ar
) which cause the build to fail.This forces me to set a
TARGET_AR
variable in myDockerfile
if I depend on crates likewasmtime
that transitively depend on crates likezstd-sys
; see this Stack Overflow question for such an example, which is itself boiled down from gradbench/gradbench#233 that was my real use case.See this GitHub repository which includes a full code example to reproduce the issue. As also written in that
README.md
, here are the different values I see returned bycc::Build::get_archiver
in various contexts:"ar"
"ar"
"ar"
"musl-ar"
"ar"
"ar"
"ar"
"ar"
"ar"
"aarch64-linux-musl-ar"
The text was updated successfully, but these errors were encountered: