Control: tags -1 + patch
Control: user [email protected]
Control: usertags -1 + ubuntu-patch

Hi,

Follow-up: the optimize=-lto workaround from my first message is not
enough. On Ubuntu's amd64v3 builds LDFLAGS also contain -march=x86-64-v3,
which apxs rejects the same way:

  apxs:Error: Unknown option: m.
  apxs:Error: Unknown option: r.

So the problem is general: any bare flag in LDFLAGS breaks the apxs call.

Attached is a proper fix (apxs-wrap-ldflags.patch, applies after
destdir.patch). apxs strips one "-Wl," from each -Wl,<flag> option and
passes <flag> on to the libtool link command, so the patch wraps every
LDFLAGS entry as -Wl,<flag>. With it, the package builds with
LDFLAGS containing "-flto=auto -ffat-lto-objects -march=x86-64-v3", and
with the default flags. The resulting module still gets full RELRO and
BIND_NOW from the hardening flags. The optimize=-lto change is not needed
with this patch.

We are applying it in Ubuntu as 1.1.19-2.2ubuntu1.

Thanks,
Description: Pass LDFLAGS to apxs in -Wl, form
 apxs only accepts linker flags as -Wl,<flag>; it strips the -Wl, prefix
 and passes <flag> to the libtool link command. Makefile.in passed LDFLAGS
 unwrapped, so any bare flag from the distribution build flags (e.g.
 -flto=auto -ffat-lto-objects with LTO, or -march=x86-64-v3 on amd64v3)
 made apxs abort with "Unknown option". Wrap each LDFLAGS entry instead.
Author: Sebastien Bacher <[email protected]>
Bug-Debian: https://bugs.debian.org/1150744
Bug-Ubuntu: https://launchpad.net/bugs/2170636
Forwarded: https://bugs.debian.org/1150744
Last-Update: 2026-10-13

--- a/Makefile.in
+++ b/Makefile.in
@@ -6,8 +6,14 @@ TLS=@TLS@
 ACTIVATE=@ACTIVATE@
 TARGET=.libs/mod_ldap_userdir.so
 
+# apxs only accepts linker flags as -Wl,<flag> (it strips the -Wl, and
+# passes <flag> on to the libtool link command), so wrap each LDFLAGS
+# entry instead of passing bare flags such as -flto=auto or -march=...
+comma:=,
+APXS_LDFLAGS=$(foreach f,$(LDFLAGS),-Wl$(comma)$(f))
+
 $(TARGET): Makefile mod_ldap_userdir.c
-	$(APXS) -c $(CPPFLAGS) $(LDFLAGS) $(LIBS) $(TLS) mod_ldap_userdir.c
+	$(APXS) -c $(CPPFLAGS) $(APXS_LDFLAGS) $(LIBS) $(TLS) mod_ldap_userdir.c
 
 install: $(TARGET)
 	$(APXS) -S LIBEXECDIR=$(DESTDIR)`$(APXS) -q LIBEXECDIR` -in ldap_userdir $(ACTIVATE) $(TARGET)

Reply via email to