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

Fails to link on some processor arches (mipsel / m68k / powerpc / sh4) #8

Open
hpreusse opened this issue Aug 2, 2023 · 4 comments

Comments

@hpreusse
Copy link

hpreusse commented Aug 2, 2023

Building (linking) the luametatex binary on some arches fails, as mimalloc uses symbols, which are only available in the atomic library. I run on Debian unstable and use gcc-13.

/usr/bin/cc -g -O2 -ffile-prefix-map=/root/luametatex-2.10.08+ds=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-z,relro CMakeFiles/luametatex.dir/source/luametatex.c.o -o luametatex  libtex.a liblua.a libmp.a libluarest.a libluasocket.a libluaoptional.a libpplib.a libminiz.a libsoftposit.a -ldl libmimalloc.a -lpthread -lm
/usr/bin/ld: libmimalloc.a(stats.c.o): in function `mi_process_info':
./obj-m68k-linux-gnu/./source/libraries/mimalloc/src/stats.c:449:(.text+0x111a): undefined reference to `__atomic_load_8'
/usr/bin/ld: libmimalloc.a(stats.c.o): in function `mi_atomic_addi64_relaxed':
./obj-m68k-linux-gnu/./source/libraries/mimalloc/include/mimalloc/atomic.h:112:(.text+0x28): undefined reference to `__atomic_fetch_add_8'
/usr/bin/ld: libmimalloc.a(stats.c.o): in function `mi_atomic_maxi64_relaxed':
./obj-m68k-linux-gnu/./source/libraries/mimalloc/include/mimalloc/atomic.h:115:(.text+0x40): undefined reference to `__atomic_load_8'
/usr/bin/ld: ./obj-m68k-linux-gnu/./source/libraries/mimalloc/include/mimalloc/atomic.h:116:(.text+0x70): undefined reference to `__atomic_compare_exchange_8'
/usr/bin/ld: libmimalloc.a(stats.c.o): in function `mi_atomic_addi64_relaxed':
<snip>

After adding the atomc lib, linking works fine:

(m68k-sid)root@sid-amd64:~/luametatex-2.10.08+ds/obj-m68k-linux-gnu# /usr/bin/cc -g -O2 -ffile-prefix-map=/root/luametatex-2.10.08+ds=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-z,relro CMakeFiles/luametatex.dir/source/luametatex.c.o -o luametatex  libtex.a liblua.a libmp.a libluarest.a libluasocket.a libluaoptional.a libpplib.a libminiz.a libsoftposit.a -ldl libmimalloc.a -lpthread -lm -latomic
(m68k-sid)root@sid-amd64:~/luametatex-2.10.08+ds/obj-m68k-linux-gnu# ldd luametatex
        libm.so.6 => /lib/m68k-linux-gnu/libm.so.6 (0x7ffb0000)
        libatomic.so.1 => /lib/m68k-linux-gnu/libatomic.so.1 (0x7ffa6000)
        libc.so.6 => /lib/m68k-linux-gnu/libc.so.6 (0x7fe20000)
        /lib/ld.so.1 (0x40000000)
(m68k-sid)root@sid-amd64:~/luametatex-2.10.08+ds/obj-m68k-linux-gnu# ls -l luametatex
-rwxr-xr-x 1 root root 12734240 Aug  2 09:45 luametatex

The full build logs are visible here.

@barracuda156
Copy link

@hpreusse This looks like mimalloc fails to link, not luametatex, but anyway, you need to pass -latomic flag.

@hpreusse
Copy link
Author

@hpreusse This looks like mimalloc fails to link, not luametatex, but anyway, you need to pass -latomic flag.

Yeah, looks like. So, this issue could have been solved by upgrading mimalloc (which was done in the last few month). I'll test if the patch I'm using is still needed (we link dynamically anyway).

@barracuda156
Copy link

@hpreusse This looks like mimalloc fails to link, not luametatex, but anyway, you need to pass -latomic flag.

Yeah, looks like. So, this issue could have been solved by upgrading mimalloc (which was done in the last few month). I'll test if the patch I'm using is still needed (we link dynamically anyway).

Do they have a working test for it?
We still add an option manually, though it could be outdated: https://github.com/macports/macports-ports/blob/f0387ce27bf3c62212c2bcabce601b1cb2a4897d/devel/mimalloc/Portfile#L52-L55

P. S. Out of curiosity, which hardware do you run m68k on? Pre-PowerPC Apple?

@hpreusse
Copy link
Author

Yeah, looks like. So, this issue could have been solved by upgrading mimalloc (which was done in the last few month). I'll test if the patch I'm using is still needed (we link dynamically anyway).

Do they have a working test for it?

My test would be to remove the link fixing patch and test if the build still works.

P. S. Out of curiosity, which hardware do you run m68k on? Pre-PowerPC Apple?

No, I don't really run it. I'm simply responsible for the luametatex Debian package and m68k is one of the arches, where the linking failed.

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