rust: kbuild: export symbols from the `uapi` crate
PATCH 1/1 rust: kbuild: export symbols from the `uapi` crate
Symbols from the bindings crate and the C helpers are exported so that loadable modules can link against code the compiler chose not to instantiate in the module itself. The uapi crate has the same problem but nothing from it is exported.
In practice this goes unnoticed because the only functions in uapi are the trivial Default implementations generated by bindgen, which rustc inlines across crates. With CONFIG_RUST_DEBUG_ASSERTIONS=y however, the Default implementation for structs can grow past the automatic cross-crate inlining threshold. The module then references the copy in uapi.o, which is not exported, and the build fails:
ERROR: modpost: drivers/gpu/nova-drm.ko: symbol '_RNvXsH_Csk9v2ZIpWbWt_4uapiNtB5_17drm_nova_info_gpuNtNtCsfr3MPOfBGpN_4core7default7Default7default' undefined!
Fix this by exporting the uapi symbols in the same way as bindings.
--- rust/Makefile | 7 ++++++- rust/exports.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
rust/Makefile +6 -1
@@ -27,6 +27,7 @@ always-$(CONFIG_RUST) += exports_bindings_generated.h exports_kernel_generated.h always-$(CONFIG_RUST) += uapi/uapi_generated.rs obj-$(CONFIG_RUST) += uapi.o +always-$(CONFIG_RUST) += exports_uapi_generated.h ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW obj-$(CONFIG_RUST) += build_error.o
@@ -575,7 +576,8 @@ $(obj)/exports_core_generated.h: $(obj)/core.o FORCE # in the crate where they are defined. Other helpers, called from non-inline # functions, may not be exported, in principle. However, in general, the Rust # compiler does not guarantee codegen will be performed for a non-inline -# function either. Therefore, we export all symbols from helpers and bindings. +# function either. Therefore, we export all symbols from helpers, bindings and +# uapi. # In the future, this may be revisited to reduce the number of exports after # the compiler is informed about the places codegen is required. $(obj)/exports_helpers_generated.h: $(obj)/helpers/helpers.o FORCE
@@ -587,6 +589,9 @@ $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE $(call if_changed,exports) +$(obj)/exports_uapi_generated.h: $(obj)/uapi.o FORCE + $(call if_changed,exports) + quiet_cmd_rustc_procmacrolibrary = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) PL $@ cmd_rustc_procmacrolibrary = \ $(rustc_target_envs) \
rust/exports.c +1 -0
@@ -17,6 +17,7 @@#include "exports_core_generated.h" #include "exports_bindings_generated.h" +#include "exports_uapi_generated.h" #include "exports_kernel_generated.h" #ifndef CONFIG_RUST_INLINE_HELPERS
base-commit: b705c185105762676aa6ec16cf976101df87cc35
Signature · 1 line
2.54.0
Gary Guo
reviewerQuoted 5 lines · Alistair Popple
Symbols from the
bindingscrate and the C helpers are exported so that loadable modules can link against code the compiler chose not to instantiate in the module itself. Theuapicrate has the same problem but nothing from it is exported.
Quoted 8 lines
In practice this goes unnoticed because the only functions in
uapiare the trivialDefaultimplementations generated bybindgen, which rustc inlines across crates. WithCONFIG_RUST_DEBUG_ASSERTIONS=yhowever, theDefaultimplementation for structs can grow past the automatic cross-crate inlining threshold. The module then references the copy inuapi.o, which is not exported, and the build fails:ERROR: modpost:
drivers/gpu/nova-drm.ko: symbol '_RNvXsH_Csk9v2ZIpWbWt_4uapiNtB5_17drm_nova_info_gpuNtNtCsfr3MPOfBGpN_4core7default7Default7default' undefined!
Hmm, uapi' ideally should just be type exports and produce no code.
Default implementation should carry #[inline] annotation so they're only codegenned in actual user crate. Rust's #[derive(Default)] would always add that. Can you check if that's bindgen-produced manual Default impl that somehow misses the attribute?
Best,
Gary
Quoted 57 lines
Fix this by exporting the
uapisymbols in the same way asbindings.Fixes 4e1746656839 ("rust: uapi: Add UAPI crate")Signed-off-by Alistair Popple <[email protected]>Assisted-by LLM--- rust/Makefile | 7 ++++++- rust/exports.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)rust/Makefile +6
-1@@ -27,6 +27,7 @@ always-$(CONFIG_RUST) += exports_bindings_generated.h exports_kernel_generated.h always-$(CONFIG_RUST) += uapi/uapi_generated.rs obj-$(CONFIG_RUST) += uapi.o +always-$(CONFIG_RUST) += exports_uapi_generated.h ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW obj-$(CONFIG_RUST) += build_error.o@@ -575,7 +576,8 @@ $(obj)/exports_core_generated.h: $(obj)/core.o FORCE # in the crate where they are defined. Other helpers, called from non-inline # functions, may not be exported, in principle. However, in general, the Rust # compiler does not guarantee codegen will be performed for a non-inline -# function either. Therefore, we export all symbols from helpers and bindings. +# function either. Therefore, we export all symbols from helpers, bindings and +# uapi. # In the future, this may be revisited to reduce the number of exports after # the compiler is informed about the places codegen is required. $(obj)/exports_helpers_generated.h: $(obj)/helpers/helpers.o FORCE@@ -587,6 +589,9 @@ $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE $(call if_changed,exports) +$(obj)/exports_uapi_generated.h: $(obj)/uapi.o FORCE + $(call if_changed,exports) + quiet_cmd_rustc_procmacrolibrary = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) PL $@ cmd_rustc_procmacrolibrary = \ $(rustc_target_envs) \rust/exports.c +1
-0@@ -17,6 +17,7 @@#include "exports_core_generated.h" #include "exports_bindings_generated.h" +#include "exports_uapi_generated.h" #include "exports_kernel_generated.h" #ifndef CONFIG_RUST_INLINE_HELPERS base-commit:
b705c185105762676aa6ec16cf976101df87cc35
On 2026-09-10 at 00:25 +1000, Gary Guo <[email protected]> wrote...
Quoted 13 lines · Alistair Popple
Quoted 12 lines
Symbols from the
bindingscrate and the C helpers are exported so that loadable modules can link against code the compiler chose not to instantiate in the module itself. Theuapicrate has the same problem but nothing from it is exported.In practice this goes unnoticed because the only functions in
uapiare the trivialDefaultimplementations generated bybindgen, which rustc inlines across crates. WithCONFIG_RUST_DEBUG_ASSERTIONS=yhowever, theDefaultimplementation for structs can grow past the automatic cross-crate inlining threshold. The module then references the copy inuapi.o, which is not exported, and the build fails:
Quoted 8 lines
Quoted 1 line
ERROR: modpost:
drivers/gpu/nova-drm.ko: symbol '_RNvXsH_Csk9v2ZIpWbWt_4uapiNtB5_17drm_nova_info_gpuNtNtCsfr3MPOfBGpN_4core7default7Default7default' undefined!Hmm, uapi' ideally should just be type exports and produce no code.
Default implementation should carry
#[inline]annotation so they're only codegenned in actual user crate. Rust's#[derive(Default)]would always add that. Can you check if that's bindgen-produced manual Default impl that somehow misses the attribute?
Right, bindgen-produced Default impl do not have that attribute. For example here is the bindgen generated implementation I see:
impl Default for drm_nova_info_gpu {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}Manually adding #[inline] fixes the problem of course. I guess we could add some sed Makefile hackery to manually add it. For example something like the below, not sure if that would be preferred?
---
rust/Makefile +0 -0
@@@ -525,13 -525,13 +525,16 @@@ quiet_cmd_bindgen = BINDGEN $ $(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \ $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) $(obj)/bindings/bindings_generated.rs: private bindgen_target_extra = ; \ -- sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g' $@ ++ sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g; \ ++ s/^([[:space:]]*)fn default\(\) -> Self \{/\1#[inline]\n\1fn default() -> Self {/' $@ $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \ $(src)/bindgen_parameters FORCE $(call if_changed_dep,bindgen) $(obj)/uapi/uapi_generated.rs: private bindgen_target_flags = \ $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) ++$(obj)/uapi/uapi_generated.rs: private bindgen_target_extra = ; \ ++ sed -Ei 's/^([[:space:]]*)fn default\(\) -> Self \{/\1#[inline]\n\1fn default() -> Self {/' $@ $(obj)/uapi/uapi_generated.rs: $(src)/uapi/uapi_helper.h \ $(src)/bindgen_parameters FORCE $(call if_changed_dep,bindgen)
Quoted 62 lines
Best,
GaryQuoted 57 lines
Fix this by exporting the
uapisymbols in the same way asbindings.Fixes 4e1746656839 ("rust: uapi: Add UAPI crate")Signed-off-by Alistair Popple <[email protected]>Assisted-by LLM--- rust/Makefile | 7 ++++++- rust/exports.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)rust/Makefile +6
-1@@ -27,6 +27,7 @@ always-$(CONFIG_RUST) += exports_bindings_generated.h exports_kernel_generated.h always-$(CONFIG_RUST) += uapi/uapi_generated.rs obj-$(CONFIG_RUST) += uapi.o +always-$(CONFIG_RUST) += exports_uapi_generated.h ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW obj-$(CONFIG_RUST) += build_error.o@@ -575,7 +576,8 @@ $(obj)/exports_core_generated.h: $(obj)/core.o FORCE # in the crate where they are defined. Other helpers, called from non-inline # functions, may not be exported, in principle. However, in general, the Rust # compiler does not guarantee codegen will be performed for a non-inline -# function either. Therefore, we export all symbols from helpers and bindings. +# function either. Therefore, we export all symbols from helpers, bindings and +# uapi. # In the future, this may be revisited to reduce the number of exports after # the compiler is informed about the places codegen is required. $(obj)/exports_helpers_generated.h: $(obj)/helpers/helpers.o FORCE@@ -587,6 +589,9 @@ $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE $(call if_changed,exports) +$(obj)/exports_uapi_generated.h: $(obj)/uapi.o FORCE + $(call if_changed,exports) + quiet_cmd_rustc_procmacrolibrary = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) PL $@ cmd_rustc_procmacrolibrary = \ $(rustc_target_envs) \rust/exports.c +1
-0@@ -17,6 +17,7 @@#include "exports_core_generated.h" #include "exports_bindings_generated.h" +#include "exports_uapi_generated.h" #include "exports_kernel_generated.h" #ifndef CONFIG_RUST_INLINE_HELPERS base-commit:
b705c185105762676aa6ec16cf976101df87cc35
Alice Ryhl
reviewerQuoted 37 lines · Alistair Popple
On 2026-09-10 at 00:25 +1000, Gary Guo <[email protected]> wrote...
Quoted 13 lines · Alistair Popple
Quoted 12 lines
Symbols from the
bindingscrate and the C helpers are exported so that loadable modules can link against code the compiler chose not to instantiate in the module itself. Theuapicrate has the same problem but nothing from it is exported.In practice this goes unnoticed because the only functions in
uapiare the trivialDefaultimplementations generated bybindgen, which rustc inlines across crates. WithCONFIG_RUST_DEBUG_ASSERTIONS=yhowever, theDefaultimplementation for structs can grow past the automatic cross-crate inlining threshold. The module then references the copy inuapi.o, which is not exported, and the build fails:Quoted 8 lines
Quoted 1 line
ERROR: modpost:
drivers/gpu/nova-drm.ko: symbol '_RNvXsH_Csk9v2ZIpWbWt_4uapiNtB5_17drm_nova_info_gpuNtNtCsfr3MPOfBGpN_4core7default7Default7default' undefined!Hmm, uapi' ideally should just be type exports and produce no code.
Default implementation should carry
#[inline]annotation so they're only codegenned in actual user crate. Rust's#[derive(Default)]would always add that. Can you check if that's bindgen-produced manual Default impl that somehow misses the attribute?Right, bindgen-produced Default impl do not have that attribute. For example here is the bindgen generated implementation I see:
impl Default for drm_nova_info_gpu { fn default() -> Self { let mut s = ::core::mem::MaybeUninit::<Self>::uninit(); unsafe { ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } }
Quoted 3 lines
Manually adding #[inline] fixes the problem of course. I guess we could add some sed
Makefilehackery to manually add it. For example something like the below, not sure if that would be preferred?
I think we should just export those symbols so it works on older bindgen, and then try to fix bindgen to emit #[inline] so that people with a new bindgen version do not get the symbols.
Alice
Gary Guo
reviewerQuoted 18 lines · Alistair Popple
On 2026-09-10 at 00:25 +1000, Gary Guo <[email protected]> wrote...
Quoted 17 lines · Alistair Popple
Quoted 5 lines
Symbols from the
bindingscrate and the C helpers are exported so that loadable modules can link against code the compiler chose not to instantiate in the module itself. Theuapicrate has the same problem but nothing from it is exported.Quoted 8 lines
In practice this goes unnoticed because the only functions in
uapiare the trivialDefaultimplementations generated bybindgen, which rustc inlines across crates. WithCONFIG_RUST_DEBUG_ASSERTIONS=yhowever, theDefaultimplementation for structs can grow past the automatic cross-crate inlining threshold. The module then references the copy inuapi.o, which is not exported, and the build fails:ERROR: modpost:
drivers/gpu/nova-drm.ko: symbol '_RNvXsH_Csk9v2ZIpWbWt_4uapiNtB5_17drm_nova_info_gpuNtNtCsfr3MPOfBGpN_4core7default7Default7default' undefined!Hmm, uapi' ideally should just be type exports and produce no code.
Quoted 7 lines
Quoted 4 lines
Default implementation should carry
#[inline]annotation so they're only codegenned in actual user crate. Rust's#[derive(Default)]would always add that. Can you check if that's bindgen-produced manual Default impl that somehow misses the attribute?Right, bindgen-produced Default impl do not have that attribute. For example here is the bindgen generated implementation I see:
Perhaps you can open an issue upstream?
Quoted 11 lines
impl Default for drm_nova_info_gpu {
fn default() -> Self {
let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
unsafe {
::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}Quoted 3 lines
Manually adding #[inline] fixes the problem of course. I guess we could add some sed
Makefilehackery to manually add it. For example something like the below, not sure if that would be preferred?
Yeah, textual hacks are a bit too fragile (especially that it'll break when upstream bindgen adds these annotations). So if you need these impls, I think exporting these symbols are fine.
That said, you can achieve what you need with drm_nova_info_gpu::zeroed() instead?
Best,
Gary
Quoted 26 lines
---
rust/Makefile +4
-1@@@ -525,13 -525,13 +525,16 @@@ quiet_cmd_bindgen = BINDGEN $ $(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \ $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) $(obj)/bindings/bindings_generated.rs: private bindgen_target_extra = ; \ -- sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g' $@ ++ sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g; \ ++ s/^([[:space:]]*)fn default\(\) -> Self \{/\1#[inline]\n\1fn default() -> Self {/' $@ $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \ $(src)/bindgen_parameters FORCE $(call if_changed_dep,bindgen) $(obj)/uapi/uapi_generated.rs: private bindgen_target_flags = \ $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) ++$(obj)/uapi/uapi_generated.rs: private bindgen_target_extra = ; \ ++ sed -Ei 's/^([[:space:]]*)fn default\(\) -> Self \{/\1#[inline]\n\1fn default() -> Self {/' $@ $(obj)/uapi/uapi_generated.rs: $(src)/uapi/uapi_helper.h \ $(src)/bindgen_parameters FORCE $(call if_changed_dep,bindgen)
On 2026-09-10 at 21:36 +1000, Gary Guo <[email protected]> wrote...
Quoted 24 lines · Alistair Popple
Quoted 23 lines
On 2026-09-10 at 00:25 +1000, Gary Guo <[email protected]> wrote...
Quoted 21 lines · Alistair Popple
Quoted 5 lines
Symbols from the
bindingscrate and the C helpers are exported so that loadable modules can link against code the compiler chose not to instantiate in the module itself. Theuapicrate has the same problem but nothing from it is exported.Quoted 8 lines
In practice this goes unnoticed because the only functions in
uapiare the trivialDefaultimplementations generated bybindgen, which rustc inlines across crates. WithCONFIG_RUST_DEBUG_ASSERTIONS=yhowever, theDefaultimplementation for structs can grow past the automatic cross-crate inlining threshold. The module then references the copy inuapi.o, which is not exported, and the build fails:ERROR: modpost:
drivers/gpu/nova-drm.ko: symbol '_RNvXsH_Csk9v2ZIpWbWt_4uapiNtB5_17drm_nova_info_gpuNtNtCsfr3MPOfBGpN_4core7default7Default7default' undefined!Hmm, uapi' ideally should just be type exports and produce no code.
Default implementation should carry
#[inline]annotation so they're only codegenned in actual user crate. Rust's#[derive(Default)]would always add that. Can you check if that's bindgen-produced manual Default impl that somehow misses the attribute?
Quoted 4 lines
Quoted 2 lines
Right, bindgen-produced Default impl do not have that attribute. For example here is the bindgen generated implementation I see:
Perhaps you can open an issue upstream?
For sure - see https://github.com/rust-lang/rust-bindgen/issues/3494
I wasn't quite sure of the justification for why we don't want to just export these, so please feel free to comment there.
Quoted 11 lines
Quoted 11 lines
impl Default for drm_nova_info_gpu { fn default() -> Self { let mut s = ::core::mem::MaybeUninit::<Self>::uninit(); unsafe { ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } }
Quoted 7 lines
Quoted 3 lines
Manually adding #[inline] fixes the problem of course. I guess we could add some sed
Makefilehackery to manually add it. For example something like the below, not sure if that would be preferred?Yeah, textual hacks are a bit too fragile (especially that it'll break when upstream bindgen adds these annotations). So if you need these impls, I think exporting these symbols are fine.
Fun though :) But yes, I agree this is pretty hacky so would rather export the symbols, at least until bindgen is fixed.
Quoted 2 lines
That said, you can achieve what you need with
drm_nova_info_gpu::zeroed()instead?
We could, but I'd rather fix this here as people are inevitably going to try and use default::Default() and the linker errors that come from it are pretty obtuse and difficult to diagnose what the problem really is.
- Alistair
Quoted 30 lines
Best,
GaryQuoted 26 lines
---
rust/Makefile +4
-1@@@ -525,13 -525,13 +525,16 @@@ quiet_cmd_bindgen = BINDGEN $ $(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \ $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) $(obj)/bindings/bindings_generated.rs: private bindgen_target_extra = ; \ -- sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g' $@ ++ sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g; \ ++ s/^([[:space:]]*)fn default\(\) -> Self \{/\1#[inline]\n\1fn default() -> Self {/' $@ $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \ $(src)/bindgen_parameters FORCE $(call if_changed_dep,bindgen) $(obj)/uapi/uapi_generated.rs: private bindgen_target_flags = \ $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) ++$(obj)/uapi/uapi_generated.rs: private bindgen_target_extra = ; \ ++ sed -Ei 's/^([[:space:]]*)fn default\(\) -> Self \{/\1#[inline]\n\1fn default() -> Self {/' $@ $(obj)/uapi/uapi_generated.rs: $(src)/uapi/uapi_helper.h \ $(src)/bindgen_parameters FORCE $(call if_changed_dep,bindgen)
Gary Guo
reviewerQuoted 28 lines · Alistair Popple
On 2026-09-10 at 21:36 +1000, Gary Guo <[email protected]> wrote...
Quoted 27 lines · Alistair Popple
Quoted 25 lines
On 2026-09-10 at 00:25 +1000, Gary Guo <[email protected]> wrote...
Quoted 13 lines · Alistair Popple
Quoted 12 lines
Symbols from the
bindingscrate and the C helpers are exported so that loadable modules can link against code the compiler chose not to instantiate in the module itself. Theuapicrate has the same problem but nothing from it is exported.In practice this goes unnoticed because the only functions in
uapiare the trivialDefaultimplementations generated bybindgen, which rustc inlines across crates. WithCONFIG_RUST_DEBUG_ASSERTIONS=yhowever, theDefaultimplementation for structs can grow past the automatic cross-crate inlining threshold. The module then references the copy inuapi.o, which is not exported, and the build fails:Quoted 8 lines
Quoted 1 line
ERROR: modpost:
drivers/gpu/nova-drm.ko: symbol '_RNvXsH_Csk9v2ZIpWbWt_4uapiNtB5_17drm_nova_info_gpuNtNtCsfr3MPOfBGpN_4core7default7Default7default' undefined!Hmm, uapi' ideally should just be type exports and produce no code.
Default implementation should carry
#[inline]annotation so they're only codegenned in actual user crate. Rust's#[derive(Default)]would always add that. Can you check if that's bindgen-produced manual Default impl that somehow misses the attribute?Right, bindgen-produced Default impl do not have that attribute. For example here is the bindgen generated implementation I see:
Quoted 6 lines
Quoted 1 line
Perhaps you can open an issue upstream?
For sure - see https://github.com/rust-lang/rust-bindgen/issues/3494
I wasn't quite sure of the justification for why we don't want to just export these, so please feel free to comment there.
Hi Alistair,
The justification is that the uapi crate should have no cost on its own (so it should generate no code), because that's just an API. Whoever uses it should pay the cost.
Exporting the symbols would hide all that.
So, I'd even suggest that ideally we don't link the object at all, so it behaves uniformly, built-in modules or not.
Best,
Gary
Quoted 62 lines
Quoted 12 lines
Quoted 12 lines
impl Default for drm_nova_info_gpu { fn default() -> Self { let mut s = ::core::mem::MaybeUninit::<Self>::uninit(); unsafe { ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); s.assume_init() } } }Quoted 7 lines
Quoted 3 lines
Manually adding #[inline] fixes the problem of course. I guess we could add some sed
Makefilehackery to manually add it. For example something like the below, not sure if that would be preferred?Yeah, textual hacks are a bit too fragile (especially that it'll break when upstream bindgen adds these annotations). So if you need these impls, I think exporting these symbols are fine.
Fun though :) But yes, I agree this is pretty hacky so would rather export the symbols, at least until bindgen is fixed.
Quoted 2 lines
That said, you can achieve what you need with
drm_nova_info_gpu::zeroed()instead?We could, but I'd rather fix this here as people are inevitably going to try and use
default::Default()and the linker errors that come from it are pretty obtuse and difficult to diagnose what the problem really is.- Alistair
Quoted 30 lines
Best,
GaryQuoted 26 lines
---
rust/Makefile +4
-1@@@ -525,13 -525,13 +525,16 @@@ quiet_cmd_bindgen = BINDGEN $ $(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \ $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) $(obj)/bindings/bindings_generated.rs: private bindgen_target_extra = ; \ -- sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g' $@ ++ sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const \1/g; \ ++ s/^([[:space:]]*)fn default\(\) -> Self \{/\1#[inline]\n\1fn default() -> Self {/' $@ $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \ $(src)/bindgen_parameters FORCE $(call if_changed_dep,bindgen) $(obj)/uapi/uapi_generated.rs: private bindgen_target_flags = \ $(shell grep -Ev '^#|^$$' $(src)/bindgen_parameters) ++$(obj)/uapi/uapi_generated.rs: private bindgen_target_extra = ; \ ++ sed -Ei 's/^([[:space:]]*)fn default\(\) -> Self \{/\1#[inline]\n\1fn default() -> Self {/' $@ $(obj)/uapi/uapi_generated.rs: $(src)/uapi/uapi_helper.h \ $(src)/bindgen_parameters FORCE $(call if_changed_dep,bindgen)