Author Topic: GCC - updates  (Read 48128 times)

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2285
  • Karma: +176/-0
    • View Profile
Re: GCC - updates
« Reply #30 on: July 08, 2024, 01:19:36 am »
VERY early days, but...

Code: [Select]
{0}[u:\t] u:\dev\gcc-os2-13.x\host-i686-pc-os2-emx\gcc\xgcc --version
xgcc.exe (GCC) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


{0}[u:\t] u:\dev\gcc-os2-13.x\host-i686-pc-os2-emx\gcc\xgcc -BU:/dev/gcc-os2-13.
x/host-i686-pc-os2-emx/gcc/ -O2 -o helloworld.exe helloworld.c

{0}[u:\t] helloworld.exe
Hello, World!

STABS support has been removed, so building with debug symbols will generate errors.

Building libgcc is a pain as for some reason, I'm getting:
Code: [Select]
../.././libgcc/../gcc/common/config/i386/cpuinfo.h: Assembler messages:
../.././libgcc/../gcc/common/config/i386/cpuinfo.h:1718: Error: unknown pseudo-op: `.text.ctors.65434'

I haven't worked out yet what's causing the ".text.ctors.65434" to be generated. For now, I can manually generate cpuinfo.S and remove the offending line and generate cpuinfo.o and I end up with a seemingly working gcc1.dll

Will have to see how things go with building the rest of the compiler...

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5026
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: GCC - updates
« Reply #31 on: July 08, 2024, 10:13:11 pm »
Hi Paul.

I'm sorry I can not provide much feedback here because of my lack of skills on this area, but I appreciate a lot your efforts in something as important as porting this compiler, and thanks for sharing your progress.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2285
  • Karma: +176/-0
    • View Profile
Re: GCC - updates
« Reply #32 on: July 09, 2024, 01:24:58 am »
Looks like the best option is to at least partially revert https://gcc.gnu.org/pipermail/gcc-patches/2022-September/600792.html and re-instate stabs support... More when there's  something to share...

Edit: looking promising....
« Last Edit: July 09, 2024, 07:07:22 am by Paul Smedley »

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2285
  • Karma: +176/-0
    • View Profile
Re: GCC - updates
« Reply #33 on: July 09, 2024, 12:18:30 pm »
VERY lightly tested - but early build of GCC 13.3.0 is at https://smedley.id.au/tmp/gcc-13.3.0-os2-20240709.zip

even lighter tested GCC 14.1.0 at https://smedley.id.au/tmp/gcc-14.1.0-os2-20240709.zip

Debug is still broken, but I think I just fixed it  - rebuilding now to test
« Last Edit: July 10, 2024, 12:08:54 am by Paul Smedley »

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2285
  • Karma: +176/-0
    • View Profile
Re: GCC - updates
« Reply #34 on: July 10, 2024, 02:02:49 am »
More testing to be done, but https://smedley.id.au/tmp/gcc-13.3.0-os2-20240710.zip seems to correctly create debug symbols...

GCC 14.1.0  is giving some errors builing libgcc with debug code:
Code: [Select]
during RTL pass: final
../.././libgcc/libgcc2.c: In function '__muldi3':
../.././libgcc/libgcc2.c:538:1: internal compiler error: in eliminate_regs, at reload1.cc:2938
  538 | }
« Last Edit: July 10, 2024, 02:51:08 am by Paul Smedley »

Mentore

  • Full Member
  • ***
  • Posts: 224
  • Karma: +11/-0
    • View Profile
Re: GCC - updates
« Reply #35 on: July 10, 2024, 08:02:18 am »
More testing to be done, but https://smedley.id.au/tmp/gcc-13.3.0-os2-20240710.zip seems to correctly create debug symbols...

GCC 14.1.0  is giving some errors builing libgcc with debug code:
Code: [Select]
during RTL pass: final
../.././libgcc/libgcc2.c: In function '__muldi3':
../.././libgcc/libgcc2.c:538:1: internal compiler error: in eliminate_regs, at reload1.cc:2938
  538 | }

As usual, fantastic job Paul.
May I ask if it is possible to directly substitute this over, say, GCC 9.2.0 from the netlabs YUM/RPM repository?
Mentore (still reinstalling ArcaOS beta to work on the italian NLS)

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2285
  • Karma: +176/-0
    • View Profile
Re: GCC - updates
« Reply #36 on: July 10, 2024, 10:09:33 am »
Hey Mentore,

I've deliberately set this up to easily work *with* rpm gcc 9.2.0.

Unzip it to the root of the same drive you have rpm installed on. To switch to a newer gcc, 'set path=c:\usr\local1330\bin;%path%' (or whatever the path is).  GCC 9.2.0 will still be installed into c:\usr\bin and it's easy to change between them.

Cheers,

Paul.

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2285
  • Karma: +176/-0
    • View Profile
Re: GCC - updates
« Reply #37 on: July 11, 2024, 02:56:06 am »
Working debug with 14.1.0  (with a hack still in place):  https://smedley.id.au/tmp/gcc-14.1.0-os2-20240711.zip

KO Myung-Hun

  • Newbie
  • *
  • Posts: 45
  • Karma: +6/-0
    • View Profile
Re: GCC - updates
« Reply #38 on: July 11, 2024, 08:34:16 am »
Hi/2.

For
Quote
Working debug with 14.1.0  (with a hack still in place):  https://smedley.id.au/tmp/gcc-14.1.0-os2-20240711.zip

404 not found error.

For
Quote
even lighter tested GCC 14.1.0 at https://smedley.id.au/tmp/gcc-14.1.0-os2-20240709.zip

1. 'a.exe' is generated unless -o is given.

2. SIGABRT because of C++ exceptions.
Quote
terminate called after throwing an instance of 'std::out_of_range'
terminate called recursively
Testcases are https://github.com/komh/gcctest/blob/master/xcpt.cpp, https://github.com/komh/gcctest/blob/master/cxx11/exception_ptr.cpp.

For
Quote
VERY lightly tested - but early build of GCC 13.3.0 is at https://smedley.id.au/tmp/gcc-13.3.0-os2-20240709.zip

1. 'a.exe' is generated unless `-o' is given.

