Skip to content

newlib-nano: fix include directory, 2nd attempt with pkg fix #9281

Closed
smlng wants to merge 6 commits intoRIOT-OS:masterfrom
smlng:pr/pkg/newlib
Closed

newlib-nano: fix include directory, 2nd attempt with pkg fix #9281
smlng wants to merge 6 commits intoRIOT-OS:masterfrom
smlng:pr/pkg/newlib

Conversation

@smlng
Copy link
Copy Markdown
Member

@smlng smlng commented Jun 4, 2018

Contribution description

based on #9216, but including fixes for cmake based external packages

Issues/PRs references

@smlng smlng added Area: doc Area: Documentation Area: build system Area: Build system Area: pkg Area: External package ports 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 and removed Area: doc Area: Documentation labels Jun 4, 2018
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 4, 2018

btw. includes all commits originally by @toonst

Toon Stegen and others added 6 commits June 5, 2018 15:25
also:
- raise error when trying to use newlib on native target
- check for existence of newlib.h file iso existence of include
directory
- use nano.specs file whenever possible
stddef.h and stdarg.h are not supplied by newlib, but by the compiler,
so we need the standard include directories to find them.
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 5, 2018

there seems to be problem with the MIPS toolchain and its _Atomic(t) macro in conjunction with the newlib stuff, somehow all the typedefs for int_least8_t (and others) are not found anymore 😩

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 5, 2018

However this is currently only a problem with tests/rmutex which is why I blacklisted the 3 MIPS boards in the last commit.

@tcschmidt tcschmidt requested a review from josephnoir June 5, 2018 17:32
Copy link
Copy Markdown
Contributor

@josephnoir josephnoir left a comment

Choose a reason for hiding this comment

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

I don't feel confident to review the newlib related changes in newlib.mk. And I don't think someone approved the previous PR.

.PHONY: all

export RIOT_CFLAGS = $(CFLAGS) $(INCLUDES)
RIOT_CFLAGS := $(INCLUDES)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be probably be renamed to RIOT_INCLUDES to reflect its contents.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

mhm, those are still CFLAGS passed to the C compiler

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmh, I can accept that. Still need someone else to review the newlib part, any suggestions who?

@josephnoir josephnoir dismissed their stale review June 8, 2018 07:55

Not enough knowledge about the RIOT build system or newlib.

@tcschmidt
Copy link
Copy Markdown
Member

@smlng can you identify a proper additional reviewer?

@cgundogan
Copy link
Copy Markdown
Member

there seems to be problem with the MIPS toolchain and its _Atomic(t) macro in conjunction with the newlib stuff, somehow all the typedefs for int_least8_t (and others) are not found anymore

However this is currently only a problem with tests/rmutex which is why I blacklisted the 3 MIPS boards in the last commit.

@smlng but essentially this breaks mips in conjunction with int_least8. I don't think blacklisting these boards is the correct way, because user applications outside of the RIOT source directory – and thus hidden to us – may break. It's probably just due to some reordering of the includes..

@neiljay are you familiar with the nano.specs newlib + MIPS or did you encounter a similar issue?

Copy link
Copy Markdown
Member

@jnohlgard jnohlgard left a comment

Choose a reason for hiding this comment

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

See my comments inline

@@ -1,7 +1,15 @@
ifeq ($(BOARD), native)
$(error Newlib is not supported on native target)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why add artifical barriers? It is possible to build newlib for Linux and windows (cygwin)

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.
NEWLIB_INCLUDES += -isystem $(NEWLIB_NANO_INCLUDE_DIR)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is the nano include dir after the regular newlib dir? The comment does not make sense

# 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
# Clang/llvm has no support for specs files
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't the test above already filter out any compiler which errors on -specs?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Even though it has no support for it, Clang does not fail when passed the -specs option. Adding -Werror makes sure Clang fails when the -specs flag is passed.

# the current PATH and use a relative path for the includes
ifeq (,$(NEWLIB_INCLUDE_DIR))
ifeq (,$(NEWLIB_INCLUDE_FILE))
$(warning Using relative include dir)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggestion: change the message to "newlib.h not found, guessing newlib include path from gcc path"

@neiljay
Copy link
Copy Markdown
Contributor

neiljay commented Jun 12, 2018

@cgundogan Hi, No I have no experience with newlib-nano I checked with our compiler team and they said they have not tried nanospecs either, with the MIPS toolchain we do supply a SmallClib (-mclib=small) and TinyClib (-mclib=tiny) which are newlib derived if you need something smaller, but these are not the same as newlib-nano though.

@toonst
Copy link
Copy Markdown
Member

toonst commented Jun 12, 2018

I addressed @gebart 's comments in #9216.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 15, 2018

closing in favour of original PR #9216

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 Area: pkg Area: External package ports 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.

make: compiling is broken for any ARM platform on OS X.

7 participants