{"record":{"id":"3e8fca662b945619","repo":"nodejs/node","slug":"preprocessing-failed-command","errorCode":null,"errorMessage":"Preprocessing failed: {command}","messagePattern":"Preprocessing failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"deps/libffi/preprocess_asm.py","lineNumber":94,"sourceCode":"    include_dirs.append(str(output.parent))\n    include_dirs = unique_paths(include_dirs)\n    output.parent.mkdir(parents=True, exist_ok=True)\n\n    if os.name == 'nt' and Path(compiler[0]).name.lower() in ('cl.exe', 'cl', 'clang-cl.exe', 'clang-cl'):\n        command = compiler + ['/nologo', '/EP', '/TC']\n        command += [f'/I{include_dir}' for include_dir in include_dirs]\n        command += [f'/D{define}' for define in args.define]\n        command += [input_path]\n    else:\n        command = compiler + ['-E', '-P', '-x', 'c']\n        command += [f'-I{include_dir}' for include_dir in include_dirs]\n        command += [f'-D{define}' for define in args.define]\n        command += [input_path]\n\n    result = subprocess.run(command, capture_output=True, text=True)\n    if result.returncode != 0:\n        sys.stderr.write(result.stderr)\n        raise RuntimeError(f'Preprocessing failed: {\" \".join(command)}')\n\n    # Strip all preprocessor directives that assemblers can't handle\n    # (e.g., armasm64.exe doesn't accept any # directives)\n    # Remove lines starting with # (preprocessor output like #line, # 1 \"file\", etc.)\n    lines = result.stdout.splitlines(keepends=True)\n    cleaned_lines = [line for line in lines if not line.lstrip().startswith('#')]\n    cleaned = ''.join(cleaned_lines)\n\n    output.write_text(cleaned, encoding='utf-8')\n\n    # If --assemble is specified, also run the assembler to produce an object file\n    if args.assemble:\n        assemble_output = Path(normalize_path(args.assemble))\n        assemble_output.parent.mkdir(parents=True, exist_ok=True)\n\n        armasm64 = find_armasm64()\n        asm_command = [armasm64, '-nologo', '-g', str(output), '-o', str(assemble_output)]\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/libffi/preprocess_asm.py#L76-L112","documentation":"preprocess_asm.py shells out to the located compiler (cl / clang / gcc) with -E -P (or MSVC equivalents) plus -I and -D flags to expand macros in an assembly source. If the compiler exits non-zero it dumps stderr and raises RuntimeError with the full command, because silently using partial preprocessor output would produce broken assembly.","triggerScenarios":"Raised when `subprocess.run(command, capture_output=True, text=True).returncode != 0` for the preprocessor invocation in preprocess(). The command is compiler + flags + input file.","commonSituations":"Missing #include the preprocessor can't find (include path not passed via --include-dir); a macro referenced by the .S file not defined via --define; wrong compiler for the syntax (gcc fed MSVC-flavored asm); corrupted/truncated source file; compiler crash.","solutions":["Read the stderr the script already printed — the real compiler error is there, not in the exception text.","Add the missing include directory with another --include-dir, or the missing macro with --define.","Make sure the compiler you resolved (CC/CXX) actually understands the source's preprocessor syntax."],"exampleFix":"# before\npython preprocess_asm.py --input src.S --output out.s\n# after (missing include + macro)\npython preprocess_asm.py --input src.S --output out.s --include-dir include --define HAVE_FFI_MMAP","handlingStrategy":"try-catch","validationCode":"result = subprocess.run(command, capture_output=True, text=True)\nif result.returncode != 0:\n    raise SystemExit(f'preprocessor failed:\\n{result.stderr}')","typeGuard":null,"tryCatchPattern":"try:\n    preprocess(args)\nexcept RuntimeError as e:\n    # the offending command is embedded in the message; compiler detail was already on stderr\n    raise SystemExit(f'libffi preprocess failed: {e}') from None","preventionTips":["Always pass the full --include-dir set the .S file's #includes need.","Define every macro the assembly references via --define before assembling."],"tags":["libffi","build","ffi","preprocessor","subprocess","compiler"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}