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

Cross-build of 1.85.0 to mipsel-unknown-netbsd fails w/missing __gnu_h2f_ieee and __gnu_f2h_ieee. #137630

Open
he32 opened this issue Feb 25, 2025 · 10 comments
Labels
A-clippy Area: Clippy A-cross Area: Cross compilation C-bug Category: This is a bug. F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` O-MIPS Target: MIPS processors T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@he32
Copy link
Contributor

he32 commented Feb 25, 2025

Summary

I'm going through the round of updating our (NetBSD's pkgsrc) rust package, and have this time come around to making a rust 1.85.0 package in pkgsrc-wip. The cross-build succeeds for most of the targets we try to support, but the 32-bit mips target now fails to build in a novel way.

Command used

Nothing special, x.py ..., cross-building from NetBSD/amd64 10.99.12.

Expected behaviour

I was expecting the build to succeed.

Actual behaviour

The build stopped after emitting these error messages:

          clippy_utils.c33fa2c5294c0ca2-cgu.08:(.text._RNvMs7_NtCsgLiP1snAFCU_12clippy_utils6constsNtB5_13ConstEvalCtxt4expr+0xa7c): undefined reference to `__gnu_h2f_ieee'
          /u/mipsel/tools/bin/../lib/gcc/mipsel--netbsd/10.5.0/../../../../mipsel--netbsd/bin/ld: clippy_utils.c33fa2c5294c0ca2-cgu.08:(.text._RNvMs7_NtCsgLiP1snAFCU_12clippy_utils6constsNtB5_13ConstEvalCtxt4expr+0xa88): undefined reference to `__gnu_h2f_ieee'
          /u/mipsel/tools/bin/../lib/gcc/mipsel--netbsd/10.5.0/../../../../mipsel--netbsd/bin/ld: clippy_utils.c33fa2c5294c0ca2-cgu.08:(.text._RNvMs7_NtCsgLiP1snAFCU_12clippy_utils6constsNtB5_13ConstEvalCtxt4expr+0xa90): undefined reference to `__gnu_f2h_ieee'
          /u/mipsel/tools/bin/../lib/gcc/mipsel--netbsd/10.5.0/../../../../mipsel--netbsd/bin/ld: clippy_utils.c33fa2c5294c0ca2-cgu.08:(.text._RNvMs7_NtCsgLiP1snAFCU_12clippy_utils6constsNtB5_13ConstEvalCtxt4expr+0xa98): undefined reference to `__gnu_f2h_ieee'
          /u/mipsel/tools/bin/../lib/gcc/mipsel--netbsd/10.5.0/../../../../mipsel--netbsd/bin/ld: clippy_utils.c33fa2c5294c0ca2-cgu.08:(.text._RNvMs7_NtCsgLiP1snAFCU_12clippy_utils6constsNtB5_13ConstEvalCtxt4expr+0xc00): undefined reference to `__gnu_h2f_ieee'
          /u/mipsel/tools/bin/../lib/gcc/mipsel--netbsd/10.5.0/../../../../mipsel--netbsd/bin/ld: clippy_utils.c33fa2c5294c0ca2-cgu.08:(.text._RNvMs7_NtCsgLiP1snAFCU_12clippy_utils6constsNtB5_13ConstEvalCtxt4expr+0xc0c): undefined reference to `__gnu_h2f_ieee'
          /u/mipsel/tools/bin/../lib/gcc/mipsel--netbsd/10.5.0/../../../../mipsel--netbsd/bin/ld: clippy_utils.c33fa2c5294c0ca2-cgu.08:(.text._RNvMs7_NtCsgLiP1snAFCU_12clippy_utils6constsNtB5_13ConstEvalCtxt4expr+0xc14): undefined reference to `__gnu_f2h_ieee'
          /u/mipsel/tools/bin/../lib/gcc/mipsel--netbsd/10.5.0/../../../../mipsel--netbsd/bin/ld: clippy_utils.c33fa2c5294c0ca2-cgu.08:(.text._RNvMs7_NtCsgLiP1snAFCU_12clippy_utils6constsNtB5_13ConstEvalCtxt4expr+0xc1c): undefined reference to `__gnu_f2h_ieee'
          /u/mipsel/tools/bin/../lib/gcc/mipsel--netbsd/10.5.0/../../../../mipsel--netbsd/bin/ld: link errors found, deleting executable `/usr/pkgsrc/wip/rust185/work/rustc-1.85.0-src/build/x86_64-unknown-netbsd/stage1-tools/mipsel-unknown-netbsd/release/deps/clippy_driver-3e44b5b01533b167'
          collect2: error: ld returned 1 exit status

