New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cortexm: Add support for building with LLVM/Clang #3119
Conversation
|
||
# define build specific options | ||
export CFLAGS_CPU = -mcpu=$(MCPU) -mlittle-endian -mthumb -mno-thumb-interwork $(CFLAGS_FPU) | ||
export CFLAGS_CPU = -mcpu=$(MCPU) -mlittle-endian -mthumb -fshort-enums $(CFLAGS_FPU) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as for -fshort-enums
:
newlib nano on my machine seems to be built with -fshort-enums
which causes warnings during linking with RIOT built using Clang. It seems like gcc defaults to using short enums and clang defaults to using word size enums because RIOT files built with GCC do not cause any warnings.
is |
I would opt for changing the switches name to something more general, maybe to
or
or anything else that might come up. So in the Makefile you could just write:
how does that sound? |
Good idea, I will adapt this pr when I am back at the computer.
|
Personally, I would prefer to set this based on the value of |
@LudwigOrtmann @haukepetersen OK, how about this: |
(and lastly go with the platform default, i.e. gnu for cortex) |
Is there any advantage in having |
@LudwigOrtmann TOOLCHAIN is the more logical name since this affects the entire chain, including compiling C, C++, assembler, linking, objcopy (though llvm doesn't have a proper replacement for that one yet) Also it is useful inside make to have a variable to check use in |
8156f15
to
02bb75e
Compare
rebased, updated with TOOLCHAIN/CC |
Added short description to https://github.com/RIOT-OS/RIOT/wiki/Build-Flags I will edit according to the final state of this PR when merged. |
|
||
# define build specific options | ||
export CFLAGS_CPU = -mcpu=$(MCPU) -mlittle-endian -mthumb -mno-thumb-interwork $(CFLAGS_FPU) | ||
export CFLAGS_CPU = -mcpu=$(MCPU) -mlittle-endian -mthumb $(CFLAGS_FPU) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this line is dependent on the toolchain, I am wondering if it would make it easier, to move this line to Makefile.include.gnu
and Makefile.include.llvm
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we move it, I think it will be easily overlooked that there are two places to modify if we need to change any flags. Also, it makes reading the files more tedious (switching back and forth between two/three files in the editor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we should keep cortex stuff out of Makefile.common.gnu/llvm, as the latter might be reused for non-cortex cpus.
By looking at the Makefile now, I am not sure if I am a big fan of deducting the |
@haukepetersen the way the board makefiles are written the CC variable can't actually be used for selecting the compiler since it is always overridden in the toolchain makefiles (both before and after this PR) |
@haukepetersen I do agree though that the CC checking block is making the file a bit more complex without adding much of a feature. All that is needed is I also added |
@LudwigOrtmann what is your opinion on this? |
@gebart yes |
02bb75e
to
f78a74d
Compare
rebased, removed the CC checks and squashed the previous commits. OK to squash all? |
@@ -1,18 +1,34 @@ | |||
# Target triple for the build. Use arm-none-eabi if you are unsure. | |||
export TARGET_TRIPLE ?= arm-none-eabi | |||
|
|||
# Toolchain prefix, defaults to target triple followed by a dash, you will most likely not need to touch this. | |||
# Use TOOLCHAIN environment variable to select the toolchain to use. | |||
ifeq (,$(TOOLCHAIN)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TOOLCHAIN ?= gnu
saves some lines here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought: many build systems use TOOLCHAIN for the actual triple prefix (e.g., arm-none-eabi-). But I can't think of a better name. Opinions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a better name either, and I have not seen the TOOLCHAIN=arch-prefix- usage yet. Is it widespread?
|
||
ifeq (,$(PREFIX)) | ||
# default toolchain prefix, defaults to target triple followed by a dash, you | ||
# will most likely not need to touch this. | ||
export PREFIX ?= $(if $(TARGET_TRIPLE),$(TARGET_TRIPLE)-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ?= and ifeq above are redundant, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, addressed.
Yeah, lets merge and improve later. |
Addressed some comments.
|
I am happy with the current state now. OK to squash again? |
yes! |
1597f7d
to
aae6802
Compare
as an alternative to the default GCC toolchain. export TOOLCHAIN=llvm to build with Clang instead of GCC
aae6802
to
f376bbc
Compare
rebased, squashed, ready |
Travis is green, any ACKs? |
ACK and go. |
cortexm: Add support for building with LLVM/Clang
as an alternative to the default GCC toolchain.
export BUILD_WITH_CLANG=1export CC=clangor
to build with Clang instead of GCC