Skip to contentSkip to conversation

package/libical: fix build with toolchains without SSP

PATCH New Yegor Yefremov 1 participant 1 message Oct 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libical: fix build with toolchains without SSP

Since version 4.0.0, libical enables the OpenSSF compiler hardening options, including -fstack-protector-strong, whenever check_compiler_flag() succeeds. That check only compiles a test program, but GCC also adds -lssp_nonshared -lssp when linking with -fstack-protector-strong if the C library doesn't provide the stack protector. With a toolchain without SSP support, the check therefore succeeds but the link fails:

[ 50%] Linking C shared library ../../lib/libical.so
ld: cannot find -lssp_nonshared: No such file or directory
ld: cannot find -lssp: No such file or directory

Add a patch, submitted upstream, to also check the flag with check_linker_flag() and only use it if linking with it works.

This issue has been present since commit 410b9c87c26d ("package/libical: bump to version 4.0.7"), which bumped libical from 3.0.20, which did not have the OpenSSF hardening options yet. It does not affect any release yet.

Fixes:
https://autobuild.buildroot.org/results/36a8ce7ee6581bd24ec013d8564bc3214400faaa

Fixes 410b9c87c26d5d5eaf44b2b2362452febf887b06 ("package/libical: bump to version 4.0.7")
Assisted-by Claude:claude-opus-5-5
---
 ...k-that-fstack-protector-strong-links.patch | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 package/libical/0001-openssf-check-that-fstack-protector-strong-links.patch
package/libical/0001-openssf-check-that-fstack-protector-strong-links.patch new file +61 -0
new file mode 100644
index 0000000000..03f085a052
@@ -0,0 +1,61 @@
+From 83314b5b234e8775e787aef0e6f713dc8b105ded Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Wed, 28 Oct 2026 06:07:44 +0100
+Subject: [PATCH] openssf - check that -fstack-protector-strong links
+
+check_compiler_flag() only compiles the test program with the given
+flag. However, GCC also adds -lssp_nonshared -lssp when linking with
+-fstack-protector-strong if the C library doesn't provide the stack
+protector itself, e.g. uClibc-ng built without SSP support. In that
+case the check succeeds, but linking libical fails:
+
+  ld: cannot find -lssp_nonshared: No such file or directory
+  ld: cannot find -lssp: No such file or directory
+
+All the checks following it fail as well, as their test programs are
+now linked with -fstack-protector-strong.
+
+Also check the flag with check_linker_flag(), so that it is only used
+if linking with it works.
+
+Assisted-by: Claude:claude-opus-5-5
+Upstream: https://github.com/libical/libical/pull/1472
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ cmake/modules/openssf-c.cmake   | 4 +++-
+ cmake/modules/openssf-cpp.cmake | 4 +++-
+ 2 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/cmake/modules/openssf-c.cmake b/cmake/modules/openssf-c.cmake
+index 7f30d5b4..c701d078 100644
+--- a/cmake/modules/openssf-c.cmake
++++ b/cmake/modules/openssf-c.cmake
+@@ -89,7 +89,9 @@ if(C_SUPPORTS_FSTACK_CLASH_PROTECTION)
+   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-clash-protection")
+ endif()
+ check_compiler_flag(C "-fstack-protector-strong" C_SUPPORTS_FSTACK_PROTECTOR_STRONG)
+-if(C_SUPPORTS_FSTACK_PROTECTOR_STRONG)
++# the stack protector may need libssp at link time, which is not always available
++check_linker_flag(C "-fstack-protector-strong" C_LINKER_SUPPORTS_FSTACK_PROTECTOR_STRONG)
++if(C_SUPPORTS_FSTACK_PROTECTOR_STRONG AND C_LINKER_SUPPORTS_FSTACK_PROTECTOR_STRONG)
+   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong")
+ endif()
+ check_compiler_flag(C "-fcf-protection=full" C_SUPPORTS_FCF_PROTECTION_FULL)
+diff --git a/cmake/modules/openssf-cpp.cmake b/cmake/modules/openssf-cpp.cmake
+index f6cc7975..c38dd6c8 100644
+--- a/cmake/modules/openssf-cpp.cmake
++++ b/cmake/modules/openssf-cpp.cmake
+@@ -89,7 +89,9 @@ if(CXX_SUPPORTS_FSTACK_CLASH_PROTECTION)
+   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-clash-protection")
+ endif()
+ check_compiler_flag(CXX "-fstack-protector-strong" CXX_SUPPORTS_FSTACK_PROTECTOR_STRONG)
+-if(CXX_SUPPORTS_FSTACK_PROTECTOR_STRONG)
++# the stack protector may need libssp at link time, which is not always available
++check_linker_flag(CXX "-fstack-protector-strong" CXX_LINKER_SUPPORTS_FSTACK_PROTECTOR_STRONG)
++if(CXX_SUPPORTS_FSTACK_PROTECTOR_STRONG AND CXX_LINKER_SUPPORTS_FSTACK_PROTECTOR_STRONG)
+   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong")
+ endif()
+ check_compiler_flag(CXX "-fcf-protection=full" CXX_SUPPORTS_FCF_PROTECTION_FULL)
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot