newlib-nano: fix include directory#9216
Conversation
jnohlgard
left a comment
There was a problem hiding this comment.
Did you test this on clang as well? IIRC we needed some extra handling for that
|
Works for me on Arch. I'm closing #9215 as it is hacky. |
|
@gebart No I did not. And you're right, it needs some extra handling. I'm looking into it. |
|
FYI I think this only works if your newlib version >= 2.8.0 (because of https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=be5926babbfb23ded1de2181a7524b8c3eebe34c ) |
|
works on macOS |
|
CCN package is broken with this PR... I'd suggest to revert to the original state and then try another option for this? |
|
can we get this merged, need this to compile arm based boards on macOS!! |
|
@smlng have you seen Murdock's output? |
|
ah damn, but its only ccn-lite 😬 otherwise we should think about reverting #9080? |
|
so its a problem with all external packages? |
4c5967a to
77e5081
Compare
|
Sorry it took this long. |
|
still works on macOS but also still get error when compiling ccn-lite-relay for any arm board. |
|
I see, then it needs a check in the pkg makefile. @toonst do you mind to provide a patch for that also? Otherwise this will be broken and cannot be merged... It can also come in a separated PR, I can do it later if needed. |
|
@kYc0o I don't know cmake, but if I just remove the RIOT CFLAGS it seems to be fine. You think this is OK? |
|
@toonst note that it is not just ccn-lite, jerryscript, relic are not working, too. It seems that all apps that use external third party package won't compile, bc the CFLAGS are passed 2 times which causes the error. |
|
@smlng @toonst What if |
20cf3fd to
2c92bff
Compare
|
I see... What do you think then on reverting #9080 while we find a proper solution? |
stddef.h and stdarg.h are not supplied by newlib, but by the compiler, so we need the standard include directories to find them.
6d567a2 to
e751ac3
Compare
* remove check for native board * add Werror so using specs fails for clang * remove useless comments
|
Do all tests complete now? Are we ready to finish the review? |
makefiles/libc/newlib.mk
Outdated
| NEWLIB_NANO_INCLUDE_DIR ?= $(firstword $(wildcard $(addprefix $(NEWLIB_INCLUDE_DIR)/, newlib-nano nano))) | ||
| ifneq ($(NEWLIB_NANO_INCLUDE_DIR),) | ||
| # newlib-nano overrides newlib.h and its include dir should therefore go before | ||
| # the regular system include dirs, but after the other newlib includes. |
There was a problem hiding this comment.
Still not seeing why the nano include dir should go after the newlib include. newlib-nano overrides the newlib.h and therefore should go before newlib include or otherwise we will get the newlib.h from the regular newlib include directory.
There was a problem hiding this comment.
You're right, I missed your first comment on it. Fixed!
| .PHONY: all | ||
|
|
||
| export RIOT_CFLAGS = $(CFLAGS) $(INCLUDES) | ||
| RIOT_CFLAGS := $(INCLUDES) |
There was a problem hiding this comment.
Does this work? Isn't $(INCLUDES) empty at this point? Should this be = instead of :=?
There was a problem hiding this comment.
As it is called with make -C pkg/PKGNAME the variable was already set from environment variable.
However, there is not reasons to set it with := either.
we don't need to search for newlib include dirs manually when using the nano.specs file
| include ../Makefile.tests_common | ||
|
|
||
| # MIPS based boards are black listed due to some issue with newlib and _Atomic | ||
| BOARD_BLACKLIST := mips-malta pic32-clicker pic32-wifire |
There was a problem hiding this comment.
note: this should be removed, if someone has solution for the MIPS toolchain. It seems that some include paths are mixed up and the mips-gcc cannot find some system header files?!
There was a problem hiding this comment.
The difference between master and this pr with make info-build:
diff -u info-build-master info-build-pr
--- info-build-master 2018-06-19 13:47:58.983288813 +0200
+++ info-build-pr 2018-06-19 13:48:08.447320615 +0200
@@ -35,6 +35,8 @@
FEATURES_CONFLICT_MSG:
INCLUDES:
+ -isystem
+ /opt/mips-mti-elf/2016.05-03/mips-mti-elf/include
-I/home/harter/work/git/RIOT/core/include
-I/home/harter/work/git/RIOT/drivers/include
-I/home/harter/work/git/RIOT/sys/include I also get warnings two times when doing info-build:
make -C tests/rmutex BOARD=pic32-wifire info-build > info-build-pr
/home/harter/work/git/RIOT/makefiles/libc/newlib.mk:51: newlib.h not found, guessing newlib include path from gcc path
/home/harter/work/git/RIOT/makefiles/libc/newlib.mk:51: newlib.h not found, guessing newlib include path from gcc path
There was a problem hiding this comment.
Where is your newlib installation located? (newlib.h)
What distro?
Edit: never mind, I didn't see the context was mips-mti-elf
There was a problem hiding this comment.
Found that the two times warning comes from $(MAKE) info-boards-supported being called during make info-build.
I use ubuntu 16.04 and I installed the mips-mti-elf as explained in the Wiki I think:
$ /opt/mips-mti-elf/2016.05-03/bin/mips-mti-elf-gcc --version
mips-mti-elf-gcc (Codescape GNU Tools 2016.05-03 for MIPS MTI Bare Metal) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
And I have a only this newlib.h in mips-mti-elf directory, no newlib-nano directory:
/opt/mips-mti-elf/2016.05-03/mips-mti-elf/include/newlib.h
There was a problem hiding this comment.
When compiling, I have errors in stdatomic.h and with the new change that puts -isystem ABC it looks like it is another stdatomic.h that is used:
I have these two:
/opt/mips-mti-elf/2016.05-03/mips-mti-elf/include/stdatomic.h
/opt/mips-mti-elf/2016.05-03/lib/gcc/mips-mti-elf/4.9.2/include/stdatomic.h
| /usr/$(TARGET_ARCH)/include \ | ||
| /usr/local/opt/$(TARGET_ARCH)*/$(TARGET_ARCH)/include \ | ||
| /usr/local/opt/gcc-*/$(TARGET_ARCH)/include \ | ||
| # |
There was a problem hiding this comment.
The comment for the backslash terminated line was removed.
| # newlib-nano overrides newlib.h and its include dir | ||
| # should therefore go before the other newlib includes. | ||
| NEWLIB_INCLUDES := -isystem $(NEWLIB_NANO_INCLUDE_DIR) $(NEWLIB_INCLUDES) | ||
| endif |
There was a problem hiding this comment.
What happens if there is no newlib-nano ?
Is it ok to ignore this as it was right now ?
There was a problem hiding this comment.
In theory, code that depends on having newlib-nano should test for the appropriate macros, so that compilation fails right away instead if causing weird errors.
There was a problem hiding this comment.
From reading around, the difference between newlib and newlib-nano, should, according to https://community.nxp.com/thread/389086, almost only be code size, so with how things are usually used, no API dependency.
So there should not be any "dependency on newlib-nano" that should be tested in the code.
I would rely on the build system to report it.
However, my knowledge on the topic is limited.
There was a problem hiding this comment.
The size and layout of some internal newlib variables and structs are affected, for example sizeof(struct reent). Using the newlib.h from normal newlib when linking against newlib nano will probably work without any errors, but waste RAM. The other way around will result in buffer overflow bugs that will be difficult to debug.
There was a problem hiding this comment.
@jcarrano Do you have some macros that could be checked to verify if newlib-nano is used ? I would like to verify that right now, some configuration are already broken and not using newlib-nano when requested.
| # but Clang, when cross-compiling, needs to be told where to find the headers | ||
| # for the system being built. | ||
| # We also add -nostdinc to avoid including the host system headers by mistake | ||
| # in case some header is missing from the cross tool chain |
There was a problem hiding this comment.
This ifeq section with the gcc case was removed and it adds a wrong -isystem directory for mips-gcc 4.9.2 on my computer.
It supplies /opt/mips-mti-elf/2016.05-03/mips-mti-elf/include/ which replaces /opt/mips-mti-elf/2016.05-03/lib/gcc/mips-mti-elf/4.9.2/include/
Which breaks compilation for mips in the rmutex example.
However, re-adding the ifeq would only solve my case but maybe not llvm as it would be using the wrong directory.
There was a problem hiding this comment.
Can you try if it works with the latest additions?
cladmi
left a comment
There was a problem hiding this comment.
I feel this is going a bit too far for a single PR and it starts having side effects. This makes it hard for me to get forward in reviewing everything.
Adding only the nano.specswhen supported in a separate PR would be already one step. Fixing the whole newlib include handling when nano.specs is not used and with llvm is another task would help the review.
I can do the split PR fixing the packages this afternoon.
|
this fixes (all) my issues on macOS with newlib, right now (2018-06-22) master is broken there |
|
however, I also agree with @cladmi that we should introduces changes/fixes step-by-step, ie. nano-spec, include-dir, and llvm support. |
also * give error when no newlib directory is found * add search for newlib/nano directory original author: cgundogan
Contribution description
Adding the nano.specs file to CFLAGS make sure the correct include directory is found. This way we don't have to explicitly add the include directory.
Issues/PRs references
Fixes #9214
Fixes PR #9080
Alternative to #9215