Discussion:
[Ghdl-discuss] GCC flavour: Problem with compilation of VHDL libs
Adrien Prost-Boucle
2016-11-19 10:37:57 UTC
Permalink
Hi,

I'm maintaining the package ghdl-gcc-git for ArchLinux distribution
https://aur.archlinux.org/packages/ghdl-gcc-git/

The package builds gcc + VHDL libs in one package, which is very convenient.
However building the libraries is now done separately according to the BUILD.txt file:
make ghhdlib
The problem is that when this command is run by the packaging script,
the GHDL executable is not yet installed in the filesystem and /usr/bin/ghdl does not exist.

Actually when doing make install from the gcc build directory,
the installed files are copied in another local directory, sort of a fake root.
I looked at the Makefile in the GHDL dir and tried that command to compile the libs:
make GHDL="/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl" vhdl.libs.all libs.vhdl.standard
That way the command uses the ghdl executable in the temp package dir, but I get these errors:
warning: library std does not exists for v87
warning: library ieee does not exists for v87

I wouldn't like splitting the package in 2, one with ghdl, which would need to be built and installed first,
and another that would just have the libs.

And I haven't found a way to compile the libs without first having installed a version of ghdl with the std lib...

Any advice on this?

Regards,
Adrien
Andrey Gursky
2016-11-19 14:15:13 UTC
Permalink
Hi,
Post by Adrien Prost-Boucle
Hi,
I'm maintaining the package ghdl-gcc-git for ArchLinux distribution
https://aur.archlinux.org/packages/ghdl-gcc-git/
The package builds gcc + VHDL libs in one package, which is very
convenient. However building the libraries is now done separately
make ghhdlib
The problem is that when this command is run by the packaging script,
the GHDL executable is not yet installed in the filesystem and /usr/bin/ghdl does not exist.
Actually when doing make install from the gcc build directory,
the installed files are copied in another local directory, sort of a
fake root. I looked at the Makefile in the GHDL dir and tried that
make GHDL="/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl" vhdl.libs.all libs.vhdl.standard
That way the command uses the ghdl executable in the temp package dir,
warning: library std does not exists for v87
warning: library ieee does not exists for v87
I wouldn't like splitting the package in 2, one with ghdl, which would
need to be built and installed first, and another that would just have
the libs.
And I haven't found a way to compile the libs without first having
installed a version of ghdl with the std lib...
Any advice on this?
I have also stumbled over this issue: violating the good triple-rule:
configure / make / make install. Building of ghdl is already more
complex due to unpacking of gcc and calling make copy-sources (though
this could be treated as bootstrap and maybe better renamed to
bootstrap, while preserving comment "copy sources"?). The other thing
is that ghdl was nicely built out-of-tree in the gcc build directory
but now make ghdllib must be called in the ghdl source directory, which
I'd like to avoid. Sorry, I haven't addressed this issue right on
July/August.

Actually using already compiled parts to generate something else during
build is not uncommon. But in such cases Makefile uses executables in
their build path, not installed one. Hopefully this could be fixed. And
the other thing would be to add something like
make copy-ghdllib-sources to build it out-of-tree also? BTW, is there
any good reason to not build ghdllib in the gcc build directory?

Thanks,
Andrey
Tristan Gingold
2016-11-19 16:53:25 UTC
Permalink
On 19/11/16 15:15, Andrey Gursky wrote:

[...]
Post by Andrey Gursky
Actually using already compiled parts to generate something else during
build is not uncommon. But in such cases Makefile uses executables in
their build path, not installed one. Hopefully this could be fixed. And
the other thing would be to add something like
make copy-ghdllib-sources to build it out-of-tree also? BTW, is there
any good reason to not build ghdllib in the gcc build directory?
It is not easy to reuse the Makefile part for the libs as is.

I think it could be possible to fix the Makefile, so that it is not
necessary to install ghdl before building the libraries.

