diff --git a/cross/ti-c6000.txt b/cross/ti-c6000.txt new file mode 100644 index 000000000000..f78cdf596542 --- /dev/null +++ b/cross/ti-c6000.txt @@ -0,0 +1,22 @@ +# Cross file tested on Texas Instruments C6000 compiler (bare metal DSP devices) +# This file assumes that path to the Texas Instruments C6000 toolchain is added +# to the environment(PATH) variable. + +[host_machine] +system = 'bare metal/c6000' +cpu_family = 'c6000' +cpu = 'c64x' +endian = 'little' + +[binaries] +c = 'cl6x' +cpp = 'cl6x' +ar = 'ar6x' +strip = 'strip6x' +nm = 'nm6x' +as = 'asm6x' + +[properties] +needs_exe_wrapper = true +has_function_printf = true +bits = 32 diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md index 4a869ad83c82..b4d7fff4fe98 100644 --- a/docs/markdown/Reference-tables.md +++ b/docs/markdown/Reference-tables.md @@ -37,6 +37,7 @@ These are return values of the `get_id` (Compiler family) and | rustc | Rust compiler | | | sun | Sun Fortran compiler | | | c2000 | Texas Instruments C/C++ Compiler (C2000) | | +| c6000 | Texas Instruments C/C++ Compiler (C6000) | | | ti | Texas Instruments C/C++ Compiler | | | valac | Vala compiler | | | xc16 | Microchip XC16 C compiler | | @@ -70,6 +71,7 @@ These are return values of the `get_linker_id` method in a compiler object. | xc16-ar | The Microchip linker, used with XC16 only | | ar2000 | The Texas Instruments linker, used with C2000 only | | ti-ar | The Texas Instruments linker | +| ar6000 | The Texas Instruments linker, used with C6000 only | | armlink | The ARM linker (arm and armclang compilers) | | pgi | Portland/Nvidia PGI | | nvlink | Nvidia Linker used with cuda | @@ -104,6 +106,7 @@ set in the cross file. | arm | 32 bit ARM processor | | avr | Atmel AVR processor | | c2000 | 32 bit C2000 processor | +| c6000 | 32 bit C6000 processor | | csky | 32 bit CSky processor | | dspic | 16 bit Microchip dsPIC | | e2k | MCST Elbrus processor | diff --git a/docs/markdown/snippets/ti_c6000_compiler_support.md b/docs/markdown/snippets/ti_c6000_compiler_support.md new file mode 100644 index 000000000000..4aa66bf5cfeb --- /dev/null +++ b/docs/markdown/snippets/ti_c6000_compiler_support.md @@ -0,0 +1,4 @@ +## Support for Texas Instruments C6000 C/C++ compiler + +Meson now supports TI C6000 C/C++ compiler used for bare metal C6000 cpu family. +The example of cross file available in `cross/ti-c6000.txt`. diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 09437037a89e..a3bd9890b2c4 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1940,8 +1940,8 @@ def post_init(self) -> None: self.suffix = 'abs' elif ('c' in self.compilers and self.compilers['c'].get_id().startswith('xc16')): self.suffix = 'elf' - elif ('c' in self.compilers and self.compilers['c'].get_id() in {'ti', 'c2000'} or - 'cpp' in self.compilers and self.compilers['cpp'].get_id() in {'ti', 'c2000'}): + elif ('c' in self.compilers and self.compilers['c'].get_id() in {'ti', 'c2000', 'c6000'} or + 'cpp' in self.compilers and self.compilers['cpp'].get_id() in {'ti', 'c2000', 'c6000'}): self.suffix = 'out' elif ('c' in self.compilers and self.compilers['c'].get_id() in {'mwccarm', 'mwcceppc'} or 'cpp' in self.compilers and self.compilers['cpp'].get_id() in {'mwccarm', 'mwcceppc'}): diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 7f9e5844c09a..e598c1e138ea 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -739,6 +739,10 @@ class C2000CCompiler(TICCompiler): # Required for backwards compat with projects created before ti-cgt support existed id = 'c2000' +class C6000CCompiler(TICCompiler): + # Required for backwards compat with projects created before ti-cgt support existed + id = 'c6000' + class MetrowerksCCompilerARM(MetrowerksCompiler, CCompiler): id = 'mwccarm' diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 3e96682621d1..0ba98c56b0f4 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -932,6 +932,10 @@ class C2000CPPCompiler(TICPPCompiler): # Required for backwards compat with projects created before ti-cgt support existed id = 'c2000' +class C6000CPPCompiler(TICPPCompiler): + # Required for backwards compat with projects created before ti-cgt support existed + id = 'c6000' + class MetrowerksCPPCompilerARM(MetrowerksCompiler, CPPCompiler): id = 'mwccarm' diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index 0bfedd13921a..08d8a66e58bf 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -204,7 +204,7 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker if any(os.path.basename(x) in {'lib', 'lib.exe', 'llvm-lib', 'llvm-lib.exe', 'xilib', 'xilib.exe'} for x in linker): arg = '/?' - elif linker_name in {'ar2000', 'ar2000.exe', 'ar430', 'ar430.exe', 'armar', 'armar.exe'}: + elif linker_name in {'ar2000', 'ar2000.exe', 'ar430', 'ar430.exe', 'armar', 'armar.exe', 'ar6x', 'ar6x.exe'}: arg = '?' else: arg = '--version' @@ -237,6 +237,8 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker if 'Texas Instruments Incorporated' in out: if 'ar2000' in linker_name: return linkers.C2000Linker(linker) + elif 'ar6000' in linker_name: + return linkers.C6000Linker(linker) else: return linkers.TILinker(linker) if out.startswith('The CompCert'): @@ -316,7 +318,7 @@ def sanitize(p: str) -> str: arg = '--version' elif 'ccomp' in compiler_name: arg = '-version' - elif compiler_name in {'cl2000', 'cl2000.exe', 'cl430', 'cl430.exe', 'armcl', 'armcl.exe'}: + elif compiler_name in {'cl2000', 'cl2000.exe', 'cl430', 'cl430.exe', 'armcl', 'armcl.exe', 'cl6x', 'cl6x.exe'}: # TI compiler arg = '-version' elif compiler_name in {'icl', 'icl.exe'}: @@ -436,6 +438,24 @@ def sanitize(p: str) -> str: return cls( compiler, version, for_machine, is_cross, info, target, exe_wrap, linker=linker) + + # must be detected here before clang because TI compilers contain 'clang' in their output and so that they can be detected as 'clang' + ti_compilers = { + 'TMS320C2000 C/C++': (c.C2000CCompiler, cpp.C2000CPPCompiler, linkers.C2000DynamicLinker), + 'TMS320C6x C/C++': (c.C6000CCompiler, cpp.C6000CPPCompiler, linkers.C6000DynamicLinker), + 'TI ARM C/C++ Compiler': (c.TICCompiler, cpp.TICPPCompiler, linkers.TIDynamicLinker), + 'MSP430 C/C++': (c.TICCompiler, cpp.TICPPCompiler, linkers.TIDynamicLinker) + } + for indentifier, compiler_classes in ti_compilers.items(): + if indentifier in out: + cls = compiler_classes[0] if lang == 'c' else compiler_classes[1] + lnk = compiler_classes[2] + env.coredata.add_lang_args(cls.language, cls, for_machine, env) + linker = lnk(compiler, for_machine, version=version) + return cls( + ccache, compiler, version, for_machine, is_cross, info, + exe_wrap, full_version=full_version, linker=linker) + if 'clang' in out or 'Clang' in out: linker = None @@ -533,19 +553,6 @@ def sanitize(p: str) -> str: return cls( ccache, compiler, version, for_machine, is_cross, info, exe_wrap, full_version=full_version, linker=l) - if 'TMS320C2000 C/C++' in out or 'MSP430 C/C++' in out or 'TI ARM C/C++ Compiler' in out: - if 'TMS320C2000 C/C++' in out: - cls = c.C2000CCompiler if lang == 'c' else cpp.C2000CPPCompiler - lnk = linkers.C2000DynamicLinker - else: - cls = c.TICCompiler if lang == 'c' else cpp.TICPPCompiler - lnk = linkers.TIDynamicLinker - - env.coredata.add_lang_args(cls.language, cls, for_machine, env) - linker = lnk(compiler, for_machine, version=version) - return cls( - ccache, compiler, version, for_machine, is_cross, info, - exe_wrap, full_version=full_version, linker=linker) if 'ARM' in out and not ('Metrowerks' in out or 'Freescale' in out): cls = c.ArmCCompiler if lang == 'c' else cpp.ArmCPPCompiler env.coredata.add_lang_args(cls.language, cls, for_machine, env) diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 61e671921e6a..fc11fa650b09 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -1065,6 +1065,10 @@ def get_library_naming(self, env: 'Environment', libtype: LibType, strict: bool elif env.machines[self.for_machine].is_cygwin(): shlibext = ['dll', 'dll.a'] prefixes = ['cyg'] + prefixes + elif self.id.lower() == 'c6000': + # TI C6000 compiler can use both extensions for static or dynamic libs. + stlibext = ['a', 'lib'] + shlibext = ['dll', 'so'] else: # Linux/BSDs shlibext = ['so'] diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index 5340521c3a4e..7648bcb70817 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -44,6 +44,7 @@ 'arm', 'avr', 'c2000', + 'c6000', 'csky', 'dspic', 'e2k', diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py index 0c2bf73be77a..3de6c2c3b3e0 100644 --- a/mesonbuild/linkers/linkers.py +++ b/mesonbuild/linkers/linkers.py @@ -501,6 +501,10 @@ class C2000Linker(TILinker): # Required for backwards compat with projects created before ti-cgt support existed id = 'ar2000' +class C6000Linker(TILinker): + # Required for backwards compat with projects created before ti-cgt support existed + id = 'ar6000' + class AIXArLinker(ArLikeLinker, StaticLinker): id = 'aixar' @@ -1099,6 +1103,10 @@ class C2000DynamicLinker(TIDynamicLinker): # Required for backwards compat with projects created before ti-cgt support existed id = 'cl2000' +class C6000DynamicLinker(TIDynamicLinker): + # Required for backwards compat with projects created before ti-cgt support existed + id = 'cl6000' + class ArmDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):