Skip to content

Compiler uses wrong library path when compiling with a local profile #2180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
TimH1502 opened this issue May 19, 2023 · 4 comments · Fixed by #2265
Closed
3 tasks done

Compiler uses wrong library path when compiling with a local profile #2180

TimH1502 opened this issue May 19, 2023 · 4 comments · Fixed by #2265
Assignees
Labels
type: imperfection Perceived defect in any part of project

Comments

@TimH1502
Copy link

Describe the problem

When i use the arduino-cli 0.32 (and nightly-20230519 Commit: 62f5caf Date: 2023-05-19T01:33:35Z) the compiler uses a wrong local library path (partly right) and the following error is shown

Error during build:
CreateFile toolchain\internal\ArduinoModbus_1.0.8_4504f0c6d4bba471\ArduinoModbus\src\toolchain\internal\ArduinoModbus_1.0.8_4504f0c6d4bba471\ArduinoModbus\src\ModbusClient.cpp: The system cannot find the path specified.

The arduino-cli is able to download the mbed-core and the libraries described in the "sketch.yaml".

The command --library or --libraries does not work with --profile

To reproduce

  • use the project (zip file): MyFirstSketch.zip
  • use the arduino-cli 0.32 (and nightly-20230519 Commit: 62f5caf date: 2023-05-19T01:33:35Z)
  • arduino-cli.exe compile -b arduino:mbed_portenta:envie_m7 --profile M7Core -v --export-binaries --config-file .\arduino-cli.yaml
    MyFirstSketch.zip

Expected behavior

Path which should be used:

toolchain\internal\ArduinoModbus_1.0.8_4504f0c6d4bba471\ArduinoModbus\src\ModbusClient.cpp

Arduino CLI version

nightly-20230519 Commit: 62f5caf date: 2023-05-19T01:33:35Z

Operating system

Windows

Operating system version

Windows 11 22621.1702 (22H2) and Windows 10 19045.2846 (22H2)

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details
@TimH1502 TimH1502 added the type: imperfection Perceived defect in any part of project label May 19, 2023
@cmaglie cmaglie self-assigned this Jun 5, 2023
@cmaglie
Copy link
Member

cmaglie commented Aug 16, 2023

I've created a patch here #2265.

Anyway I see that inside your sketch you have a local config file that sets the data directory and the user directory as a sub-directory of the sketch itself:

directories:
  data: toolchain
  user: toolchain
metrics:
  enabled: false
  always_export_binaries: true

This config will make the arduino-cli download again all the tools inside the sketch, wasting a lot of disk space.
This is useless since arduino-cli already uses a private internal space to download the platforms/tools needed for a profile, and this space is shared among all sketches, and it won't interfere with the platforms/tools installed globally (for use without profiles).

So my recommendation is to simply remove the local arduino-cli.yaml config and the toolchain folder.

@TimH1502
Copy link
Author

TimH1502 commented Aug 18, 2023

First off all thank you for your patch.

Your concern about the disk space is justified. So it is possible to leave the tools (dfu-util etc.) in the arduino folder and just have the board files locally in the project folder?

The advantage through the yaml file was that you need only the the project files (*.yaml, *.ino, etc.) and the cli downloads everything and the project is ready to compile. With the other setup, if I understand correctly, the user needs to install the board package and libraries manually via the cli. With your fix that works quite well, despite the other path/compiler problem mentioned below.

If use a different folder structure:

C:\Users\USERNAME\Downloads\Projects\MyFirstProject\MyFirstProject.ino

the compiler can't access the <bits/c++config.h>

Complete error message:

In file included from c:\users\USERNAME\downloads\projects\myfirstsketch\toolchain\internal\arduino_arm-none-eabi-gcc_7-2017q4_7b7be9f526b2cb64\arm-none-eabi\include\c++\7.2.1\math.h:36:0, 
                 from toolchain\internal\arduino_mbed_portenta_4.0.4_038db0ce27dff130\cores\arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_def.h:33, 
                 from toolchain\internal\arduino_mbed_portenta_4.0.4_038db0ce27dff130\cores\arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_rcc.h:29, 
                 from toolchain\internal\arduino_mbed_portenta_4.0.4_038db0ce27dff130\cores\arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/stm32h7xx_hal_conf.h:398, 
                 from toolchain\internal\arduino_mbed_portenta_4.0.4_038db0ce27dff130\cores\arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal.h:30, 
                 from toolchain\internal\arduino_mbed_portenta_4.0.4_038db0ce27dff130\cores\arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7xx.h:223, 
                 from toolchain\internal\arduino_mbed_portenta_4.0.4_038db0ce27dff130\cores\arduino/mbed/targets/TARGET_STM/TARGET_STM32H7/cmsis.h:22, 
                 from toolchain\internal\arduino_mbed_portenta_4.0.4_038db0ce27dff130\cores\arduino/mbed/targets/TARGET_STM/PinNamesTypes.h:33, 
                 from toolchain\internal\arduino_mbed_portenta_4.0.4_038db0ce27dff130\variants\PORTENTA_H7_M7/pinmode_arduino.h:24, 
                 from toolchain\internal\arduino_mbed_portenta_4.0.4_038db0ce27dff130\cores\arduino/Arduino.h:26, 
                 from C:\Users\USERNAME\AppData\Local\Temp\arduino\sketches\362617C8BF6AEA5AA483D0348C335006\sketch\MyFirstSketch.ino.cpp:1: 
c:\users\USERNAME\downloads\projects\myfirstsketch\toolchain\internal\arduino_arm-none-eabi-gcc_7-2017q4_7b7be9f526b2cb64\arm-none-eabi\include\c++\7.2.1\cmath:41:10: fatal error: bits/c++config.h: No such file or directory 
#include <bits/c++config.h> 
          ^~~~~~~~~~~~~~~~~~ 
compilation terminated.

Using the following structure:

C:\Users\USERNAME\Downloads\MyFirstProject\MyFirstProject.ino

the compilation succeeds.

Projects.zip

@cmaglie
Copy link
Member

cmaglie commented Aug 21, 2023

Unfortunately, this is a known issue of arm-none-eabi-gcc 7-2017q4, which cannot handle paths with more than ~150 chars on Windows.

AFAIK the last time I checked (about a year ago) the issue was still present upstream, I don't know if it has been fixed in the meantime in the most recent version of arm-gcc.

In any case, this is not related to the CLI but to the compiler.

@TimH1502
Copy link
Author

Okay if I move the project it seems to work as expected.
Are there any plans in the future to change the gcc version to 2021?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants