Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amiga-gcc 13.2 built executable exits with error code 121 #402

Open
trholding opened this issue Aug 11, 2024 · 9 comments
Open

amiga-gcc 13.2 built executable exits with error code 121 #402

trholding opened this issue Aug 11, 2024 · 9 comments

Comments

@trholding
Copy link

Dear Bebbo, thank you for keeping Amiga development alive!

I once owned an Amiga 500 back when I was a kid, and decades later I have the urge to make a demo for the Amiga.

I am thankful that folks like you exist that keeps the machine and dream alive.

I am an absolute noob to Amiga development and I encountered an error:

helloamiga

Unable to load helloamiga.exe: Error code 121

I built the helloamiga.c to target Amiga 500 with kickstart 1.3 ROM without errors:

m68k-amigaos-gcc -o helloamiga.exe helloamiga.c  -lm -mcrt=nix13

I used the amiga-gcc 13.2 toolchain (make branch branch=amiga13.1 mod=gcc)

m68k-amigaos-gcc -v
Using built-in specs.
COLLECT_GCC=m68k-amigaos-gcc
COLLECT_LTO_WRAPPER=/opt/amiga/libexec/gcc/m68k-amigaos/13.2.0/lto-wrapper
Target: m68k-amigaos
Configured with: /home/linux/AMIGA/amiga-gcc/projects/gcc/configure --prefix=/opt/amiga --target=m68k-amigaos --enable-languages=c,c++,objc, --enable-version-specific-runtime-libs --disable-libssp --disable-nls --with-headers=/home/linux/AMIGA/amiga-gcc/projects/newlib-cygwin/newlib/libc/sys/amigaos/include/ --disable-shared --enable-threads=no --with-stage1-ldflags='-dynamic-libgcc -dynamic-libstdc++' --with-boot-ldflags='-dynamic-libgcc -dynamic-libstdc++'
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (GCC) 

The helloamiga.exe was packaged as adf with exe2adf:

exe2adf -i helloamiga.exe -a helloamiga.adf

Then I ran it with fs-uae.

I do not know if I did something wrong or related to amiga-gcc. Any hints for a fix is highly appreciated as I am trying to avoid building lower versions of amiga-gcc from scratch to test out.

The helloamiga.c test code as well as the exe and adf is attached here in a zip:
helloamiga.zip
.

@trholding
Copy link
Author

I have built amiga-gcc with gcc 6 on another system, but running the resulting exe leads to error 20:

m68k-amigaos-gcc -v
Using built-in specs.
COLLECT_GCC=m68k-amigaos-gcc
COLLECT_LTO_WRAPPER=/opt/amiga/libexec/gcc/m68k-amigaos/6.5.0b/lto-wrapper
Target: m68k-amigaos
Configured with: /home/ubuntu/SPACE/amiga-gcc/projects/gcc/configure --prefix=/opt/amiga --target=m68k-amigaos --enable-languages=c,c++,objc, --enable-version-specific-runtime-libs --disable-libssp --disable-nls --with-headers=/home/ubuntu/SPACE/amiga-gcc/projects/newlib-cygwin/newlib/libc/sys/amigaos/include/ --disable-shared --enable-threads=no --with-stage1-ldflags='-dynamic-libgcc -dynamic-libstdc++' --with-boot-ldflags='-dynamic-libgcc -dynamic-libstdc++'
Thread model: single
gcc version 6.5.0b 240620092724 (GCC) 

I get further but some math libraries are not loading:
helloamiga_2

It was compiled like this:

m68k-amigaos-gcc -o HELLOAMIGA.exe helloamiga.c  -lm -mcrt=nix13

@bebbo
Copy link
Owner

bebbo commented Aug 15, 2024

For now you have to strip the executable using v 13.2.

Add -s to the gcc command line performs an immediate strip.

or use m68k-amigaos-strip

@trholding
Copy link
Author

I'll try these two and get back to you:

Add -s to the gcc command line performs an immediate strip.
or use m68k-amigaos-strip

Thank you! Danke!

@trholding
Copy link
Author

I've tried this with amiga-gcc 6:

m68k-amigaos-gcc -s -o HELLOAMIGA.exe helloamiga.c  -lm -mcrt=nix13

Also statically compiled with gcc 6:

m68k-amigaos-gcc -static -o HELLOAMIGA.exe helloamiga.c  -lm -mcrt=nix13

I've also compiled with amiga-gcc 6 and stripped with amiga-gcc 13.2:

m68k-amigaos-gcc -o HELLOAMIGA.exe helloamiga.c  -lm -mcrt=nix13    # gcc 6
m68k-amigaos-strip HELLOAMIGA.exe # gcc 13.2 

And I ran each build on fs-uae after converting to adf and the results are same "... failed with return code 20", amiga-gcc 13.2 fails with "Error code 121"

Should I build gcc 13.1 and see?

@bebbo
Copy link
Owner

bebbo commented Aug 15, 2024

Ensure that mathieeedoubbas.library and mathieeedoubtrans.library are present.

@trholding
Copy link
Author

I use <math.h> / libm and link with -lm , and I took it for granted. Man I have to really appreciate you for porting so much stuff that people take for granted.

Maybe I have to do it the Amiga way:

http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node048A.html
https://aminet.net/package/util/libs/MathLibsUAE
http://aminet.net/package/util/libs/HSMathLibs_040

Since it is for an Amiga 500 Kickstart 1.3 I'd need to find a softfp version.

Perhaps I'll have to write my own simplified / equivalent math functions or use something like https://core-math.gitlabpages.inria.fr/

Thank you for the support.

@bebbo
Copy link
Owner

bebbo commented Aug 15, 2024

What's the problem? Both libs are available with kick 1.3. Check the workbench's libs folder.

@trholding
Copy link
Author

trholding commented Aug 15, 2024

What's the problem? Both libs are available with kick 1.3. Check the workbench's libs folder.

Okay I guess the problem was that I am an idiot and noob to amiga dev stuff. Your hint and (bebbo/libnix#36) solved it! Thanks a ton!!! I learned something new.

Success

Leaving this here for any new folks who encounter issues with libraries not found:

mkdir D1
sudo mount  -t affs  -o loop ./<Workbench 1.3 Disk 1 filename>.adf ./D1
sudo cp -R D1/libs ./
chmod -Rv 777 libs
exe2adf -i <yourprogram>.exe -d libs -a <yourprogram>.adf

Now only the issue with amiga-gcc 13.2 built executable exiting with error code 121 remains. But I guess gcc 6 is fine for my purposes unless gcc 13.2 compiles way more efficient binaries.

Edit: This is such excitement and a dream come true that after 3 decades I can run My Own Amiga Program (TM), I have found closure to my childhood pains. And feels like the first time I discovered programming. Much Love! Keep up the awesome work.

@bebbo
Copy link
Owner

bebbo commented Oct 2, 2024

please retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants