ARC: Strip libgcc debug information when generating BTF
Subsystems (2)
PATCH 1/1 ARC: Strip libgcc debug information when generating BTF
ARC links against the compiler's libgcc archive. The ARC GNU 2023.03 toolchain ships this library with debug information, including complex floating-point types in integer arithmetic helpers such as __udivdi3. These types reach vmlinux even though the kernel does not use complex floating-point arithmetic.
When floating-point BTF encoding is enabled, pahole rejects those types:
Complex, interval and imaginary float types are not supported Error while encoding BTF.
FAILED: load BTF from .tmp_vmlinux1.BTF.1: No such file or directory
KernelCI's upgrade to pahole 1.31 exposed this long-standing problem as failed ARC builds. As of 1.32, pahole still rejects these types, and older versions will stay in use, so the kernel build has to keep them out of vmlinux. Commit f122668ddcce ("ARC: Add eBPF JIT support") documented the same failure along with a workaround of disabling floating-point BTF encoding, but that also discards supported floating-point types from kernel BTF.
For CONFIG_DEBUG_INFO_BTF, generate a debug-stripped copy of the selected libgcc archive in the output tree and link that copy. Preserve the archive structure so that only needed helpers are linked, and use the normal Kbuild objcopy rule to track input and command changes. The trade-off is that vmlinux in BTF-enabled builds no longer carries DWARF for the libgcc helpers. Debug information for kernel code, the installed toolchain and non-BTF builds stay unchanged.
Reproduced and tested with ARC GCC 12.2.1 and pahole 1.31 and 1.32 using an ARCv2 tinyconfig with BPF_SYSCALL and DWARF4/BTF enabled. Before and after vmlinux.o files are identical after stripping debug information.
--- arch/arc/Makefile | 9 ++++++++- arch/arc/lib/Makefile | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
arch/arc/Makefile +8 -1
@@ -86,7 +86,14 @@ core-$(CONFIG_ARC_PLAT_TB10X) += arch/arc/plat-tb10x/ core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/ core-$(CONFIG_ARC_SOC_HSDK) += arch/arc/plat-hsdk/ -libs-y += arch/arc/lib/ $(LIBGCC) +libs-y += arch/arc/lib/ + +ifdef CONFIG_DEBUG_INFO_BTF +export LIBGCC := $(LIBGCC) +libs-y += arch/arc/lib/libgcc.a +else +libs-y += $(LIBGCC) +endif boot := arch/arc/boot
arch/arc/lib/Makefile +8 -0
@@ -13,3 +13,11 @@ lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs-unaligned.o else lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs.o endif + +# libgcc can contain complex floating-point debug types unsupported by BTF. +# Strip only the debug information from a local copy of the selected archive. +always-$(CONFIG_DEBUG_INFO_BTF) += libgcc.a +OBJCOPYFLAGS_libgcc.a := --strip-debug + +$(obj)/libgcc.a: $(LIBGCC) FORCE + $(call if_changed,objcopy)
Signature · 1 line
2.53.0
Quoted 28 lines · Sasha Levin
ARC links against the compiler's libgcc archive. The ARC GNU 2023.03 toolchain ships this library with debug information, including complex floating-point types in integer arithmetic helpers such as
__udivdi3. These types reach vmlinux even though the kernel does not use complex floating-point arithmetic.When floating-point BTF encoding is enabled, pahole rejects those types:
Complex, interval and imaginary float types are not supported Error while encoding BTF.
FAILED: load BTF from .tmp_vmlinux1.BTF.1: No such file or directoryKernelCI's upgrade to pahole 1.31 exposed this long-standing problem as failed ARC builds. As of 1.32, pahole still rejects these types, and older versions will stay in use, so the kernel build has to keep them out of vmlinux. Commit
f122668ddcce("ARC: Add eBPF JIT support") documented the same failure along with a workaround of disabling floating-point BTF encoding, but that also discards supported floating-point types from kernel BTF.For
CONFIG_DEBUG_INFO_BTF, generate a debug-stripped copy of the selected libgcc archive in the output tree and link that copy. Preserve the archive structure so that only needed helpers are linked, and use the normalKbuildobjcopy rule to track input and command changes. The trade-off is that vmlinux in BTF-enabled builds no longer carries DWARF for the libgcc helpers. Debug information for kernel code, the installed toolchain and non-BTF builds stay unchanged.
Quoted 7 lines
Reproduced and tested with ARC GCC 12.2.1 and pahole 1.31 and 1.32 using an ARCv2 tinyconfig with
BPF_SYSCALLand DWARF4/BTF enabled. Before and after vmlinux.o files are identical after stripping debug information.Fixes db16c1fe92d7 ("bpf: Generate BTF_KIND_FLOAT when linking vmlinux")Signed-off-by Sasha Levin <[email protected]>
Thanks for the fix Sasha! More complete floating point representations for BTF should definitely be on the to-do list..
Vineet Gupta
maintainerQuoted 66 lines · Sasha Levin
ARC links against the compiler's libgcc archive. The ARC GNU 2023.03 toolchain ships this library with debug information, including complex floating-point types in integer arithmetic helpers such as
__udivdi3. These types reach vmlinux even though the kernel does not use complex floating-point arithmetic.When floating-point BTF encoding is enabled, pahole rejects those types:
Complex, interval and imaginary float types are not supported Error while encoding BTF.
FAILED: load BTF from .tmp_vmlinux1.BTF.1: No such file or directoryKernelCI's upgrade to pahole 1.31 exposed this long-standing problem as failed ARC builds. As of 1.32, pahole still rejects these types, and older versions will stay in use, so the kernel build has to keep them out of vmlinux. Commit
f122668ddcce("ARC: Add eBPF JIT support") documented the same failure along with a workaround of disabling floating-point BTF encoding, but that also discards supported floating-point types from kernel BTF.For
CONFIG_DEBUG_INFO_BTF, generate a debug-stripped copy of the selected libgcc archive in the output tree and link that copy. Preserve the archive structure so that only needed helpers are linked, and use the normalKbuildobjcopy rule to track input and command changes. The trade-off is that vmlinux in BTF-enabled builds no longer carries DWARF for the libgcc helpers. Debug information for kernel code, the installed toolchain and non-BTF builds stay unchanged.Reproduced and tested with ARC GCC 12.2.1 and pahole 1.31 and 1.32 using an ARCv2 tinyconfig with
BPF_SYSCALLand DWARF4/BTF enabled. Before and after vmlinux.o files are identical after stripping debug information.Fixes db16c1fe92d7 ("bpf: Generate BTF_KIND_FLOAT when linking vmlinux")Signed-off-by Sasha Levin <[email protected]>--- arch/arc/Makefile | 9 ++++++++- arch/arc/lib/Makefile | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)arch/arc/Makefile +8
-1@@ -86,7 +86,14 @@ core-$(CONFIG_ARC_PLAT_TB10X) += arch/arc/plat-tb10x/ core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/ core-$(CONFIG_ARC_SOC_HSDK) += arch/arc/plat-hsdk/ -libs-y += arch/arc/lib/ $(LIBGCC) +libs-y += arch/arc/lib/ + +ifdef CONFIG_DEBUG_INFO_BTF +export LIBGCC := $(LIBGCC) +libs-y += arch/arc/lib/libgcc.a +else +libs-y += $(LIBGCC) +endif boot := arch/arc/bootarch/arc/lib/Makefile +0
-0@@ -13,3 +13,11 @@ lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs-unaligned.o else
arch/arc/lib/Makefile lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs-unaligned.o · line 23
Quoted 10 lines
arch/arc/lib/Makefile +8
-0lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs.o endif + +# libgcc can contain complex floating-point debug types unsupported by BTF. +# Strip only the debug information from a local copy of the selected archive. +always-$(CONFIG_DEBUG_INFO_BTF) += libgcc.a +OBJCOPYFLAGS_libgcc.a := --strip-debug + +$(obj)/libgcc.a: $(LIBGCC) FORCE + $(call if_changed,objcopy)
I'm working on getting rid of libgcc linking for ARC.
This requires adding some GENERIC_LIB_* routines, but as part of that series I'll propose a revert of this and then the dropping the first link. Don't intend to revert this per se, but revert just makes it cleaner.
Just FYI.
Thx,
-Vineet
Quoted 15 lines · Vineet Gupta
Quoted 13 lines · Sasha Levin
arch/arc/lib/Makefile +5
-0@@ -13,3 +13,11 @@ lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs-unaligned.o else lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs.o endif + +# libgcc can contain complex floating-point debug types unsupported by BTF. +# Strip only the debug information from a local copy of the selected archive. +always-$(CONFIG_DEBUG_INFO_BTF) += libgcc.a +OBJCOPYFLAGS_libgcc.a := --strip-debug
Quoted 8 lines
arch/arc/lib/Makefile lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs-unaligned.o · line 23
Quoted 3 lines
arch/arc/lib/Makefile +3
-0+ +$(obj)/libgcc.a: $(LIBGCC) FORCE + $(call if_changed,objcopy)I'm working on getting rid of libgcc linking for ARC.
This requires adding some GENERIC_LIB_* routines, but as part of that series I'll propose a revert of this and then the dropping the first link. Don't intend to revert this per se, but revert just makes it cleaner.
Have you seen Simon's series?
I hope there is some overlap with what you need for arc in the lib/*.c functions. I can take both through the asm-generic tree to reduce the dependencies if that helps.
Arnd
Vineet Gupta
maintainerQuoted 5 lines · Arnd Bergmann
Quoted 4 lines
I'm working on getting rid of libgcc linking for ARC.
This requires adding some GENERIC_LIB_* routines, but as part of that series I'll propose a revert of this and then the dropping the first link. Don't intend to revert this per se, but revert just makes it cleaner.Have you seen Simon's series?
No I didn't until now.
Quoted 5 lines
I hope there is some overlap with what you need for arc in the
lib/*.cfunctions. I can take both through the asm-generic tree to reduce the dependencies if that helps.
Oh that fits the bill perfectly. Mine also switched the others (with build test using their cross tool-chains).
Anyhow I'll wait for that to land. Would this need to wait full cycle ? If it can land in 7.4-rcX, I can hold off my existing patches for switching to current in-tree lib/* to also use the new ones and be done with libgcc.
Thx,
-Vineet
Quoted 7 lines · Vineet Gupta
Quoted 5 lines · Arnd Bergmann
Quoted 1 line
I'm working on getting rid of libgcc linking for ARC.
I hope there is some overlap with what you need for arc in the
lib/*.cfunctions. I can take both through the asm-generic tree to reduce the dependencies if that helps.
Quoted 6 lines
Oh that fits the bill perfectly. Mine also switched the others (with build test using their cross tool-chains).
Anyhow I'll wait for that to land. Would this need to wait full cycle ? If it can land in 7.4-rcX, I can hold off my existing patches for switching to current in-treelib/*to also use the new ones and be done with libgcc.
If you need this to fix the regression, I think it's fine to merge the shared lib/*.c files for for 7.4 along with whatever you need on top. I suspect though based on Sasha's patch, the only thing we actually need is to stop exporting the floating point functions so the types don't leak into btf. If you can verify that this is the case, I would do the full conversion for both nios2 and arc in 7.5.
Arnd
Vineet Gupta
maintainerQuoted 6 lines · Arnd Bergmann
Quoted 6 lines
Oh that fits the bill perfectly. Mine also switched the others (with build test using their cross tool-chains).
Anyhow I'll wait for that to land. Would this need to wait full cycle ? If it can land in 7.4-rcX, I can hold off my existing patches for switching to current in-treelib/*to also use the new ones and be done with libgcc.
Quoted 7 lines
If you need this to fix the regression, I think it's fine to merge the shared
lib/*.cfiles for for 7.4 along with whatever you need on top. I suspect though based on Sasha's patch, the only thing we actually need is to stop exporting the floating point functions so the types don't leak into btf. If you can verify that this is the case, I would do the full conversion for both nios2 and arc in 7.5.
Yeah Sasha's fix works w/o eliding the FP routines (there's an unrelated issue which I send a fix for [1])
As of 7.4-rc1, I have 2 ARC only changes to
1. Switch to existing in-tree GENERIC_LIB*
2. Dropping FP symbols
I can post them now. Once Simon's changes land, lefover ARC conversion and and removal of libgcc can all go together via your tree if that's OK with you.
Thx,
-Vineet
Quoted 13 lines · Vineet Gupta
Quoted 7 lines · Arnd Bergmann
If you need this to fix the regression, I think it's fine to merge the shared
lib/*.cfiles for for 7.4 along with whatever you need on top. I suspect though based on Sasha's patch, the only thing we actually need is to stop exporting the floating point functions so the types don't leak into btf. If you can verify that this is the case, I would do the full conversion for both nios2 and arc in 7.5.Yeah Sasha's fix works w/o eliding the FP routines (there's an unrelated issue which I send a fix for [1])
Quoted 7 lines
As of 7.4-rc1, I have 2 ARC only changes to
1. Switch to existing in-tree GENERIC_LIB*
2. Dropping FP symbolsI can post them now. Once Simon's changes land, lefover ARC conversion and and removal of libgcc can all go together via your tree if that's OK with you.
Sounds good to me,
Arnd