Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbbc20c8

Browse files
committed
Don't put library-supplied -L/-I switches before user-supplied ones.
For many optional libraries, we extract the -L and -l switches neededto link the library from a helper program such as llvm-config. Insome cases we put the resulting -L switches into LDFLAGS ahead of-L switches specified via --with-libraries. That risks breakingthe user's intention for --with-libraries.It's not such a problem if the library's -L switch points to adirectory containing only that library, but on some platforms alibrary helper may "helpfully" offer a switch such as -L/usr/libthat points to a directory holding all standard libraries. If theuser specified --with-libraries in hopes of overriding the standardbuild of some library, the -L/usr/lib switch prevents that fromhappening since it will come before the user-specified directory.To fix, avoid inserting these switches directly into LDFLAGS duringconfigure, instead adding them to LIBDIRS or SHLIB_LINK. They willstill eventually get added to LDFLAGS, but only after the switchescoming from --with-libraries.The same problem exists for -I switches: those coming from--with-includes should appear before any coming from helper programssuch as llvm-config. We have not heard field complaints about thiscase, but it seems certain that a user attempting to override astandard library could have issues.The changes for this go well beyond configure itself, however,because many Makefiles have occasion to manipulate CPPFLAGS toinsert locally-desirable -I switches, and some of them got it wrong.The correct ordering is any -I switches pointing at within-the-source-tree-or-build-tree directories, then those from the tree-wideCPPFLAGS, then those from helper programs. There were several placesthat risked pulling in a system-supplied copy of libpq headers, forexample, instead of the in-tree files. (Commitcb36f8e fixed oneinstance of that a few months ago, but this exercise found more.)The Meson build scripts may or may not have any comparable problems,but I'll leave it to someone else to investigate that.Reported-by: Charles Samborski <demurgos@demurgos.net>Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/70f2155f-27ca-4534-b33d-7750e20633d7@demurgos.netBackpatch-through: 13
1 parent762c6d8 commitbbc20c8

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

‎config/llvm.m4‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# -----------------
55
#
66
# Look for the LLVM installation, check that it's new enough, set the
7-
# corresponding LLVM_{CFLAGS,CXXFLAGS,BINPATH} and LDFLAGS
7+
# corresponding LLVM_{CFLAGS,CXXFLAGS,BINPATH,LIBS}
88
# variables. Also verify that CLANG is available, to transform C
99
# into bitcode.
1010
#
@@ -55,7 +55,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
5555
5656
for pgac_option in `$LLVM_CONFIG --ldflags`; do
5757
case $pgac_option in
58-
-L*)LDFLAGS="$LDFLAGS $pgac_option";;
58+
-L*)LLVM_LIBS="$LLVM_LIBS $pgac_option";;
5959
esac
6060
done
6161

‎configure‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5207,7 +5207,7 @@ fi
52075207

52085208
for pgac_option in `$LLVM_CONFIG --ldflags`; do
52095209
case $pgac_option in
5210-
-L*)LDFLAGS="$LDFLAGS $pgac_option";;
5210+
-L*)LLVM_LIBS="$LLVM_LIBS $pgac_option";;
52115211
esac
52125212
done
52135213

@@ -9332,12 +9332,12 @@ fi
93329332
# Note the user could also set XML2_CFLAGS/XML2_LIBS directly
93339333
for pgac_option in $XML2_CFLAGS; do
93349334
case $pgac_option in
9335-
-I*|-D*)CPPFLAGS="$CPPFLAGS $pgac_option";;
9335+
-I*|-D*)INCLUDES="$INCLUDES $pgac_option";;
93369336
esac
93379337
done
93389338
for pgac_option in $XML2_LIBS; do
93399339
case $pgac_option in
9340-
-L*)LDFLAGS="$LDFLAGS $pgac_option";;
9340+
-L*)LIBDIRS="$LIBDIRS $pgac_option";;
93419341
esac
93429342
done
93439343
fi
@@ -9562,12 +9562,12 @@ fi
95629562
# note that -llz4 will be added by AC_CHECK_LIB below.
95639563
for pgac_option in $LZ4_CFLAGS; do
95649564
case $pgac_option in
9565-
-I*|-D*)CPPFLAGS="$CPPFLAGS $pgac_option";;
9565+
-I*|-D*)INCLUDES="$INCLUDES $pgac_option";;
95669566
esac
95679567
done
95689568
for pgac_option in $LZ4_LIBS; do
95699569
case $pgac_option in
9570-
-L*)LDFLAGS="$LDFLAGS $pgac_option";;
9570+
-L*)LIBDIRS="$LIBDIRS $pgac_option";;
95719571
esac
95729572
done
95739573
fi
@@ -9703,12 +9703,12 @@ fi
97039703
# note that -lzstd will be added by AC_CHECK_LIB below.
97049704
for pgac_option in $ZSTD_CFLAGS; do
97059705
case $pgac_option in
9706-
-I*|-D*)CPPFLAGS="$CPPFLAGS $pgac_option";;
9706+
-I*|-D*)INCLUDES="$INCLUDES $pgac_option";;
97079707
esac
97089708
done
97099709
for pgac_option in $ZSTD_LIBS; do
97109710
case $pgac_option in
9711-
-L*)LDFLAGS="$LDFLAGS $pgac_option";;
9711+
-L*)LIBDIRS="$LIBDIRS $pgac_option";;
97129712
esac
97139713
done
97149714
fi
@@ -16721,7 +16721,7 @@ fi
1672116721