OTOH, ghdl is expected to be location neutral, so it could be
configured to be installed in one directory but really installed
in another.

Tristan.
Adrien Prost-Boucle
2016-11-19 21:08:29 UTC
Permalink
Post by Tristan Gingold
OTOH, ghdl is expected to be location neutral, so it could be
configured to be installed in one directory but really installed
in another.
I thought so, so I did the ghdl fake-install with
make DESTDIR="${pkgdir}" install
and used the ghdl "installed" there to launch build of libs with
make GHDL="${pkgdir}/usr/bin/ghdl" vhdl.libs.all libs.vhdl.standard
(command line taken from inside Makefile, to set my own path to ghdl)

And compilation of libs does launch, but I get these errors:

/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/std_logic_1164.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/std_logic_1164_body.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/numeric_bit.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
...

I don't understand the error and don't know how to solve it...

Adrien
Adrien Prost-Boucle
2016-11-19 21:14:53 UTC
Permalink
Ah, I still had a ghdl version installed on my system and some errors were hidden:
When just making the target libs.vhdl.standard I get this error:

[adrien] > make GHDL=/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl libs.vhdl.standard
cd lib/ghdl/v93/std; \
 /home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl --bootstrap-standard  --std=93 
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl: installation problem: lib/gcc/x86_64-unknown-linux-gnu/4.9.3/ghdl1 not found
make: *** [Makefile:351: lib/ghdl/v93/std/std_standard.o] Error 1

I'll find a workaround for that, force my GHDL path for this target, and report the result.

Adrien
Post by Adrien Prost-Boucle
Post by Tristan Gingold
OTOH, ghdl is expected to be location neutral, so it could be
configured to be installed in one directory but really installed
in another.
I thought so, so I did the ghdl fake-install with
make DESTDIR="${pkgdir}" install
and used the ghdl "installed" there to launch build of libs with
make GHDL="${pkgdir}/usr/bin/ghdl" vhdl.libs.all libs.vhdl.standard
(command line taken from inside Makefile, to set my own path to ghdl)
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/std_logic_1164.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/std_logic_1164_body.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/numeric_bit.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
...
I don't understand the error and don't know how to solve it...
Adrien
_______________________________________________
Ghdl-discuss mailing list
https://mail.gna.org/listinfo/ghdl-discuss
Adrien Prost-Boucle
2016-11-19 21:41:02 UTC
Permalink
In the Makefile line 344 there

ifeq "$(backend)" "gcc"
# ghdl with gcc backend is already installed, no need to specify ghdl1
# (and we don't know where it is).
STD_GHDL_FLAGS=
else
...

I commented STD_GHDL_FLAGS= so I could manually set the path to ghdl1 from command line
Then I launched

make \
GHDL=/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl \
STD_GHDL_FLAGS=--GHDL1=/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/ghdl1 \
libs.vhdl.all libs.vhdl.standard

The target libs.vhdl.standard executes with no error, but for the target libs.vhdl.all I still get the errors

/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/std_logic_1164.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
...

So now I'm blocked, no other idea about what to try...
Any idea?

Adrien
Post by Adrien Prost-Boucle
[adrien] > make GHDL=/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl libs.vhdl.standard
cd lib/ghdl/v93/std; \
 /home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl --bootstrap-standard  --std=93 
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl: installation problem: lib/gcc/x86_64-unknown-linux-gnu/4.9.3/ghdl1 not found
make: *** [Makefile:351: lib/ghdl/v93/std/std_standard.o] Error 1
I'll find a workaround for that, force my GHDL path for this target, and report the result.
Adrien
Post by Adrien Prost-Boucle
Post by Tristan Gingold
OTOH, ghdl is expected to be location neutral, so it could be
configured to be installed in one directory but really installed
in another.
I thought so, so I did the ghdl fake-install with
make DESTDIR="${pkgdir}" install
and used the ghdl "installed" there to launch build of libs with
make GHDL="${pkgdir}/usr/bin/ghdl" vhdl.libs.all libs.vhdl.standard
(command line taken from inside Makefile, to set my own path to ghdl)
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/std_logic_1164.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/std_logic_1164_body.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/numeric_bit.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
...
I don't understand the error and don't know how to solve it...
Adrien
_______________________________________________
Ghdl-discuss mailing list
https://mail.gna.org/listinfo/ghdl-discuss
_______________________________________________
Ghdl-discuss mailing list
https://mail.gna.org/listinfo/ghdl-discuss
Adrien Prost-Boucle
2016-11-27 21:57:23 UTC
Permalink
Hi,