2. Some symbols are missing:
Quote
g++  -o ctype.exe ctype.o
../../.././libstdc++-v3/libsupc++/eh_personality.cc:457 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol __Unwind_GetIPInfo referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:157 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_mutex_lock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:261 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_cond_wait_recursive referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:169 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_mutex_unlock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:169 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_mutex_unlock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:157 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_mutex_lock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:248 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_cond_broadcast referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:169 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_mutex_unlock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:157 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_mutex_lock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:248 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_cond_broadcast referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:169 (g:/usr/local1330/lib/libstdc++.a(guard.o)): Undefined symbol ___gthread_os2_mutex_unlock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:139 (g:/usr/local1330/lib/libstdc++.a(locale.o)): Undefined symbol ___gthread_os2_mutex_unlock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:127 (g:/usr/local1330/lib/libstdc++.a(locale.o)): Undefined symbol ___gthread_os2_mutex_lock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:139 (g:/usr/local1330/lib/libstdc++.a(locale.o)): Undefined symbol ___gthread_os2_mutex_unlock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:139 (g:/usr/local1330/lib/libstdc++.a(locale_init.o)): Undefined symbol ___gthread_os2_mutex_unlock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:127 (g:/usr/local1330/lib/libstdc++.a(locale_init.o)): Undefined symbol ___gthread_os2_mutex_lock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:139 (g:/usr/local1330/lib/libstdc++.a(locale_init.o)): Undefined symbol ___gthread_os2_mutex_unlock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:127 (g:/usr/local1330/lib/libstdc++.a(locale_init.o)): Undefined symbol ___gthread_os2_mutex_lock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:139 (g:/usr/local1330/lib/libstdc++.a(locale_init.o)): Undefined symbol ___gthread_os2_mutex_unlock referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:601 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol ___chkstk_ms referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:610 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol ___chkstk_ms referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:1095 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol ___chkstk_ms referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:1256 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol ___chkstk_ms referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:1277 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol ___chkstk_ms referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:601 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol ___chkstk_ms referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:610 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol ___chkstk_ms referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:1095 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol ___chkstk_ms referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:1256 (g:/usr/local1330/lib/libstdc++.a()): Undefined symbol ___chkstk_ms referenced from text segment
U:/dev/gcc-os2-13.x/libstdc++-v3/include/bits/locale_facets_nonio.tcc:0 (g:/usr/local1330/lib/libstdc++.a()): More undefined symbol ___chkstk_ms refs follow
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:127 (g:/usr/local1330/lib/libstdc++.a(eh_alloc.o)): Undefined symbol ___gthread_os2_mutex_lock referenced from text segment
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:0 (g:/usr/local1330/lib/libstdc++.a(eh_alloc.o)): More undefined symbol ___gthread_os2_mutex_unlock refs follow
U:/dev/gcc-os2-13.x/i686-pc-os2-emx/libstdc++-v3/include/i686-pc-os2-emx/bits/gthr-default.h:127 (g:/usr/local1330/lib/libstdc++.a(eh_alloc.o)): Undefined symbol ___gthread_os2_mutex_lock referenced from text segment
A testcase is https://github.com/komh/gcctest/blob/master/ctype.cpp. However, this error occurs with any other testcases with g++, too.

Thanks a lot!

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2285
  • Karma: +176/-0
    • View Profile
Re: GCC - updates
« Reply #39 on: July 11, 2024, 09:04:08 am »
oops gcc-14.1.0-os2-20240711.zip is there now

GCC 14.1.0 - please retest with latest  drop

GCC 13.3.0 -  suspect you need to manually add the libs with those symbols - the solution is probably to generate a stdcppxx.dll instead of shipping a static lib...

re: a.exe problem - I think I remember something - need to go investigate... I seem to  remember getting an error from gcc around some failed assertion in LINK_SPEC....
« Last Edit: July 11, 2024, 10:13:31 am by Paul Smedley »

Mentore

  • Full Member
  • ***
  • Posts: 224
  • Karma: +11/-0
    • View Profile
