1From 001971eef84485562f912d8edd4fc7688acfad91 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 8 Mar 2022 22:38:47 -0800
4Subject: [PATCH] configure: Pass LDFLAGS to link tests
5
6LDFLAGS can contain critical flags without which linking wont succeed
7therefore ensure that all configure tests involving link time checks are
8using LDFLAGS on compiler commandline along with CFLAGS to ensure the
9tests perform correctly. Without this some tests may fail resulting in
10wrong confgure result, ending in miscompiling the package
11
12Upstream-Status: Submitted [https://github.com/madler/zlib/pull/599]
13
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 configure | 12 ++++++------
17 1 file changed, 6 insertions(+), 6 deletions(-)
18
19diff --git a/configure b/configure
20index e974d1f..69dfa3f 100755
21--- a/configure
22+++ b/configure
23@@ -410,7 +410,7 @@ if test $shared -eq 1; then
24   echo Checking for shared library support... | tee -a configure.log
25   # we must test in two steps (cc then ld), required at least on SunOS 4.x
26   if try $CC -w -c $SFLAGS $test.c &&
27-     try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
28+     try $LDSHARED $SFLAGS $LDFLAGS -o $test$shared_ext $test.o; then
29     echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
30   elif test -z "$old_cc" -a -z "$old_cflags"; then
31     echo No shared library support. | tee -a configure.log
32@@ -492,7 +492,7 @@ int main(void) {
33 }
34 EOF
35   fi
36-  if try $CC $CFLAGS -o $test $test.c; then
37+  if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
38     sizet=`./$test`
39     echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
40   else
41@@ -530,7 +530,7 @@ int main(void) {
42   return 0;
43 }
44 EOF
45-  if try $CC $CFLAGS -o $test $test.c; then
46+  if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
47     echo "Checking for fseeko... Yes." | tee -a configure.log
48   else
49     CFLAGS="${CFLAGS} -DNO_FSEEKO"
50@@ -547,7 +547,7 @@ cat > $test.c <<EOF
51 #include <errno.h>
52 int main() { return strlen(strerror(errno)); }
53 EOF
54-if try $CC $CFLAGS -o $test $test.c; then
55+if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
56   echo "Checking for strerror... Yes." | tee -a configure.log
57 else
58   CFLAGS="${CFLAGS} -DNO_STRERROR"
59@@ -654,7 +654,7 @@ int main()
60   return (mytest("Hello%d\n", 1));
61 }
62 EOF
63-  if try $CC $CFLAGS -o $test $test.c; then
64+  if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
65     echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
66
67     echo >> configure.log
68@@ -744,7 +744,7 @@ int main()
69 }
70 EOF
71
72-  if try $CC $CFLAGS -o $test $test.c; then
73+  if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
74     echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
75
76     echo >> configure.log
77--
782.35.1
79
80