Discussion:
[Ghdl-discuss] GHDL-0.32rc1 problem on FreeBSD-10.1
Adam Jensen
2015-03-22 19:11:27 UTC
Permalink
The GHDL build on FreeBSD is smooth enough but the ghdl executable has a problem. Has anyone seen anything like this before?

After compiling:

% ghdl -a foo.vhdl
% ghdl -e foo
/usr/local/bin/ld: foo: local symbol `environ' in /usr/lib/crt1.o is referenced by DSO
/usr/local/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
ghdl: compilation error


% ld --version
GNU ld (GNU Binutils) 2.25


% objdump -t /usr/lib/crt1.o
/usr/lib/crt1.o: file format elf32-i386-freebsd

SYMBOL TABLE:
00000000 l d .note.tag 00000000 .note.tag
00000000 l d .text 00000000 .text
00000000 l d .rodata.str1.1 00000000 .rodata.str1.1
00000000 l d .eh_frame 00000000 .eh_frame
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .comment 00000000 .comment
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
00000000 l df *ABS* 00000000 /usr/src/lib/csu/i386-elf/crt1_c.c
00000000 l O .note.tag 00000018 abitag
00000018 l O .note.tag 00000018 crt_noinit_tag
00000170 l F .text 0000003a finalizer
00000020 l F .text 00000142 .hidden _start1
00000000 w *UND* 00000000 _DYNAMIC
00000000 *UND* 00000000 .hidden __fini_array_end
00000000 *UND* 00000000 .hidden _init
00000004 O *COM* 00000004 environ
00000000 g O .data 00000004 __progname
00000000 g F .text 00000019 _start
00000000 *UND* 00000000 .hidden __fini_array_start
00000000 *UND* 00000000 main
00000000 *UND* 00000000 _init_tls
00000000 *UND* 00000000 .hidden __init_array_end
00000000 *UND* 00000000 .hidden _fini
00000000 *UND* 00000000 atexit
00000000 *UND* 00000000 .hidden __preinit_array_end
00000000 *UND* 00000000 exit
00000000 *UND* 00000000 .hidden __init_array_start
00000000 *UND* 00000000 .hidden __preinit_array_start
Tristan Gingold
2015-03-23 06:56:41 UTC
Permalink
Post by Adam Jensen
The GHDL build on FreeBSD is smooth enough but the ghdl executable has a problem. Has anyone seen anything like this before?
% ghdl -a foo.vhdl
% ghdl -e foo
/usr/local/bin/ld: foo: local symbol `environ' in /usr/lib/crt1.o is referenced by DSO
/usr/local/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
ghdl: compilation error
Try: ghdl -e -v foo, you should have the linker command line.
Was GHDL built with gcc ?