I have found a way to compile the VHDL libraries without first installing GHDL in the system.
The warnings are still there but it seems to work.
Overall I think what I needed could be enabled with rather generic modifications to the ghdl Makefile.
Here are my build steps in hope it's useful.

1) Compile gcc with normal make in the gcc build dir
2) Patch the Makefile in the ghdl source directory (see attached patch)
3) Build libraries with that command:

make \
GHDL="${srcdir}/gcc-build/gcc/ghdl" \
ANALYZE_OPTS="--GHDL1=${srcdir}/gcc-build/gcc/ghdl1" \
STD_GHDL_FLAGS="--GHDL1=${srcdir}/gcc-build/gcc/ghdl1" \
vhdl.libs.all libs.vhdl.standard

4) Built grt: make libgrt.a
5) Install gcc and libraries as described in file BUILD.txt

So I patch the Makefile to be able to manually set the variables ANALYZE_OPTS and STD_GHDL_FLAGS from my build script.
And I have to split the original command "make ghdllib" into the steps 3) and 4) because otherwise the path the GHDL is overwritten.

Regards,
Adrien
Post by Adrien Prost-Boucle
In the Makefile line 344 there
ifeq "$(backend)" "gcc"
  # ghdl with gcc backend is already installed, no need to specify ghdl1
  # (and we don't know where it is).
  STD_GHDL_FLAGS=
else
...
I commented STD_GHDL_FLAGS= so I could manually set the path to ghdl1 from command line
Then I launched
make \
  GHDL=/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl \
  STD_GHDL_FLAGS=--GHDL1=/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/ghdl1 \
  libs.vhdl.all libs.vhdl.standard
The target libs.vhdl.standard executes with no error, but for the target libs.vhdl.all I still get the errors
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl -a --std=87 -P../std --work=ieee ../../src/ieee/std_logic_1164.v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library std does not exists for v87
/home/adrien/Dev/AUR/ghdl-gcc-git/pkg/ghdl-gcc-git/usr/bin/ghdl:warning: library ieee does not exists for v87
...
So now I'm blocked, no other idea about what to try...
Any idea?
Adrien
Tristan Gingold
2016-11-29 19:11:03 UTC
Permalink
Post by Adrien Prost-Boucle
Hi,
I have found a way to compile the VHDL libraries without first installing GHDL in the system.
The warnings are still there but it seems to work.
Overall I think what I needed could be enabled with rather generic modifications to the ghdl Makefile.
Here are my build steps in hope it's useful.
Thank you for the instructions.
Post by Adrien Prost-Boucle
1) Compile gcc with normal make in the gcc build dir
2) Patch the Makefile in the ghdl source directory (see attached patch)
make \
GHDL="${srcdir}/gcc-build/gcc/ghdl" \
ANALYZE_OPTS="--GHDL1=${srcdir}/gcc-build/gcc/ghdl1" \
STD_GHDL_FLAGS="--GHDL1=${srcdir}/gcc-build/gcc/ghdl1" \
vhdl.libs.all libs.vhdl.standard
4) Built grt: make libgrt.a
5) Install gcc and libraries as described in file BUILD.txt
So I patch the Makefile to be able to manually set the variables ANALYZE_OPTS and STD_GHDL_FLAGS from my build script.
And I have to split the original command "make ghdllib" into the steps 3) and 4) because otherwise the path the GHDL is overwritten.
Are you sure you need to comment out ANALYZE_OPTS and STD_GHDL_FLAGS ?
Usually, Makefile variables set on the command line overrides the
definitions.

