AdaCore / gprbuild

GPRbuild is an advanced build system designed to help automate the construction of multi-language systems.
Other
64 stars 21 forks source link

Problem with building relocatable libraries under FSF GCC #5

Closed simonjwright closed 7 years ago

simonjwright commented 8 years ago

Building, for example, GNATCOLL under GCC 6.1.0 x86_64-apple-darwin15 results in

$ make
====== Building relocatable libraries ======
gprbuild -m -j0 -XLIBRARY_TYPE=relocatable -Pgnatcoll_build -p
gcc -c -fPIC -O2 -gnatn -gnatws -gnat05 gnatcoll-xref-database_names.ads
gcc -c -fPIC -O2 -gnatn -gnatws -gnat05 gnatcoll-xref-database.adb
gcc -c -fPIC -O2 -gnatn -gnatws -gnat05 gnatcoll-xref.adb
gprlib gnatcoll_sqlite.lexch
g++ -dynamiclib -shared-libgcc -o /Users/simon/tmp/gnatcoll-gpl-2015-src/src/lib/sqlite/relocatable/libgnatcoll_sqlite.dylib.1.8w ... /Users/simon/tmp/gnatcoll-gpl-2015-src/src/obj/sqlite/relocatable/sqlite3.o ...
ld: library not found for -lgnat-6.1
collect2: error: ld returned 1 exit status
gprlib: /opt/gcc-6.1.0/bin/g++ execution error
gprbuild: could not build library for project gnatcoll_sqlite
make: *** [build_library_type/relocatable] Error 4

because, as built, $prefix/lib/gcc/x86_64-apple-darwin15/6.1.0/adalib contains

-rwxr-xr-x  1 root  admin   383616  5 May 11:10 libgnarl-6.dylib
lrwxr-xr-x  1 root  admin       16  5 May 11:10 libgnarl.dylib -> libgnarl-6.dylib
-rwxr-xr-x  1 root  admin  5165388  5 May 11:10 libgnat-6.dylib
lrwxr-xr-x  1 root  admin       15  5 May 11:10 libgnat.dylib -> libgnat-6.dylib

I think this is because the [TOOLCHAIN VERSION] section of the .lexch file contains

[TOOLCHAIN VERSION]
ada
GNAT 6.1

and gprlib.adb:1164 says

                 Libgnat :=
                   new String'
                     ("-lgnat-" & Line (6 .. Last));
                 Libgnarl :=
                   new String'
                     ("-lgnarl-" & Line (6 .. Last));

I must say I don't understand why in this case it's necessary to alter Libgnat, Libgnarl at all?

Do you think this is actually an FSF GCC issue?

simonjwright commented 8 years ago

I think this may be because at GCC 4 the .ali files started e.g. V "GNAT Lib v4.7” but from GCC 5 it’s been V "GNAT Lib v5".

t-14 commented 8 years ago

We are aware of this issue and are currently discussing how to fix this properly. By means of a workaround, you can modify regexp at share/gprconfig/compilers.xml:745 like this:

`

`

simonjwright commented 8 years ago

Thanks; that worked for (my version of) gnat_util, but not for GNATCOLL; will investigate ...

(later) I had an old default.cgpr in the project’s root directory. All good now.

t-14 commented 7 years ago

This should now work as expected for any known flavor and version of gnat toolchains.