{"record":{"id":"0dfbc3b9cc58e32a","repo":"PyO3/pyo3","slug":"build-flags-contains-py-gil-disabled-but-target-ab","errorCode":null,"errorMessage":"build_flags contains Py_GIL_DISABLED but target_abi '{target_abi}' is not free-threaded","messagePattern":"build_flags contains Py_GIL_DISABLED but target_abi '(.+?)' is not free-threaded","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pyo3-build-config/src/impl_.rs","lineNumber":1370,"sourceCode":"            (Some(target_abi), false) => target_abi,\n            // Target ABI set + Py_GIL_DISABLED: reconcile.\n            (Some(target_abi), true) => match target_abi.kind() {\n                // abi3 + Py_GIL_DISABLED: the abi3 feature is a no-op on free-threaded\n                // interpreters, so for backward compatibility fall back to a free-threaded\n                // version-specific build.\n                PythonAbiKind::Stable(StableAbi::Abi3) => {\n                    let new_abi =\n                        PythonAbiBuilder::new(target_abi.implementation(), target_abi.version())\n                            .free_threaded()\n                            .finalize()?;\n                    warn!(\n                        \"Targeting an abi3 build but build_flags contains Py_GIL_DISABLED, \\\n                         falling back to a version-specific free-threaded build\"\n                    );\n                    new_abi\n                }\n                // GIL-enabled version-specific + Py_GIL_DISABLED is contradictory.\n                PythonAbiKind::VersionSpecific(GilUsed::GilEnabled) => bail!(\n                    \"build_flags contains Py_GIL_DISABLED but target_abi \\\n                     '{target_abi}' is not free-threaded\"\n                ),\n                // Already free-threaded (Stable(Abi3t) or VersionSpecific(FreeThreaded)).\n                _ => target_abi,\n            },\n        };\n        if target_abi.kind().is_free_threaded() {\n            build_flags.0.insert(BuildFlag::Py_GIL_DISABLED);\n        }\n        #[expect(\n            deprecated,\n            reason = \"constructing an InterpreterConfig directly, need to write to fields\"\n        )]\n        Ok(InterpreterConfig {\n            implementation: self.implementation,\n            version: self.version,\n            shared: self.shared,","sourceCodeStart":1352,"sourceCodeEnd":1388,"githubUrl":"https://github.com/PyO3/pyo3/blob/ac9b6899d348be4d54614d060dea53a645a12e36/pyo3-build-config/src/impl_.rs#L1352-L1388","documentation":"Consistency error raised while reconciling the ABI selected via PYO3_CROSS_PYTHON_ABI / cargo features with the build flags parsed from sysconfigdata: the flags contain Py_GIL_DISABLED (interpreter is free-threaded) but the configured target_abi is not a free-threaded kind, so the two sources of truth disagree.","triggerScenarios":"Thrown at pyo3-build-config/src/impl_.rs:1370 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set PYO3_CROSS_PYTHON_ABI (or the cargo abi3 selection) to the free-threaded ABI matching the interpreter","Remove Py_GIL_DISABLED from the interpreter/sysconfigdata being targeted, or point the build at a GIL-enabled interpreter","Let the build script auto-derive the ABI instead of pinning a conflicting one"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ac9b6899d348be4d54614d060dea53a645a12e36","analyzedAt":"2026-09-05T09:20:35.319Z","contentChangedAt":"2026-09-05T09:20:35.319Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}