Tristan.
Adam Jensen
2015-03-23 14:35:17 UTC
Permalink
On Mon, 23 Mar 2015 07:56:41 +0100
Post by Tristan Gingold
Try: ghdl -e -v foo, you should have the linker command line.
Was GHDL built with gcc ?
I made a mistake in the original post - the GHDL version I'm using is tip (which will become 0.32rc2 (?)). It's built with and into gcc-4.9.2 - the gcc-aux port on FreeBSD-10.1 (https://www.freebsd.org/news/status/report-2013-07-2013-09.html#FreeBSD-Ada-Ports).

% ghdl -e -v foo
/home/hanzer/local/libexec/gcc/i386-unknown-freebsd10.1/4.9.2/ghdl1 -P/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/std/ -P/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/ --elab foo -l e~foo.lst -quiet -o e~foo.s e~foo
/usr/local/bin/as -o e~foo.o e~foo.s
/home/hanzer/local/bin/gcc -o foo e~foo.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/std/std_standard.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/std_logic_1164.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/std_logic_1164_body.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/numeric_std.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/numeric_std-body.o foo.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//libgrt.a -lm -Wl,--version-script=/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//grt.ver -Wl,--export-dynamic -L./ -lz
/usr/local/bin/ld: foo: local symbol `environ' in /usr/lib/crt1.o is referenced by DSO
/usr/local/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
ghdl: compilation error

From this, I notice two slashes in some of the paths: ".../4.9.2/vhdl//v93/..."
^^
Probably not related to the current problem, but interesting.
Tristan Gingold
2015-03-24 05:08:08 UTC
Permalink
Post by Adam Jensen
On Mon, 23 Mar 2015 07:56:41 +0100
Post by Tristan Gingold
Try: ghdl -e -v foo, you should have the linker command line.
Was GHDL built with gcc ?
I made a mistake in the original post - the GHDL version I'm using is tip (which will become 0.32rc2 (?)). It's built with and into gcc-4.9.2 - the gcc-aux port on FreeBSD-10.1 (https://www.freebsd.org/news/status/report-2013-07-2013-09.html#FreeBSD-Ada-Ports).
% ghdl -e -v foo
/home/hanzer/local/libexec/gcc/i386-unknown-freebsd10.1/4.9.2/ghdl1 -P/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/std/ -P/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/ --elab foo -l e~foo.lst -quiet -o e~foo.s e~foo
/usr/local/bin/as -o e~foo.o e~foo.s
/home/hanzer/local/bin/gcc -o foo e~foo.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/std/std_standard.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/std_logic_1164.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/std_logic_1164_body.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/numeric_std.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//v93/ieee/numeric_std-body.o foo.o /home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//libgrt.a -lm -Wl,--version-script=/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl//grt.ver -Wl,--export-dynamic -L./ -lz
/usr/local/bin/ld: foo: local symbol `environ' in /usr/lib/crt1.o is referenced by DSO
/usr/local/bin/ld: final link failed: Bad value
Now that you have the complete linker line, try to find the offending
option or library.

GHDL doesn't create a DSO, so there is something strange. Try without
the --export-dynamic and/or --version-script.
Post by Adam Jensen
collect2: error: ld returned 1 exit status
ghdl: compilation error
From this, I notice two slashes in some of the paths: ".../4.9.2/vhdl//v93/..."
^^
Probably not related to the current problem, but interesting.
This s harmless.

Tristan.
Adam Jensen
2015-03-24 16:14:13 UTC
Permalink
On Tue, 24 Mar 2015 06:08:08 +0100
Post by Tristan Gingold
Now that you have the complete linker line, try to find the offending
option or library.
GHDL doesn't create a DSO, so there is something strange. Try without
the --export-dynamic and/or --version-script.
Nice hint, thanks! This works:

% ghdl -a hello.vhdl

% /home/hanzer/local/libexec/gcc/i386-unknown-freebsd10.1/4.9.2/ghdl1 \
-P/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/ \
-P/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/ieee/ \
--elab hello -l e~hello.lst -quiet -o e~hello.s e~hello

% /usr/local/bin/as -o e~hello.o e~hello.s

% /home/hanzer/local/bin/gcc -o hello e~hello.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/std_standard.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/textio.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/textio_body.o \
hello.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/libgrt.a -lm -L./ -lz

% ghdl -r hello
Hello world!

I'm not sure if I understand the implications of this. Any additional guidance or insights will be greatly appreciated!


Ref:
% cat hello.vhdl
use std.textio.all;

entity hello is
end hello;

architecture behaviour of hello is
begin
process
variable l : line;
begin
write (l, String'("Hello world!"));
writeline (output, l);
wait;
end process;
end behaviour;
Adam Jensen
2015-03-24 16:54:08 UTC
Permalink
BTW - It also works with --export-dynamic. Including --version-script results in the link error.

On Tue, 24 Mar 2015 12:14:13 -0400
Post by Adam Jensen
% ghdl -a hello.vhdl
% /home/hanzer/local/libexec/gcc/i386-unknown-freebsd10.1/4.9.2/ghdl1 \
-P/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/ \
-P/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/ieee/ \
--elab hello -l e~hello.lst -quiet -o e~hello.s e~hello
% /usr/local/bin/as -o e~hello.o e~hello.s
% /home/hanzer/local/bin/gcc -o hello e~hello.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/std_standard.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/textio.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/textio_body.o \
hello.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/libgrt.a -lm -L./ -lz
% /home/hanzer/local/bin/gcc -o hello e~hello.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/std_standard.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/textio.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/v93/std/textio_body.o \
hello.o \
/home/hanzer/local/lib/gcc/i386-unknown-freebsd10.1/4.9.2/vhdl/libgrt.a \
-lm -Wl,--export-dynamic -L./ -lz
Post by Adam Jensen
% ghdl -r hello
Hello world!
Tristan Gingold
2015-03-24 17:56:49 UTC
Permalink
Post by Adam Jensen
BTW - It also works with --export-dynamic. Including --version-script results in the link error.
So you need to adjust these lines in src/grt/Makefile.inc:

ifeq ($(filter-out i%86 freebsd%,$(arch) $(osys)),)
GRT_TARGET_OBJS=i386.o linux.o times.o
GRT_EXTRA_LIB=-lm $(GRT_ELF_OPTS)
ADAC=ada
endif


Tristan.
Adam Jensen
2015-03-25 00:51:50 UTC
Permalink
On Tue, 24 Mar 2015 18:56:49 +0100
Groovy. With this patch:

--- Makefile.inc.orig 2015-03-24 18:03:24.000000000 -0400
+++ Makefile.inc 2015-03-24 17:58:50.000000000 -0400
@@ -63,7 +63,7 @@
endif
ifeq ($(filter-out i%86 freebsd%,$(arch) $(osys)),)
GRT_TARGET_OBJS=i386.o linux.o times.o
- GRT_EXTRA_LIB=-lm $(GRT_ELF_OPTS)
+ GRT_EXTRA_LIB=-lm
ADAC=ada
endif
ifeq ($(filter-out x86_64 freebsd%,$(arch) $(osys)),)


The vests tests pass:

./testsuite.sh: Success (ghdl)
GHDL 0.33dev (20141104) [Dunoon edition]
Compiled with GNAT Version: 4.9.2 20141030 (release)
GCC back-end code generator

And a little foreign function (in C) test works. Thanks for the awesome response!

Ref:
% gcc -c inc_int.c
% ghdl -a hello.vhdl && ghdl -e -Wl,inc_int.o hello && ghdl -r hello
Hello world!
4

% cat inc_int.c

int inc_int(int num) {
num++;
return num;
}

% cat hello.vhdl

use std.textio.all;

entity hello is
end hello;

architecture behaviour of hello is
begin
process
variable l : line;
variable data : integer;
function inc_int (v : integer) return integer is
begin
assert false severity failure;
end inc_int;
attribute foreign of inc_int : function is "VHPIDIRECT inc_int";
begin
write (l, String'("Hello world!"));
writeline (output, l);
data := inc_int(3);
write (l, data);
writeline (output, l);
wait;
end process;
end behaviour;
Tristan Gingold
2015-03-25 07:02:26 UTC
Permalink
Post by Adam Jensen
./testsuite.sh: Success (ghdl)
GHDL 0.33dev (20141104) [Dunoon edition]
Compiled with GNAT Version: 4.9.2 20141030 (release)
GCC back-end code generator
And a little foreign function (in C) test works.
Great. Did you try vpi plugins ? I am not sure they will work.
(OTOH, that's a minor issue).
Post by Adam Jensen
Thanks for the awesome response!
You're welcome.

Tristan.
Adam Jensen
2015-03-25 16:10:58 UTC
Permalink
On Wed, 25 Mar 2015 08:02:26 +0100
Post by Tristan Gingold
Great. Did you try vpi plugins ? I am not sure they will work.
I haven't been able to find any GHDL-VPI documentation.
Post by Tristan Gingold
(OTOH, that's a minor issue).
It would be nice if all of the capabilities of the tool were enabled and functioning on the BSD's.
Tristan Gingold
2015-03-26 07:03:45 UTC
Permalink
Post by Adam Jensen
On Wed, 25 Mar 2015 08:02:26 +0100
Post by Tristan Gingold
Great. Did you try vpi plugins ? I am not sure they will work.
I haven't been able to find any GHDL-VPI documentation.
Post by Tristan Gingold
(OTOH, that's a minor issue).
It would be nice if all of the capabilities of the tool were enabled and functioning on the BSD's.
OTOH, if nobody uses that feature this restriction is not a real issue!
Adam Jensen
2015-03-26 13:21:16 UTC
Permalink
On Thu, 26 Mar 2015 08:03:45 +0100
Post by Tristan Gingold
Post by Adam Jensen
On Wed, 25 Mar 2015 08:02:26 +0100
Post by Tristan Gingold
Great. Did you try vpi plugins ? I am not sure they will work.
I haven't been able to find any GHDL-VPI documentation.
Post by Tristan Gingold
(OTOH, that's a minor issue).
It would be nice if all of the capabilities of the tool were enabled and functioning on the BSD's.
OTOH, if nobody uses that feature this restriction is not a real issue!
Cool. I'll add it to my to-do/watch list and when an opportunity arises to investigate it further, I can revisit it. So far, 0.32rc2 (--rev 3f2fcad4d876) looks pretty good on FreeBSD-x86 (comparable to Linux except for the potential VPI issue (though, I can't verify whether or not it's actually an issue until I figure out how it works (are these nested parenthesis annoying? (lisp warped my mind)))). I haven't explored any gna test issues, yet. Currently, on Linux and FreeBSD, they stop at:

GNA dir bug09:
analyze univ1.vhdl
elaborate and simulate (failure expected) univ1
univ1.vhdl:19:5:@0ms:(assertion error): i = -1
./univ1:error: error expected, but none occured
ghdl: compilation error
Tristan Gingold
2015-03-27 07:05:03 UTC
Permalink
Post by Adam Jensen
On Thu, 26 Mar 2015 08:03:45 +0100
Post by Tristan Gingold
Post by Adam Jensen
On Wed, 25 Mar 2015 08:02:26 +0100
Post by Tristan Gingold
Great. Did you try vpi plugins ? I am not sure they will work.
I haven't been able to find any GHDL-VPI documentation.
Post by Tristan Gingold
(OTOH, that's a minor issue).
It would be nice if all of the capabilities of the tool were enabled and functioning on the BSD's.
OTOH, if nobody uses that feature this restriction is not a real issue!
analyze univ1.vhdl
elaborate and simulate (failure expected) univ1
./univ1:error: error expected, but none occured
ghdl: compilation error
This one also fails on linux with the gcc backend.

Tristan.

Loading...