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

Missing math symbols starting from nightly-2024-04-15 #5

Open
Enet4 opened this issue Jul 27, 2024 · 1 comment
Open

Missing math symbols starting from nightly-2024-04-15 #5

Enet4 opened this issue Jul 27, 2024 · 1 comment

Comments

@Enet4
Copy link
Contributor

Enet4 commented Jul 27, 2024

Starting from nightly-2024-04-15, there was an update to compiler_builtins which changed the way that math functions are linked (rust-lang/compiler-builtins#577). As a consequence, programs combining converted objects fail to build and link with the DJGPP toolchain because it cannot find the various functions in compiler_builtins::math.

I've been looking into this problem here and I'm thinking whether it would be best resolved at elf2djgpp directly.
Would it make sense to also translate symbols in compiler_builtins::math using this tool?


As it turns out, I could reproduce the same problem with the example project after a few changes:

cd example
./build-dos-lib.sh
Converting ELF objects to COFF-GO32...
[WARN] Replacing bad extern compiler_builtins::mem::memcpy::h812ddf986f30a505 with memcpy
[WARN] Replacing bad extern compiler_builtins::mem::memset::hf5e04de1043dcb43 with memset
[WARN] Replacing bad extern compiler_builtins::mem::memcmp::hccf529a20986adb3 with memcmp
[WARN] Replacing bad extern compiler_builtins::mem::bcmp::h08ab184912ed088e with bcmp
[WARN] Replacing bad extern compiler_builtins::mem::memmove::h1be8968bbec95ef8 with memmove
build/debug/librust_lib.a built
make debug
i686-pc-msdosdjgpp-gcc -g -O0 -o build/debug/example.exe example.c build/debug/librust_lib.a
/usr/lib/gcc/i686-pc-msdosdjgpp/14.1.0/../../../../i686-pc-msdosdjgpp/bin/ld: build/debug/librust_lib.a(compiler_builtins-959ba4b0dcda654e.compiler_builtins.25b58a9b9e6e87fe-cgu.1.rcgu.o):compiler_builtins.25b58a9b9e6e87fe-cgu.1:(.text+0xc): undefined reference to `compiler_builtins::math::round'
/usr/lib/gcc/i686-pc-msdosdjgpp/14.1.0/../../../../i686-pc-msdosdjgpp/bin/ld: build/debug/librust_lib.a(compiler_builtins-959ba4b0dcda654e.compiler_builtins.25b58a9b9e6e87fe-cgu.1.rcgu.o):compiler_builtins.25b58a9b9e6e87fe-cgu.1:(.text+0xc): undefined reference to `compiler_builtins::math::trunc'
/usr/lib/gcc/i686-pc-msdosdjgpp/14.1.0/../../../../i686-pc-msdosdjgpp/bin/ld: build/debug/librust_lib.a(compiler_builtins-959ba4b0dcda654e.compiler_builtins.25b58a9b9e6e87fe-cgu.1.rcgu.o):compiler_builtins.25b58a9b9e6e87fe-cgu.1:(.text+0xa): undefined reference to `compiler_builtins::math::asinf'
...
@Enet4
Copy link
Contributor Author

Enet4 commented Jul 27, 2024

OK, so with this teeny change:

diff --git a/src/coff_go32.rs b/src/coff_go32.rs
index d0bd2d4..1aeb7a4 100644
--- a/src/coff_go32.rs
+++ b/src/coff_go32.rs
@@ -32,13 +32,14 @@ pub const R_386_GOTPC: u32 = 10;
 ///
 /// Link them to the real DJGPP functions instead by renaming the symbols, what could possibly go
 /// wrong
-const FIX_EXTERN_SYMBOLS_PREFIXES: [(&str, &[u8]); 6] = [
+const FIX_EXTERN_SYMBOLS_PREFIXES: [(&str, &[u8]); 7] = [
     ("compiler_builtins::mem::memset", b"memset"),
     ("compiler_builtins::mem::memcmp", b"memcmp"),
     ("compiler_builtins::mem::bcmp", b"bcmp"),
     ("compiler_builtins::mem::strlen", b"strlen"),
     ("compiler_builtins::mem::memcpy", b"memcpy"),
     ("compiler_builtins::mem::memmove", b"memmove"),
+    ("compiler_builtins::math::", b""),
 ];
 
 pub fn fix_extern_symbol(name: Cow<[u8]>) -> Cow<[u8]> {

I could build my projects successfully using nightly-2024-04-15 as well as the latest nightly, nightly-2024-07-26. Please let me know if you want me to send a PR your way. :)

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

1 participant