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

Have a question about our Software Developer Kit? Ask them here.
Post Reply
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

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

Post by ChrisH »

After booting AmigaOS4.1FE on an X1000, 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 occasionally 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.

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. Increasing the stack did not help. I am using the "latest" SDK (53.30).
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

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

Post by Raziel »

@ChrisH

I know this error (the assertion was very randomly for me) but the "internal error" hit me reproducably, but only when I was messing around with more than 4 GB of RAM and more than 2 RAM sockets occupied.
With the above setup I could reproduce the issue nearly all the time.

Without the setup (right now I have two RAM sockets with 2x2 GB installed) I only get this kind of error when the compiler runs out of memory (roughly 1.6 GB usable before it happens).
It did get better since using GCC 8.3.0.

Which gcc version are you using?
I assume you have 2 GB RAM installed?
Have you checked where your project peaks at RAM?
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

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

Post by ChrisH »

Hi Raziel. Slightly encouraging to know I'm not the sole person to get this error (which a Google search seemed to suggest!).

Yes, I have 2GB of RAM (2*1GB DIMMs). But it happens even with the smallest possible C/C++ project:

Code: Select all

int main() {
	return 0;
}
So GCC memory usage shouldn't be a factor. (In fact it happens even with an *empty file*, if I attempt to compile it!)

I am using the version of GCC/G++ that comes with SDK 53.30, which appears to be 4.2.4 (adtools build 20090118).

How do you get a newer version of GCC/G++? (Please don't say I have to compile it myself!)
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

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

Post by Raziel »

ChrisH wrote: Sun Aug 09, 2020 2:30 pm Hi Raziel. Slightly encouraging to know I'm not the sole person to get this error (which a Google search seemed to suggest!).

Yes, I have 2GB of RAM (2*1GB DIMMs). But it happens even with the smallest possible C/C++ project:

Code: Select all

int main() {
	return 0;
}
So GCC memory usage shouldn't be a factor. (In fact it happens even with an *empty file*, if I attempt to compile it!)
That is very bad and should not happen, I would suspect a broken gcc install.
I am using the version of GCC/G++ that comes with SDK 53.30, which appears to be 4.2.4 (adtools build 20090118).

How do you get a newer version of GCC/G++? (Please don't say I have to compile it myself!)
Hehehe, don't fear, if I would have to build it myself I wouldn't be able to use it :-)

You can get the latest newlib version from Sebastian Bauer's adtools github page.

Latest newlib is adtools-os4-8-20200408-704.lha with gcc8.3.0 (i believe, cant check) within, which you can get from here

Good luck and keep us updated
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

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

Post by ChrisH »

I would suspect a broken gcc install.
Yes, but why sometimes work & sometimes not? And why do all the files exactly match those from the original SDK archive?
You can get the latest newlib version from Sebastian Bauer's adtoolsgithub page.
Great, thanks for the link. First test suggests this *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... which I seem to have achieved using this:

Code: Select all

; 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
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

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

Post by Raziel »

I simply backed up (by renaming) the old gcc/adtools stuff and installed the new one to my SDK.

Works here.
Hope it will fix your issues.
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

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

Post by ChrisH »

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 :-(
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

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

Post by ChrisH »

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 :-)
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

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

Post by Raziel »

I know this error as well, but I can normally fix it by adding -lpthread to the linker line, but I guess that is not the problem you're facing.
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Post Reply