Maybe I should change the BUILD.txt ?

Tristan.
Adrien Prost-Boucle
2016-11-29 22:16:34 UTC
Permalink
Post by Tristan Gingold
Are you sure you need to comment out ANALYZE_OPTS and STD_GHDL_FLAGS ?
Usually, Makefile variables set on the command line overrides the 
definitions.
I wasn't aware of this subtelty... it seems so wrong to me...
But anyway, indeed the "instructions" that set these variables inside the Makefile are kind of skipped.
I'll have to read some docs on that topic.

So no need to patch the Makefile.
I did a fast try on an unclean build directory (and with GHDL installed on my machine...) and it seems this command works fine:

make \
GHDL="${srcdir}/gcc-build/gcc/ghdl" \
ANALYZE_OPTS="--GHDL1=${srcdir}/gcc-build/gcc/ghdl1" \
STD_GHDL_FLAGS="--GHDL1=${srcdir}/gcc-build/gcc/ghdl1" \
ghdllib

So no need to split build of libraries and of runtime...
I'll rebuild with no ghdl installed and with clean build directory, but tomorrow I think.

Regards,
Adrien
Adrien Prost-Boucle
2016-11-30 18:24:56 UTC
Permalink
Nope, compilation of libs does not work if there is no ghdl already installed in the system!
the culprit is in the ghdl Makefile, line 173:

libs.vhdl.gcc:
$(MAKE) GHDL=$(bindir)/ghdl$(EXEEXT) vhdl.libs.all libs.vhdl.standard

So in my call to "make GHDL=<my-path> ghdllibs", the GHDL= is discarded.
What's needed is that the GHDL variable is kept for that recursive make call.

Otherwise, I have to keep my build stuff split, like that (seems a bit fragile):
make <variables=my-paths> vhdl.libs.all libs.vhdl.standard
make libgrt.a

Adrien
Post by Adrien Prost-Boucle
Post by Tristan Gingold
Are you sure you need to comment out ANALYZE_OPTS and STD_GHDL_FLAGS ?
Usually, Makefile variables set on the command line overrides the 
definitions.
I wasn't aware of this subtelty... it seems so wrong to me...
But anyway, indeed the "instructions" that set these variables inside the Makefile are kind of skipped.
I'll have to read some docs on that topic.
So no need to patch the Makefile.
make \
GHDL="${srcdir}/gcc-build/gcc/ghdl" \
ANALYZE_OPTS="--GHDL1=${srcdir}/gcc-build/gcc/ghdl1" \
STD_GHDL_FLAGS="--GHDL1=${srcdir}/gcc-build/gcc/ghdl1" \
ghdllib
So no need to split build of libraries and of runtime...
I'll rebuild with no ghdl installed and with clean build directory, but tomorrow I think.
Regards,
Adrien
_______________________________________________
Ghdl-discuss mailing list
https://mail.gna.org/listinfo/ghdl-discuss
Tristan Gingold
2016-12-01 07:05:07 UTC
Permalink
Post by Adrien Prost-Boucle
Nope, compilation of libs does not work if there is no ghdl already installed in the system!
$(MAKE) GHDL=$(bindir)/ghdl$(EXEEXT) vhdl.libs.all libs.vhdl.standard
So in my call to "make GHDL=<my-path> ghdllibs", the GHDL= is discarded.
Correct.
Post by Adrien Prost-Boucle
What's needed is that the GHDL variable is kept for that recursive make call.
make <variables=my-paths> vhdl.libs.all libs.vhdl.standard
make libgrt.a
Not sure it is that fragile.

Anyway, you have fully explained the issue and I understood it. Now I
know how to improve the Makefile.

Tristan.

Loading...