[llvm] [M68k] implement -mxgot (PR #119803)

John Paul Adrian Glaubitz via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 2 14:15:15 PDT 2025


glaubitz wrote:

I think implementing support for `-mxgot` will be the last piece for getting `std` to build on `m68k-unknown-linux-gnu`.

After [this change](https://github.com/rust-lang/cc-rs/pull/1505), trying to build a cross-compiler for `m68k-unknown-linux-gnu` fails due to truncated sections:

```
Building stage1 library artifacts (x86_64-unknown-linux-gnu -> m68k-unknown-linux-gnu)
   Compiling core v0.0.0 (/home/glaubitz/rust/library/core)
   Compiling libc v0.2.174
   Compiling object v0.37.1
   Compiling std v0.0.0 (/home/glaubitz/rust/library/std)
   Compiling compiler_builtins v0.1.160 (/home/glaubitz/rust/library/compiler-builtins/compiler-builtins)
   Compiling rustc-std-workspace-core v1.99.0 (/home/glaubitz/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/home/glaubitz/rust/library/alloc)
   Compiling cfg-if v1.0.1
   Compiling memchr v2.7.5
   Compiling adler2 v2.0.1
   Compiling rustc-demangle v0.1.25
   Compiling panic_abort v0.0.0 (/home/glaubitz/rust/library/panic_abort)
   Compiling unwind v0.0.0 (/home/glaubitz/rust/library/unwind)
   Compiling rustc-std-workspace-alloc v1.99.0 (/home/glaubitz/rust/library/rustc-std-workspace-alloc)
   Compiling panic_unwind v0.0.0 (/home/glaubitz/rust/library/panic_unwind)
   Compiling std_detect v0.1.5 (/home/glaubitz/rust/library/std_detect)
   Compiling gimli v0.32.0
   Compiling hashbrown v0.15.4
   Compiling miniz_oxide v0.8.9
   Compiling addr2line v0.25.0
error: linking with `m68k-linux-gnu-gcc` failed: exit status: 1
  |
  = note:  "m68k-linux-gnu-gcc" "-Wl,--version-script=/tmp/rustcK1ntgn/list" "-Wl,--no-undefined-version" "/tmp/rustcK1ntgn/symbols.o" "<16 object files omitted>" "/tmp/rustcK1ntgn/rmeta.o" "<1 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/{libpanic_unwind-41954d64cd0e5131,libobject-e7dfe859492e5a92,libmemchr-904192e833d8658e,libaddr2line-bdd16ac6594eb4ec,libgimli-06cea671b41d1cdb,librustc_demangle-1c25569d8f953578,libstd_detect-67ced8ec75312637,libhashbrown-e99b721c6daa8274,librustc_std_workspace_alloc-dc4cb631b4b0371a,libminiz_oxide-266aaf724348ab44,libadler2-3f06c74eae179545,libunwind-08f83db3fc345c63,libcfg_if-cec9171082ee08e4,liblibc-f7f7de4e63c839c7,librustc_std_workspace_core-e05d712ea321af2a,liballoc-09c7b5f14549671f,libcore-086b16fd023003ef,libcompiler_builtins-175b35e00a2eb49a}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcK1ntgn/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/usr/m68k-linux-gnu/lib/" "-L" "<sysroot>-std/m68k-unknown-linux-gnu/release/build/compiler_builtins-5d87df611ece33fa/out" "-L" "<sysroot>/lib/rustlib/m68k-unknown-linux-gnu/lib" "-o" "<sysroot>-std/m68k-unknown-linux-gnu/release/deps/libstd-a16e04ed26b3b450.so" "-shared" "-Wl,-soname=libstd-a16e04ed26b3b450.so" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/std-a16e04ed26b3b450.std.b9b2668642209c3a-cgu.03.rcgu.o: in function `<&T as core::fmt::Debug>::fmt':
          std.b9b2668642209c3a-cgu.03:(.text._ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h472b78aaa4f6be72E+0x1c): relocation truncated to fit: R_68K_PLT16 against symbol `<std::sys_common::wtf8::Wtf8 as core::fmt::Debug>::fmt' defined in .text._ZN64_$LT$std..sys_common..wtf8..Wtf8$u20$as$u20$core..fmt..Debug$GT$3fmt17h42e207a2f1798686E section in /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/std-a16e04ed26b3b450.std.b9b2668642209c3a-cgu.03.rcgu.o
          /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/std-a16e04ed26b3b450.std.b9b2668642209c3a-cgu.03.rcgu.o: in function `<&T as core::fmt::Debug>::fmt':
          std.b9b2668642209c3a-cgu.03:(.text._ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h6080b056058b9a0aE+0x12): relocation truncated to fit: R_68K_PC16 against `.rodata.cst16'
          std.b9b2668642209c3a-cgu.03:(.text._ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h6080b056058b9a0aE+0x2e): relocation truncated to fit: R_68K_PLT16 against symbol `core::fmt::Formatter::debug_tuple' defined in .text._ZN4core3fmt9Formatter11debug_tuple17h9067524984b1253eE section in /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/libcore-086b16fd023003ef.rlib(core-086b16fd023003ef.core.96277101e887f271-cgu.15.rcgu.o)
          std.b9b2668642209c3a-cgu.03:(.text._ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h6080b056058b9a0aE+0x38): relocation truncated to fit: R_68K_PC16 against `.data.rel.ro..Lanon.8b7e79c921bf64809c31e332eda2ec20.65'
          std.b9b2668642209c3a-cgu.03:(.text._ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h6080b056058b9a0aE+0x46): relocation truncated to fit: R_68K_PLT16 against symbol `core::fmt::builders::DebugTuple::field' defined in .text._ZN4core3fmt8builders10DebugTuple5field17h094a038c299c5ac5E section in /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/libcore-086b16fd023003ef.rlib(core-086b16fd023003ef.core.96277101e887f271-cgu.05.rcgu.o)
          std.b9b2668642209c3a-cgu.03:(.text._ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h6080b056058b9a0aE+0x4c): relocation truncated to fit: R_68K_PLT16 against symbol `core::fmt::builders::DebugTuple::finish' defined in .text._ZN4core3fmt8builders10DebugTuple6finish17h6eecb3a577c4183aE section in /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/libcore-086b16fd023003ef.rlib(core-086b16fd023003ef.core.96277101e887f271-cgu.05.rcgu.o)
          /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/std-a16e04ed26b3b450.std.b9b2668642209c3a-cgu.03.rcgu.o: in function `core::fmt::num::<impl core::fmt::Debug for i32>::fmt':
          std.b9b2668642209c3a-cgu.03:(.text._ZN4core3fmt3num50_$LT$impl$u20$core..fmt..Debug$u20$for$u20$i32$GT$3fmt17h27630fa28532ecf5E+0x3c): relocation truncated to fit: R_68K_PLT16 against symbol `core::fmt::num::imp::<impl core::fmt::Display for i32>::fmt' defined in .text._ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$i32$GT$3fmt17hc83db331b6f1e2a6E section in /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/libcore-086b16fd023003ef.rlib(core-086b16fd023003ef.core.96277101e887f271-cgu.12.rcgu.o)
          std.b9b2668642209c3a-cgu.03:(.text._ZN4core3fmt3num50_$LT$impl$u20$core..fmt..Debug$u20$for$u20$i32$GT$3fmt17h27630fa28532ecf5E+0x56): relocation truncated to fit: R_68K_PLT16 against symbol `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt' defined in .text._ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$i32$GT$3fmt17hbf7c72afe10669fdE section in /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/libcore-086b16fd023003ef.rlib(core-086b16fd023003ef.core.96277101e887f271-cgu.00.rcgu.o)
          std.b9b2668642209c3a-cgu.03:(.text._ZN4core3fmt3num50_$LT$impl$u20$core..fmt..Debug$u20$for$u20$i32$GT$3fmt17h27630fa28532ecf5E+0x70): relocation truncated to fit: R_68K_PLT16 against symbol `core::fmt::num::<impl core::fmt::UpperHex for i32>::fmt' defined in .text._ZN4core3fmt3num53_$LT$impl$u20$core..fmt..UpperHex$u20$for$u20$i32$GT$3fmt17h9b0a939ed41c6306E section in /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/libcore-086b16fd023003ef.rlib(core-086b16fd023003ef.core.96277101e887f271-cgu.00.rcgu.o)
          /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/std-a16e04ed26b3b450.std.b9b2668642209c3a-cgu.03.rcgu.o: in function `core::ptr::drop_in_place<alloc::vec::Vec<u8>>':
          std.b9b2668642209c3a-cgu.03:(.text._ZN4core3ptr46drop_in_place$LT$alloc..vec..Vec$LT$u8$GT$$GT$17hd5f5412e1703927bE.llvm.6252559591537011569+0x22): relocation truncated to fit: R_68K_PLT16 against symbol `__rustc::__rust_dealloc' defined in .text._RNvCs8U6DUB3qQ2r_7___rustc14___rust_dealloc section in /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/std-a16e04ed26b3b450.0ik6ynatekbmgq2qygacp4ml4.rcgu.o
          /home/glaubitz/rust/build/x86_64-unknown-linux-gnu/stage1-std/m68k-unknown-linux-gnu/release/deps/std-a16e04ed26b3b450.std.b9b2668642209c3a-cgu.03.rcgu.o: in function `core::ptr::drop_in_place<std::ffi::os_str::OsString>':
          std.b9b2668642209c3a-cgu.03:(.text._ZN4core3ptr47drop_in_place$LT$std..ffi..os_str..OsString$GT$17h0e8fbd0660a0fb23E+0x26): additional relocation overflows omitted from the output
          collect2: error: ld returned 1 exit status


error: could not compile `std` (lib) due to 1 previous error
Build completed unsuccessfully in 0:14:07
```

@mshockwave Any chance you could get `-mxgot` implemented?

https://github.com/llvm/llvm-project/pull/119803


More information about the llvm-commits mailing list