add clang-arm support.

This commit is contained in:
guozhanxin 2021-12-22 00:39:08 +08:00 committed by Bernard Xiong
parent f20eef99db
commit a5f6fdc780
7 changed files with 41 additions and 6 deletions

View File

@ -24,7 +24,7 @@ path += [cwd + '/ports']
startup_path_prefix = SDK_LIB startup_path_prefix = SDK_LIB
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc' or rtconfig.CROSS_TOOL == 'clang':
src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/startup_stm32l496xx.s'] src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/startup_stm32l496xx.s']
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/arm/startup_stm32l496xx.s'] src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/arm/startup_stm32l496xx.s']

View File

@ -24,6 +24,9 @@ elif CROSS_TOOL == 'keil':
elif CROSS_TOOL == 'iar': elif CROSS_TOOL == 'iar':
PLATFORM = 'iar' PLATFORM = 'iar'
EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0' EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0'
elif CROSS_TOOL == 'clang':
PLATFORM = 'clang'
EXEC_PATH = r'D:\envs\LLVMEmbeddedToolchainForArm-13.0.0\bin'
if os.getenv('RTT_EXEC_PATH'): if os.getenv('RTT_EXEC_PATH'):
EXEC_PATH = os.getenv('RTT_EXEC_PATH') EXEC_PATH = os.getenv('RTT_EXEC_PATH')
@ -176,6 +179,38 @@ elif PLATFORM == 'iar':
EXEC_PATH = EXEC_PATH + '/arm/bin/' EXEC_PATH = EXEC_PATH + '/arm/bin/'
POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin'
elif PLATFORM == 'clang':
# toolchains
PREFIX = 'llvm-'
CC = 'clang'
AS = 'clang'
AR = PREFIX + 'ar'
CXX = 'clang++'
LINK = 'clang'
TARGET_EXT = 'elf'
SIZE = PREFIX + 'size'
OBJDUMP = PREFIX + 'objdump'
OBJCPY = PREFIX + 'objcopy'
DEVICE = ' --config armv7em_hard_fpv4_sp_d16_nosys'
CFLAGS = DEVICE
AFLAGS = ' -c' + DEVICE + ' -Wa,-mimplicit-it=thumb ' ## -x assembler-with-cpp
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-u,Reset_Handler -T board/linker_scripts/link.lds'
CPATH = ''
LPATH = ''
if BUILD == 'debug':
CFLAGS += ' -O0 -gdwarf-2 -g'
AFLAGS += ' -gdwarf-2'
else:
CFLAGS += ' -O2'
CXXFLAGS = CFLAGS
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
def dist_handle(BSP_ROOT, dist_dir): def dist_handle(BSP_ROOT, dist_dir):
import sys import sys
cwd_path = os.getcwd() cwd_path = os.getcwd()

View File

@ -25,7 +25,7 @@ if GetDepend('RT_USING_SFUD'):
CPPPATH += [cwd + '/sfud/inc'] CPPPATH += [cwd + '/sfud/inc']
if GetDepend('RT_SFUD_USING_SFDP'): if GetDepend('RT_SFUD_USING_SFDP'):
src_device += ['sfud/src/sfud_sfdp.c'] src_device += ['sfud/src/sfud_sfdp.c']
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc' or rtconfig.CROSS_TOOL == 'clang':
LOCAL_CCFLAGS += ' -std=c99' LOCAL_CCFLAGS += ' -std=c99'
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
if rtconfig.PLATFORM == 'armcc': if rtconfig.PLATFORM == 'armcc':

View File

@ -10,6 +10,6 @@ group = []
if GetDepend('RT_USING_LIBC'): if GetDepend('RT_USING_LIBC'):
src += Glob('*.c') src += Glob('*.c')
if rtconfig.PLATFORM != 'gcc' or rtconfig.ARCH == 'sim': if (rtconfig.PLATFORM != 'gcc' and rtconfig.PLATFORM != 'clang') or rtconfig.ARCH == 'sim':
group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH) group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH)
Return('group') Return('group')

View File

@ -7,7 +7,7 @@ group = []
LIBS = ['m'] # link libm LIBS = ['m'] # link libm
CPPPATH = [cwd] CPPPATH = [cwd]
if rtconfig.PLATFORM == 'gcc': if rtconfig.PLATFORM == 'gcc' or rtconfig.PLATFORM == 'clang':
if GetDepend('RT_USING_LIBC'): if GetDepend('RT_USING_LIBC'):
LIBS += ['c'] # link libc LIBS += ['c'] # link libc
src += Glob('*.c') src += Glob('*.c')

View File

@ -14,7 +14,7 @@ if rtconfig.PLATFORM == 'armcc' or rtconfig.PLATFORM == 'armclang':
if rtconfig.PLATFORM == 'armclang': if rtconfig.PLATFORM == 'armclang':
src += Glob('*_rvds.S') src += Glob('*_rvds.S')
if rtconfig.PLATFORM == 'gcc': if rtconfig.PLATFORM == 'gcc' or rtconfig.PLATFORM == 'clang':
src += Glob('*_init.S') src += Glob('*_init.S')
src += Glob('*_gcc.S') src += Glob('*_gcc.S')

View File

@ -121,7 +121,7 @@ class Win32Spawn:
def GenCconfigFile(env, BuildOptions): def GenCconfigFile(env, BuildOptions):
import rtconfig import rtconfig
if rtconfig.PLATFORM == 'gcc': if rtconfig.PLATFORM == 'gcc' or rtconfig.PLATFORM == 'clang':
contents = '' contents = ''
if not os.path.isfile('cconfig.h'): if not os.path.isfile('cconfig.h'):
import gcc import gcc