alire-project / alire

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

Cross toolchain selection breaks native get configuration #1613

Open kevlar700 opened 7 months ago

kevlar700 commented 7 months ago

This is a fairly minor issue but may leave users scratching their heads and asking for help. Perhaps I am doing something wrong but one thing that I was hoping might be fixed by rc1 is that when I have been working with an arm toolchain and e.g. do.

alr get svd2ada

I get

svd2ada=0.1.0 successfully retrieved.
Dependencies were solved as follows:                               

   +📦 gnat   13.2.1 (new,gnat_arm_elf,indirect,binary)
   +   xmlada 22.0.0 (new)
cd svd2ada*
alr toolchain --select
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.

ⓘ Currently configured: gnat_arm_elf=13.2.1

Please select the gnat version for use with this configuration
  1. gnat_native=13.2.1
  2. None
  3. gnat_external=10.5.0 [Detected at /usr/bin/gnat]
  4. gnat_arm_elf=13.2.1
  5. gnat_avr_elf=13.2.1
  6. gnat_riscv64_elf=13.2.1
  7. gnat_arm_elf=13.1.0
  8. gnat_avr_elf=13.1.0
  9. gnat_native=13.1.0
  0. gnat_riscv64_elf=13.1.0
  a. (See more choices...)
Enter your choice index (first is default):
> 1
ⓘ Selected tool version gnat_native=13.2.1

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

ⓘ Currently configured: gprbuild=22.0.1

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
alr build --release
ⓘ Running post-fetch actions for xmlada=22.0.0...                                                                         
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking whether gnat can build shared libs... no
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
configure: creating ./config.status
config.status: creating xmlada_shared.gpr
config.status: creating Makefile
config.status: creating tests/dom/default.gpr
ⓘ Building svd2ada=0.1.0/svd2ada.gpr...
gprconfig: can't find a native toolchain for language 'ada'
gprconfig: can't find a native toolchain for language 'ada'
Setup
   [mkdir]        object directory for project XmlAda_Sax
   [mkdir]        library directory for project XmlAda_Sax
   [mkdir]        object directory for project XmlAda_Schema
   [mkdir]        exec directory for project SVD2ada
xmlada_unicode.gpr:28:25: warning: libraries are not supported on this platform
xmlada_sax.gpr:30:25: warning: libraries are not supported on this platform
xmlada_input.gpr:29:25: warning: libraries are not supported on this platform
xmlada_dom.gpr:30:25: warning: libraries are not supported on this platform
xmlada_schema.gpr:31:25: warning: libraries are not supported on this platform
xmlada_schema.gpr:29:09: no compiler for language "Ada", cannot compile "schema.adb"
gprbuild: *** compilation phase failed
error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/mnt/crypt/elansys/code/Ada/svd2ada_0.1.0_6eb0b591/svd2ada.gpr"] exited with code 4
error: Compilation failed.

ⓘ Building svd2ada=0.1.0/svd2ada.gpr...                                    
gprconfig: can't find a native toolchain for language 'ada'
gprconfig: can't find a native toolchain for language 'ada'
xmlada_unicode.gpr:28:25: warning: libraries are not supported on this platform
xmlada_sax.gpr:30:25: warning: libraries are not supported on this platform
xmlada_input.gpr:29:25: warning: libraries are not supported on this platform
xmlada_dom.gpr:30:25: warning: libraries are not supported on this platform
xmlada_schema.gpr:31:25: warning: libraries are not supported on this platform
xmlada_schema.gpr:29:09: no compiler for language "Ada", cannot compile "schema.adb"
gprbuild: *** compilation phase failed
error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/mnt/crypt/elansys/code/Ada/svd2ada_0.1.0_6eb0b591/svd2ada.gpr"] exited with code 4
error: Compilation failed.

Then I

cd ..
rm -rf svd2ada_0.1.0_6eb0b591
alr get svd2ada

And all is well

mosteo commented 7 months ago

Mmm. So the problem is that the crate was solved with the previously selected compiler, and after picking the new one no attempt is made to re-resolve. I'm guessing that an alr update would also fix the issue.

I can only think of storing the timestamp when the compiler was changed and if the workspace solution is older, automatically prompt to update. Seems fairly involved for a likely infrequent situation, but worth keeping in mind.

So I see this more as a fix for 2.1 rather than risking breaking something in the process.

PS: confirmed that alr update does fix the issue.