Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
ccb5653f
Unverified
Commit
ccb5653f
authored
6 years ago
by
Martine Lenders
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #9515 from cladmi/pr/make/newlib/fixandstuff
newlib.mk: fix regressions
parents
7f04742e
3226918e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
makefiles/libc/newlib.mk
+37
-26
37 additions, 26 deletions
makefiles/libc/newlib.mk
with
37 additions
and
26 deletions
makefiles/libc/newlib.mk
+
37
−
26
View file @
ccb5653f
...
...
@@ -19,46 +19,57 @@ endif
export
LINKFLAGS
+=
-lc
# Note on `realpath` vs `abspath`
#
# `realpath` is used instead of `abspath` to support Mingw32
# It fixes issues when using windows formatted paths like in the gcc output
# It does leave the trailing `/` on windows though
# Search for Newlib include directories
# Try to search for newlib in the standard search path of the compiler for includes
ifeq
(,$(NEWLIB_INCLUDE_DIR))
COMPILER_INCLUDE_PATHS
:=
$(
shell
$(
PREFIX
)
gcc
-v
-x
c
-E
/dev/null 2>&1 |
grep
'^\s'
|
tr
-d
'\n'
)
NEWLIB_INCLUDE_DIR
:=
$(
firstword
$(
dir
$(
wildcard
$(
addsuffix /newlib.h,
$(
COMPILER_INCLUDE_PATHS
)))))
COMPILER_INCLUDE_PATHS
:=
$(
shell
$(
PREFIX
)
gcc
-v
-x
c
-E
/dev/null 2>&1 |
\
sed
\
-e
'1,/\#include <...> search starts here:/d'
\
-e
'/End of search list./,$$d'
\
-e
's/^ *//'
)
NEWLIB_INCLUDE_DIR
:=
$(
firstword
$(
realpath
$(
dir
$(
wildcard
$(
addsuffix /newlib.h,
$(
COMPILER_INCLUDE_PATHS
))))))
endif
ifeq
(,$(NEWLIB_INCLUDE_DIR))
# Since Clang is not installed as a separate instance for each crossdev target
# we need to tell it where to look for platform specific includes (Newlib
# headers instead of Linux/Glibc headers.)
# On GCC this is done when building the cross compiler toolchain so we do not
# actually need to specify the include paths for system includes.
# Ubuntu gcc-arm-embedded toolchain (https://launchpad.net/gcc-arm-embedded)
# places newlib headers in several places, but the primary source seem to be
# /etc/alternatives/gcc-arm-none-eabi-include
# Gentoo Linux crossdev place the newlib headers in /usr/arm-none-eabi/include
# Arch Linux also place the newlib headers in /usr/arm-none-eabi/include
# Ubuntu seem to put a copy of the newlib headers in the same place as
# Gentoo crossdev, but we prefer to look at /etc/alternatives first.
# On OSX, newlib includes are possibly located in
# /usr/local/opt/arm-none-eabi*/arm-none-eabi/include or /usr/local/opt/gcc-arm/arm-none-eabi/include
# Since Clang is not installed as a separate instance for each crossdev target
# we need to tell it where to look for platform specific includes (Newlib
# headers instead of Linux/Glibc headers.)
# On GCC this is done when building the cross compiler toolchain so we do not
# actually need to specify the include paths for system includes.
# Ubuntu gcc-arm-embedded toolchain (https://launchpad.net/gcc-arm-embedded)
# places newlib headers in several places, but the primary source seem to be
# /etc/alternatives/gcc-arm-none-eabi-include
# Gentoo Linux crossdev place the newlib headers in /usr/arm-none-eabi/include
# Arch Linux also place the newlib headers in /usr/arm-none-eabi/include
# Ubuntu seem to put a copy of the newlib headers in the same place as
# Gentoo crossdev, but we prefer to look at /etc/alternatives first.
# On OSX, newlib includes are possibly located in
# /usr/local/opt/arm-none-eabi*/arm-none-eabi/include or /usr/local/opt/gcc-arm/arm-none-eabi/include
NEWLIB_INCLUDE_PATTERNS
?=
\
/etc/alternatives/gcc-
$(
TARGET_ARCH
)
-include
\
/usr/
$(
TARGET_ARCH
)
/include
\
/usr/local/opt/
$(
TARGET_ARCH
)
*
/
$(
TARGET_ARCH
)
/include
\
/usr/local/opt/gcc-
*
/
$(
TARGET_ARCH
)
/include
\
#
# Use the wildcard Makefile function to search for existing directories matching
# the patterns above. We use the -isystem gcc/clang argument to add the include
# directories as system include directories, which means they will not be
# searched until after all the project specific include directories (-I/path)
NEWLIB_INCLUDE_DIR
?
=
$(
firstword
$(
dir
$(
wildcard
$(
addsuffix /newlib.h,
$(
NEWLIB_INCLUDE_PATTERNS
)))))
# Use the wildcard Makefile function to search for existing directories matching
# the patterns above. We use the -isystem gcc/clang argument to add the include
# directories as system include directories, which means they will not be
# searched until after all the project specific include directories (-I/path)
NEWLIB_INCLUDE_DIR
:
=
$(
firstword
$(
realpath
$(
dir
$(
wildcard
$(
addsuffix /newlib.h,
$(
NEWLIB_INCLUDE_PATTERNS
)))))
)
endif
# If nothing was found we will try to fall back to searching for a cross-gcc in
# the current PATH and use a relative path for the includes
ifeq
(,$(NEWLIB_INCLUDE_DIR))
NEWLIB_INCLUDE_DIR
:=
$(
abs
path
$(
wildcard
$(
dir
$(
shell
command
-v
$(
PREFIX
)
gcc 2>/dev/null
))
/../
$(
TARGET_ARCH
)
/include
))
NEWLIB_INCLUDE_DIR
:=
$(
real
path
$(
wildcard
$(
dir
$(
shell
command
-v
$(
PREFIX
)
gcc 2>/dev/null
))
/../
$(
TARGET_ARCH
)
/include
))
endif
ifeq
($(TOOLCHAIN),llvm)
...
...
@@ -68,7 +79,7 @@ ifeq ($(TOOLCHAIN),llvm)
# We also add -nostdinc to avoid including the host system headers by mistake
# in case some header is missing from the cross tool chain
NEWLIB_INCLUDES
:=
-isystem
$(
NEWLIB_INCLUDE_DIR
)
-nostdinc
NEWLIB_INCLUDES
+=
$(
addprefix
-isystem
,
$(
abs
path
$(
wildcard
$(
dir
$(
NEWLIB_INCLUDE_DIR
))
/usr/include
)))
NEWLIB_INCLUDES
+=
$(
addprefix
-isystem
,
$(
real
path
$(
wildcard
$(
dir
$(
NEWLIB_INCLUDE_DIR
))
/usr/include
)))
# Newlib includes should go before GCC includes. This is especially important
# when using Clang, because Clang will yield compilation errors on some GCC-
...
...
@@ -79,9 +90,9 @@ ifeq ($(TOOLCHAIN),llvm)
endif
ifeq
(1,$(USE_NEWLIB_NANO))
NEWLIB_NANO_INCLUDE_DIR
?=
$(
firstword
$(
wildcard
$(
NEWLIB_INCLUDE_DIR
)
newlib-nano
\
$(
NEWLIB_INCLUDE_DIR
)
newlib/nano
\
$(
NEWLIB_INCLUDE_DIR
)
nano
))
NEWLIB_NANO_INCLUDE_DIR
?=
$(
firstword
$(
wildcard
$(
NEWLIB_INCLUDE_DIR
)
/
newlib-nano
\
$(
NEWLIB_INCLUDE_DIR
)
/
newlib/nano
\
$(
NEWLIB_INCLUDE_DIR
)
/
nano
))
# newlib-nano overrides newlib.h and its include dir should therefore go before
# the regular system include dirs.
INCLUDES
:=
-isystem
$(
NEWLIB_NANO_INCLUDE_DIR
)
$(
INCLUDES
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment