GCC & G++ randomly unable to compile C/C++ programs

9 posts / 0 new
Last post
ChrisH
ChrisH's picture
Offline
Last seen: 3 months 2 weeks ago
Joined: 2010-12-07 20:22
GCC & G++ randomly unable to compile C/C++ programs

After booting AmigaOS4.1FE, sometimes I find that GCC/G++ refuses to compile any C/C++ program. G++ just reports:

assertion "cached == 0" failed: file "../../gcc/libcpp/line-map.c", line 277
cc1plus: internal compiler error: Aborted
Please submit a full bug report,
with preprocessed source if appropriate.
See URL:http://www.sf.net/projects/adtools/ for instructions.

While GCC just reports:

assertion "cached == 0" failed: file "../../gcc/libcpp/line-map.c", line 277
cc1: internal compiler error: Aborted
Please submit a full bug report,
with preprocessed source if appropriate.
See URL:http://www.sf.net/projects/adtools/ for instructions.

And mostly it seems to fail for the rest of the day, despite hard/soft reboots, but then another day it may work perfectly, despite many hard/soft reboots. But sometimes it will suddenly start working without rebooting, and then continue to work until I *do* reboot!

I haven't yet worked out a pattern, and it's very frustrating, as it means I can't do any software development on OS4.

Does anyone have any suggestions? Seems like maybe some kind of race condition with the OS or other software, but I have no idea where to look. I tried disabling WB Startup programs & User-Startup progs, without any improvement. I am using the "latest" SDK (53.30).

thomas
thomas's picture
Offline
Last seen: 1 day 16 hours ago
Joined: 2011-05-16 14:23
Re: GCC & G++ randomly unable to compile C/C++ programs

Try the usual first: increase stack size.

ChrisH
ChrisH's picture
Offline
Last seen: 3 months 2 weeks ago
Joined: 2010-12-07 20:22
Re: GCC & G++ randomly unable to compile C/C++ programs

Good idea, but sadly it didn't help. (Also tried doubling Prefs/DOS's Process Stack Size.)


Author of the PortablE programming language. I love using Amiga OS4.1 on my X1000 & Sam440 :-D
kas1e
kas1e's picture
Offline
Last seen: 20 hours 40 min ago
Joined: 2010-11-30 15:30
Re: GCC & G++ randomly unable to compile C/C++ programs

@ChrisH
Those kinds of things happen for me on my old peg2 for sure with public SDK. But they seem didn't happen for me anymore on my x5000 and on cross-compiler setup, but I install of course latest adtools on top of public SDK, so it gives GCC 8.4.0 + stuff.

In other words, a suggestion is to update to the latest adtools on top of latest public SDK firstly. Not that it should 100% cure the problems, but may very well help.

ChrisH
ChrisH's picture
Offline
Last seen: 3 months 2 weeks ago
Joined: 2010-12-07 20:22
Re: GCC & G++ randomly unable to compile C/C++ programs

