Skip to content

Commit eb74bb8

Browse files
PetrMachacek2Njpakkane
authored andcommitted
Added support for Texas Instruments C6000 compiler.
1 parent 7399be4 commit eb74bb8

File tree

10 files changed

+72
-16
lines changed

10 files changed

+72
-16
lines changed

cross/ti-c6000.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Cross file tested on Texas Instruments C6000 compiler (bare metal DSP devices)
2+
# This file assumes that path to the Texas Instruments C6000 toolchain is added
3+
# to the environment(PATH) variable.
4+
5+
[host_machine]
6+
system = 'c6000'
7+
cpu_family = 'c6000'
8+
cpu = 'c64x'
9+
endian = 'little'
10+
11+
[binaries]
12+
c = 'cl6x'
13+
cpp = 'cl6x'
14+
ar = 'ar6x'
15+
strip = 'strip6x'
16+
nm = 'nm6x'
17+
as = 'asm6x'
18+
19+
[properties]
20+
needs_exe_wrapper = true
21+
has_function_printf = true
22+
bits = 32

docs/markdown/Reference-tables.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ These are return values of the `get_id` (Compiler family) and
3737
| rustc | Rust compiler | |
3838
| sun | Sun Fortran compiler | |
3939
| c2000 | Texas Instruments C/C++ Compiler (C2000) | |
40+
| c6000 | Texas Instruments C/C++ Compiler (C6000) | |
4041
| ti | Texas Instruments C/C++ Compiler | |
4142
| valac | Vala compiler | |
4243
| xc16 | Microchip XC16 C compiler | |
@@ -70,6 +71,7 @@ These are return values of the `get_linker_id` method in a compiler object.
7071
| xc16-ar | The Microchip linker, used with XC16 only |
7172
| ar2000 | The Texas Instruments linker, used with C2000 only |
7273
| ti-ar | The Texas Instruments linker |
74+
| ar6000 | The Texas Instruments linker, used with C6000 only |
7375
| armlink | The ARM linker (arm and armclang compilers) |
7476
| pgi | Portland/Nvidia PGI |
7577
| nvlink | Nvidia Linker used with cuda |
@@ -105,6 +107,7 @@ set in the cross file.
105107
| arm | 32 bit ARM processor |
106108
| avr | Atmel AVR processor |
107109
| c2000 | 32 bit C2000 processor |
110+
| c6000 | 32 bit C6000 processor |
108111
| csky | 32 bit CSky processor |
109112
| dspic | 16 bit Microchip dsPIC |
110113
| e2k | MCST Elbrus processor |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Support for Texas Instruments C6000 C/C++ compiler
2+
3+
Meson now supports the TI C6000 C/C++ compiler use for the C6000 cpu family.
4+
The example cross file is available in `cross/ti-c6000.txt`.

mesonbuild/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,8 +1976,8 @@ def post_init(self) -> None:
19761976
self.suffix = 'abs'
19771977
elif ('c' in self.compilers and self.compilers['c'].get_id().startswith('xc16')):
19781978
self.suffix = 'elf'
1979-
elif ('c' in self.compilers and self.compilers['c'].get_id() in {'ti', 'c2000'} or
1980-
'cpp' in self.compilers and self.compilers['cpp'].get_id() in {'ti', 'c2000'}):
1979+
elif ('c' in self.compilers and self.compilers['c'].get_id() in {'ti', 'c2000', 'c6000'} or
1980+
'cpp' in self.compilers and self.compilers['cpp'].get_id() in {'ti', 'c2000', 'c6000'}):
19811981
self.suffix = 'out'
19821982
elif ('c' in self.compilers and self.compilers['c'].get_id() in {'mwccarm', 'mwcceppc'} or
19831983
'cpp' in self.compilers and self.compilers['cpp'].get_id() in {'mwccarm', 'mwcceppc'}):

mesonbuild/compilers/c.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,9 @@ class C2000CCompiler(TICCompiler):
735735
# Required for backwards compat with projects created before ti-cgt support existed
736736
id = 'c2000'
737737

738+
class C6000CCompiler(TICCompiler):
739+
id = 'c6000'
740+
738741
class MetrowerksCCompilerARM(MetrowerksCompiler, CCompiler):
739742
id = 'mwccarm'
740743

mesonbuild/compilers/cpp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,9 @@ class C2000CPPCompiler(TICPPCompiler):
960960
# Required for backwards compat with projects created before ti-cgt support existed
961961
id = 'c2000'
962962

963+
class C6000CPPCompiler(TICPPCompiler):
964+
id = 'c6000'
965+
963966
class MetrowerksCPPCompilerARM(MetrowerksCompiler, CPPCompiler):
964967
id = 'mwccarm'
965968

mesonbuild/compilers/detect.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker
198198

199199
if any(os.path.basename(x) in {'lib', 'lib.exe', 'llvm-lib', 'llvm-lib.exe', 'xilib', 'xilib.exe'} for x in linker):
200200
arg = '/?'
201+
elif linker_name in {'ar2000', 'ar2000.exe', 'ar430', 'ar430.exe', 'armar', 'armar.exe', 'ar6x', 'ar6x.exe'}:
202+
arg = '?'
201203
else:
202204
arg = '--version'
203205
try:
@@ -231,6 +233,9 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker
231233
return linkers.C2000Linker(linker)
232234
else:
233235
return linkers.TILinker(linker)
236+
if 'Texas Instruments Incorporated' in out:
237+
if 'ar6000' in linker_name:
238+
return linkers.C6000Linker(linker)
234239
if out.startswith('The CompCert'):
235240
return linkers.CompCertLinker(linker)
236241
if out.strip().startswith('Metrowerks') or out.strip().startswith('Freescale'):
@@ -308,7 +313,7 @@ def sanitize(p: str) -> str:
308313
arg = '--version'
309314
elif 'ccomp' in compiler_name:
310315
arg = '-version'
311-
elif compiler_name in {'cl2000', 'cl2000.exe', 'cl430', 'cl430.exe', 'armcl', 'armcl.exe'}:
316+
elif compiler_name in {'cl2000', 'cl2000.exe', 'cl430', 'cl430.exe', 'armcl', 'armcl.exe', 'cl6x', 'cl6x.exe'}:
312317
# TI compiler
313318
arg = '-version'
314319
elif compiler_name in {'icl', 'icl.exe'}:
@@ -428,6 +433,24 @@ def sanitize(p: str) -> str:
428433
return cls(
429434
compiler, version, for_machine, is_cross, info, target,
430435
exe_wrap, linker=linker)
436+
437+
# must be detected here before clang because TI compilers contain 'clang' in their output and so that they can be detected as 'clang'
438+
ti_compilers = {
439+
'TMS320C2000 C/C++': (c.C2000CCompiler, cpp.C2000CPPCompiler, linkers.C2000DynamicLinker),
440+
'TMS320C6x C/C++': (c.C6000CCompiler, cpp.C6000CPPCompiler, linkers.C6000DynamicLinker),
441+
'TI ARM C/C++ Compiler': (c.TICCompiler, cpp.TICPPCompiler, linkers.TIDynamicLinker),
442+
'MSP430 C/C++': (c.TICCompiler, cpp.TICPPCompiler, linkers.TIDynamicLinker)
443+
}
444+
for indentifier, compiler_classes in ti_compilers.items():
445+
if indentifier in out:
446+
cls = compiler_classes[0] if lang == 'c' else compiler_classes[1]
447+
lnk = compiler_classes[2]
448+
env.coredata.add_lang_args(cls.language, cls, for_machine, env)
449+
linker = lnk(compiler, for_machine, version=version)
450+
return cls(
451+
ccache, compiler, version, for_machine, is_cross, info,
452+
exe_wrap, full_version=full_version, linker=linker)
453+
431454
if 'clang' in out or 'Clang' in out:
432455
linker = None
433456

@@ -525,19 +548,6 @@ def sanitize(p: str) -> str:
525548
return cls(
526549
ccache, compiler, version, for_machine, is_cross, info,
527550
exe_wrap, full_version=full_version, linker=l)
528-
if 'TMS320C2000 C/C++' in out or 'MSP430 C/C++' in out or 'TI ARM C/C++ Compiler' in out:
529-
if 'TMS320C2000 C/C++' in out:
530-
cls = c.C2000CCompiler if lang == 'c' else cpp.C2000CPPCompiler
531-
lnk = linkers.C2000DynamicLinker
532-
else:
533-
cls = c.TICCompiler if lang == 'c' else cpp.TICPPCompiler
534-
lnk = linkers.TIDynamicLinker
535-
536-
env.coredata.add_lang_args(cls.language, cls, for_machine, env)
537-
linker = lnk(compiler, for_machine, version=version)
538-
return cls(
539-
ccache, compiler, version, for_machine, is_cross, info,
540-
exe_wrap, full_version=full_version, linker=linker)
541551
if 'ARM' in out and not ('Metrowerks' in out or 'Freescale' in out):
542552
cls = c.ArmCCompiler if lang == 'c' else cpp.ArmCPPCompiler
543553
env.coredata.add_lang_args(cls.language, cls, for_machine, env)

mesonbuild/compilers/mixins/clike.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,10 @@ def get_library_naming(self, env: 'Environment', libtype: LibType, strict: bool
10521052
elif env.machines[self.for_machine].is_cygwin():
10531053
shlibext = ['dll', 'dll.a']
10541054
prefixes = ['cyg'] + prefixes
1055+
elif self.id.lower() == 'c6000' or self.id.lower() == 'ti':
1056+
# TI C6000 compiler can use both extensions for static or dynamic libs.
1057+
stlibext = ['a', 'lib']
1058+
shlibext = ['dll', 'so']
10551059
else:
10561060
# Linux/BSDs
10571061
shlibext = ['so']

mesonbuild/envconfig.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'arm',
3535
'avr',
3636
'c2000',
37+
'c6000',
3738
'csky',
3839
'dspic',
3940
'e2k',

mesonbuild/linkers/linkers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,9 @@ class C2000Linker(TILinker):
492492
# Required for backwards compat with projects created before ti-cgt support existed
493493
id = 'ar2000'
494494

495+
class C6000Linker(TILinker):
496+
id = 'ar6000'
497+
495498

496499
class AIXArLinker(ArLikeLinker, StaticLinker):
497500
id = 'aixar'
@@ -1094,6 +1097,9 @@ class C2000DynamicLinker(TIDynamicLinker):
10941097
# Required for backwards compat with projects created before ti-cgt support existed
10951098
id = 'cl2000'
10961099

1100+
class C6000DynamicLinker(TIDynamicLinker):
1101+
id = 'cl6000'
1102+
10971103

10981104
class ArmDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
10991105

0 commit comments

Comments
 (0)