1672216722
if test "$with_icu" = yes; then
1672316723
ac_save_CPPFLAGS=$CPPFLAGS
16724-
CPPFLAGS="$ICU_CFLAGS $CPPFLAGS"
16724+
CPPFLAGS="$CPPFLAGS $ICU_CFLAGS"
1672516725

1672616726
# Verify we have ICU's header files
1672716727
ac_fn_c_check_header_mongrel "$LINENO" "unicode/ucol.h" "ac_cv_header_unicode_ucol_h" "$ac_includes_default"
@@ -18876,7 +18876,7 @@ Use --without-tcl to disable building PL/Tcl." "$LINENO" 5
1887618876
fi
1887718877
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
1887818878
ac_save_CPPFLAGS=$CPPFLAGS
18879-
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
18879+
CPPFLAGS="$CPPFLAGS $TCL_INCLUDE_SPEC"
1888018880
ac_fn_c_check_header_mongrel "$LINENO" "tcl.h" "ac_cv_header_tcl_h" "$ac_includes_default"
1888118881
if test "x$ac_cv_header_tcl_h" = xyes; then :
1888218882

@@ -18945,7 +18945,7 @@ fi
1894518945
# check for <Python.h>
1894618946
if test "$with_python" = yes; then
1894718947
ac_save_CPPFLAGS=$CPPFLAGS
18948-
CPPFLAGS="$python_includespec $CPPFLAGS"
18948+
CPPFLAGS="$CPPFLAGS $python_includespec"
1894918949
ac_fn_c_check_header_mongrel "$LINENO" "Python.h" "ac_cv_header_Python_h" "$ac_includes_default"
1895018950
if test "x$ac_cv_header_Python_h" = xyes; then :
1895118951

‎configure.ac‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,12 +1071,12 @@ if test "$with_libxml" = yes ; then
10711071
# Note the user could also set XML2_CFLAGS/XML2_LIBS directly
10721072
for pgac_option in $XML2_CFLAGS; do
10731073
case $pgac_option in
1074-
-I*|-D*)CPPFLAGS="$CPPFLAGS $pgac_option";;
1074+
-I*|-D*)INCLUDES="$INCLUDES $pgac_option";;
10751075
esac
10761076
done
10771077
for pgac_option in $XML2_LIBS; do
10781078
case $pgac_option in
1079-
-L*)LDFLAGS="$LDFLAGS $pgac_option";;
1079+
-L*)LIBDIRS="$LIBDIRS $pgac_option";;
10801080
esac
10811081
done
10821082
fi
@@ -1120,12 +1120,12 @@ if test "$with_lz4" = yes; then
11201120
# note that -llz4 will be added by AC_CHECK_LIB below.
11211121
for pgac_option in $LZ4_CFLAGS; do
11221122
case $pgac_option in
1123-
-I*|-D*)CPPFLAGS="$CPPFLAGS $pgac_option";;
1123+
-I*|-D*)INCLUDES="$INCLUDES $pgac_option";;
11241124
esac
11251125
done
11261126
for pgac_option in $LZ4_LIBS; do
11271127
case $pgac_option in
1128-
-L*)LDFLAGS="$LDFLAGS $pgac_option";;
1128+
-L*)LIBDIRS="$LIBDIRS $pgac_option";;
11291129
esac
11301130
done
11311131
fi
@@ -1145,12 +1145,12 @@ if test "$with_zstd" = yes; then
11451145
# note that -lzstd will be added by AC_CHECK_LIB below.
11461146
for pgac_option in $ZSTD_CFLAGS; do
11471147
case $pgac_option in
1148-
-I*|-D*)CPPFLAGS="$CPPFLAGS $pgac_option";;
1148+
-I*|-D*)INCLUDES="$INCLUDES $pgac_option";;
11491149
esac
11501150
done
11511151
for pgac_option in $ZSTD_LIBS; do
11521152
case $pgac_option in
1153-
-L*)LDFLAGS="$LDFLAGS $pgac_option";;
1153+
-L*)LIBDIRS="$LIBDIRS $pgac_option";;
11541154
esac
11551155
done
11561156
fi
@@ -1949,7 +1949,7 @@ fi
19491949