Bootstrap configuration (config.toml)

For what it's worth:

profile = 'dist'
[llvm]
release-debuginfo = false
static-libstdcpp = false
ninja = false
targets = 'Mips;X86'
[build]
host = ['mipsel-unknown-netbsd']
target = ['mipsel-unknown-netbsd']
cargo = '/usr/pkgsrc/wip/rust185/work/rust-bootstrap/bin/cargo'
rustc = '/usr/pkgsrc/wip/rust185/work/rust-bootstrap/bin/rustc'
docs = false
compiler-docs = false
python = '/usr/pkg/bin/python3.12'
vendor = true
extended = true
cargo-native-static = true
configure-args = ['--prefix=/usr/pkg', '--mandir=/usr/pkg/man', '--sysconfdir=/usr/pkg/etc', '--python=/usr/pkg/bin/python3.12', '--release-channel=stable', '--local-rust-root=/usr/pkgsrc/wip/rust185/work/rust-bootstrap', '--enable-extended', '--enable-rpath', '--disable-codegen-tests', '--disable-compiler-docs', '--disable-llvm-static-stdcpp', '--disable-ninja', '--dist-compression-formats=xz', '--set', 'dist.vendor=false', '--host=mipsel-unknown-netbsd', '--target=mipsel-unknown-netbsd', '--set=target.mipsel-unknown-netbsd.cc=/usr/pkgsrc/wip/rust185/work/scripts/gcc-wrap', '--set=target.mipsel-unknown-netbsd.cxx=/usr/pkgsrc/wip/rust185/work/scripts/c++-wrap', '--set=target.mipsel-unknown-netbsd.linker=/usr/pkgsrc/wip/rust185/work/scripts/gcc-wrap', '--set=target.mipsel-unknown-netbsd.ar=/u/mipsel/tools/bin/mipsel--netbsd-ar', '--enable-vendor', '--disable-debug', '--disable-debug-assertions', '--disable-llvm-release-debuginfo', '--debuginfo-level=0', '--debuginfo-level-rustc=0', '--debuginfo-level-std=0', '--debuginfo-level-tools=0', '--debuginfo-level-tests=0', '--set', 'llvm.targets=Mips;X86', '--enable-cargo-native-static', '--disable-docs']
[install]
prefix = '/usr/pkg'
sysconfdir = '/usr/pkg/etc'
mandir = '/usr/pkg/man'
[rust]
debug = false
debug-assertions = false
debuginfo-level = 0
debuginfo-level-rustc = 0
debuginfo-level-std = 0
debuginfo-level-tools = 0
debuginfo-level-tests = 0
channel = 'stable'
rpath = true
codegen-tests = false
[target.x86_64-unknown-netbsd]
[target.mipsel-unknown-netbsd]
cc = '/usr/pkgsrc/wip/rust185/work/scripts/gcc-wrap'
cxx = '/usr/pkgsrc/wip/rust185/work/scripts/c++-wrap'
ar = '/u/mipsel/tools/bin/mipsel--netbsd-ar'
linker = '/usr/pkgsrc/wip/rust185/work/scripts/gcc-wrap'
[dist]
compression-formats = ['xz']
vendor = false

Operating system

