Skip to content
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

make: newlib: check if newlib nano folder was found #11145

Merged
merged 1 commit into from
Mar 11, 2019

Conversation

kaspar030
Copy link
Contributor

Contribution description

The logic for finding the newlib nano include dir can, if no folder is found, end up with an empty "-I".
This leads to weird error messages, like:

cc1: error: -I/home/kaspar/src/riot/core/include: No such file or directory [-Werror=missing-include-dirs]

followed by many headers that cannot be found.

This is caused by "-I -Icpu/include". I lost a while debugging this, and just yesterday another user on IRC popped up with the same problem.

Underlying is a fedora newlib packaging problem, which seems to not build with nanospecs.

This PR adds a simple check whether NEWLIB_NANO_INCLUDE_DIR is empty despite nanospecs enabled, and outputs an error.

Testing procedure

Move the newlib nano folder (/usr/arm-none-eabi/include/newlib-nano on my arch) out of the way. Compile on master and with this PR.

Issues/PRs references

none

@kaspar030 kaspar030 added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 8, 2019
@kaspar030 kaspar030 requested a review from cladmi March 8, 2019 23:28
@cladmi
Copy link
Contributor

cladmi commented Mar 11, 2019

I had a similar change there #9384 putting a warning, so was thinking about the same thing.

By re-reading the error message mentioning the private USE_NEWLIB_NANO variable (only used in this file, not documented) I was thinking that I would prefer that it says something about newlib_nano module, not an internal variable. But maybe it just showed me the issue.

So I re-read the file to know the difference and now I question if the global handling of newlib_nano is correct.

Why do we need the USE_NEWLIB_NANO in the first place ?

In this file USE_NEWLIB_NANO is set if newlib_nano module is requested and available for the linker

# Test if nano.specs is available
ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
USE_NEWLIB_NANO = 1

But why then treat not having the header as an error and not just set USE_NEWLIB_NANO = 0 in the same way.

However, in some tests I used #ifdef MODULE_NEWLIB_NANO to know if newlib nano is enabled, but it may be set without being enabled, so it is inconsistent, and now I do not know how to get the information.

So I question if there is any reason justifying having USE_NEWLIB_NANO ?

Copy link
Contributor

@jcarrano jcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested. The error message is much more clear now.

@jcarrano jcarrano merged commit f7cdbda into RIOT-OS:master Mar 11, 2019
@kaspar030 kaspar030 deleted the test_newlib_nano_path_empty branch March 11, 2019 13:58
@danpetry danpetry added this to the Release 2019.04 milestone Mar 12, 2019
@gschorcht
Copy link
Contributor

@kaspar030 When upgrading the compiler version for ESP32 as a prerequisite for upgrading to the current ESP-IDF version, I encountered a problem with the variable NEWLIB_NANO_INCLUDE_DIR.

Although xtensa-esp32-elf-gcc version 8.4.0 uses the nanospecs, there is no separate include directory for the nano version of newlib.h. When the nano version of newlib is created with crosstool-NG, the newlib.h in the default include directory is just the nano version. This was not a problem with xtensa-esp32-elf-gcc version 5.2.0 because it doesn't use nanospecs.

Do you have any idea how to solve the problem other than compiling newlib-nano and newlib separately and preparing the folder structure by hand? I could not find any option in crosstool-NG to create separate directories for the nano version of newlib.

@gschorcht
Copy link
Contributor

I wonder if NEWLIB_NANO_INCLUDE_DIR has to point to a different directory than NEWLIB_INCLUDE_DIR or if it can just be the same if no separate directory is found.

gschorcht added a commit to gschorcht/RIOT-Xtensa-ESP that referenced this pull request Jan 23, 2022
The check introduced with PR RIOT-OS#11145 assumes that a toolchain which provides `newlib-nano` provides both the normal version and the nano version, and therefore has a separate directory for the nano version of `newlib.h`. This is the case for toolchains which allow to use both the normal and the nano version, e.g. for ARM and RISC-V.
However, if the toolchain provides `newlib_nano` but only allows the use of the nano version, it will only have the nano version of `newlib.h` and no separate directory for it, e.g. for ESP32.
To still be able to use such toolchains with `newlib_nano`, the check is changed so that the setting of the `-isystem` option depends on the existence of the separate directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants