{"record":{"id":"96b8ca95052f084a","repo":"nodejs/node","slug":"assembly-failed-asm-command","errorCode":null,"errorMessage":"Assembly failed: {asm_command}","messagePattern":"Assembly failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"deps/libffi/preprocess_asm.py","lineNumber":117,"sourceCode":"    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\n        asm_result = subprocess.run(asm_command, capture_output=True, text=True)\n        if asm_result.returncode != 0:\n            sys.stderr.write(asm_result.stderr)\n            sys.stderr.write(asm_result.stdout)\n            raise RuntimeError(f'Assembly failed: {\" \".join(asm_command)}')\n\n\ndef main(argv=None):\n    parser = argparse.ArgumentParser(description='Preprocess libffi assembly source')\n    parser.add_argument('--input', required=True)\n    parser.add_argument('--output', required=True)\n    parser.add_argument('--include-dir', action='append', default=[])\n    parser.add_argument('--define', action='append', default=[])\n    parser.add_argument('--assemble', help='Also assemble the output to this object file')\n    args = parser.parse_args(argv)\n\n    preprocess(args)\n    return 0\n\n\nif __name__ == '__main__':\n    raise SystemExit(main())\n","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/libffi/preprocess_asm.py#L99-L135","documentation":"After preprocessing, if --assemble was requested, preprocess_asm.py invokes armasm64.exe to turn the cleaned .s text into a .obj. If armasm64 exits non-zero the script logs both stderr and stdout and raises RuntimeError with the assembler command, rather than writing a half-assembled object file.","triggerScenarios":"Raised when `subprocess.run(asm_command, ...).returncode != 0` in the `if args.assemble:` branch. asm_command is [armasm64, '-nologo', '-g', <preprocessed file>, '-o', <object file>].","commonSituations":"Preprocessor left a directive armasm64 can't parse (stripping of '#' lines was incomplete); ARM syntax the toolchain version doesn't accept; wrong ARM toolchain major version; source file targets a different ARM ISA than the installed armasm64.","solutions":["Inspect the armasm64 stderr/stdout the script already wrote to find the offending line/instruction.","Verify the preprocessed output (the --output file) is clean ARM assembly with no stray C directives.","Match the armasm64 version to the ARM ISA the source targets (e.g. ARMv8.3 vs v8.0)."],"exampleFix":"# before: preprocessed output still has stray # line markers\npython preprocess_asm.py --input src.S --output out.s --assemble out.obj\n# after: regenerate clean preprocessed file, then assemble\npython preprocess_asm.py --input src.S --output out.s --include-dir include --assemble out.obj","handlingStrategy":"try-catch","validationCode":"asm_result = subprocess.run(asm_command, capture_output=True, text=True)\nif asm_result.returncode != 0:\n    raise SystemExit(f'armasm64 failed:\\n{asm_result.stderr}{asm_result.stdout}')","typeGuard":null,"tryCatchPattern":"try:\n    preprocess(args)\nexcept RuntimeError as e:\n    raise SystemExit(f'libffi assembly failed: {e}') from None","preventionTips":["Inspect the cleaned preprocessed output before assembling to catch stray directives.","Pin the MSVC/armasm64 version to one matching the source's ARM ISA target."],"tags":["libffi","build","ffi","arm64","assembler","windows","subprocess"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}