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

AEABI division function linking problems (again) #533

Open
Lokathor opened this issue Jun 27, 2023 · 2 comments
Open

AEABI division function linking problems (again) #533

Lokathor opened this issue Jun 27, 2023 · 2 comments

Comments

@Lokathor
Copy link
Contributor

I got a bug report yesterday that the gba crate no longer builds because of linking errors (rust-console/gba#187).

error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "gnu" "C:\\Users\\Daniel\\AppData\\Local\\Temp\\rustccI5P5G\\symbols.o" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\examples\\hello-472b02b74d42dc56.hello.ff7e989594f6dafe-cgu.0.rcgu.o" "--as-needed" "-L" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\deps" "-L" "D:\\dev\\gba\\target\\debug\\deps" "-L" "C:\\Users\\Daniel\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\thumbv4t-none-eabi\\lib" "-Bstatic" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\deps\\libgba-9a437158f6d53742.rlib" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\deps\\libbracer-de8a5334b1c7d053.rlib" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\deps\\libbitfrob-c6a9cbfb626642c0.rlib" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\deps\\libvoladdress-6c15bc02bfc75894.rlib" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\deps\\librustc_std_workspace_core-a7ec4ea53facd032.rlib" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\deps\\libcore-71be2443f3a85b43.rlib" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\deps\\libcompiler_builtins-d2b4ad49f4a33cb8.rlib" "-Bdynamic" "--eh-frame-hdr" "-z" "noexecstack" "-L" "C:\\Users\\Daniel\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\thumbv4t-none-eabi\\lib" "-o" "D:\\dev\\gba\\target\\thumbv4t-none-eabi\\debug\\examples\\hello-472b02b74d42dc56" "--gc-sections" "-O1" "-Tlinker_scripts/mono_boot.ld"
  = note: rust-lld: error: duplicate symbol: __aeabi_uidiv
          >>> defined at asm_runtime.rs:206 (src\asm_runtime.rs:206)
          >>>            gba-9a437158f6d53742.gba.d4abc47cdc4ad47-cgu.0.rcgu.o:(__aeabi_uidiv) in archive D:\dev\gba\target\thumbv4t-none-eabi\debug\deps\libgba-9a437158f6d53742.rlib
          >>> defined at macros.rs:372 (src\macros.rs:372)
          >>>            compiler_builtins-d2b4ad49f4a33cb8.compiler_builtins.ee71fd72058c181a-cgu.0.rcgu.o:(.text.__aeabi_uidiv+0x1) in archive D:\dev\gba\target\thumbv4t-none-eabi\debug\deps\libcompiler_builtins-d2b4ad49f4a33cb8.rlib

          rust-lld: error: duplicate symbol: __aeabi_idiv
          >>> defined at asm_runtime.rs:248 (src\asm_runtime.rs:248)
          >>>            gba-9a437158f6d53742.gba.d4abc47cdc4ad47-cgu.0.rcgu.o:(__aeabi_idiv) in archive D:\dev\gba\target\thumbv4t-none-eabi\debug\deps\libgba-9a437158f6d53742.rlib
          >>> defined at macros.rs:372 (src\macros.rs:372)
          >>>            compiler_builtins-d2b4ad49f4a33cb8.compiler_builtins.ee71fd72058c181a-cgu.0.rcgu.o:(.text.__aeabi_idiv+0x1) in archive D:\dev\gba\target\thumbv4t-none-eabi\debug\deps\libcompiler_builtins-d2b4ad49f4a33cb8.rlib


error: could not compile `gba` (example "hello") due to previous error

And, indeed, if I comment the division functions from the gba crate then it does build.

In #478 the division functions were made to be weak-link, so this seems to be a regression of some form.

Looking into the recent PRs, #526 may have done something weird? I'm not familiar enough with the macros to say for sure, but the person who reported the bug to the gba crate said that the Nightly from May 1 didn't have the problem, and now there is the problem, so the dates would seem to line up.

@Amanieu
Copy link
Member

Amanieu commented Jun 29, 2023

Can you try building with -Z build-std-features=compiler-builtins-weak-intrinsics? It should force all intrinsics to be built as weak functions.

@Lokathor
Copy link
Contributor Author

I updated the project's .cargo/config.toml "unstable" section:

[unstable]
build-std = ["core"]
build-std-features = ["compiler-builtins-weak-intrinsics"]

and it does work now on Nightly-2023-07-11 (compiler_builtins-0.1.95)

I guess my question is why this was moved behind a feature flag?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants