On 2025-12-17 08:37, Matthias Klose wrote:
> > on arm64 libgfortran.so.5.0.0 is currently built without PAC/BTI/GCS
> > support.
> > 
> > Please consider the attached patch to add -mbranch-protection=standard
> > to FCFLAGS where appropriate.
> 
> please could you write that the same way you did for CFLAGS/CXXFLAGS to
> correctly pass for the cross compilers as well?

Adding FCFLAGS to the list of flags to pass to cross compilers did the
trick, I double-checked that usr/aarch64-linux-gnu/lib/libgfortran.so.5
as shipped by libgfortran5-arm64-cross_15.2.0-11cross1_all.deb has the
flags.

Updated patch attached.
commit 5280bfe9d00f17f499fb5e1b1885e2791c75aefc
Author: Emanuele Rocca <[email protected]>
Date:   Tue Dec 16 13:43:04 2025 +0100

    Enable PAC/BTI/GCS support in libgfortran

diff --git a/debian/rules2 b/debian/rules2
index 8c78e32..30892e5 100644
--- a/debian/rules2
+++ b/debian/rules2
@@ -217,6 +217,10 @@ ifeq ($(DEB_TARGET_ARCH),arm64)
     CFLAGS_SECURE =
   endif
 
+  ifneq (,$(findstring -mbranch-protection=standard,$(shell DEB_HOST_ARCH=$(DEB_TARGET_ARCH) dpkg-buildflags --get FCFLAGS)))
+    FCFLAGS += -mbranch-protection=standard
+  endif
+
   ifeq ($(DEB_CROSS),yes)
     # Building cross compilers
     CFLAGS_FOR_TARGET += $(CFLAGS_SECURE)
@@ -255,7 +259,7 @@ endif
 # set CFLAGS/LDFLAGS for the configure step only, maybe be modifed for some target
 # all other flags are passed to the make step.
 pass_vars = $(foreach v,$(1),$(if $($(v)),$(v)="$($(v))"))
-flags_to_pass := CFLAGS CXXFLAGS LIBCFLAGS LIBCXXFLAGS LDFLAGS
+flags_to_pass := CFLAGS CXXFLAGS LIBCFLAGS LIBCXXFLAGS LDFLAGS FCFLAGS
 
 docdir		= usr/share/doc
 
@@ -1208,6 +1212,7 @@ endif
 	@echo "CPPFLAGS: $(CPPFLAGS)"
 	@echo "CFLAGS: $(CFLAGS)"
 	@echo "LDFLAGS: $(LDFLAGS)"
+	@echo "FCFLAGS: $(FCFLAGS)"
 	@echo "BOOT_CFLAGS: $(BOOT_CFLAGS)"
 	@echo "DEBIAN_BUILDARCH: $(DEBIAN_BUILDARCH)"
 	@echo "Install prefix: /$(PF)"
@@ -1450,7 +1455,7 @@ else ifneq (,$(filter $(build_type),build-cross cross-build-native cross-build-c
 	  $(SET_LOCPATH) \
 	    $(time_command) $(MAKE) $(NJOBS) -C $(builddir) \
 		$(call pass_vars, BOOT_CFLAGS       BOOT_LDFLAGS \
-		                  CFLAGS_FOR_TARGET LDFLAGS_FOR_TARGET) \
+		                  CFLAGS_FOR_TARGET LDFLAGS_FOR_TARGET FCFLAGS) \
 		; \
 	  echo $$? > status; \
 	  echo === TIME $@ ===; \

Reply via email to