English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 29 October 2021, 08:42   #1321
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
Sure, but I'd rather not have this dependency just to calculate the gamma correction table at startup. I try to require only Kickstart 3.x libraries whenever possible, and make the rest optional. Later I'll replace this table with a precalculated variant.
BSzili is offline  
Old 05 November 2021, 08:42   #1322
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
I was wondering, would it be possible to include swapstack.o in libnix20.a? It's already present in libnix13.a so it shouldn't cause any issues, as it doesn't get linked unless __stkinit is referenced.
BSzili is offline  
Old 06 November 2021, 18:08   #1323
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
I seem to have a difficult time getting the stackswap code to work. I created a small example that crashes at exit if the stackswap code runs. If I give a large stack before starting the program it exits normally.
stkswaptest.c
Code:
extern void __stkinit(void);
void * __x = __stkinit;
unsigned long __stack = (32*1024);
int main(void)
{
	return 0;
}
I build it with this command:
m68k-amigaos-gcc -noixemul -m68060 -m68881 -ffast-math -O2 -fomit-frame-pointer -o stkswap stkswaptest.c /opt/amiga/m68k-amigaos/libnix/lib/libm020/libm881/swapstack.o


Could this be an issue with libnix?
BSzili is offline  
Old 27 November 2021, 17:44   #1324
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
Quote:
Originally Posted by BSzili View Post
I seem to have a difficult time getting the stackswap code to work. I created a small example that crashes at exit if the stackswap code runs. If I give a large stack before starting the program it exits normally.
stkswaptest.c
Code:
extern void __stkinit(void);
void * __x = __stkinit;
unsigned long __stack = (32*1024);
int main(void)
{
    return 0;
}
I build it with this command:
m68k-amigaos-gcc -noixemul -m68060 -m68881 -ffast-math -O2 -fomit-frame-pointer -o stkswap stkswaptest.c /opt/amiga/m68k-amigaos/libnix/lib/libm020/libm881/swapstack.o


Could this be an issue with libnix?

I modified libnix to not use the AmigaOS SwapStack method...
... as for kick 1.3
bebbo is offline  
Old 29 November 2021, 19:52   #1325
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
Thanks, I'll test it soon! Do you think it would be possible to include swapstack.o in libnix20.a like it is in libnix13.a?
BSzili is offline  
Old 02 December 2021, 11:51   #1326
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
Quote:
Originally Posted by BSzili View Post
I was wondering, would it be possible to include swapstack.o in libnix20.a? It's already present in libnix13.a so it shouldn't cause any issues, as it doesn't get linked unless __stkinit is referenced.

done
bebbo is offline  
Old 04 December 2021, 07:44   #1327
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
Thank you! I retested my all-exhaustive test program, and it no longer crashes at exit. stackwap.o also got linked nicely
BSzili is offline  
Old 05 December 2021, 20:16   #1328
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
fyi: exceptions and rtti should now work with 68000/68010.
bebbo is offline  
Old 09 December 2021, 07:12   #1329
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
Did something change recently regarding the code generation for -m68060? I rebuilt Duke3D to test the recently added control presets, and it now has some graphics glitches, sometimes CON parsing won't work, and the maps won't load. I tried to compare the asm output with -m68040 and it looks like the compiler now emits FPU instructions for certain multiplications. For example what compiles to
muls.l #936,d0
becomes
Code:
	fmove.l d1,fp0
	fmul.l #936,fp0
	fmod.s #0x4f800000,fp0
	fmove.l fp0,d2
This could be a problem, because I change the FPU rounding for the custom 64-bit integer math replacement routines, which probably messes with the ones generated by the compiler. Is it possible to disable this optimization?

Edit: This is a small function that now has FPU instructions with -m68060, but with -m68040 it doesn't:
http://franke.ms/cex/z/T7rj6q

Last edited by BSzili; 09 December 2021 at 07:54.
BSzili is offline  
Old 04 January 2022, 01:23   #1330
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
Hi,
I am using latest update from github.