@kas1e
Thanks for your suggestion. Now a stupid question from me:
How do I get a newer version of GCC/G++ for AmigaOS4? (Please don't say I have to compile it myself!)
Update: Never mind, someone pointed me to https://github.com/sba1/adtools


Author of the PortablE programming language. I love using Amiga OS4.1 on my X1000 & Sam440 :-D
ChrisH
ChrisH's picture
Offline
Last seen: 3 months 2 weeks ago
Joined: 2010-12-07 20:22
Re: GCC & G++ randomly unable to compile C/C++ programs

First test suggests the new Adtools *may* have fixed the issue, but I will need longer testing to be sure.

Also, to get it to work I had to replace SDK:gcc folder with a soft link to the Adtools folder, but I dislike this as updating the SDK might then overwrite Adtools.

I would rather have some commands that run after the BEGIN/END "AmigaOS 4.1 SDK" bit in S:User-Startup, which just update assigns & path, but my first attempt didn't work at all (it complains about missing executables). Do you have any suggestions? which I seem to have achieved using this:

; Override SDK with Adtools (GCC)
Path gcc:bin remove
Path SDK:Local/C remove
Assign GCC: "YOUR ADTOOLS PATH HERE"
Assign LIB: GCC:lib
Path gcc:bin add
Path SDK:Local/C add


Author of the PortablE programming language. I love using Amiga OS4.1 on my X1000 & Sam440 :-D
ChrisH
ChrisH's picture
Offline
Last seen: 3 months 2 weeks ago
Joined: 2010-12-07 20:22
Re: GCC & G++ randomly unable to compile C/C++ programs

I spoke too soon. Although it probably fixes my original issue, I have a new one where attempting to compile even the most simple PortablE program (from the C++ code it generates) produces something like:

/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `__gnu_cxx::__mutex::lock()':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:150: undefined reference to `__gthread_active_p'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `__gnu_cxx::__mutex::unlock()':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:161: undefined reference to `__gthread_active_p'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `_ZN9__gnu_cxx13__scoped_lockC4ERNS_7__mutexE':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:152: undefined reference to `__gthread_mutex_lock'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `_ZN9__gnu_cxx13__scoped_lockD4Ev':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:163: undefined reference to `__gthread_mutex_unlock'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `__gnu_cxx::__mutex::lock()':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:150: undefined reference to `__gthread_active_p'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `__gnu_cxx::__mutex::unlock()':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:161: undefined reference to `__gthread_active_p'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `_ZN9__gnu_cxx13__scoped_lockC4ERNS_7__mutexE':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:152: undefined reference to `__gthread_mutex_lock'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `_ZN9__gnu_cxx13__scoped_lockD4Ev':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:163: undefined reference to `__gthread_mutex_unlock'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `_ZN9__gnu_cxx7__mutexC4Ev':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:134: undefined reference to `__gthread_active_p'
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:135: undefined reference to `__gthread_mutex_init'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `_ZN9__gnu_cxx7__mutexD4Ev':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:142: undefined reference to `__gthread_active_p'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_alloc.o): In function `__static_initialization_and_destruction_0':
/var/lib/jenkins/workspace/native-gcc-8/native-build/gcc-native-build-8.4.0/ppc-amigaos/libstdc++-v3/include/ext/concurrence.h:143: undefined reference to `__gthread_mutex_destroy'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_globals.o): In function `__cxa_get_globals_fast':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libstdc++-v3/libsupc++/eh_globals.cc:116: undefined reference to `__gthread_getspecific'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_globals.o): In function `__cxa_get_globals':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libstdc++-v3/libsupc++/eh_globals.cc:128: undefined reference to `__gthread_getspecific'
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libstdc++-v3/libsupc++/eh_globals.cc:132: undefined reference to `__gthread_setspecific'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_globals.o): In function `_ZN17__eh_globals_initC4Ev':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libstdc++-v3/libsupc++/eh_globals.cc:97: undefined reference to `__gthread_active_p'
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libstdc++-v3/libsupc++/eh_globals.cc:98: undefined reference to `__gthread_key_create'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/../../../libstdc++.a(eh_globals.o): In function `_ZN17__eh_globals_initD4Ev':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libstdc++-v3/libsupc++/eh_globals.cc:104: undefined reference to `__gthread_key_delete'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/libgcc_eh.a(unwind-sjlj.o): In function `fc_key_init_once':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:114: undefined reference to `__gthread_once'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/libgcc_eh.a(unwind-sjlj.o): In function `fc_key_init':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:107: undefined reference to `__gthread_key_create'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/libgcc_eh.a(unwind-sjlj.o): In function `_Unwind_SjLj_SetContext':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:160: undefined reference to `__gthread_setspecific'
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:160: undefined reference to `__gthread_setspecific'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/libgcc_eh.a(unwind-sjlj.o): In function `_Unwind_SjLj_Register':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:128: undefined reference to `__gthread_getspecific'
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:129: undefined reference to `__gthread_setspecific'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/libgcc_eh.a(unwind-sjlj.o): In function `_Unwind_SjLj_SetContext':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:160: undefined reference to `__gthread_setspecific'
/GCC_adtools/bin/../lib/gcc/ppc-amigaos/8.4.0/libgcc_eh.a(unwind-sjlj.o): In function `_Unwind_SjLj_GetContext':
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:147: undefined reference to `__gthread_getspecific'
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:147: undefined reference to `__gthread_getspecific'
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:147: undefined reference to `__gthread_getspecific'
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:147: undefined reference to `__gthread_getspecific'
/var/lib/jenkins/workspace/native-gcc-8/gcc/repo/libgcc/unwind-sjlj.c:147: undefined reference to `__gthread_getspecific'

My first guess is that the C++ compiler hasn't been properly tested :-(


Author of the PortablE programming language. I love using Amiga OS4.1 on my X1000 & Sam440 :-D
ChrisH
ChrisH's picture
Offline
Last seen: 3 months 2 weeks ago
Joined: 2010-12-07 20:22
Re: GCC & G++ randomly unable to compile C/C++ programs

I've seen the above problem with:
adtools-os4-8-20190301-697.lha
adtools-os4-8-20200408-704.lha
(These appear to be GCC v8.x)

However it does seem to compile OK using:
adtools-os4-20180501-552.lha
(This appears to be GCC v5.5.0)

So it looks like the port of GCC v8 hasn't been tested much (if at all) for C++ code, or else there isn't any interest in fixing C++ code to compile on AmigaOS :-/

Hopefully GCC v5.5 will work for me in more complex cases (to be tested)...
UPDATE: Yes, it seems to work fine more bigger programs :-)


Author of the PortablE programming language. I love using Amiga OS4.1 on my X1000 & Sam440 :-D
kas1e
kas1e's picture
Offline
Last seen: 20 hours 40 min ago
Joined: 2010-11-30 15:30
Re: GCC & G++ randomly unable to compile C/C++ programs

@ChrisH

No no, its all fine. Gcc 8.4.0 used already in all our still alive projects. For example latest version of Odyssey betas use 8.4.0 (and its full blown c++).

It's just now as there is support for threading in C with all that c++11 stuff, there was implemented native thread support , but it's currently just not default so you need to provide "-athread=native" option and on linking add -lpthread.

__gthread specific errors you have now, because you didn't provide "-athread=native" , and it tries to use posix-threads, which didnt' implemented properly too.

In other words , example are : "gcc -athread=native file.c -o file -lpthread"

Log in or register to post comments