Skip to content

Spurious "No such file or directory" errors printed in verbose compile output #2263

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
per1234 opened this issue Aug 13, 2023 · 0 comments · Fixed by #2267
Closed
3 tasks done

Spurious "No such file or directory" errors printed in verbose compile output #2263

per1234 opened this issue Aug 13, 2023 · 0 comments · Fixed by #2267
Assignees
Labels
conclusion: resolved Issue was resolved topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Aug 13, 2023

Describe the problem

In order to save the user from the need to manually configure the compiler "search path" for the individual library dependencies of each sketch, Arduino CLI's compile command includes a "library discovery" step that automatically finds the paths of the library dependencies and passes them to the compilation command.

The following procedure is used recursively for library discovery:

  1. Sketch code file is subjected to C++ preprocessing
  2. Error messages are parsed to determine the filenames of header files not found in the search path
  3. The path of the library providing the header is added to the search path

So error messages specific to missing header files are an expected and integral part of the library discovery process internally.

🐛 These expected error message are printed in the verbose output of the compile command. Since the users don't know how the library discovery system works internally, these error messages might give them the impression that something went wrong during the compilation process.

To reproduce

$ git clone https://github.com/arduino/arduino-cli

[...]

$ cd arduino-cli

$ git checkout 0585435f~1  # checkout the last commit before the regression

$ task build

[...]

$ ./arduino-cli version

arduino-cli.exe  Version: git-snapshot Commit: 9ce2904b Date: 2023-08-11T08:22:02Z

$ ./arduino-cli lib install Arduino_BuiltIn  # Install an arbitrary library to use for the demo

[...]

$ mkdir /tmp/FooSketch

$ printf "#include <Arduino_BuiltIn.h>\nvoid setup() {}\nvoid loop() {}\n" > "/tmp/FooSketch/FooSketch.ino"

$ ./arduino-cli compile --fqbn arduino:avr:uno --verbose /tmp/FooSketch  # there are no confusing error messages in the output

[...]

Detecting libraries used...
"C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\per\\AppData\\Local\\Temp\\arduino\\sketches\\2405C4C9F90028537C79B0744BCE536E\\sketch\\FooSketch.ino.cpp" -o nul
Alternatives for Arduino_BuiltIn.h: [[email protected]]
ResolveLibrary(Arduino_BuiltIn.h)
  -> candidates: [[email protected]]

[...]

$ git checkout master  # checkout the last commit before the regression

$ task build

[...]

$ ./arduino-cli version

arduino-cli.exe  Version: git-snapshot Commit: e9c7d86e Date: 2023-08-11T08:00:04Z

$ ./arduino-cli compile --fqbn arduino:avr:uno --verbose /tmp/FooSketch

Detecting libraries used...
C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\per\AppData\Local\Temp\arduino\sketches\2405C4C9F90028537C79B0744BCE536E\sketch\FooSketch.ino.cpp -o nul
C:\Users\per\AppData\Local\Temp\FooSketch\FooSketch.ino:1:10: fatal error: Arduino_BuiltIn.h: No such file or directory
 #include <Arduino_BuiltIn.h>
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
Alternatives for Arduino_BuiltIn.h: [[email protected]]
ResolveLibrary(Arduino_BuiltIn.h)
  -> candidates: [[email protected]]

[...]

Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

Used library    Version Path
Arduino_BuiltIn 1.0.0   C:\Users\per\Documents\Arduino\libraries\Arduino_BuiltIn

Used platform Version Path
arduino:avr   1.8.6   C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

🐛 A confusing error message appeared in the output even though the compilation was successful and completely normal:

C:\Users\per\AppData\Local\Temp\FooSketch\FooSketch.ino:1:10: fatal error: Arduino_BuiltIn.h: No such file or directory
 #include <Arduino_BuiltIn.h>
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

Expected behavior

The expected error messages generated by the recipe.preproc.macros command invocations during library discovery are not printed in the compile command output.

Unexpected error messages generated by the recipe.preproc.macros command should still be printed to the command output in order to facilitate troubleshooting.

Arduino CLI version

e9c7d86

Operating system

Windows

Operating system version

Windows 11

Additional context

I bisected the regression to 0585435 (does not occur when using the build from the previous commit 9ce2904).

0585435 is described as a refactoring that is not expected to change behavior (#2194), which leads me to believe this was unintentional.

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
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: build-process Related to the sketch build process labels Aug 13, 2023
@cmaglie cmaglie self-assigned this Aug 17, 2023
@cmaglie cmaglie added this to the Arduino CLI 0.34.0 milestone Aug 17, 2023
@per1234 per1234 added the conclusion: resolved Issue was resolved label Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants