alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
288 stars 49 forks source link

Missing crt1.o and libc in x86_64 native toolchain #1225

Closed rodrigargar closed 2 years ago

rodrigargar commented 2 years ago

Hi,

I have just learned about the Alire project and I wanted to give it a try by running the hello crate as explained in the Getting Started guide. However, when executing alr run for the first time, after selecting the default native toolchain I get the error below. Do I need to install the libc native package on my system? I am using Ubuntu 20.04 on WSL2 on Windows.

$ alr run
Welcome to the toolchain selection assistant

In this assistant you can set up the default toolchain to be used with any crate
that does not specify its own top-level dependency on a version of gnat or
gprbuild.

If you choose "None", Alire will use whatever version is found in the
environment.

ⓘ gnat is currently not configured. (alr will use the version found in the environment.)

Please select the gnat version for use with this configuration
  1. gnat_native=12.1.2
  2. None
  3. gnat_arm_elf=12.1.2
  4. gnat_avr_elf=12.1.2
  5. gnat_riscv64_elf=12.1.2
  6. gnat_arm_elf=12.1.1
  7. gnat_avr_elf=12.1.1
  8. gnat_native=12.1.1
  9. gnat_riscv64_elf=12.1.1
  0. gnat_arm_elf=11.2.4
  a. (See more choices...)
Enter your choice index (first is default):
>
ⓘ Selected tool version gnat_native=12.1.2

ⓘ Choices for the following tool are narrowed down to releases compatible with just selected gnat_native=12.1.2

ⓘ gprbuild is currently not configured. (alr will use the version found in the environment.)

Please select the gprbuild version for use with this configuration
  1. gprbuild=22.0.1
  2. None
  3. gprbuild=21.0.2
  4. gprbuild=21.0.1
Enter your choice index (first is default):
>
ⓘ Selected tool version gprbuild=22.0.1
ⓘ Deploying gprbuild=22.0.1...
################################################################################################################# 100.0%ⓘ gprbuild=22.0.1 installed successfully.
ⓘ Deploying gnat_native=12.1.2...
################################################################################################################# 100.0%ⓘ gnat_native=12.1.2 installed successfully.
ⓘ Building hello/hello.gpr...
Setup
   [mkdir]        object directory for project Libhello
   [mkdir]        library directory for project Libhello
   [mkdir]        object directory for project Hello
   [mkdir]        exec directory for project Hello
Compile
   [Ada]          hello.adb
   [Ada]          libhello_config.ads
   [Ada]          libhello.adb
Build Libraries
   [gprlib]       Libhello.lexch
   [archive]      libLibhello.a
   [index]        libLibhello.a
Bind
   [gprbind]      hello.bexch
   [Ada]          hello.ali
Link
   [link]         hello.adb
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -ldl: No such file or directory
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lc: No such file or directory
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
gprbuild: link of hello.adb failed
gprbuild: failed command was: /home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/bin/gcc hello.o b__hello.o /home/rodrigo/repos/personal/hello_1.0.2_5715870b/alire/cache/dependencies/libhello_1.0.1_3c15bc7f/lib/libLibhello.a -L/home/rodrigo/repos/personal/hello_1.0.2_5715870b/obj/development/ -L/home/rodrigo/repos/personal/hello_1.0.2_5715870b/obj/development/ -L/home/rodrigo/repos/personal/hello_1.0.2_5715870b/alire/cache/dependencies/libhello_1.0.1_3c15bc7f/lib/ -L/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/adalib/ -static-libgcc /home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/adalib/libgnat.a -ldl -Wl,-rpath-link,/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0//adalib -Wl,-z,origin,-rpath,$ORIGIN/..//obj/development:$ORIGIN/..//alire/cache/dependencies/libhello_1.0.1_3c15bc7f/lib:$ORIGIN/../../../..//.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/adalib -o /home/rodrigo/repos/personal/hello_1.0.2_5715870b/bin//hello
error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/home/rodrigo/repos/personal/hello_1.0.2_5715870b/hello.gpr"] exited with code 4
error: Build failed

If I look for the crt files in the alire folder, this is what I get:

$ find /home/rodrigo/.config/alire/ -name "crt*"
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/crtbegin.o
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/crtprec64.o
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/crtbeginT.o
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/crtprec80.o
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/crtend.o
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/crtfastmath.o
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/crtprec32.o
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/crtbeginS.o
/home/rodrigo/.config/alire/cache/dependencies/gnat_native_12.1.2_66b989b5/lib/gcc/x86_64-pc-linux-gnu/12.1.0/crtendS.o
mosteo commented 2 years ago

Hi Rodrigo, I guess you're the first to try Alire on top of WSL.

Could you try to install the libc6-dev package and try again?

rodrigargar commented 2 years ago

Hi Alejandro,

As suggested, installing the libc6-dev package solved the issue. Thank you.

I suppose then that the missing files are only included in the toolchains for cross-compilation, right?

mosteo commented 2 years ago

As suggested, installing the libc6-dev package solved the issue. Thank you.

This seems to be an unstated dependency of the compilers. I guess it's mostly impossible not to have that installed in a regular Linux distro so we hadn't noticed.