The host OS is NetBSD/amd64 10.99.12. It has successfully cross-built rust 1.85.0 for riscv64, i586, powerpc, sparc64, armv7, armv6, aarch64 and aarch64_eb, so the host system is not under suspicion of misbehaving.

HEAD

This is the 1.85.0 release bits from your tarball distribution, i.e. not checkout out from git.

Additional context

I'm curious what's needed to get rid of this error.
I can't seem to find a pattern to follow from the other mips target descriptions.

Build Log

The build log ends with

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)

error: could not compile `clippy` (bin "clippy-driver") due to 1 previous error
Build completed unsuccessfully in 1:24:08
*** Error code 1

Stop.
make[2]: stopped in /usr/pkgsrc/wip/rust185
*** Error code 1

and an overview of the different phases already completed:

: {149} egrep '^[B0-9]' list.31
Based on these variables, the following variables have been set:
Building bootstrap
Building LLVM for mipsel-unknown-netbsd
Building LLVM for x86_64-unknown-netbsd
Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/CodeGenIntrinsics.cpp.o
Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/SDNodeProperties.cpp.o
Building stage0 library artifacts (x86_64-unknown-netbsd)
Building compiler artifacts (stage0 -> stage1, x86_64-unknown-netbsd)
Building stage0 tool lld-wrapper (x86_64-unknown-netbsd)
Building LLD for x86_64-unknown-netbsd
Building stage0 tool wasm-component-ld (x86_64-unknown-netbsd)
Building tool llvm-bitcode-linker (stage0 -> stage1, x86_64-unknown-netbsd)
Building stage1 library artifacts (x86_64-unknown-netbsd -> mipsel-unknown-netbsd)
Building stage1 library artifacts (x86_64-unknown-netbsd)
Building compiler artifacts (stage1:x86_64-unknown-netbsd -> stage2:mipsel-unknown-netbsd)
Building stage1 tool lld-wrapper (x86_64-unknown-netbsd -> mipsel-unknown-netbsd)
Building LLD for mipsel-unknown-netbsd
Building stage1 tool wasm-component-ld (x86_64-unknown-netbsd -> mipsel-unknown-netbsd)
Building tool llvm-bitcode-linker (stage1:x86_64-unknown-netbsd -> stage2:mipsel-unknown-netbsd)
Building tool rustdoc (stage1 -> stage2, mipsel-unknown-netbsd)
Building tool rust-analyzer-proc-macro-srv (stage1:x86_64-unknown-netbsd -> stage2:mipsel-unknown-netbsd)
Building stage0 tool rust-installer (x86_64-unknown-netbsd)
Building tool cargo (stage1:x86_64-unknown-netbsd -> stage2:mipsel-unknown-netbsd)
Building tool rls (stage1:x86_64-unknown-netbsd -> stage2:mipsel-unknown-netbsd)
Building tool rust-analyzer (stage1:x86_64-unknown-netbsd -> stage2:mipsel-unknown-netbsd)
Building tool rustfmt (stage1:x86_64-unknown-netbsd -> stage2:mipsel-unknown-netbsd)
Building tool cargo-fmt (stage1:x86_64-unknown-netbsd -> stage2:mipsel-unknown-netbsd)
Building tool clippy-driver (stage1:x86_64-unknown-netbsd -> stage2:mipsel-unknown-netbsd)
Build completed unsuccessfully in 1:24:08
81994.208u 5484.812s 1:27:59.08 1657.0% 29+5k 450+1805352io 21651pf+0w
: {150} 

@he32 he32 added C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Feb 25, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 25, 2025
@beetrees
Copy link
Contributor

For context: compiler-builtins usually supplies __gnu_h2f_ieee and __gnu_f2h_ieee, but these were disabled on MIPS due to LLVM bugs in LLVM 19 (this bug has since been fixed in LLVM 20).

