Adding experimental clang compiler support for arm-none-eabi
- Currently builds larger binaries than gcc (RAM)
This commit is contained in:
parent
f5a1e1bcf5
commit
621d8736e7
@ -28,6 +28,20 @@ set( CHIP
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
# Compiler Selection
|
||||||
|
#
|
||||||
|
|
||||||
|
#| *** EXPERIMENTAL ***
|
||||||
|
#| Stick with gcc unless you know what you're doing
|
||||||
|
#| Currently only arm is supported with clang
|
||||||
|
set( COMPILER
|
||||||
|
"gcc" # arm-none-eabi-gcc / avr-gcc - Default
|
||||||
|
# "clang" # arm-none-eabi
|
||||||
|
CACHE STRING "Compiler Type" )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Compiler Intialization
|
# Compiler Intialization
|
||||||
#
|
#
|
||||||
|
@ -13,9 +13,20 @@
|
|||||||
|
|
||||||
#| Set the Compilers (must be set first)
|
#| Set the Compilers (must be set first)
|
||||||
include( CMakeForceCompiler )
|
include( CMakeForceCompiler )
|
||||||
cmake_force_c_compiler ( arm-none-eabi-gcc ARMCCompiler )
|
message( STATUS "Compiler Selected:" )
|
||||||
cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler )
|
if ( "${COMPILER}" MATCHES "gcc" )
|
||||||
set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
|
cmake_force_c_compiler ( arm-none-eabi-gcc ARMCCompiler )
|
||||||
|
cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler )
|
||||||
|
set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
|
||||||
|
message( "gcc" )
|
||||||
|
elseif ( "${COMPILER}" MATCHES "clang" )
|
||||||
|
cmake_force_c_compiler ( clang ARMCCompiler )
|
||||||
|
cmake_force_cxx_compiler( clang++ ARMCxxCompiler )
|
||||||
|
set( _CMAKE_TOOLCHAIN_PREFIX llvm- )
|
||||||
|
message( "clang" )
|
||||||
|
else ()
|
||||||
|
message( AUTHOR_WARNING "COMPILER: ${COMPILER} - Unknown compiler selection" )
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -134,6 +145,8 @@ set( WARN "-Wall -ggdb3" )
|
|||||||
if( BOOTLOADER )
|
if( BOOTLOADER )
|
||||||
set( TUNING "-D_bootloader_ -Wno-main -msoft-float -mthumb -fplan9-extensions -ffunction-sections -fdata-sections -fno-builtin -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -nostdlib" )
|
set( TUNING "-D_bootloader_ -Wno-main -msoft-float -mthumb -fplan9-extensions -ffunction-sections -fdata-sections -fno-builtin -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -nostdlib" )
|
||||||
#set( TUNING "-mthumb -fdata-sections -ffunction-sections -fno-builtin -msoft-float -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -fwhole-program -Wno-main -nostartfiles -fplan9-extensions -D_bootloader_" )
|
#set( TUNING "-mthumb -fdata-sections -ffunction-sections -fno-builtin -msoft-float -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -fwhole-program -Wno-main -nostartfiles -fplan9-extensions -D_bootloader_" )
|
||||||
|
elseif ( "${COMPILER}" MATCHES "clang" )
|
||||||
|
set( TUNING "-target arm-none-eabi -mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin" )
|
||||||
else()
|
else()
|
||||||
set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin -nostartfiles" )
|
set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin -nostartfiles" )
|
||||||
endif()
|
endif()
|
||||||
@ -181,5 +194,9 @@ set( BIN_FLAGS -O binary )
|
|||||||
|
|
||||||
|
|
||||||
#| Lss Flags
|
#| Lss Flags
|
||||||
set( LSS_FLAGS -h -S -z )
|
if ( "${COMPILER}" MATCHES "clang" )
|
||||||
|
set( LSS_FLAGS -section-headers -triple=arm-none-eabi )
|
||||||
|
else ()
|
||||||
|
set( LSS_FLAGS -h -S -z )
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
@ -33,22 +33,33 @@ set_target_properties( ${TARGET_ELF} PROPERTIES
|
|||||||
SUFFIX "" # XXX Force Windows to keep the .exe off
|
SUFFIX "" # XXX Force Windows to keep the .exe off
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#| llvm-clang does not have an objcopy equivalent
|
||||||
|
if ( "${COMPILER}" MATCHES "clang" )
|
||||||
|
if ( "${COMPILER_FAMILY}" MATCHES "arm" )
|
||||||
|
set ( OBJ_COPY arm-none-eabi-objcopy )
|
||||||
|
elseif ( "${COMPILER_FAMILY}" MATCHES "arm" )
|
||||||
|
set ( OBJ_COPY avr-objcopy )
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
set ( OBJ_COPY ${CMAKE_OBJCOPY} )
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
#| Convert the .ELF into a .bin to load onto the McHCK
|
#| Convert the .ELF into a .bin to load onto the McHCK
|
||||||
if( DEFINED DFU )
|
if ( DEFINED DFU )
|
||||||
set( TARGET_BIN ${TARGET}.dfu.bin )
|
set( TARGET_BIN ${TARGET}.dfu.bin )
|
||||||
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
||||||
COMMAND ${CMAKE_OBJCOPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
|
COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
|
||||||
COMMENT "Creating dfu binary file: ${TARGET_BIN}"
|
COMMENT "Creating dfu binary file: ${TARGET_BIN}"
|
||||||
)
|
)
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
#| Convert the .ELF into a .HEX to load onto the Teensy
|
#| Convert the .ELF into a .HEX to load onto the Teensy
|
||||||
if ( DEFINED TEENSY )
|
if ( DEFINED TEENSY )
|
||||||
set( TARGET_HEX ${TARGET}.teensy.hex )
|
set( TARGET_HEX ${TARGET}.teensy.hex )
|
||||||
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
||||||
COMMAND ${CMAKE_OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
|
COMMAND ${OBJ_COPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
|
||||||
COMMENT "Creating iHex file to load: ${TARGET_HEX}"
|
COMMENT "Creating iHex file to load: ${TARGET_HEX}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
Reference in New Issue
Block a user