AdaCore / gnat-llvm

LLVM based GNAT compiler
179 stars 18 forks source link

Ubuntu 20.04 - Linker command failed - undefined reference to `gnat_version_string' #26

Closed TintoEdoardo closed 2 years ago

TintoEdoardo commented 2 years ago

Good morning,

I am trying to compile the gnat-llvm project without success.

In order to build the project, I followed the suggestions provided in the README.md file, therefore:

Below I reported some more information regarding the version of each component:

gprbuild --version 
GPRBUILD Community 2020 (20200818) (x86_64-pc-linux-gnu)
Copyright (C) 2004-2020, AdaCore
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
clang --version
Ubuntu clang version 12.0.0-3ubuntu1~20.04.5
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-12/bin
llvm-config  --version
12.0.0

The compilation ends with the following error:

clang++ gnat1drv.o /tmp/GNAT-TEMP-000010.TMP libgnat_llvm.a -L/usr/lib/llvm-12/lib -lLLVM-12 -static-libstdc++ -L/home/edoardo/Documents/gnat-llvm/llvm-interface/obj/ -L/home/edoardo/Documents/gnat-llvm/llvm-interface/obj/ -L/home/edoardo/opt/GNAT/2020/lib/gcc/x86_64-pc-linux-gnu/9.3.1/adalib/ /home/edoardo/opt/GNAT/2020/lib/gcc/x86_64-pc-linux-gnu/9.3.1/adalib/libgnat.a -ldl -Wl,-rpath-link,/home/edoardo/opt/GNAT/2020/lib/gcc/x86_64-pc-linux-gnu/9.3.1//adalib -shared-libgcc -Wl,-z,origin,-rpath,/usr/lib/llvm-12/lib:$ORIGIN/..//obj:$ORIGIN/../../../..//opt/GNAT/2020/lib/gcc/x86_64-pc-linux-gnu/9.3.1/adalib -o /home/edoardo/Documents/gnat-llvm/llvm-interface/bin//llvm-gnat1
/usr/bin/ld: /home/edoardo/Documents/gnat-llvm/llvm-interface/obj/gnatvsn.o: in function `gnatvsn__gnat_version_string':
/home/edoardo/Documents/gnat-llvm/llvm-interface/gnat_src/gnatvsn.adb:66: undefined reference to `gnat_version_string'
/usr/bin/ld: /home/edoardo/Documents/gnat-llvm/llvm-interface/gnat_src/gnatvsn.adb:68: undefined reference to `gnat_version_string'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gprbuild: link of gnat1drv.adb failed
make[1]: *** [Makefile:76: build] Error 4
make[1]: Leaving directory '/home/edoardo/Documents/gnat-llvm/llvm-interface'
make: *** [Makefile:2: all] Error 2

Is there any further configuration I might have missed in order to build the project?

If I am using the wrong version of some tools, please let me know and I will change it accordingly. Finally, I would be glad to provide any further information regarding the current configuration of my environment, if that could be useful.

Thanks in advance for the support.

Best regards, Edoardo Tinto

ArnaudCharlet commented 2 years ago

Hi Edoardo, You should use master and the GCC master sources, this will solve your issue. Also the requirement has been bumped recently to LLVM 13.0.x, we'll update the README.md accordingly.

TintoEdoardo commented 2 years ago

Good afternoon,

thanks for your reply. I have just tried the following configuration:

gcc --version
gcc (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
clang --version
clang version 13.0.1
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-13/bin
llvm-config --version
13.0.1
gprbuild --version
GPRBUILD Community 2021 (20210519) (x86_64-pc-linux-gnu)
Copyright (C) 2004-2021, AdaCore
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

However, I encountered the following error:

/usr/bin/ranlib /home/edoardo/Documents/gnat-llvm/llvm-interface/lib/rts-native/adalib/libgnat.a
gprlib: could not copy ALI files to library directory
gprbuild: could not build library for project libgnat
make[2]: *** [Makefile:229: quicklib] Error 4
make[2]: Leaving directory '/home/edoardo/Documents/gnat-llvm/llvm-interface'
make[1]: *** [Makefile:209: gnatlib-automated] Error 2
make[1]: Leaving directory '/home/edoardo/Documents/gnat-llvm/llvm-interface'
make: *** [Makefile:2: all] Error 2

In addition, I used the GNAT toolchain 2021, because with the previous version (2020) I encountered the following error, which is already discussed in another issue:

g-comlin.ads:1100:54: illegal character, replaced by "("
g-comlin.ads:1104:50: illegal character, replaced by "("

   compilation of gnatchop.adb failed

gprbuild: *** compilation phase failed
make[1]: *** [Makefile:77: build] Error 4
make[1]: Leaving directory '/home/edoardo/Documents/gnat-llvm/llvm-interface'
make: *** [Makefile:2: all] Error 2

Best regards, Edoardo Tinto

ArnaudCharlet commented 2 years ago

I suspect you got other errors before this last one: /usr/bin/ranlib /home/edoardo/Documents/gnat-llvm/llvm-interface/lib/rts-native/adalib/libgnat.a gprlib: could not copy ALI files to library directory gprbuild: could not build library for project libgnat

So you need to look at your log file in more details to find the first error.

TintoEdoardo commented 2 years ago

Thanks for the suggestion. I can see just one warning in the log, starting at line 466. Am I missing something?

Best regards, Edoardo Tinto

ArnaudCharlet commented 2 years ago

Indeed, no other error in sight, that's very strange. I would suggest double checking your permissions and verify that you have enough disk space available. Looks like for some reason gprbuild cannot copy ali files.

TintoEdoardo commented 2 years ago

Good afternoon,

I am still trying to figure out how to solve the error here.

Changing the permissions of the folders in /gnat-llvm/llvm-interface/lib/rts-native/ after creation, from the /gnat-llvm/llvm-interface/Makefiledoes not solve the issue.

Therefore, I try to build the project libgnat and libgnarl separately (both are located in /gnat-llvm/llvm-interface/lib/rts-native/adainclude/ and are part of the aggregate project libada). It seems that the project libgnarl is built without any issue, here is the log. However, when I try to build libgnat, I get the same error in the log.

From what I can see in the libgnat.gpr and libgnarl.gpr files, both projects share the same object and library directories.

Please, let me know if it would be better to open a different issue for this topic.

Best regards, Edoardo Tinto