]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: extract ARCH_FLAGS out of LDFLAGS
authorWilly Tarreau <w@1wt.eu>
Wed, 10 Apr 2024 16:16:44 +0000 (18:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Apr 2024 15:33:28 +0000 (17:33 +0200)
ARCH_FLAGS used to be merged into LDFLAGS so that it was not possible to
pass extra options to LDFLAGS without losing ARCH_FLAGS. This commit now
splits them apart and leaves LDFLAGS empty by default. The doc explains
how to use it for rpath and such occasional use cases.

INSTALL
Makefile

diff --git a/INSTALL b/INSTALL
index 48260e481c2af9c0f9e7f9b0080489ae3cb3e818..2e15c8398a66e1e6ec08aa9b3893e8f8c7c8f544 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -622,6 +622,15 @@ and building with the address sanitizer (ASAN) simply requires:
 
     $ make TARGET=linux-glibc ARCH_FLAGS="-fsanitize=address -g"
 
+If a particular target requires specific link-time flags, these can be passed
+via the LDFLAGS variable. This variable is passed to the linker immediately
+after ARCH_FLAGS. One of the common use cases is to add some run time search
+paths for a dynamic library that's not part of the default system search path:
+
+    $ make -j $(nproc) TARGET=generic USE_OPENSSL_AWSLC=1 USE_QUIC=1 \
+      SSL_INC=/opt/aws-lc/include SSL_LIB=/opt/aws-lc/lib \
+      LDFLAGS="-Wl,-rpath,/opt/aws-lc/lib"
+
 Recent systems can resolve IPv6 host names using getaddrinfo(). This primitive
 is not present in all libcs and does not work in all of them either. Support in
 glibc was broken before 2.3. Some embedded libs may not properly work either,
index 44d5bd9a86a51f6ad815f9f1c45f8c0d8069980f..c308a8fdeb7f320822883c0c55022b76c21158ed 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -290,11 +290,12 @@ ARCH_FLAGS        = -g
 # Just set CFLAGS to the desired ones on the "make" command line.
 CFLAGS =
 
-#### Common LDFLAGS
-# These LDFLAGS are used as the first "ld" options, regardless of any library
-# path or any other option. They may be changed to add any linker-specific
-# option at the beginning of the ld command line.
-LDFLAGS = $(ARCH_FLAGS) -g
+#### Extra LDFLAGS
+# These LDFLAGS are used as the first "ld" options just after ARCH_FLAGS,
+# regardless of any library path or any other option. They may be used to add
+# any linker-specific option at the beginning of the ld command line. It may be
+# convenient to set a run time search path (-rpath), see INSTALL for more info.
+LDFLAGS =
 
 #### list of all "USE_*" options. These ones must be updated if new options are
 # added, so that the relevant options are properly added to the CFLAGS and to
@@ -1000,7 +1001,7 @@ else
 endif # non-empty target
 
 haproxy: $(OPTIONS_OBJS) $(OBJS)
-       $(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
+       $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS)
 
 objsize: haproxy
        $(Q)objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
@@ -1009,31 +1010,31 @@ objsize: haproxy
        $(cmd_CC) $(COPTS) -c -o $@ $<
 
 admin/halog/halog: admin/halog/halog.o admin/halog/fgets2.o src/ebtree.o src/eb32tree.o src/eb64tree.o src/ebmbtree.o src/ebsttree.o src/ebistree.o src/ebimtree.o
-       $(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
+       $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS)
 
 admin/dyncookie/dyncookie: admin/dyncookie/dyncookie.o
-       $(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
+       $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS)
 
 dev/flags/flags: dev/flags/flags.o
-       $(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
+       $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS)
 
 dev/haring/haring: dev/haring/haring.o
-       $(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
+       $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS)
 
 dev/hpack/%: dev/hpack/%.o
-       $(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
+       $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS)
 
 dev/poll/poll:
        $(cmd_MAKE) -C dev/poll poll CC='$(CC)' OPTIMIZE='$(COPTS)' V='$(V)'
 
 dev/qpack/decode: dev/qpack/decode.o
-       $(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
+       $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS)
 
 dev/tcploop/tcploop:
        $(cmd_MAKE) -C dev/tcploop tcploop CC='$(CC)' OPTIMIZE='$(COPTS)' V='$(V)'
 
 dev/udp/udp-perturb: dev/udp/udp-perturb.o
-       $(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
+       $(cmd_LD) $(ARCH_FLAGS) $(LDFLAGS) -o $@ $^ $(LDOPTS)
 
 # rebuild it every time
 .PHONY: src/version.c dev/poll/poll dev/tcploop/tcploop