nodejs/node · error · RuntimeError
Unable to locate a compiler for preprocessing assembly
Error message
Unable to locate a compiler for preprocessing assembly
What it means
preprocess_asm.py needs a C/C++ compiler to run the preprocessor (-E -P) over .S assembly sources before handing them to an assembler. find_compiler() first honors CC then CXX, then falls back to a hard-coded list (cl.exe, clang-cl, cc, clang, gcc); if none resolves to an executable on PATH, it raises RuntimeError.
Source
Thrown at deps/libffi/preprocess_asm.py:33
return None
value = value.strip()
if not value:
return None
return shlex.split(value, posix=(os.name != 'nt'))
def find_compiler():
for var in ('CC', 'CXX'):
command = split_command(os.environ.get(var))
if command and shutil.which(command[0]):
return command
for name in ('cl.exe', 'cl', 'clang-cl.exe', 'clang-cl', 'cc', 'clang', 'gcc'):
path = shutil.which(name)
if path:
return [path]
raise RuntimeError('Unable to locate a compiler for preprocessing assembly')
def find_armasm64():
"""Find armasm64.exe in the PATH or common Visual Studio locations."""
# First check PATH
path = shutil.which('armasm64.exe')
if path:
return path
# Check common VS locations via environment
vc_install_dir = os.environ.get('VCINSTALLDIR', '')
if vc_install_dir:
candidate = os.path.join(vc_install_dir, 'bin', 'Hostx64', 'arm64', 'armasm64.exe')
if os.path.exists(candidate):
return candidate
candidate = os.path.join(vc_install_dir, 'bin', 'Hostarm64', 'arm64', 'armasm64.exe')
if os.path.exists(candidate):
return candidateView on GitHub (pinned to 1b2de5e052)
Solutions
- Export CC (or CXX) pointing at your compiler, e.g. `export CC=clang`.
- Ensure the compiler is on PATH (run vcvarsall.bat / activate the toolchain on Windows; install build-essential/clang on Linux).
- If shelling out from a build system, propagate the same CC it uses to this script's environment.
Example fix
# before: empty toolchain env python preprocess_asm.py --input src/aarch64/sysv.S --output out.s # after export CC=clang python preprocess_asm.py --input src/aarch64/sysv.S --output out.s
Defensive patterns
Strategy: validation
Validate before calling
import os, shutil
cc = os.environ.get('CC') or next((c for c in ('cl.exe','clang-cl.exe','cc','clang','gcc') if shutil.which(c)), None)
assert cc and shutil.which(cc.split()[0]), 'no compiler on PATH; export CC=...' Try / catch
try:
compiler = find_compiler()
except RuntimeError:
raise SystemExit('Install a C/C++ compiler or set CC/CXX before building libffi asm') Prevention
- Always export CC (and CXX) in build scripts so the toolchain is explicit.
- Validate the compiler in CI before invoking libffi's header/asm generators.
When it happens
Trigger: Raised when split_command(os.environ.get('CC'))/CXX don't yield a program that shutil.which() can find, AND none of cl.exe/cl/clang-cl.exe/clang-cl/cc/clang/gcc are on PATH.
Common situations: Minimal build containers without a compiler installed; PATH not inheriting the active compiler toolchain (common on Windows where CC isn't set and cl.exe lives behind a vcvarsall shell); CI images that install the compiler into a non-PATH location; cross-compile envs that forgot to export CC for the host.
Related errors
- Unable to locate armasm64.exe
- Preprocessing failed: {command}
- Unsupported libffi target {os_name}/{target_arch}.
- Missing libffi target header: {ffitarget_src}
- Unsupported host platform {sys.platform!r}
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/15217d811fb4c13d.
Report an issue: GitHub.