Skip to content

Cross-build of rust 1.91.0 fails for powerpc-unknown-netbsd with linker errors #148497

@he32

Description

@he32

Summary

The cross-build for the powerpc-unknown-netbsd target fails during the build of

Building stage2 rust-analyzer (stage1:x86_64-unknown-netbsd -> stage2:powerpc-unknown-netbsd)

so at the very end of the build. The failure is:

          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: /u/macppc/dest/usr/lib/crt0.o: in function `__start':
          (.text+0x120): relocation truncated to fit: R_PPC_PLTREL24 against symbol `abort' defined in .text section in /u/macppc/dest/lib/libc.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: /u/macppc/dest/usr/lib/crt0.o: in function `___start':
          (.text+0x1bc): relocation truncated to fit: R_PPC_PLTREL24 against symbol `atexit' defined in .text section in /u/macppc/dest/lib/libc.so+8000

and many, many more similar ones.
This apparently indicates that the attempted-to-be-linked program has bloated beyond 32MB.

Command used

python3.12 ./x.py dist -j 40

with lots of environment variable tweaks for cross compilation.

Expected behaviour

I expected the build to complete without error.

Actual behaviour

See above. Some parts of the code which wants to call each other gets displaced more than 32MB apart, so the code can no longer safely use the PC-relative R_PPC_PLTREL24 relocation type (which apparently refers to 32-bit words, since 2^24 is 16M).

Bootstrap configuration (bootstrap.toml)

(empty here)

An updated bootstrap.toml can be uploaded if needed later (I'm currently building for another target...)

Operating system

Host OS: NetBSD/amd64 10.1

HEAD

castor: {11} echo `cat work/rustc-1.91.0-src/git-commit-hash `
f8297e351a40c1439a467bbbb6879088047f50b3
castor: {12} 

I.e. extracted from the 1.91.0 tarball.

Discussion

I know that on PowerPC, gcc has the additional options -mlongcall, and depending on linker and gcc version, -no-pltseq may then also be required. I will try to see if I can direct the cross-build to use these options.

However, I would like some hints how I can direct the rust compiler to do similarly for the code it generates.

Additional context

Build Log

Some more parts of the build log (still incomplete):

          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: /u/macppc/dest/usr/lib/crt0.o: in function `__start':
          (.text+0x120): relocation truncated to fit: R_PPC_PLTREL24 against symbol `abort' defined in .text section in /u/macppc/dest/lib/libc.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: /u/macppc/dest/usr/lib/crt0.o: in function `___start':
          (.text+0x1bc): relocation truncated to fit: R_PPC_PLTREL24 against symbol `atexit' defined in .text section in /u/macppc/dest/lib/libc.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: (.text+0x1c0): relocation truncated to fit: R_PPC_PLTREL24 against symbol `_libc_init' defined in .text section in /u/macppc/dest/lib/libc.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: (.text+0x1fc): relocation truncated to fit: R_PPC_PLTREL24 against symbol `atexit' defined in .text section in /u/macppc/dest/lib/libc.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: (.text+0x22c): relocation truncated to fit: R_PPC_PLTREL24 against symbol `atexit' defined in .text section in /u/macppc/dest/lib/libc.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: (.text+0x244): relocation truncated to fit: R_PPC_PLTREL24 against symbol `exit' defined in .text section in /u/macppc/dest/lib/libc.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: (.text+0x270): relocation truncated to fit: R_PPC_PLTREL24 against symbol `__syscall' defined in .text section in /u/macppc/dest/lib/libc.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: (.text+0x278): relocation truncated to fit: R_PPC_PLTREL24 against symbol `_exit' defined in .text section in /u/macppc/dest/lib/libc.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: /usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/build/x86_64-unknown-netbsd/stage2-tools/powerpc-unknown-netbsd/release/deps/rust_analyzer-26adb153f4b9bf2a.rust_analyzer.4917a4ff91af159c-cgu.03.rcgu.o: in function `_RNvMs4_NtCsdJJMeYLMKtb_12sharded_slab4pageINtB5_6SharedNtNtNtCs3uf4daDK168_18tracing_subscriber8registry7sharded9DataInnerNtNtB7_3cfg13DefaultConfigE8allocateCs6h4gWHgiW4G_13rust_analyzer':
          rust_analyzer.4917a4ff91af159c-cgu.03:(.text.unlikely._RNvMs4_NtCsdJJMeYLMKtb_12sharded_slab4pageINtB5_6SharedNtNtNtCs3uf4daDK168_18tracing_subscriber8registry7sharded9DataInnerNtNtB7_3cfg13DefaultConfigE8allocateCs6h4gWHgiW4G_13rust_analyzer+0x7c): relocation truncated to fit: R_PPC_PLTREL24 against symbol `alloc::raw_vec::handle_error' defined in .text section in /usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/build/x86_64-unknown-netbsd/stage1/lib/rustlib/powerpc-unknown-netbsd/lib/librustc_driver-0b5acf8e509b6fda.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: rust_analyzer.4917a4ff91af159c-cgu.03:(.text.unlikely._RNvMs4_NtCsdJJMeYLMKtb_12sharded_slab4pageINtB5_6SharedNtNtNtCs3uf4daDK168_18tracing_subscriber8registry7sharded9DataInnerNtNtB7_3cfg13DefaultConfigE8allocateCs6h4gWHgiW4G_13rust_analyzer+0x8c): relocation truncated to fit: R_PPC_PLTREL24 against symbol `_RNvCsg3D0vmXOPdo_7___rustc35___rust_no_alloc_shim_is_unstable_v2' defined in .text section in /usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/build/x86_64-unknown-netbsd/stage1/lib/rustlib/powerpc-unknown-netbsd/lib/librustc_driver-0b5acf8e509b6fda.so+8000
          /u/macppc/tools/bin/../lib/gcc/powerpc--netbsd/7.4.0/../../../../powerpc--netbsd/bin/ld: rust_analyzer.4917a4ff91af159c-cgu.03:(.text.unlikely._RNvMs4_NtCsdJJMeYLMKtb_12sharded_slab4pageINtB5_6SharedNtNtNtCs3uf4daDK168_18tracing_subscriber8registry7sharded9DataInnerNtNtB7_3cfg13DefaultConfigE8allocateCs6h4gWHgiW4G_13rust_analyzer+0x9c): relocation truncated to fit: R_PPC_PLTREL24 against symbol `_RNvCsg3D0vmXOPdo_7___rustc12___rust_alloc' defined in .text section in /usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/build/x86_64-unknown-netbsd/stage1/lib/rustlib/powerpc-unknown-netbsd/lib/librustc_driver-0b5acf8e509b6fda.so+8000

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-crossArea: Cross compilationC-bugCategory: This is a bug.O-PowerPCTarget: PowerPC processorsO-netbsdOperating system: NetBSDT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions