{"record":{"id":"feb77e71c8fb18d3","repo":"rust-lang/rust","slug":"build-id-not-found-for-binary-binary","errorCode":null,"errorMessage":"Build ID not found for binary {binary}","messagePattern":"Build ID not found for binary (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/ci/docker/scripts/fuchsia-test-runner.py","lineNumber":228,"sourceCode":"            e.add_note(\n                f'Failed to read \"NoteSections\" from llvm-readelf for binary {binary}'\n            )\n            e.add_note(f\"elf_output: {elf_output}\")\n            raise\n\n        for entry in note_sections:\n            try:\n                note_section = entry[\"NoteSection\"]\n                if note_section[\"Name\"] == \".note.gnu.build-id\":\n                    return note_section[\"Notes\"][0][\"Build ID\"]\n            except Exception as e:\n                e.add_note(\n                    f'Failed to read \".note.gnu.build-id\" from NoteSections \\\n                        entry in llvm-readelf for binary {binary}'\n                )\n                e.add_note(f\"NoteSections: {note_sections}\")\n                raise\n        raise Exception(f\"Build ID not found for binary {binary}\")\n\n    def generate_buildid_dir(\n        self,\n        binary: Path,\n        build_id_dir: Path,\n        build_id: str,\n        log_handler: logging.Logger,\n    ):\n        os.makedirs(build_id_dir, exist_ok=True)\n        suffix = \".debug\"\n        # Hardlink the original binary\n        build_id_prefix_dir = build_id_dir.joinpath(build_id[:2])\n        unstripped_binary = build_id_prefix_dir.joinpath(build_id[2:] + suffix)\n        build_id_prefix_dir.mkdir(parents=True, exist_ok=True)\n        atomic_link(unstripped_binary, binary)\n        assert unstripped_binary.exists()\n        stripped_binary = unstripped_binary.with_suffix(\"\")\n        llvm_objcopy = Path(self.toolchain_dir).joinpath(\"bin\", \"llvm-objcopy\")","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/ci/docker/scripts/fuchsia-test-runner.py#L210-L246","documentation":"Raised by TestEnvironment.build_id() after llvm-readelf succeeded and returned JSON, but none of the NoteSections entries had Name == '.note.gnu.build-id'. The build-id is mandatory because it becomes part of the Fuchsia package name and the .build-id directory layout used by the debugger. Its absence means the binary was linked without a build-id note.","triggerScenarios":"TestEnvironment.build_id(binary) is called (via 'run' at fuchsia-test-runner.py:696) and the loop at lines 216-227 completes without returning because every entry's NoteSection.Name is something other than .note.gnu.build-id, or the Notes array is empty.","commonSituations":"The Rust target spec or linker flags for Fuchsia dropped -Wl,--build-id; a custom RUSTFLAGS override stripped build-id generation; the binary is a stub/wrapper rather than the real test executable; llvm-readelf JSON schema changed and the note is present under a different key.","solutions":["Inspect the binary's notes: `llvm-readelf -n <binary>` and confirm a `.note.gnu.build-id` section is listed.","If missing, ensure the linker is invoked with build-id enabled (default for most targets); check RUSTFLAGS / target spec for `-Wl,--build-id=none` and remove it.","Rebuild the affected crate so the note is embedded, then re-run the test runner.","If the note exists but under a different JSON key, align the llvm-readelf version with what the runner expects."],"exampleFix":"// before\n# linker invoked with build-id disabled\nRUSTFLAGS=\"-C link-arg=-Wl,--build-id=none\"\n\n// after\nRUSTFLAGS=\"\"  # let the linker emit a default build-id\n# verify:\n$ llvm-readelf -n <binary> | grep build-id","handlingStrategy":"validation","validationCode":"import subprocess\n\ndef has_build_id(readelf, binary):\n    out = subprocess.run([str(readelf), \"-n\", str(binary)],\n                         stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout\n    return b\"build\" in out.lower() and b\".note.gnu.build-id\" in out\n\nif not has_build_id(Path(env.toolchain_dir)/\"bin\"/\"llvm-readelf\", bin_path):\n    raise SystemExit(\"binary has no .note.gnu.build-id; rebuild without --build-id=none\")","typeGuard":"null","tryCatchPattern":"try:\n    build_id = test_env.build_id(bin_path)\nexcept Exception as e:\n    if \"Build ID not found\" in str(e):\n        logging.error(\"linker did not emit build-id; check RUSTFLAGS / target spec\")\n    raise","preventionTips":["Never pass -Wl,--build-id=none for Fuchsia test binaries.","Confirm build-id presence with `llvm-readelf -n <bin>` in CI before invoking the runner.","Keep the llvm-readelf version aligned with the JSON schema the runner parses."],"tags":["fuchsia","llvm","elf","build-id","linker"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}