19501950
if test "$with_icu" = yes; then
19511951
ac_save_CPPFLAGS=$CPPFLAGS
1952-
CPPFLAGS="$ICU_CFLAGS $CPPFLAGS"
1952+
CPPFLAGS="$CPPFLAGS $ICU_CFLAGS"
19531953

19541954
# Verify we have ICU's header files
19551955
AC_CHECK_HEADER(unicode/ucol.h,[],
@@ -2298,7 +2298,7 @@ Use --without-tcl to disable building PL/Tcl.])
22982298
fi
22992299
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
23002300
ac_save_CPPFLAGS=$CPPFLAGS
2301-
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
2301+
CPPFLAGS="$CPPFLAGS $TCL_INCLUDE_SPEC"
23022302
AC_CHECK_HEADER(tcl.h,[],[AC_MSG_ERROR([header file <tcl.h> is required for Tcl])])
23032303
CPPFLAGS=$ac_save_CPPFLAGS
23042304
fi
@@ -2335,7 +2335,7 @@ fi
23352335
# check for <Python.h>
23362336
if test "$with_python" = yes; then
23372337
ac_save_CPPFLAGS=$CPPFLAGS
2338-
CPPFLAGS="$python_includespec $CPPFLAGS"
2338+
CPPFLAGS="$CPPFLAGS $python_includespec"
23392339
AC_CHECK_HEADER(Python.h,[],[AC_MSG_ERROR([header file <Python.h> is required for Python])])
23402340
CPPFLAGS=$ac_save_CPPFLAGS
23412341
fi

‎src/Makefile.global.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ CPP = @CPP@
240240
CPPFLAGS = @CPPFLAGS@
241241
PG_SYSROOT = @PG_SYSROOT@
242242

243-
overrideCPPFLAGS:=$(ICU_CFLAGS)$(CPPFLAGS)
243+
overrideCPPFLAGS+=$(ICU_CFLAGS)
244244

245245
ifdefPGXS
246246
overrideCPPFLAGS := -I$(includedir_server) -I$(includedir_internal)$(CPPFLAGS)

‎src/backend/jit/llvm/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ endif
3131
# All files in this directory use LLVM.
3232
CFLAGS +=$(LLVM_CFLAGS)
3333
CXXFLAGS +=$(LLVM_CXXFLAGS)
34-
overrideCPPFLAGS:=$(LLVM_CPPFLAGS)$(CPPFLAGS)
34+
overrideCPPFLAGS+=$(LLVM_CPPFLAGS)
3535
SHLIB_LINK +=$(LLVM_LIBS)
3636

3737
# Because this module includes C++ files, we need to use a C++

‎src/bin/initdb/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ subdir = src/bin/initdb
1616
top_builddir = ../../..
1717
include$(top_builddir)/src/Makefile.global
1818

19-
overrideCPPFLAGS := -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone$(ICU_CFLAGS)$(CPPFLAGS)
19+
overrideCPPFLAGS := -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone$(CPPFLAGS)$(ICU_CFLAGS)
2020

2121
# Note: it's important that we link to encnames.o from libpgcommon, not
2222
# from libpq, else we have risks of version skew if we run with a libpq

‎src/interfaces/libpq/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ NAME= pq
2222
SO_MAJOR_VERSION= 5
2323
SO_MINOR_VERSION=$(MAJORVERSION)
2424

25-
overrideCPPFLAGS :=-I$(srcdir)$(CPPFLAGS)-I$(top_builddir)/src/port -I$(top_srcdir)/src/port
25+
overrideCPPFLAGS := -I$(srcdir) -I$(top_builddir)/src/port -I$(top_srcdir)/src/port$(CPPFLAGS)
2626
ifneq ($(PORTNAME), win32)
2727
overrideCFLAGS +=$(PTHREAD_CFLAGS)
2828
endif

‎src/pl/plpython/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ifeq ($(PORTNAME), win32)
1111
overridepython_libspec =
1212
endif
1313

14-
overrideCPPFLAGS := -I. -I$(srcdir)$(python_includespec)$(CPPFLAGS)
14+
overrideCPPFLAGS := -I. -I$(srcdir)$(CPPFLAGS)$(python_includespec)
1515

1616
rpathdir =$(python_libdir)
1717

‎src/pl/tcl/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ top_builddir = ../../..
1111
include$(top_builddir)/src/Makefile.global
1212

1313

14-
overrideCPPFLAGS := -I. -I$(srcdir)$(TCL_INCLUDE_SPEC)$(CPPFLAGS)
14+
overrideCPPFLAGS := -I. -I$(srcdir)$(CPPFLAGS)$(TCL_INCLUDE_SPEC)
1515

1616
# On Windows, we don't link directly with the Tcl library; see below
1717
ifneq ($(PORTNAME), win32)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp