gabriele-galeotti / SweetAda

Ada-language framework
https://sweetada.org
Other
38 stars 4 forks source link

When running make without arguments, an error appears instead of help #7

Closed Irvise closed 3 months ago

Irvise commented 3 months ago

When running make or make help, the error Makefile:522: *** Error: no valid CPU. Stop. shows up. Nothing else gets printed.

The line 522 is being processed before the target help, and therefore it errors out even before printing any form or useful information.

Could the help target be moved earlier than the checks in order to ensure that it can always be printed?

Edit:

If i run make CPU=RISC-V the error then becomes cpus/RISC-V/configuration.in:11: *** Error: : no CPU model supported. Stop. as I have not provided the variant version. I believe the error message should report what the user has to select. Something like

Error: : no CPU model supported.  Stop.
Select between the 32 or 64-bit variants by indicating CPU_MODEL=RV32 or CPU_MODEL=RV64

After running make CPU=RISC-V CPU_MODEL=RV32, the help finally appears.

gabriele-galeotti commented 3 months ago

Most likely you have an old configuration.in in your platform directory.

The master Makefile (if not in the process of configuration with the "createkernelcfg" target) tries to read the kernel.cfg file. You probably have a "PLATFORM := " in your kernel.cfg. This will force the Makefile to read the platform's configuration.in in that directory. That file should contain the CPU and CPU_MODEL specifiers.

The "CPU :=" line selects the "whole" CPU type. I recently made some changes in order to select a CPU model. Check if the CPU_MODEL := is compatible with the values, apart your clone being synchronized with the repository.

Current accepted values are: CPU_MODEL := RV32[xxxxx] (e.g., RV32, RV32IMAFC, etc) CPU_MODEL := RV64[xxxxx] (e.g., RV64, RV64IMAC, etc)

CPU_MODEL so far is only a coarse select between SweetAda's 32/64-bit cpu libraries.

The problem vanishes because you just overrides values in the command line with correct ones.

Then, the exact string specifier of your CPU model must be recognized by your toolchain, otherwise you get an error during the compile phase, but this is another story because you have to write it down in GCC_SWITCHES_PLATFORM with something like "-march=......".

That being said, I can think about a change, so that the configuration file is not read when one specifies an empty target or the "help" target. Maybe also a message hint if the CPU is wrong. Errors in configuration files should not interfere with other Makefile targets, that is fair. I've already taken countemeasures, but this case perhaps is not covered.

Let me know if this solves your problem, bye.

Irvise commented 3 months ago

Hi Gabriele,

I have just done a clean clone of SweetAda, and, without any other modifications or changes, when I run make help, the problem still exists. I assume there are no "dirty" files as it is a clean clone. Here is what I just did:

fernando@localhost:~/Build> git clone --depth=1 https://github.com/gabriele-galeotti/SweetAda SweetAda-truck
Cloning into 'SweetAda-truck'...
remote: Enumerating objects: 1652, done.
remote: Counting objects: 100% (1652/1652), done.
remote: Compressing objects: 100% (1129/1129), done.
remote: Total 1652 (delta 1128), reused 758 (delta 512), pack-reused 0
Receiving objects: 100% (1652/1652), 4.45 MiB | 7.13 MiB/s, done.
Resolving deltas: 100% (1128/1128), done.

fernando@localhost:~/Build> cd SweetAda-truck/

fernando@localhost:~/Build/SweetAda-truck> make help
Makefile:548: *** Error: no valid CPU.  Stop.

fernando@localhost:~/Build/SweetAda-truck> 

After selecting a CPU, it does work as expected:

fernando@localhost:~/Build/SweetAda-truck> make help CPU=RISC-V
cpus/RISC-V/configuration.in:11: *** Warning: "": no CPU model supported. Available CPU_MODEL are: RV32[...] RV64[...].
make help (default)
  Display an help about make targets.
make [RTS=<rts>] [CPU=<cpu>] [CPU_MODEL=<cpu_model>] [TOOLCHAIN_NAME=<toolchain_name>] rts
  Build RTS <rts> for CPU <cpu> [CPU model <cpu_model>] using toolchain <toolchain_name>.
make PLATFORM=<platform> [SUBPLATFORM=<subplatform>] createkernelcfg
  Create the 'kernel.cfg' main configuration file.
make configure
  Create configuration/support files for this platform.
make all
  Perform the same as 'make kernel'.
[...]

It would be better if not even the CPU had to be selected. After all, a new user may not know the available CPU values that the Makefile is expecting.

Best regards, Fer

Irvise commented 3 months ago

An update from my side.

From the indications that you gave me, you are right. I indeed have the $CPU variable set to x86_64. I do not know where it comes from or where it is set.

After I run a unset CPU and I ask make help, it works without issue!!!

I will close the issue now as this is related to my own computer and not SweetAda.

Thank you very much for your help, Fer