rust-console / gba

A crate that helps you make GBA games
https://docs.rs/gba
Apache License 2.0
646 stars 50 forks source link

Linker errors on newer nightly Rust builds #187

Closed gruxor closed 7 months ago

gruxor commented 1 year ago

Title, more or less. Getting the following:

rust-lld: error: duplicate symbol: __aeabi_idiv
          >>> defined at asm_runtime.rs:248 (src\asm_runtime.rs:248)
          >>>            gba-ffbf70226406fe56.gba.73b0a98ac837cf68-cgu.13.rcgu.o:(__aeabi_idiv) in archive C:\dev\rust\crex\target\thumbv4t-none-eabi\debug\deps\libgba-ffbf70226406fe56.rlib
          >>> defined at macros.rs:372 (src\macros.rs:372)
          >>>            compiler_builtins-b0a5ccc670b7af0d.compiler_builtins.db29d814410a5d62-cgu.15.rcgu.o:(.text.__aeabi_idiv+0x1) in archive C:\dev\rust\crex\target\thumbv4t-none-eabi\debug\deps\libcompiler_builtins-b0a5ccc670b7af0d.rlib

rust-lld: error: duplicate symbol: __aeabi_uidiv
          >>> defined at asm_runtime.rs:206 (src\asm_runtime.rs:206)
          >>>            gba-ffbf70226406fe56.gba.73b0a98ac837cf68-cgu.13.rcgu.o:(__aeabi_uidiv) in archive C:\dev\rust\crex\target\thumbv4t-none-eabi\debug\deps\libgba-ffbf70226406fe56.rlib
          >>> defined at macros.rs:372 (src\macros.rs:372)
          >>>            compiler_builtins-b0a5ccc670b7af0d.compiler_builtins.db29d814410a5d62-cgu.8.rcgu.o:(.text.__aeabi_uidiv+0x1) in archive C:\dev\rust\crex\target\thumbv4t-none-eabi\debug\deps\libcompiler_builtins-b0a5ccc670b7af0d.rlib

Issue occurs even with a barebones/brand new project, just by importing the prelude or anything that uses the above MMIO functions. I'm guessing they implemented these functions on the target with the same names, but I'm not familiar enough with the guts of the toolchain to know one way or the other.

Did do some minor testing to see roughly when it started, it appears nightly-2023-05-01-x86_64-pc-windows-msvc works but nightly-2023-06-01-x86_64-pc-windows-msvc doesn't, so it's a change sometime in May. Didn't test this on other operating systems yet, could be isolated to Windows.

Lokathor commented 1 year ago

Yes, as you guessed: This is an issue with the compiler built-ins crate providing a symbol that the gba crate also provides (since it's standard ARM function it's got a standard name so llvm can link to it). I thought we'd fixed this but i guess there's some sort of regression going on. I will attempt to look into it tomorrow. I expect the fix to be small, but even if so it will probably be a few days minimum for an updated compiler_builtins crate to get out to Nightly.

If you want to get a temporary fix immediately while also using latest Nightly you can clone this repo and delete those two functions and it should build. However, using a Nightly from May is probably also fine until this gets sorted out.

Lokathor commented 7 months ago

There's a work around: https://github.com/rust-lang/compiler-builtins/issues/533#issuecomment-1631869408

Since there's been no movement in a while, I just put this info in the README and I guess it's "fine".