adtools icon indicating copy to clipboard operation
adtools copied to clipboard

Current builds can't link natively.

Open AV00 opened this issue 7 years ago • 9 comments

Hi.

I've tried compiling natively a small C++ example and it fails with many missing references to calls such as __gthread_getspecific , __gthread_setspecific and __gthread_active_p . The references are from unwind_sjlj and others in the C++ library (include/ext/atomicity.h) .

If I forcefully supply the gthr_amigaos_native.o on the command line, then link is successfull and the program run.

AV00 avatar Jun 30 '18 18:06 AV00

You should use the -athread=native (or --athread=native) option if your program requires threading. Let me know if this works (it should link against gthr_amigaos_native.o). I'm reluctant to make this the default option for now, because the hides the fact that program requires some form of threading support (other choices are single and posix). If the implementation is proven to be stable enough, I will think about a default value.

Unfortunately, the thread model has to be decided at compile time of gcc/gthread but this is not so great on AmigaOS (native would be preferred because it doesn't depend on any other library but some ported application may depend on pthread/posix). So I decided to use a custom thread model that allows the user to specify at link time which implementation should be taken.

sba1 avatar Jun 30 '18 19:06 sba1

On 2018-06-30 21:00, Sebastian Bauer wrote:

You should use the -athread=native (or --athread=native) option if your program requires threading.

Well, but it doesn't! It's a 5 line test that initializes a std::vector of ints and then prints them out! My guess is that other components in libstdc++ require it. See the first post, references to gthr_amigaos* come from unwind_sjlj , which I believe to be related to exceptions.

Unfortunately, the thread model has to be decided at compile time of gcc/gthread but this is not so great on AmigaOS (native would be preferred because it doesn't depend on any other library but some ported application may depend on pthread/posix). So I decided to use a custom thread model that allows the user to specify at link time which implementation should be taken.

That is fine, having working threads is wonderful, but it seems it got caught as a dependency for stdlibc++ . Do you need the full list of linker errors ?

AV00 avatar Jun 30 '18 20:06 AV00

Basically every program that uses libstdc++ requires threading and thus a threading implementation.

sba1 avatar Jul 01 '18 09:07 sba1

On 2018-07-01 11:41, Sebastian Bauer wrote:

Basically every that uses libstdc++ requires threading and thus a threading implementation.

So, should the SPEC file be changed to always include one of those threading flags ? Or should it be solved at Makefile level and have anything being compiled with the new GCC have one of the threading flags ?

Thanks.

AV00 avatar Jul 02 '18 06:07 AV00

Am 2018-07-02 08:52, schrieb AV00:

On 2018-07-01 11:41, Sebastian Bauer wrote:

Basically every that uses libstdc++ requires threading and thus a threading implementation. So, should the SPEC file be changed to always include one of those threading flags ? Or should it be solved at Makefile level and have anything being compiled with the new GCC have one of the threading flags ?

For now the latter, but later, if the resulting binaries are stable, we can make the native mode the default. This was at least my plan.

sba1 avatar Jul 02 '18 07:07 sba1

On lunedì 2 luglio 2018 00:53:35 CEST Sebastian Bauer wrote:

Or should it be solved at Makefile level and have anything being compiled with the new GCC have one of the threading flags ?

For now the latter, but later, if the resulting binaries are stable, we can make the native mode the default. This was at least my plan.

Understood.

I'd keep this ticket open till you consider it stable, if you don't mind. So we keep track of the progress.

-- Bye, A.

AV00 avatar Jul 02 '18 15:07 AV00

Slightly off-topic, but would it be possible to document the available threading options? http://www.amigans.net/modules/xforum/viewtopic.php?post_id=111276#forumpost111276

By the way, -athread=pthread doesn't work for me (latest native GCC8), apparently gthr_amigaos_pthread.o is missing.

Also "--athread=native" is not recognized here.

capehill avatar Aug 19 '18 16:08 capehill

@capehill

Good call regarding the documentation.

It should be "-athread=native" (mind the double "-" in front of your line) and should reside in LDFLAGS (but you probably knew that already(?) - Thanks to MickJT for that hint...

raziel- avatar Aug 19 '18 16:08 raziel-

Am 2018-08-19 18:12, schrieb capehill:

Slightly off-topic, but would it be possible to document the available threading options? http://www.amigans.net/modules/xforum/viewtopic.php?post_id=111276#forumpost111276

You find some tiny documentation in the doc folder.

The patch itself is here:

https://github.com/sba1/adtools/blob/master/gcc/8/patches/0025-Add-amigaos-thread-model.patch

sba1 avatar Aug 21 '18 19:08 sba1