[z88dk-dev] floating point linking broken on all classic compiles?

Bridge to the z88dk-developers mailing list
Post Reply
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

[z88dk-dev] floating point linking broken on all classic compiles?

Post by alvin »

I just noticed I couldn't compile a program that needed float math for cpm or the test target using the classic c library. I think all the cfg files are missing:

Z88MATHFLG -D__NATIVE_MATH__

except for zx and zx81?



------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/ ... 1&iu=/4140
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

>Z88MATHFLG -D__NATIVE_MATH__
>
>except for zx and zx81?

It could be. It is very long I don't use the FP code outside the Sinclair clones (the last time it was for the Lambda 8300, but issue we were having on sccz80 confused me a lot). If you're busy I can put the definition on the CFG files.



------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/ ... 1&iu=/4140
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Z88MATHFLG -D__NATIVE_MATH__

except for zx and zx81?
It could be. It is very long I don't use the FP code outside the Sinclair clones (the last time it was for the Lambda 8300, but issue we were having on sccz80 confused me a lot). If you're busy I can put the definition on the CFG files.
Maybe doublecheck if that's the problem? If you're volunteering to fix things up I'm ok with that :D



------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/ ... 1&iu=/4140
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Z88MATHFLG -D__NATIVE_MATH__

except for zx and zx81?
It could be. It is very long I don't use the FP code outside the Sinclair clones (the last time it was for the Lambda 8300, but issue we were having on sccz80 confused me a lot). If you're busy I can put the definition on the CFG files.
I also changed line 619 in zcc.c to disable the math lib configuration for new c lib compiles some time ago. I don't think that's the problem but just so you know.



------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/ ... 1&iu=/4140
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

On Mon, 9 Nov 2015, alvin (alvin_albrecht@...) wrote:
I just noticed I couldn't compile a program that needed float math for
cpm or the test target using the classic c library. I think all the cfg
files are missing:

Z88MATHFLG -D__NATIVE_MATH__

except for zx and zx81?
I think that's only needed for the CPC maths library. The main thing is
sorting out how the fp number is represented - the -math-z88 flag switches
on the 40 bit representation, though I think CPC might need -doublestr to
work correctly.


------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/ ... 1&iu=/4140
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I think that's only needed for the CPC maths library. The main thing is
sorting out how the fp number is represented - the -math-z88 flag switches
on the 40 bit representation, though I think CPC might need -doublestr to
work correctly.
That's right, I got to the same conclusion checking the configurations.

The CPC related part doesn't even need the "-D__NATIVE_MATH__" flag: checking for the target type is enough for "math.h".
Time ago I chose to keep this same definition on the Sinclair machines because they could have had extra native math functions in ROM, but it was useless. I'm going to fix "math.h", so you need to care for the -math-z88 flag only.



------------------------------------------------------------------------------
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

I isolated an example:


#include <stdio.h>

unsigned int c;
unsigned long d;

main()
{
printf("%.4d", c + (unsigned int)(d / 10000UL));
}

zcc +cpm -vn test.c -o test

Comes up with missing float routines. I assumed that sccz80 decided to pull in the large printf with %f in it so another compile with -lm:

zcc +cpm -vn test.c -o test -lm

Leads to even more errors.

A compile with zx target *with the float library linked* works:

zcc +zx -vn test.c -o test -lndos -lm

This only affects classic c compiles.


I successfully compiled the whetstone benchmark with classic c using a cpm target so it's not that the float library can't be used with cpm (eg) there is something else here.



------------------------------------------------------------------------------
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Comes up with missing float routines. I assumed that sccz80 decided to pull in the large printf with %f in it so another compile with -lm:

zcc +cpm -vn test.c -o test -lm

Leads to even more errors.

A compile with zx target *with the float library linked* works:

zcc +zx -vn test.c -o test -lndos -lm

This only affects classic c compiles.

I successfully compiled the whetstone benchmark with classic c using a cpm target so it's not that the float library can't be used with cpm (eg) there is something else here.
That's a fun one, because it's dragging in the FP version of printf then we need to get the FP accumulator in the crt in - it's excluded by default for space reasons. It looks like that isn't happening automatically, so you need to compile with an extra option: zcc +cpm -pragma-need=floatpack test.c -lm

In the ZX crt0 it looks like fa etc are always included regardless of whether they are used.



------------------------------------------------------------------------------
Post Reply