eclipse-embed-cdt / eclipse-plugins

The Eclipse Embedded CDT plug-ins for Arm & RISC-V C/C++ developers (formerly known as the GNU MCU Eclipse plug-ins). Includes the archive of previous plug-ins versions, as Releases.
http://eclipse-embed-cdt.github.io/
Eclipse Public License 2.0
558 stars 130 forks source link

Improper build support for multi-target ARM + Risc-V project #496

Open nvitya opened 2 years ago

nvitya commented 2 years ago

Description

Hi,

I've created a project with multiple build configurations. The project was originally created with Risc-V target, and then I've added a build configuration with ARM (Cortex-M). The build configuration for ARM is not fully supported. At the Project properties / "C/C++ Build" / "Settings" / "Toolchains" tab is a limited version is displayed without "Create Flash Image" and "Print Size" checkboxes.

The build basically works for the ARM, but without creating HEX file or printing the size of the compiled project.

If you create a new project with ARM first then the ARM is fully supported and the Risc-V build will be somewhat limited.

Steps to Reproduce

  1. Create a C/C++ Managed Project with "Risc-V Cross GCC"
  2. Add a new build configuration "ARM TEST", and set the toolchain to "Arm Cross GCC"
  3. Select the "ARM TEST" build configuration, and go to the Project properties / "C/C++ Build" / "Settings" / "Toolchains" tab

Expected behaviour: there should be the "Create Flash Image" and "Print Size" checkboxes.

Actual behaviour: they are not there...

Versions

ilg-ul commented 2 years ago

I confirm the bug.

ilg-ul commented 2 years ago

The problem was related to the logic that identifies own managed build plug-ins by the ids, which use both ilg.gnuarmeclipse and ilg.gnumcueclipse.

Fixed on 2021-10-24.

ilg-ul commented 2 years ago

Please use Install new Software to install the 6.2.0 pre-release from:

and let me know if it is ok.

nvitya commented 2 years ago

I've installed the pre-release. Now the "Toolchains" tabs looks the same, but still no HEX file generation and size report is done, however the checkboxes are active. Even if I toggled them. I've also created a new project from zero to test it properly, without success (still no HEX + size report for the secondary architecture - after successful compilation and linking).

ilg-ul commented 2 years ago

Can you double check if you have the 6.2.0 features installed?

Screenshot 2021-10-25 at 22 29 33

The bug affected the logic used to decide what elements should be displayed, and normally should not store anything in the persistent store, so it should help for old projects too.

ilg-ul commented 2 years ago

Here it is how it looks on my Mac:

Screenshot 2021-10-25 at 22 25 12

The original build configurations were created for RISC-V:

Screenshot 2021-10-25 at 22 26 56

nvitya commented 2 years ago

Yes, that's fine, I see these pages already too. But the "Create flash image" and "Print size" does not have an effect on the second created architecture.

ilg-ul commented 2 years ago

Ah, that's different. So you see the radio buttons, but the functionality associated with them is not there?

nvitya commented 2 years ago

multiarch_test.zip

Here is a small test project. Risc-V output:

21:39:50 **** Build of configuration RV32I for project multiarch_test ****
make all 
Building file: ../main.c
Invoking: GNU RISC-V Cross C Compiler
riscv-none-embed-gcc -march=rv32i -msmall-data-limit=8 -mno-save-restore -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding  -g3 -std=gnu11 -MMD -MP -MF"main.d" -MT"main.o" -c -o "main.o" "../main.c"
Finished building: ../main.c

Building target: multiarch_test.elf
Invoking: GNU RISC-V Cross C Linker
riscv-none-embed-gcc -march=rv32i -msmall-data-limit=8 -mno-save-restore -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding  -g3 -nostartfiles -Xlinker --gc-sections -Wl,-Map,"multiarch_test.map" --specs=nano.specs -o "multiarch_test.elf"  ./main.o   
Finished building target: multiarch_test.elf

Invoking: GNU RISC-V Cross Create Flash Image
riscv-none-embed-objcopy -O ihex "multiarch_test.elf"  "multiarch_test.hex"
Finished building: multiarch_test.hex

Invoking: GNU RISC-V Cross Print Size
riscv-none-embed-size --format=berkeley "multiarch_test.elf"
   text    data     bss     dec     hex filename
     32       0       0      32      20 multiarch_test.elf
Finished building: multiarch_test.siz

21:39:50 Build Finished. 0 errors, 0 warnings. (took 161ms)

ARMM compile output:

21:44:04 **** Incremental Build of configuration ARMM for project multiarch_test ****
make all 
Building file: ../main.c
Invoking: GNU Arm Cross C Compiler
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -O2 -fmessage-length=0 -ffunction-sections -fdata-sections -ffreestanding  -g -std=gnu11 -MMD -MP -MF"main.d" -MT"main.o" -c -o "main.o" "../main.c"
Finished building: ../main.c

Building target: multiarch_test.elf
Invoking: GNU Arm Cross C Linker
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -O2 -fmessage-length=0 -ffunction-sections -fdata-sections -ffreestanding  -g -nostartfiles -Xlinker --gc-sections -Wl,-Map,"multiarch_test.map" --specs=nano.specs -o "multiarch_test.elf"  ./main.o   
Finished building target: multiarch_test.elf

21:44:04 Build Finished. 0 errors, 0 warnings. (took 110ms)
ilg-ul commented 2 years ago

Thank you, that should be helpful.

I don't know yet how difficult to fix is this, I'll further investigate.

ilg-ul commented 2 years ago

I successfully imported your project and took a look at the .cproject file. At first sight I could not spot anything wrong, it'll require a more thorough analysis.

The creation of the make files is done in the parent CDT classes, based on the content of .cproject and the toolchain definitions in the plug-ins.

I'll take a second look in a few days, time permitting.

ilg-ul commented 2 years ago

I confirm that I encountered this issue myself.

My use case was reversed, I had several Arm build configurations and added a RISC-V configuration. So the problem is not specific to Arm or RISC-V separately, it seems to affect all configurations.

The 3 options related to hex/listing/size did not show in the configuration page, although they were present in the .cproject. However they were functional, the build created those files, and manually editing .cproject changed the behaviour.

@jonahgraham, time permitting, probably we should try to identify why CDT does not display these options, otherwise functional in ECDT.

ilg-ul commented 2 years ago

@jonahgraham, please ignore the previous request, I took a more careful look and the missing widgets are not in the tab rendered by CDT, but in a tab rendered by the ECDT plug-ins, so it is a bug in my code.

I'll fix it shortly.