Due to some platforms still having LLVM bugs, building the compiler/tools shouldn't require these symbols. What was the last version that worked? Looking at clippy_utils::consts, there do seem to be several uses of f16, all added in #126636. cc @tgross35

@beetrees
Copy link
Contributor

@rustbot label +F-f16_and_f128 +A-clippy +O-MIPS

@rustbot rustbot added A-clippy Area: Clippy F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` O-MIPS Target: MIPS processors labels Feb 25, 2025
@tgross35
Copy link
Contributor

Could you try this again after today's nightly comes out? The update of compiler-builtins that just went through should start building these symbols on mips.

@he32
Copy link
Contributor Author

he32 commented Feb 25, 2025

What was the last version that worked?

1.84.1 completed the cross-build for this target.

@tgross35
Copy link
Contributor

tgross35 commented Feb 25, 2025

Hm. That gives a reasonably narrow window of 2024-11-22 when 1.84 branched from master, and 2025-01-03 when 1.85 branched, but I don't see anything obvious. We could probably work around this by changing f16 to u16 in Clippy since we should only be relying on its storage format.

However, I'm not sure a workaround is worth it since f16 support was fixed upstream anyway, unless other architectures are also experiencing the problem. Would it be possible to patch the build to provide these symbols? It is probably fine to just add unimplemented!() stubs, or use compiler-builtins patched with rust-lang/compiler-builtins#762 (should be built with LLVM20 for llvm/llvm-project#110199 to have accurate results, but since LLVM19 is inaccurate rather than crashing that should still work in a pinch).

@martn3 have you noticed any similar errors while building mips, or @uweigand for s390x?

@fmease fmease added A-cross Area: Cross compilation and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 25, 2025
@beetrees
Copy link
Contributor

Looking at the list of architectures that still have compiler-builtins-blocking bugs in LLVM 20, I think the only ones that support host tools are s390x, PowerPC/PowerPC64 and SPARC64. Of those, AFAIK only the s390x bug causes compilation failures itself. The other three cause infinite recursion at runtime; however as compiler-builtins disables the affected builtins on these targets compilation errors will occur anyway. Until these bugs are fixed we probably want to avoid using f16 in the compiler/tools; even if compilation succeeds initially it might fail later due to e.g. an unrelated change changing how LLVM optimises the code (and therefore which builtins are used). (The situation for f128 is much better, with the only buggy host tools platform remaining being powerpc64-ibm-aix).

@beetrees
Copy link
Contributor

I've made a small patch for 1.85.0 that changes clippy_utils to store f16/f128 as their u16/u128 bit representation. Could you check whether it fixes the issue?

@uweigand
Copy link
Contributor

I've not seen any errors on s390x in our daily builds. We don't do regular cross-builds however, if that makes any difference.

Currently, f16 is still not supported at all on s390x - we've been making good progress with implementing this, but it's not quite ready yet. (f128 has always been fully supported, however.)

@martn3
Copy link

martn3 commented Feb 27, 2025

@martn3 have you noticed any similar errors while building mips

I have not, but in my setup I don't think I build any host tools such as clippy_utils.

@he32
Copy link
Contributor Author

he32 commented Feb 27, 2025

I've made a small patch for 1.85.0 that changes clippy_utils to store f16/f128 as their u16/u128 bit representation. Could you check whether it fixes the issue?

Thanks a bunch! I can confirm that with this patch applied, the cross-build of 1.85.0 for mipsel-unknown-netbsd now succeeds.

wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this issue Feb 27, 2025
Following on from rust-lang/rust#137630
apply patch gracefully supplied in
beetrees/rust@21f8bda
.patch
by @beetrees.

Fixes cross-build for the mipsel-unknown-netbsd target on NetBSD
which does not (yet?) support the f16 data type, at least not with
the LLVM embedded in 1.85.0 (which is LLVM version 19.1.7).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy A-cross Area: Cross compilation C-bug Category: This is a bug. F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` O-MIPS Target: MIPS processors T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

7 participants