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

rust: cross build broken on armv*hf-musl #3605

Closed
Gottox opened this issue Oct 9, 2018 · 10 comments · Fixed by #3652
Closed

rust: cross build broken on armv*hf-musl #3605

Gottox opened this issue Oct 9, 2018 · 10 comments · Fixed by #3652

Comments

@Gottox
Copy link
Member

Gottox commented Oct 9, 2018

In the last few days we made huge steps forward to get a cross (and native non-x86) environment for rust.

@Cogitri, @jnbr, and I fixed all glibc platforms and aarch64 for both musl and glibc. The only platforms that remained broken are armv6hf-musl and armv7hf-musl.

The error occurs during cross building while linking rustc. It seems that libunwind is built with a wrong configuration. As noted in https://github.com/rust-lang/rust/blob/1.29.1/src/libunwind/libunwind.rs#L178, _Unwind_GetIP is implemented as a macro which is handled below the comment. As you can see in the buildlog, the linker complains about the missing function which indicates, that at https://github.com/rust-lang/rust/blob/1.29.1/src/libunwind/libunwind.rs#L96 the wrong branch is taken.

https://gist.github.com/Gottox/ebb16c18150b5d6daec7c67daaacd4b4

@Cogitri
Copy link
Contributor

Cogitri commented Oct 9, 2018

Well, the easiest way to find out is removing the supposedly wrong branch, I guess :D
https://gist.githubusercontent.com/Cogitri/3877c5ef3a08a8ad68a26a7b81d2df21/raw/b5fed95dbb0ccb2d970a12aefb906fb8f1f1461e/diff

Currently building with this - not that I actually want to use it, but it'd be good to know if it's actually caused by this.

@Gottox
Copy link
Member Author

Gottox commented Oct 9, 2018

wouldn't that break the stage1 compiler?

@Cogitri
Copy link
Contributor

Cogitri commented Oct 9, 2018

Oh, oops, yes. Currently testing some other stuff, let's see...

@Cogitri
Copy link
Contributor

Cogitri commented Oct 9, 2018

Hm, I've reversed the logic of that function and it still returns the same error, I start doubting that the error actually comes from that...
https://gist.github.com/48ed2b3a37f3184aba866a3d2e1f7f98

@Duncaen
Copy link
Member

Duncaen commented Oct 10, 2018

I looked into it again but couldn't find a better explanation.
there is backtrace-sys/libbacktrace, but I think the files that actually use _Unwind_GetIP{,Info} are not actually used.

I don't have a machine to do test builds, so what I found was by looking at the sources.
Maybe a comparison between builds armv7 with glibc and musl would be interesting.

@jnbr
Copy link
Contributor

jnbr commented Oct 10, 2018

Comparing the libstd-xxx.so files on glibc and musl shows that in both cases the correct branch is taken in libunwind/libunwind.rs. The problem is, that musl additionally links against _unwind_GetIP which comes from unwind() from src/vendor/backtrace-sys/src/libbacktrace/backtrace.c.

@Duncaen
Copy link
Member

Duncaen commented Oct 11, 2018

The difference is the the default include path order is different in musl and glibc.
Musl builds use libunwinds unwind.h and glibc builds use the unwind.h file provided by gcc.

They both provide the same api/prototypes, except that libgcc_s.so does not provide some functions (_Unwind_GetIP being one of them) for arm and defines a macro instead.
This is not directly a problem for other architectures where libgcc_s.so provides all the defined functions but still a mess and I don't really know how to work around it.

There are a few possible solutions I can think of:

  • Get rid of libunwind entirely if this would be possible.
  • Rename the header in libunwind.
  • Use #include_next <unwind.h> in libunwinds header, but this would still mean glibc and musl builds use different header files.

@jnbr
Copy link
Contributor

jnbr commented Oct 11, 2018

libunwind wasn't used before rust-1.28. Re-adding some old patches should make it work without again. Waiting for the build to complete ...

@Duncaen
Copy link
Member

Duncaen commented Oct 11, 2018

Nice I got the same feedback from musls freenode channel and a patch smaeul/rust@e3b9058

jnbr added a commit to jnbr/void-packages that referenced this issue Oct 11, 2018
@jnbr
Copy link
Contributor

jnbr commented Oct 11, 2018

we're currently building rust without crt-static, also bootstrap/sanity.rs errors out if there is no libunwind.a

jnbr added a commit to jnbr/void-packages that referenced this issue Oct 11, 2018
Gottox pushed a commit that referenced this issue Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants