Skip to content

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

@he32

Description

@he32
Contributor

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} 

Activity

added
C-bugCategory: This is a bug.
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
on Feb 25, 2025
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 25, 2025
beetrees

beetrees commented on Feb 25, 2025

@beetrees
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

beetrees commented on Feb 25, 2025

@beetrees
Contributor

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

added
F-f16_and_f128`#![feature(f16)]`, `#![feature(f128)]`
O-MIPSTarget: MIPS processors
on Feb 25, 2025
tgross35

tgross35 commented on Feb 25, 2025

@tgross35
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

he32 commented on Feb 25, 2025

@he32
ContributorAuthor

What was the last version that worked?

1.84.1 completed the cross-build for this target.

tgross35

tgross35 commented on Feb 25, 2025

@tgross35
Contributor

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?

added
A-crossArea: Cross compilation
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 25, 2025
beetrees

beetrees commented on Feb 25, 2025

@beetrees
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

beetrees commented on Feb 25, 2025

@beetrees
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?

7 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-clippyArea: ClippyA-crossArea: Cross compilationC-bugCategory: This is a bug.F-f16_and_f128`#![feature(f16)]`, `#![feature(f128)]`O-MIPSTarget: MIPS processorsT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @he32@uweigand@tgross35@fmease@rustbot

        Issue actions

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