{"record":{"id":"15217d811fb4c13d","repo":"nodejs/node","slug":"unable-to-locate-a-compiler-for-preprocessing-asse","errorCode":null,"errorMessage":"Unable to locate a compiler for preprocessing assembly","messagePattern":"Unable to locate a compiler for preprocessing assembly","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"deps/libffi/preprocess_asm.py","lineNumber":33,"sourceCode":"        return None\n    value = value.strip()\n    if not value:\n        return None\n    return shlex.split(value, posix=(os.name != 'nt'))\n\n\ndef find_compiler():\n    for var in ('CC', 'CXX'):\n        command = split_command(os.environ.get(var))\n        if command and shutil.which(command[0]):\n            return command\n\n    for name in ('cl.exe', 'cl', 'clang-cl.exe', 'clang-cl', 'cc', 'clang', 'gcc'):\n        path = shutil.which(name)\n        if path:\n            return [path]\n\n    raise RuntimeError('Unable to locate a compiler for preprocessing assembly')\n\n\ndef find_armasm64():\n    \"\"\"Find armasm64.exe in the PATH or common Visual Studio locations.\"\"\"\n    # First check PATH\n    path = shutil.which('armasm64.exe')\n    if path:\n        return path\n\n    # Check common VS locations via environment\n    vc_install_dir = os.environ.get('VCINSTALLDIR', '')\n    if vc_install_dir:\n        candidate = os.path.join(vc_install_dir, 'bin', 'Hostx64', 'arm64', 'armasm64.exe')\n        if os.path.exists(candidate):\n            return candidate\n        candidate = os.path.join(vc_install_dir, 'bin', 'Hostarm64', 'arm64', 'armasm64.exe')\n        if os.path.exists(candidate):\n            return candidate","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/libffi/preprocess_asm.py#L15-L51","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before: empty toolchain env\npython preprocess_asm.py --input src/aarch64/sysv.S --output out.s\n# after\nexport CC=clang\npython preprocess_asm.py --input src/aarch64/sysv.S --output out.s","handlingStrategy":"validation","validationCode":"import os, shutil\ncc = os.environ.get('CC') or next((c for c in ('cl.exe','clang-cl.exe','cc','clang','gcc') if shutil.which(c)), None)\nassert cc and shutil.which(cc.split()[0]), 'no compiler on PATH; export CC=...'","typeGuard":null,"tryCatchPattern":"try:\n    compiler = find_compiler()\nexcept RuntimeError:\n    raise SystemExit('Install a C/C++ compiler or set CC/CXX before building libffi asm')","preventionTips":["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."],"tags":["libffi","build","ffi","compiler","toolchain","environment"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}