I cannot complie when using ChooserLabels() and FreeChooserLabels() from <clib/reaction_lib_protos.h>. I got a linker error:
undefined reference to `ChooserLabels'

Can I workaroud it somehow?

For now I found Stephan Rupprecht's reaction library replecemnt source in C,
so that functions are just creating standard lists, so I can reimplenet in my code.

But it would be great if standard way could work.. I also got similar problem with other
reaction function, but again I woraround it with another..

Thank You in advance.
mateusz_s is offline  
Old 04 January 2022, 13:28   #1331
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
ok, nevermind.. it can be replaced with: AllocChooserNode()
mateusz_s is offline  
Old 09 January 2022, 13:31   #1332
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
Quote:
Originally Posted by BSzili View Post
Did something change recently regarding the code generation for -m68060? I rebuilt Duke3D to test the recently added control presets, and it now has some graphics glitches, sometimes CON parsing won't work, and the maps won't load. I tried to compare the asm output with -m68040 and it looks like the compiler now emits FPU instructions for certain multiplications. For example what compiles to
muls.l #936,d0
becomes
Code:
    fmove.l d1,fp0
    fmul.l #936,fp0
    fmod.s #0x4f800000,fp0
    fmove.l fp0,d2
This could be a problem, because I change the FPU rounding for the custom 64-bit integer math replacement routines, which probably messes with the ones generated by the compiler. Is it possible to disable this optimization?

Edit: This is a small function that now has FPU instructions with -m68060, but with -m68040 it doesn't:
http://franke.ms/cex/z/T7rj6q

I rolled that change back a while ago and now I added another feature:


Quote:
implement direct MathIeeeSingTransBase/MathIeeeDoubTransBase calls

this is triggered for 68040/68060 if -ffast-math gets used.
bebbo is offline  
Old 09 January 2022, 13:36   #1333
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
Quote:
Originally Posted by BSzili View Post
Did something change recently regarding the code generation for -m68060? I rebuilt Duke3D to test the recently added control presets, and it now has some graphics glitches, sometimes CON parsing won't work, and the maps won't load. I tried to compare the asm output with -m68040 and it looks like the compiler now emits FPU instructions for certain multiplications. For example what compiles to
muls.l #936,d0
becomes
Code:
    fmove.l d1,fp0
    fmul.l #936,fp0
    fmod.s #0x4f800000,fp0
    fmove.l fp0,d2
This could be a problem, because I change the FPU rounding for the custom 64-bit integer math replacement routines, which probably messes with the ones generated by the compiler. Is it possible to disable this optimization?

Edit: This is a small function that now has FPU instructions with -m68060, but with -m68040 it doesn't:
http://franke.ms/cex/z/T7rj6q

I rolled that change back a while ago and now I added another feature:


Quote:
implement direct MathIeeeSingTransBase/MathIeeeDoubTransBase calls

this is triggered for 68040/68060 if -ffast-math gets used.



https://franke.ms/cex/z/75YoWe
bebbo is offline  
Old 09 January 2022, 18:10   #1334
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
I see, thanks now it works fine with the latest version.
BSzili is offline  
Old 07 February 2022, 10:58   #1335
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,099
Using latest version of amiga-gcc (4766d09 / Dec 24 2021) atan2(-1, 1) has wrong sign when compiling with -m68881 but *without* -noiexemul. I think this is the case for the entire quadrant.

Test case:
Code:
#include <stdio.h>
#include <math.h>
volatile double x = 1, y = -1;
int main() {
    printf("atan2(%f, %f) = %f (%f degrees)\n", y, x, atan2(y, x), atan2(y, x) * 180 / 3.141592653589793);
    return 0;
}
Results:
Code:
-mcpu=68020 -m68881 -lm             atan2(-1.000000, 1.000000) = 0.785398 (45.000000 degrees)
-mcpu=68020 -lm                     atan2(-1.000000, 1.000000) = -0.785398 (-45.000000 degrees)
-mcpu=68020 -m68881 -noixemul -lm   atan2(-1.000000, 1.000000) = -0.785398 (-45.000000 degrees)
(Not a big deal, the only reason I compiled without -noixemul is because I forgot, but quite noticeable when creating a tunnel table )
paraj is offline  
Old 07 February 2022, 22:08   #1336
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
Quote:
Originally Posted by paraj View Post
Using latest version of amiga-gcc (4766d09 / Dec 24 2021) atan2(-1, 1) has wrong sign when compiling with -m68881 but *without* -noiexemul. I think this is the case for the entire quadrant.

Test case:
Code:
#include <stdio.h>
#include <math.h>
volatile double x = 1, y = -1;
int main() {
    printf("atan2(%f, %f) = %f (%f degrees)\n", y, x, atan2(y, x), atan2(y, x) * 180 / 3.141592653589793);
    return 0;
}
Results:
Code:
-mcpu=68020 -m68881 -lm             atan2(-1.000000, 1.000000) = 0.785398 (45.000000 degrees)
-mcpu=68020 -lm                     atan2(-1.000000, 1.000000) = -0.785398 (-45.000000 degrees)
-mcpu=68020 -m68881 -noixemul -lm   atan2(-1.000000, 1.000000) = -0.785398 (-45.000000 degrees)
(Not a big deal, the only reason I compiled without -noixemul is because I forgot, but quite noticeable when creating a tunnel table )

the libs for 68881 weren't build, which are returning fp values in fp0...
I supplemented the missing combinations to the multilib info and with the correct version linked also the default (newlib) yields the correct result.


... and building takes now: infinite + x% ^^
bebbo is offline  
Old 08 February 2022, 19:51   #1337
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,099
Quote:
Originally Posted by bebbo View Post
the libs for 68881 weren't build, which are returning fp values in fp0...
I supplemented the missing combinations to the multilib info and with the correct version linked also the default (newlib) yields the correct result.


... and building takes now: infinite + x% ^^

Luckily inf + n = inf



Is the change in a development branch? Just curious, like I wrote I don't need it and there's an easy workaround.
paraj is offline  
Old 14 February 2022, 10:47   #1338
girv
Mostly Harmless
 
girv's Avatar
 
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,109
I'm exploring using this toolchain (and vasm) for a game. I've skimmed this epic thread and done a lot of poking around, and I have a few questions still.

What code is run at startup? I'd like to use -nostartfiles (and -nostdlib) to minimise the code size, but I'm also curious what this leaves out. Are these the relevant sources?
https://github.com/bebbo/libnix/tree...ources/startup
-nostartfiles only seems to drop a few hundred bytes though and I guess I can live with that.

Do -nostartfiles and -nostdlib interact? Does -nostdlib imply -nostartfiles?
edit: found the manual for these flags https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

Are -flto and/or -fwhole-program supported?
I was experimenting with my own vasm startup code and got "undefined reference to 'SysBase'" when linking with -flto, but it linked sucessfully without that flag.
edit: resolved the error, I was actually using -flto and -fwhole-program together which is not correct, but the question stands.

With -fbaserel, are messages like this errors or warnings?
"reloc for _state_game_copper0 is out of range: 00000000"
state_game_copper0 is an XDEF label in a vasm .obj and ideally in a separate section (but see next question!) - do I need to declare "state_game_copper0" as __far in the C code?

Is it possible to have a .obj file assembled by vasm produce an Amiga HUNKF_CHIP hunk? I see the amiga.x linker script has "datachip" and "bsschip" sections - are these special names recognised by your ld? Though ld seems to use amiga_bss.x instead anyway which lacks these sections.

Thanks

Last edited by girv; 14 February 2022 at 14:53.
girv is offline  
Old 14 February 2022, 22:46   #1339
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
Quote:
Originally Posted by girv View Post
I'm exploring using this toolchain (and vasm) for a game. I've skimmed this epic thread and done a lot of poking around, and I have a few questions still.
oh no

Quote:
Originally Posted by girv View Post


What code is run at startup? I'd like to use -nostartfiles (and -nostdlib) to minimise the code size, but I'm also curious what this leaves out. Are these the relevant sources?
https://github.com/bebbo/libnix/tree...ources/startup
if you are using -noixemul aka -mcrt=nix20 or -mcrt=nix13, then libnix is used.
The default is newlib, which I wouldn't use, it's a place holder for ixemul in the far future
And there -mcrt=clib2, which I also don't use.

Quote:
Originally Posted by girv View Post
-nostartfiles only seems to drop a few hundred bytes though and I guess I can live with that.
-noixemul provides library auto init, a memory allocater and some more posix stuff... it's like a religion

Quote:
Originally Posted by girv View Post
Do -nostartfiles and -nostdlib interact? Does -nostdlib imply -nostartfiles? edit: found the manual for these flags https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
using stdlib requires some startup which initializes the stuff like stdio, etc.p.p. so you'd have to create some proper startup code yourself.

Quote:
Originally Posted by girv View Post

Are -flto and/or -fwhole-program supported?
I was experimenting with my own vasm startup code and got "undefined reference to 'SysBase'" when linking with -flto, but it linked sucessfully without that flag.
edit: resolved the error, I was actually using -flto and -fwhole-program together which is not correct, but the question stands.

With -fbaserel, are messages like this errors or warnings?
"reloc for _state_game_copper0 is out of range: 00000000"
state_game_copper0 is an XDEF label in a vasm .obj and ideally in a separate section (but see next question!) - do I need to declare "state_game_copper0" as __far in the C code?
if it's a variable and not referenced via A4: yes
Quote:
Originally Posted by girv View Post

Is it possible to have a .obj file assembled by vasm produce an Amiga HUNKF_CHIP hunk? I see the amiga.x linker script has "datachip" and "bsschip" sections - are these special names recognised by your ld?
the m68k-amigaos-ld uses the names to set the flags for chip or fast memory. you can use theses section names with vasm too.
Quote:
Originally Posted by girv View Post
Though ld seems to use amiga_bss.x instead anyway which lacks these sections.
this still should work

Quote:
Originally Posted by girv View Post
Thanks

Last edited by bebbo; 15 February 2022 at 06:45.
bebbo is offline  
Old 03 March 2022, 15:10   #1340
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
random info...:
bebbo is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
New GCC based dev toolchain for AmigaOS 3.x cla Coders. Releases 8 24 December 2017 10:18
Issue with photon/xxxx WinUAE Toolchain arpz Coders. Asm / Hardware 2 26 September 2015 22:33
New 68k gcc toolchain arti Coders. C/C++ 17 31 July 2015 03:59
Hannibal's WinUAE Demo Toolchain 5 Bobic Amiga scene 1 23 July 2015 21:04
From gcc to vbcc. Cowcat Coders. General 9 06 June 2014 14:45

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:43.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.14438 seconds with 15 queries