Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cortexm: Add support for building with LLVM/Clang
as an alternative to the default GCC toolchain. export TOOLCHAIN=llvm to build with Clang instead of GCC
- Loading branch information
Joakim Gebart
committed
Jun 1, 2015
1 parent
fecc105
commit aae6802
Showing
3 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export GDBPREFIX ?= $(PREFIX) | ||
export LLVMPREFIX ?= llvm- | ||
export CC = clang | ||
export CXX = clang++ | ||
export LINK = $(CC) | ||
export AS = $(LLVMPREFIX)as | ||
export AR = $(LLVMPREFIX)ar | ||
export NM = $(LLVMPREFIX)nm | ||
# There is no LLVM linker yet, use GNU binutils. | ||
#export LINKER = $(LLVMPREFIX)ld | ||
# objcopy does not have a clear substitute in LLVM, use GNU binutils | ||
#export OBJCOPY = $(LLVMPREFIX)objcopy | ||
export OBJCOPY = $(PREFIX)objcopy | ||
export OBJDUMP = $(LLVMPREFIX)objdump | ||
export SIZE = $(LLVMPREFIX)size | ||
export DBG = $(GDBPREFIX)gdb | ||
# LLVM lacks a binutils strip tool as well... | ||
#export STRIP = $(LLVMPREFIX)strip | ||
|
||
# Tell clang to cross compile | ||
export CFLAGS += -target $(TARGET_TRIPLE) | ||
export CXXFLAGS += -target $(TARGET_TRIPLE) | ||
export LINKFLAGS += -target $(TARGET_TRIPLE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,33 @@ | ||
UNDEF := $(BINDIR)newlib/syscalls.o $(UNDEF) | ||
|
||
# Search for Newlib include directories | ||
|
||
# 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 | ||
NEWLIB_INCLUDE_PATTERNS ?= \ | ||
/etc/alternatives/gcc-$(TARGET_TRIPLE)-include \ | ||
/usr/$(TARGET_TRIPLE)/include \ | ||
/usr/local/opt/$(TARGET_TRIPLE)*/$(TARGET_TRIPLE)/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_INCLUDES ?= \ | ||
$(foreach dir, \ | ||
$(foreach pat, $(NEWLIB_INCLUDE_PATTERNS), $(wildcard $(pat))), \ | ||
-isystem $(dir)) | ||
|
||
export INCLUDES += $(NEWLIB_INCLUDES) |