arm-none-eabi-g++ pulls the wrong version of newlib.h if -specs=nano.specs selected

Bug #1661882 reported by Hermann Kleier on 2017-02-04
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Thomas Preud'homme

Bug Description

The is for arm-none-eabi-g++ 6.2 and linking against newlib-nano.

When I preprocess a C-source with -specs=nano.specs, the file newlib.h from the directory newlib-nano is included:

echo '#include <string.h>' |\
/opt/gcc-arm-none-eabi-6_2-2016q4/bin/arm-none-eabi-gcc -specs=nano.specs -x c -E - |\
grep '^# 1 .*newlib\.h'

outputs # 1 "/opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/newlib-nano/newlib.h" 1 3 4 (as expected). This is because the file nano.specs contains (among others) the lines

%rename cpp nano_cpp
-isystem =/include/newlib-nano %(nano_cpp)

But if I feed a C++-source through the same compiler

echo '#include <string.h>' |\
/opt/gcc-arm-none-eabi-6_2-2016q4/bin/arm-none-eabi-gcc -specs=nano.specs -x c++ -E - |\
grep '^# 1 .*newlib\.h'

the output reads # 1 "/opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/newlib.h" 1 3.

In other words: The specs-file is ignored.

I am aware that I should include <cstring> instead of <string.h> in C++ sources and that GNU g++ is commonly invoked by …/arm-none-eabi-c++ instead of …/arm-none-eabi-gcc -x c++ but I did that to carve out the small difference. And: this does not change the matter.

Question: What do I have to add to the specs-file to let C++-files include newlib-nano/newlib.h?

(I put this as a question in stackoverflow but did not get any tip:

Changed in gcc-arm-embedded:
status: New → Confirmed
Changed in gcc-arm-embedded:
assignee: nobody → Thomas Preud'homme (thomas-preudhomme)
status: Confirmed → In Progress
Changed in gcc-arm-embedded:
status: In Progress → Fix Committed
Changed in gcc-arm-embedded:
milestone: none → 6-2017-q1-update
Changed in gcc-arm-embedded:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers