English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. Language (http://eab.abime.net/forumdisplay.php?f=114)
-   -   GCC on Linux and MathIeeeDoubTrans (http://eab.abime.net/showthread.php?t=62003)

tygre 25 November 2011 06:22

GCC on Linux and MathIeeeDoubTrans
 
Dear all!

Could someone help me understand why what I am doing works ;)

I am compiling PHP v4.2.3. The maths functions "used" by PHP, such as "atan2", were leading to compilation errors. I solved these errors by adding the options "-m68020 -m68881" to GCC :). Yet, two compilation errors still remained, for "asinh" and "acosh":

Code:

./.libs/libphp4cli.a(math.o)(.text+0x1150): In function `_zif_asinh':
/php-4.2.3/ext/standard/math.c:329: undefined reference to `_asinh'
./.libs/libphp4cli.a(math.o)(.text+0x1230): In function `_zif_acosh':
/php-4.2.3/ext/standard/math.c:345: undefined reference to `_acosh'

Digging up, I found that "configure" was telling me that it cannot find the math library:

Code:

configure:5776: checking for sin in -lm
configure:5795: /usr/local/amiga/bin/m68k-amigaos-gcc.exe -m68020 -m68881 -o conftest -g -O2  conftest.c -lm  1>&5
/usr/local/amiga/lib/gcc/m68k-amigaos/3.4.0/../../../../m68k-amigaos/bin/ld: cannot find -lm

So, I thought, GCC cannot find "libm.a", in which "asinh" and "acosh" must be defined, so let's give it it one and I added:

Code:

LDFLAGS="-L/usr/local/amiga/m68k-amigaos/lib/libb/libm020/libm881/libnix/"
which led to "configure" to complain about MathIEEEDoubTrans:

Code:

configure:5776: checking for sin in -lm
configure:5795: /usr/local/amiga/bin/m68k-amigaos-gcc.exe -m68020 -m68881 -o conftest -g -O2  -L/usr/local/amiga/m68k-amigaos/lib/libb/libm020/libm881/libnix/ conftest.c -lm  1>&5
/usr/local/amiga/m68k-amigaos/lib/libb/libm020/libm881/libnix//libm.a(sin.o)(.text+0x4):sin.o: undefined reference to `___MathIeeeDoubTransBase'

Then, I found the excellent Geek Gadgets documentation, removed the "LDFLAGS", added the option "-ixemul", and and "configure" is happy :cool because it finds "sin":

Code:

configure:5776: checking for sin in -lm
configure:5795: /usr/local/amiga/bin/m68k-amigaos-gcc.exe -m68020 -m68881 -noixemul -o conftest -g -O2  conftest.c -lm  1>&5

... but... why? :blased What could be the alternative then if I wanted to use "ixemul"?

And, of course, I cannot compile PHP without "ixemul" because some functions are then missing, such as "strtod": so, at this point either I have "sin" and other compilation errors or no compilation errors but for the missing "asinh" and "acosh"... :sad (Interestingly, "math.c" also contains a call to "atanh", which is not causing any compilation error...)

How can I link to these functions?

Thanks to explain a newbie!
Tygre

NovaCoder 26 November 2011 07:44

Hiya,

I'm no expert in this stuff but when you're compiling stuff that was coded for UNIX (eg PHP) you normally have to use the crappy old unix emulation lib ixemul (because the Amiga libs lack many of the Unix library functions).

I don't use ixemul in my code as it slows everything down, if I'm missing a couple of UNIX methods I just have to code them into my application.

It also looks like PHP may need an FPU.

I normal use GCC C++ with these options:

-fno-rtti
-m68040
-O2
-finline-function

tygre 27 November 2011 05:20

Quote:

Originally Posted by NovaCoder (Post 787418)
I don't use ixemul in my code as it slows everything down, if I'm missing a couple of UNIX methods I just have to code them into my application.


Hi there!

Thanks for the info. I begin to understand... With your help and this page, which states that:

If -noixemul is specified on the GCC command line, the executable created will not require ixemul.library -- it will use the static linker library LibNIX instead. This library is very Amiga-like and SAS/C-like, so it is convenient for the AmigaOS-specific development.

I understand that, when I put "-noixemul", "configure" uses LibNIX, and thus can find "sin" but that it cannot find "sin" without "-noixemul" because... "sin" is not present in "ixemul"? :nuts

Also, I still don't understand why are "asinh" and "acosh" missing from "ixemul" but not "atanh". I must be overlooking something there... Any idea?

Quote:

Originally Posted by NovaCoder (Post 787418)
-fno-rtti
-m68040
-O2
-finline-function

Thanks, will try that too!

Cheers!
Yann


All times are GMT +2. The time now is 18:06.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.

Page generated in 0.04441 seconds with 11 queries