Closed mikrosk closed 6 months ago
Interestingly the same error is printed when (cross-)compiling libstd++v3 for all flavours (m68000, m68020-60, m5475):
onfigure:54029: checking whether the target supports thread-local storage
configure:54043: /home/mikro/atari/compilers/m68k-atari-mint-build/m68k-atari-mint-gcc-gcc-13-mintelf-m68000-cross-final/./gcc/xgcc -B/home/mikro/atari/compilers/m68k-atari-mint-build/m68k-atari-mint-gcc-gcc-13-mintelf-m68000-cross-final/./gcc/ -B/home/mikro/gnu-tools/m68000/m68k-atari-mintelf/bin/ -B/home/mikro/gnu-tools/m68000/m68k-atari-mintelf/lib/ -isystem /home/mikro/gnu-tools/m68000/m68k-atari-mintelf/include -isystem /home/mikro/gnu-tools/m68000/m68k-atari-mintelf/sys-include -o conftest -O2 -fomit-frame-pointer conftest.c >&5
/home/mikro/gnu-tools/m68000/m68k-atari-mintelf/bin/ld: /tmp/ccvEoxXY.o: in function `main':
conftest.c:(.text.startup+0xa): undefined reference to `__m68k_read_tp'
FYI, in my initial mintelf work I focused on the new PRG/ELF file format produced with a cross-compiler. Compiling newer binutils for the MiNT host is a completely new challenge - never tried by me.
@vinriviere can you perhaps check whether you see the error in libstd++v3's config.log? (that happened during cross-compilation)
I've already built binutils 2.42 for m68k (see http://tho-otto.de/crossmint.php#binutils) so i think that is an issue with your cross-compiler.
That m68k_read_tp issue sounds familiar to me. That has something to do with variables being declared as __thread local. I've also fixed that in gcc: https://github.com/th-otto/m68k-atari-mint-gcc/commit/9ce1d8d4b98f4686515ffc2e7db5b948a783e377
Edit: you can check that with something like this:
__thread int a; int b; int main() { return a = b; }
It should emit library calls to emutls_get_address, not m68k_read_tp. That is suboptimal when you really don't have threads, but works, because emutls_get_address is part of libgcc.a
I've also fixed that in gcc: https://github.com/th-otto/m68k-atari-mint-gcc/commit/9ce1d8d4b98f4686515ffc2e7db5b948a783e377
I think that's the crucial difference here. ;) Since the libstdc++v3 test also fails on some thread-local storage stuff, I'd say this is it. I'll test tonight.
That indeed fixed both libstdc++-v3 and native binutils build. Thanks!
Edit: you can check that with something like this:
__thread int a; int b; int main() { return a = b; }
I also do have the issue.
Interestingly the same error is printed when (cross-)compiling libstd++v3 for all flavours (m68000, m68020-60, m5475):
Any idea why I don't have trouble when compiling libstd++v3? This can be seen in the gcc build log I've already posted.
checking whether the target supports thread-local storage... no
But that's the outcome of the problem. ;) If you checked config.log, you'd see the error. Fixed libstdc++-v3 says "yes" there.
Ah! But our MiNT kernel (or even TOS) doesn't support real thread-local storage. So I would say that "no" is more accurate, isn't it?
The problem is that libstdc++v3 then does not declare the thread_local keyword, and that causes other packages fail to compile (gdb amongst others IIRC)
I'm wondering whether --disable-threads
and/or --disable-tls
do not affect this behaviour? I'm compiling with the former but maybe the latter would remove the need for Thorsten's patch?
--disable-tls
might work too, haven't checked that. OTOH, the patch just adds 3 lines...
Edit, no that would be different. It would not compile emutls support into libgcc, and then give the same problem: using thread would result into a call to m68k_read_tp, and the c++ thread_local keyword won't be defined.
--disable-tls might work too, haven't checked that. OTOH, the patch just adds 3 lines...
And it indeed works. It's not about number of lines but about what's the most proper approach: now our target, as the sole one, required tricking the assembler into an empty operation. Using the right switch makes the toolchain not assuming the presence of __m68k_read_tp and avoiding the problem altogether.
Plus if someone in the future comes and implements some sort of threading model into atari/mint, it will be much easier to spot one switch in ./configure than a buried commit tricking the assembler to ignore it.
Edit, no that would be different. It would not compile emutls support into libgcc, and then give the same problem: using thread would result into a call to m68k_read_tp, and the c++ thread_local keyword won't be defined.
It seems you didn't tried it, I did. And your example works, no compiler/linker errors. libstdc++-v3 returns OK, native binutils compiles, too.
So I'm resetting our branch to Vincent's which included the 13.3 merge and your new mint-atomic.c, i.e. basically what I would do, too.
@vinriviere you may want to add --disable-threads --disable-tls
to your scripts.
It's not about number of lines but about what's the most proper approach:
Its your opinion that this is "more proper". In my opinion, it should be the source that should make sure the code produces the correct results, just like is done there in autoconf for a lot of other targets. And my approach works even if someone does not add --disable-tls
in the script, like vincent.
Similarly to https://github.com/freemint/m68k-atari-mint-gcc/issues/41 I have discovered that I'm unable to build native mintelf binutils. It fails on:
So it fails on compiling
as
. ./configure flags are nothing special:--target=m68k-atari-mintelf --host=m68k-atari-mintelf --disable-nls --prefix=/usr --disable-gdb --disable-libdecnumber --disable-readline --disable-sim
so perhaps nobody has tried it yet?Changelog.git contains an interesting entry: