Newbie: ieee.math_real + ghdl

A

Andreas

User-Agent: OSXnews 2.07
Xref: number1.nntp.dca.giganews.com comp.lang.vhdl:57850



Hi all,

I've got a linking problem using the ieee.math_real package with ghdl. I
removed nearly all code from my Application (see below) and it compiles
as far as I remove the 'use ieee.math_real.all'. Here's what I got
from the console (without removing the ieee.math_real.all)
So here is what I got from the console:
ghdl -a CompMy.vhdl
ghdl -e CompMy
/usr/bin/ld:
/Developer/Simulator/GHDL/lib/gcc/powerpc-apple-darwin8.2.1/4.0.2/vhdl/lib/v93/ieee/math_real-body.o has external relocation
entries in non-writable section (__TEXT,__text) for symbols:_atanh
_acosh
_atan2
_acos
_asin
_log
_exp
_sqrt
collect2: ld returned 1 exit status
ghdl: compilation error


MyComp.vhdl:

library ieee;
use ieee.std_logic_1164.all;
use ieee.math_real.all;

entity compMy is
port( clk : in std_logic);
end compMy;

architecture behaviour of compMy is
begin
StateMy: process(clk)
begin
if(clk = '1' and clk'event) then
wait 1 ns;
end if;
end process StateMy;
end behaviour;

I'm using ghdl 0.20 (20051015) on Mac OSX 10.4.3 with Xcode 2.0

Looking at google had no success and the ghdl doc's aren't very
detailed, so anybody got a hint for me?
Thanks says
Andreas
 
M

Mike Treseler

Andreas said:
entity compMy is
port( clk : in std_logic);
end compMy;

architecture behaviour of compMy is
begin
StateMy: process(clk)
begin
if(clk = '1' and clk'event) then
wait 1 ns;
Looking at google had no success and the ghdl doc's aren't very
detailed, so anybody got a hint for me?

get rid of the wait or the process list.
It's either one or the other.

-- Mike Treseler
 
J

john Doef

Andreas a écrit :
User-Agent: OSXnews 2.07
Xref: g2news1.google.com comp.lang.vhdl:1636



Hi all,

I've got a linking problem using the ieee.math_real package with ghdl. I
removed nearly all code from my Application (see below) and it compiles
as far as I remove the 'use ieee.math_real.all'. Here's what I got
from the console (without removing the ieee.math_real.all)
So here is what I got from the console:
/usr/bin/ld:
/Developer/Simulator/GHDL/lib/gcc/powerpc-apple-darwin8.2.1/4.0.2/vhdl/lib/v93/ieee/math_real-body.o has external relocation
entries in non-writable section (__TEXT,__text) for symbols:_atanh
_acosh
_atan2
_acos
_asin
_log
_exp
_sqrt
collect2: ld returned 1 exit status
ghdl: compilation error
I'm using ghdl 0.20 (20051015) on Mac OSX 10.4.3 with Xcode 2.0

Looking at google had no success and the ghdl doc's aren't very
detailed, so anybody got a hint for me? Hi,

From ghdl mailing list, you should add -Wl,-lm during elaboration.

JD.
 
A

Andreas

User-Agent: OSXnews 2.07
Xref: number1.nntp.dca.giganews.com comp.lang.vhdl:57861

get rid of the wait or the process list.
It's either one or the other.

Hi Mike,

thanks for the hint, but I don't think it's the wait statement or the
process list, since the file compiles without the 'use ieee.math_real.all;
' line and works as expected.So this produces no errors:

library ieee;
use ieee.std_logic_1164.all;

entity compMy is
port( clk : in std_logic);
end compMy;
...

and this does produce the errors mentioned in my original posting:

library ieee;
use ieee.std_logic_1164.all;
use ieee.math_real.all;

entity compMy is
port( clk : in std_logic);
end compMy;
...

So if there's a problem with wait or the process it should arise in both
cases,isn't it?
Andreas
 
A

Arnim Laeuger

ghdl -e CompMy
/usr/bin/ld:
/Developer/Simulator/GHDL/lib/gcc/powerpc-apple-darwin8.2.1/4.0.2/vhdl/lib/v93/ieee/math_real-body.o has external relocation
entries in non-writable section (__TEXT,__text) for symbols:_atanh
_acosh
_atan2
_acos
_asin
_log
_exp
_sqrt
collect2: ld returned 1 exit status
ghdl: compilation error

The linker tells you that the object code of your compiled design
references math functions that can't be resolved.
You want to pass the approriate option to the linker so that libm is
considered during linking:

$ ghdl -e -Wl,-lm CompMy


Best regards

Arnim
 
A

Andreas

User-Agent: OSXnews 2.07
Xref: number1.nntp.dca.giganews.com comp.lang.vhdl:57863


Arnim Laeuger said:
The linker tells you that the object code of your compiled design
references math functions that can't be resolved.
You want to pass the approriate option to the linker so that libm is
considered during linking:

$ ghdl -e -Wl,-lm CompMy

Hi Arnim,
that's more the direction my thought go to. But it seems that libm isn't
the right library, since I got the same error again. Maybe I have to
pass the math_real library to the compiler, but I couldn't find the
library files, just the object files (the ones that the linker mentioned)
Best regards
Andreas
 
A

Arnim Laeuger

Hi!
that's more the direction my thought go to. But it seems that libm isn't
the right library, since I got the same error again. Maybe I have to
pass the math_real library to the compiler, but I couldn't find the
library files, just the object files (the ones that the linker mentioned)

Strange, elaboration works here with the mentioned option while it fails
without.
Is the gcc tool-chain set-up properly on your machine? Can you compile
the following C-code:

#include <stdio.h>
#include <math.h>

int main (int argc, char *argv[]) {
printf("sin(0): %f\n", sin(0));
return(0);
}

$ gcc -o tm -lm tm.c


Besides that, googling for the error message reveals a lot of reports
describing this problem on powerpc-apple-* systems. One common solution
is to pass option -lcc_dynamic to the linker:

http://sourceforge.net/mailarchive/forum.php?forum_id=3200&style=flat&viewday=6&viewmonth=200307
http://null.perl-hackers.net/archives/programming/

No idea what it is required for.

This translates to the following elaboration command:

$ ghdl -e -Wl,-lm -Wl,-lcc_dynamic CompMy

Sorry, here you're on your own as I have no possibility to test such
things myself.


Cheers

Arnim
 
P

Phil Tomson

That recommendation would be for the case where you were trying to write some
foreign models in C and were trying to call functions in C's libm. Not the
case here. He's trying to call some functions from math_real.
Hi Arnim,
that's more the direction my thought go to. But it seems that libm isn't
the right library, since I got the same error again. Maybe I have to
pass the math_real library to the compiler, but I couldn't find the
library files, just the object files (the ones that the linker mentioned)

Yes, I think you need to recompile math_real. Did you recently upgrade to a
newer GHDL version? I would look for math_real.vhd somewhere on the web and
try putting it in your directory and then math_real.vhd before you do the
linking step.

Phil
 
P

Phil Tomson

Hi all,

I've got a linking problem using the ieee.math_real package with ghdl. I
removed nearly all code from my Application (see below) and it compiles
as far as I remove the 'use ieee.math_real.all'. Here's what I got
from the console (without removing the ieee.math_real.all)
So here is what I got from the console:
/usr/bin/ld:
/Developer/Simulator/GHDL/lib/gcc/powerpc-apple-darwin8.2.1/4.0.2/vhdl/lib/v93/ieee/math_real-body.o has external relocation
entries in non-writable section (__TEXT,__text) for symbols:_atanh
_acosh
_atan2
_acos
_asin
_log
_exp
_sqrt
collect2: ld returned 1 exit status
ghdl: compilation error


MyComp.vhdl:

library ieee;
use ieee.std_logic_1164.all;
use ieee.math_real.all;

entity compMy is
port( clk : in std_logic);
end compMy;

architecture behaviour of compMy is
begin
StateMy: process(clk)
begin
if(clk = '1' and clk'event) then
wait 1 ns;
end if;
end process StateMy;
end behaviour;

I'm using ghdl 0.20 (20051015) on Mac OSX 10.4.3 with Xcode 2.0

Looking at google had no success and the ghdl doc's aren't very
detailed, so anybody got a hint for me?
Thanks says
Andreas

here's my guess:

Did you build ghdl on OSX, or did you get a ready-made executable?

First off, try this:
gcc_select

If it returns a message that says something about the current default gcc is
4.0.x, then try the following:
sudo gcc_select 3.3

(that will change the gcc version used from then on to 3.3 instead of
Tiger's default 4.x) From the error listing above, it looks like you're using
4.0.2:
/Developer/Simulator/GHDL/lib/gcc/powerpc-apple-darwin8.2.1/4.0.2

Then run your ghdl -a, ghdl -e commands over again.

My guess is that maybe the ghdl executable and libraries you downloaded were
built with gcc 3.3 and thus will not work if you're using gcc 4.0.x.

Or possibly, it's the other way around, maybe the ghdl package you downloaded
was compiled with gcc 4.0.x and you've done a gcc_select 3.3 somewhere along
the line? If gcc_select told you that the default gcc is 3.3, then try
setting the default back to 4.0:
sudo gcc_select 4.0

....and then run the analysis and elaboration again...

(I still have ghdl 0.17 installed on my OSX machine, so I can't quite
reproduce what you're seeing because 0.17 didn't seem to come with a
math_real library at all.)

Phil
 
P

Phil Tomson

here's my guess:

Did you build ghdl on OSX, or did you get a ready-made executable?

First off, try this:

If it returns a message that says something about the current default gcc is
4.0.x, then try the following:


(that will change the gcc version used from then on to 3.3 instead of
Tiger's default 4.x) From the error listing above, it looks like you're using
4.0.2:

Then run your ghdl -a, ghdl -e commands over again.

My guess is that maybe the ghdl executable and libraries you downloaded were
built with gcc 3.3 and thus will not work if you're using gcc 4.0.x.

Or possibly, it's the other way around, maybe the ghdl package you downloaded
was compiled with gcc 4.0.x and you've done a gcc_select 3.3 somewhere along
the line? If gcc_select told you that the default gcc is 3.3, then try
setting the default back to 4.0:


...and then run the analysis and elaboration again...

(I still have ghdl 0.17 installed on my OSX machine, so I can't quite
reproduce what you're seeing because 0.17 didn't seem to come with a
math_real library at all.)

Sorry to answer my own post, but here's another datapoint:

I installed 0.20 and set gcc_select to 3.3 and I get the following:

l% sudo gcc_select 3.3
Default compiler has been set to:
gcc version 3.3 20030304 (Apple Computer, Inc. build 1809)
% ghdl -a CompMy.vhd
% ghdl -e compMy
ld: warning prebinding disabled because of undefined symbols
ld: Undefined symbols:
_fprintf$LDBLStub
_vprintf$LDBLStub
ghdl: compilation error

(BTW: you need to get rid of the wait statement in your VHDL file)

Then I switched to 4.0 and tried it:

% sudo gcc_select 4.0
Default compiler has been set to:
gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4061)
% ghdl -a CompMy.vhd
% ghdl -e compMy
/usr/bin/ld:
/Developer/Simulator/GHDL/lib/gcc/powerpc-apple-darwin8.2.1/4.0.2/vhdl/lib/v93/ieee/math_real-body.o
relocation overflow for relocation entry 294 in section (__TEXT,__text)
(displacement too large)


(commenting out the line: use ieee.math_real.all; leads to success, so the
problem is with that library)

I would send an email to Felix Bertram:
(e-mail address removed)

He's the maintainer of the ghdl OSX package.

Phil
 
P

Phil Tomson

Andreas a écrit :

/Developer/Simulator/GHDL/lib/gcc/powerpc-apple-darwin8.2.1/4.0.2/vhdl/lib/v93/ieee/math_real-body.o has external relocation

Didn't seem to work, but maybe I'm getting a different error:

l% ghdl -e -Wl,-lm compMy
/usr/bin/ld:
/Developer/Simulator/GHDL/lib/gcc/powerpc-apple-darwin8.2.1/4.0.2/vhdl/lib/v93/ieee/math_real-body.o
relocation overflow for relocation entry 294 in section (__TEXT,__text)
(displacement too large)

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top