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
[SR-14186] swiftc doesn't work under qemu-x86-64 emulation #56564
Comments
@swift-ci create |
qemu's strace says
but weirdly, if I just run the step that allegedly failed, it works:
finishes without an error and produces More interestingly, if I link that myself using
that works and produces
|
Same with the latest
|
Okay, so I think the problem is here:
contains this Intel code
and after that's run, we get into The ARM code for that above TB (translation block) is
|
yes, when running qemu like
it outputs
so there's a signal 4 (SIGILL) right when running that code. |
I've played a little more with this. First of all, I created this (multi-stage) docker file which gets you from nothing to:
So basically if you put the following file as
and then you run
then after a while you should have a docker image called
inside there, you can then
to give it a shot. I'll fail, but you can then further debug with for example
which in my case again leads to
again pointing to that |
Okay, I made a major leap forward and could reproduce this in a tiny C program. First of all, my latest
and then the C repro program:
The C program just executes a The outcome is this: 1. works when run directly (no fork/exec)
2. works when we do the
3. FAILS if the
The reason the third case fails is because likely because it uses |
Okay, I have not fully debugged this. So basically the problem is that qemu-user doesn't do anything special on exec. That means that in most cases, execing from a qemu-user (if the target architecture is different to the host architecture) would actually fail because the exec'd binary will be for the wrong architecture. Long story "short": I can work around this problem by doing the following steps:
Then, I actually got the whole thing working!!! I just successfully compiled SwiftNIO for x86_64 using the normal swift.org toolchain for Ubuntu 20.04 (on x86_64) on an M1 Mac in Docker 🙂 |
My Dockerfile that builds the whole thing, including the Qemu patch but EXCLUDING (don't think that's possible) the binfmt_misc handler is here
|
This issue can be closed. It works with Selecting |
If Docker for Mac fix issue docker/for-mac#5561 , then we can probably remove the |
Additional Detail from JIRA
md5: 2010a8bbf8ef17bc2b4c8edbd4aa7eca
Issue Description:
When running the
swift:5.3
docker image which is only available for x86-64 on the M1 Docker for Mac, swiftc crashes immediately.Run docker on an M1 Mac as
then in the container, run swiftc
symbolised, this roughly is
The text was updated successfully, but these errors were encountered: