NationalSecurityAgency/ghidra · error · Exception
Toolchain type %(toolchain_type)s not known
Error message
Toolchain type %(toolchain_type)s not known
What it means
Raised by PCodeTestBuild.factory() in pcodetest.py when config.toolchain_type is not one of the recognized values ('gcc','ccs','sdcc','llvm'). The factory dispatches on toolchain_type to pick the right compiler wrapper; an unknown value means no build strategy exists. The message is produced via config.format() so %(toolchain_type)s is interpolated with the offending value.
Source
Thrown at Ghidra/Extensions/SleighDevTools/pcodetest/pcodetest.py:81
class PCodeTestBuild(BuildUtil):
def __init__(self, pcode_test):
super(PCodeTestBuild, self).__init__()
self.config = Config(pcode_test.config)
self.config.cwd = self.getcwd()
@classmethod
def factory(cls, pcode_test):
if pcode_test.config.toolchain_type == 'gcc':
return PCodeBuildGCC(pcode_test)
elif pcode_test.config.toolchain_type == 'ccs':
return PCodeBuildCCS(pcode_test)
elif pcode_test.config.toolchain_type == 'sdcc':
return PCodeBuildSDCC(pcode_test)
elif pcode_test.config.toolchain_type == 'llvm':
return PCodeBuildLLVM(pcode_test)
else:
raise Exception(pcode_test.config.format('Toolchain type %(toolchain_type)s not known'))
def which(self, what):
return self.config.format('%(toolchain_dir)s/%(' + what + ')s')
def compile(self, input_files, opt_cflag, output_base):
self.log_err(self.config.format('compile not implemented for %(toolchain_type)s'))
# generic build a single PCodeTest for all variants
def main(self):
# make sure compiler exists and runnable
self.config.compile_exe = self.config.exec_dir + self.config.exec_prefix + self.config.compile_exe
self.config.strip_exe = self.config.exec_dir + str(self.config.exec_prefix) + str(self.config.strip_exe)
self.config.objdump_exe = self.config.exec_dir + str(self.config.exec_prefix) + str(self.config.objdump_exe)
self.config.readelf_exe = self.config.exec_dir + str(self.config.exec_prefix) + str(self.config.readelf_exe)
self.config.nm_exe = self.config.exec_dir + str(self.config.exec_prefix) + str(self.config.nm_exe)
if not self.is_executable_file(self.which('compile_exe')):View on GitHub (pinned to d5f144c24d)
Solutions
- Set toolchain_type to one of 'gcc', 'ccs', 'sdcc', 'llvm' (lowercase, exact).
- If you genuinely need a new toolchain, add a PCodeBuild subclass and a factory branch for it before using the type.
- Check the test config file (the descriptor feeding pcode_test.config) for the typo and re-run.
Example fix
# before toolchain_type: GCC # case mismatch -> raises # after toolchain_type: gcc
Defensive patterns
Strategy: validation
Validate before calling
KNOWN = {'gcc', 'ccs', 'sdcc', 'llvm'}
tt = pcode_test.config.toolchain_type
if tt not in KNOWN:
raise ValueError(f"unsupported toolchain_type {tt!r}; must be one of {sorted(KNOWN)}")
PCodeTestBuild.factory(pcode_test) Type guard
def is_known_toolchain(tt: str) -> bool:
return tt in {'gcc', 'ccs', 'sdcc', 'llvm'} Try / catch
try:
builder = PCodeTestBuild.factory(pcode_test)
except Exception as e:
if 'Toolchain type' in str(e):
# fix toolchain_type in the test descriptor and re-run
pass
else:
raise Prevention
- Use lowercase exact values 'gcc','ccs','sdcc','llvm' for toolchain_type.
- Validate toolchain_type against the known set in your test descriptor schema.
- Extend the factory (add a subclass + branch) before introducing a new type.
When it happens
Trigger: PCodeTestBuild.factory(pcode_test) where pcode_test.config.toolchain_type is misspelled (e.g. 'GCC', 'clang', 'arm-gcc') or unset; a test config (.pspec/.cfg) declares an unsupported toolchain.
Common situations: Adding a new target whose toolchain_type doesn't match the four known strings; typo in the YAML/JSON test descriptor; case mismatch ('GCC' vs 'gcc'); a toolchain type the build harness was never extended to support.
Related errors
- Invalid number of elements specified: {}
- pos cannot be less than zero
- %s: unknown demangling style `%s'
- Max ascii string size is %d you provided: %lu chars. Exiting
- need even-number of ascii chars for byte-stream: (offset: %0
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/2f94f51aabafd71b.
Report an issue: GitHub.