bpfilter: check if $(CC) can static link in Kconfig
Subsystems (4)
PATCH 1/1 bpfilter: check if $(CC) can static link in Kconfig
On Fedora, linking static libraries requires the glibc-static RPM package, which is not part of the glibc-devel package.
CONFIG_CC_CAN_LINK does not check the capability of static linking, so you can enable CONFIG_BPFILTER_UMH, then fail to build.
HOSTLD net/bpfilter/bpfilter_umh/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
Add CONFIG_CC_CAN_LINK_STATIC, and make CONFIG_BPFILTER_UMH depend on it.
---
I will insert this after
https://patchwork.kernel.org/patch/11515997/
init/Kconfig | 5 +++++ net/bpfilter/Kconfig | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
init/Kconfig +5 -0
@@ -49,6 +49,11 @@ config CC_CAN_LINK default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(m64-flag)) if 64BIT default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(m32-flag)) +config CC_CAN_LINK_STATIC + bool + default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static $(m64-flag)) if 64BIT + default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static $(m32-flag)) + config CC_HAS_ASM_GOTO def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
net/bpfilter/Kconfig +1 -1
@@ -9,7 +9,7 @@ menuconfig BPFILTER if BPFILTER config BPFILTER_UMH tristate "bpfilter kernel module with user mode helper" - depends on CC_CAN_LINK + depends on CC_CAN_LINK_STATIC default m help This builds bpfilter kernel module with embedded user mode helper
Signature · 1 line
2.25.1
Quoted 11 lines · Masahiro Yamada
On Fedora, linking static libraries requires the glibc-static RPM package, which is not part of the glibc-devel package.
CONFIG_CC_CAN_LINKdoes not check the capability of static linking, so you can enableCONFIG_BPFILTER_UMH, then fail to build.HOSTLD
net/bpfilter/bpfilter_umh/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
Quoted 5 lines
Add
CONFIG_CC_CAN_LINK_STATIC, and makeCONFIG_BPFILTER_UMHdepend on it.Reported-by Valdis Kletnieks <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
Thanks!
Quoted 13 lines · Alexei Starovoitov
Quoted 11 lines · Masahiro Yamada
On Fedora, linking static libraries requires the glibc-static RPM package, which is not part of the glibc-devel package.
CONFIG_CC_CAN_LINKdoes not check the capability of static linking, so you can enableCONFIG_BPFILTER_UMH, then fail to build.HOSTLD
net/bpfilter/bpfilter_umh/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
Quoted 8 lines
Quoted 5 lines
Add
CONFIG_CC_CAN_LINK_STATIC, and makeCONFIG_BPFILTER_UMHdepend on it.Reported-by Valdis Kletnieks <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>Thanks!
Applied to linux-kbuild
with Alexei's Ack.
Signature · 2 lines
Best Regards Masahiro Yamada