{"record":{"id":"c3358ed760e2e504","repo":"nodejs/node","slug":"missing-libffi-target-header-ffitarget-src","errorCode":null,"errorMessage":"Missing libffi target header: {ffitarget_src}","messagePattern":"Missing libffi target header: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"deps/libffi/generate-headers.py","lineNumber":194,"sourceCode":"        '#endif',\n        '#endif',\n        '',\n        '#endif  /* LIBFFI_FFICONFIG_H_ */',\n        '',\n    ])\n\n    return '\\n'.join(lines)\n\n\ndef generate_headers(output_dir, target_arch, os_name):\n    base_dir = Path(__file__).resolve().parent\n    output_dir = Path(str(output_dir).strip().strip('\"'))\n    output_dir.mkdir(parents=True, exist_ok=True)\n\n    target, target_dir = get_target(os_name, target_arch)\n    ffitarget_src = base_dir / 'src' / target_dir / 'ffitarget.h'\n    if not ffitarget_src.exists():\n        raise FileNotFoundError(f'Missing libffi target header: {ffitarget_src}')\n\n    (output_dir / 'ffi.h').write_text(\n        render_ffi_header(base_dir, os_name, target_arch, target),\n        encoding='utf-8')\n    (output_dir / 'fficonfig.h').write_text(\n        render_fficonfig(os_name, target_arch),\n        encoding='utf-8')\n    (output_dir / 'ffitarget.h').write_text(\n        ffitarget_src.read_text(encoding='utf-8'),\n        encoding='utf-8')\n\n\ndef detect_os_name():\n    if sys.platform.startswith('win'):\n        return 'win'\n    if sys.platform == 'darwin':\n        return 'mac'\n    if sys.platform.startswith('linux'):","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/libffi/generate-headers.py#L176-L212","documentation":"After get_target() returns a (target_define, target_dir) pair, generate_headers() looks for deps/libffi/src/<target_dir>/ffitarget.h and copies it into the output directory. If that specific header file is missing from the source tree, it raises FileNotFoundError before writing any header, so the build fails fast rather than emitting an empty ffitarget.h.","triggerScenarios":"Raised when `ffitarget_src = base_dir / 'src' / target_dir / 'ffitarget.h'` does not exist on disk. target_dir comes from get_target(), so this fires when the directory mapping is known but the header file itself was deleted, not vendored, or sits behind a git-lfs/submodule that wasn't fetched.","commonSituations":"Shallow or partial git checkout of deps/libffi that omitted src/<arch>/; a subtree split or vendor script that dropped architecture-specific headers; a forked libffi that renamed target directories without updating get_target().","solutions":["Run a clean checkout / `git submodule update --init --recursive` for deps/libffi so src/<arch>/ffitarget.h is present.","Verify the target_dir returned by get_target() actually has a directory under deps/libffi/src/.","If the header genuinely isn't shipped for your target, add it upstream or switch to a supported target."],"exampleFix":"# before: shallow checkout missing src/aarch64/ffitarget.h\npython generate-headers.py --output-dir out --target-arch arm64\n# after\ngit -C deps/libffi fetch --unshallow && git -C deps/libffi checkout origin/main -- src/aarch64\npython generate-headers.py --output-dir out --target-arch arm64","handlingStrategy":"validation","validationCode":"from pathlib import Path\nh = Path('deps/libffi/src') / target_dir / 'ffitarget.h'\nassert h.exists(), f'missing ffitarget header {h}; run a full checkout of deps/libffi'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use `git submodule update --init --recursive` (or the project's fetch script) so arch-specific headers are present.","Add a CI step that asserts expected ffitarget.h files exist before building."],"tags":["libffi","build","ffi","missing-file","checkout"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}