Re: GCC - updates
« Reply #40 on: July 11, 2024, 11:15:03 am »
Hey Mentore,

I've deliberately set this up to easily work *with* rpm gcc 9.2.0.

Unzip it to the root of the same drive you have rpm installed on. To switch to a newer gcc, 'set path=c:\usr\local1330\bin;%path%' (or whatever the path is).  GCC 9.2.0 will still be installed into c:\usr\bin and it's easy to change between them.

Cheers,

Paul.

Fantastic job Paul, as usual.
Thanks!

Mentore

KO Myung-Hun

  • Newbie
  • *
  • Posts: 45
  • Karma: +6/-0
    • View Profile
Re: GCC - updates
« Reply #41 on: July 12, 2024, 08:02:19 am »
Quote
oops gcc-14.1.0-os2-20240711.zip is there now

GCC 14.1.0 - please retest with latest  drop

I've downloaded and tested it, but it has no differences.

Quote
GCC 13.3.0 -  suspect you need to manually add the libs with those symbols - the solution is probably to generate a stdcppxx.dll instead of shipping a static lib...

I had tested without `-static-libgcc', and failed due to 'undefined symbols'. However, if it is given, it has the same results as 14.1.0.

I've investigated further more, and found that `gcc1.dll' does not have any export entry. As a resut, `libgcc_so_d.a' has no import entries at all. This was the cause.

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2285
  • Karma: +176/-0
    • View Profile
Re: GCC - updates
« Reply #42 on: July 12, 2024, 09:40:31 am »
I can reproduce issue with xcpt.cpp.

ctype.cpp works for me:
Code: [Select]
{0}[u:\dev\gcc-os2-14.x] g++ ctype.cpp

{0}[u:\dev\gcc-os2-14.x] a
default locale:
  Column
  1,Column
  2,Column
  3
  123,456,789
locale with modified ctype:
  Column 1
  Column 2
  Column 3
  123
  456
  789

'g++ -static-libgcc ctype.cpp'  also works for me (with 14.1.0)

I see the missing symbols errors with 13.3.0 - perhaps I've (accidentally?) fixed something locally in 14.1.0!

Latest 14.1.0 is https://smedley.id.au/tmp/gcc-14.1.0-os2-20240712.zip
« Last Edit: July 12, 2024, 10:08:34 am by Paul Smedley »

Paul Smedley

  • Hero Member
  • *****
  • Posts: 2285
  • Karma: +176/-0
    • View Profile
Re: GCC - updates
« Reply #43 on: July 12, 2024, 11:31:42 am »
OK I found the problem with gcc1.dll. New 13.3.0 build coming once it finishes -  most likely Saturday morning my time....

https://smedley.id.au/tmp/gcc-13.3.0-os2-20240712.zip

xcpt.cpp now gives the same results on both 13.3.0 and 14.1.0,  that is:
Code: [Select]
terminate called after throwing an instance of 'char const*'
terminate called recursively

Killed by SIGABRT
pid=0x63dd ppid=0x0048 tid=0x0001 slot=0x001a pri=0x0200 mc=0x0001 ps=0x0010
U:\DEV\GCC-OS2-13.X\A.EXE
Creating 63DD_01.TRP
Moved 63dd_01.TRP to C:\var\log\app\6691818b-63dd_01-A-exceptq.txt
« Last Edit: July 12, 2024, 11:50:13 am by Paul Smedley »

KO Myung-Hun

  • Newbie
  • *
  • Posts: 45
  • Karma: +6/-0
    • View Profile
Re: GCC - updates
« Reply #44 on: July 12, 2024, 02:08:23 pm »
At the beginning, ctype.cpp had no problems with gcc v14.1.0, but with gcc v13.3.0 only.

For both gcc v14.1.0-20240712 and v13.3.0-20240712

They cause SIGSEGV when executing `exception_ptr.exe'.

Quote
g++ -std=c++11 -c -o cxx11/exception_ptr.o cxx11/exception_ptr.cpp
g++  -o cxx11/exception_ptr.exe cxx11/exception_ptr.o
./cxx11/exception_ptr.exe > /dev/null

Killed by SIGSEGV
pid=0x00e2 ppid=0x00e1 tid=0x0001 slot=0x00ad pri=0x0200 mc=0x0001 ps=0x0010
F:\LANG\WORK\TEST\GCCTEST\CXX11\EXCEPTION_PTR.EXE
cs:eip=0000:00000000      ss:esp=0000:00000000      ebp=d003ffff
 ds=021fff8c      es=0000      fs=0000      gs=0000     efl=00000000
eax=021ff70c ebx=021ff730 ecx=00000053 edx=000a3cb3 edi=021ff6f8 esi=1c029d48

I attach .trp file for this.

And SIGABRT.

Quote
Assertion failed: !"Dead lock" || mutex->recursive || ulCount == 1, file
../.././libgcc/gthr-os2.c, line 93

Killed by SIGABRT
pid=0x00e2 ppid=0x00e1 tid=0x0001 slot=0x00ad pri=0x0200 mc=0x0002 ps=0x0017
F:\LANG\WORK\TEST\GCCTEST\CXX11\EXCEPTION_PTR.EXE