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

add mips/mips64 compiler-rt fallbacks so that libgcc is not required #341

Merged
merged 1 commit into from
Aug 23, 2020

Conversation

vfreex
Copy link
Contributor

@vfreex vfreex commented Feb 12, 2020

This adds compiler-rt fallbacks for mips and mips64 arches.

Solves linking issues like rust-lang/rust#57820.

Signed-off-by: Yuxiang Zhu vfreex@gmail.com

@vfreex vfreex force-pushed the add-mips-compiler-rt-fallback branch 2 times, most recently from ea4c64f to cc90d0e Compare February 12, 2020 07:32
@vfreex
Copy link
Contributor Author

vfreex commented Feb 12, 2020

It looks like compiler-rt builds for mips targets were never run before. There are some build failures like this:

cargo:warning=mips64el-linux-gnuabi64-gcc: error: ./compiler-rt/lib/builtins/fp_mode.c: No such file or directory

That is because fp_mode.c was introduced in llvm 9 (https://github.com/llvm-mirror/compiler-rt/commits/master/lib/builtins/arm/fp_mode.c) however the CI system uses llvm 8 fork https://github.com/rust-lang/llvm-project.

Really like to have mips arches rolling without linking to libgcc. Not sure how to proceed now. But let me try fixing the CI error first.

@vfreex vfreex force-pushed the add-mips-compiler-rt-fallback branch from cc90d0e to aaca9e1 Compare February 12, 2020 19:31
This adds compiler-rt fallbacks for mips and mips64 arches.

Solves linking issues like rust-lang/rust#57820.

Signed-off-by: Yuxiang Zhu <vfreex@gmail.com>
@vfreex vfreex force-pushed the add-mips-compiler-rt-fallback branch from aaca9e1 to 3f012a8 Compare February 12, 2020 19:34
@nivkner
Copy link

nivkner commented Feb 14, 2020

I see this includes fall-backs for __addtf3, __multf3 and __subtf3,
which are also missing from aarch64-unknown-linux-musl, as seen in #201 .
can this PR include those symbols for aarch64 so that issue can also be fixed?

@vfreex
Copy link
Contributor Author

vfreex commented Feb 17, 2020

@nivkner I haven't checked aarch64 build. Would like to have them in another PR.
I think ideally we should have rust implementations for those missing functions eventually. Not sure what the rust developers' plan about that.

Getting rid of libgcc/libgcc_s will make cross compiling much easier (closer to golang's cross compiling experience)

("__fixunstfsi", "fixunstfsi.c"),
("__floatunsitf", "floatunsitf.c"),
("__fe_getround", "fp_mode.c"),
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list should probably contain all the tf (long double) builtins from compiler-rt:

set(GENERIC_TF_SOURCES
  comparetf2.c
  extenddftf2.c
  extendsftf2.c
  fixtfdi.c
  fixtfsi.c
  fixtfti.c
  fixunstfdi.c
  fixunstfsi.c
  fixunstfti.c
  floatditf.c
  floatsitf.c
  floattitf.c
  floatunditf.c
  floatunsitf.c
  floatuntitf.c
  multc3.c
  trunctfdf2.c
  trunctfsf2.c
)

We can't implement these in Rust since Rust doesn't have a long double type.

@Amanieu Amanieu merged commit caa19a7 into rust-lang:master Aug 23, 2020
@Amanieu
Copy link
Member

Amanieu commented Aug 23, 2020

Since the author is inactive, I'll make the requested changes in another PR.

@messense
Copy link
Contributor

messense commented Mar 24, 2021

I'm getting the following error in https://github.com/messense/rust-musl-cross/runs/2181084617?check_suite_focus=true

  = note: /usr/local/musl/bin/../lib/gcc/mips64-unknown-linux-muslabi64/9.2.0/../../../../mips64-unknown-linux-muslabi64/bin/ld: /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mips64-unknown-linux-muslabi64/lib/liblibc-66e0d59b0ec4686b.rlib(vfscanf.lo): in function `vfscanf':
          /build/musl-1.1.24/src/stdio/vfscanf.c:306: undefined reference to `__trunctfsf2'
          /usr/local/musl/bin/../lib/gcc/mips64-unknown-linux-muslabi64/9.2.0/../../../../mips64-unknown-linux-muslabi64/bin/ld: /build/musl-1.1.24/src/stdio/vfscanf.c:306: undefined reference to `__trunctfsf2'
          /usr/local/musl/bin/../lib/gcc/mips64-unknown-linux-muslabi64/9.2.0/../../../../mips64-unknown-linux-muslabi64/bin/ld: /build/musl-1.1.24/src/stdio/vfscanf.c:309: undefined reference to `__trunctfdf2'
          /usr/local/musl/bin/../lib/gcc/mips64-unknown-linux-muslabi64/9.2.0/../../../../mips64-unknown-linux-muslabi64/bin/ld: /build/musl-1.1.24/src/stdio/vfscanf.c:309: undefined reference to `__trunctfdf2'
          /usr/local/musl/bin/../lib/gcc/mips64-unknown-linux-muslabi64/9.2.0/../../../../mips64-unknown-linux-muslabi64/bin/ld: /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mips64-unknown-linux-muslabi64/lib/liblibc-66e0d59b0ec4686b.rlib(floatscan.lo): in function `decfloat':
          /build/musl-1.1.24/src/internal/floatscan.c:304: undefined reference to `__trunctfdf2'
          /usr/local/musl/bin/../lib/gcc/mips64-unknown-linux-muslabi64/9.2.0/../../../../mips64-unknown-linux-muslabi64/bin/ld: /build/musl-1.1.24/src/internal/floatscan.c:304: undefined reference to `__trunctfdf2'
          /usr/local/musl/bin/../lib/gcc/mips64-unknown-linux-muslabi64/9.2.0/../../../../mips64-unknown-linux-muslabi64/bin/ld: /build/musl-1.1.24/src/internal/floatscan.c:172: undefined reference to `__divtf3'
          /usr/local/musl/bin/../lib/gcc/mips64-unknown-linux-muslabi64/9.2.0/../../../../mips64-unknown-linux-muslabi64/bin/ld: /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mips64-unknown-linux-muslabi64/lib/liblibc-66e0d59b0ec4686b.rlib(fmodl.lo): in function `fmodl':
          /build/musl-1.1.24/src/math/fmodl.c:17: undefined reference to `__divtf3'

Is it resolvable by adding the missing sources like this PR does?

Edit: Opened #408

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 this pull request may close these issues.

4 participants