On Mon, Dec 31, 2018 at 11:24 PM Donald Dong <xd...@csumb.edu> wrote: > > Hi, > > In src/test/example, the implicit make rules produce errors: > > make -C ../../../src/backend generated-headers > make[1]: Entering directory '/home/ddong/postgresql/bld/src/backend' > make -C catalog distprep generated-header-symlinks > make[2]: Entering directory '/home/ddong/postgresql/bld/src/backend/catalog' > make[2]: Nothing to be done for 'distprep'. > make[2]: Nothing to be done for 'generated-header-symlinks'. > make[2]: Leaving directory '/home/ddong/postgresql/bld/src/backend/catalog' > make -C utils distprep generated-header-symlinks > make[2]: Entering directory '/home/ddong/postgresql/bld/src/backend/utils' > make[2]: Nothing to be done for 'distprep'. > make[2]: Nothing to be done for 'generated-header-symlinks'. > make[2]: Leaving directory '/home/ddong/postgresql/bld/src/backend/utils' > make[1]: Leaving directory '/home/ddong/postgresql/bld/src/backend' > gcc -Wall -Wmissing-prototypes -Wpointer-arith > -Wdeclaration-after-statement -Werror=vla -Wendif-labels > -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing > -fwrapv -fexcess-precision=standard -Wno-format-truncation -O2 > -I/home/ddong/postgresql/bld/../src/interfaces/libpq > -I../../../src/include -I/home/ddong/postgresql/bld/../src/include > -D_GNU_SOURCE -c -o testlibpq.o > /home/ddong/postgresql/bld/../src/test/examples/testlibpq.c > gcc -L../../../src/port -L../../../src/common -L../../../src/common > -lpgcommon -L../../../src/port -lpgport > -L../../../src/interfaces/libpq -lpq -Wl,--as-needed > -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags testlibpq.o -o > testlibpq > testlibpq.o: In function `exit_nicely': > testlibpq.c:(.text.unlikely+0x5): undefined reference to `PQfinish' > testlibpq.o: In function `main': > testlibpq.c:(.text.startup+0x22): undefined reference to `PQconnectdb' > testlibpq.c:(.text.startup+0x2d): undefined reference to `PQstatus' > testlibpq.c:(.text.startup+0x44): undefined reference to `PQexec’ > … > > I think the -lpq flag does not have any effects in the middle of the > arguments. It works if move the flag to the end: > > gcc -L../../../src/port -L../../../src/common -L../../../src/common > -lpgcommon -L../../../src/port -lpgport > -L../../../src/interfaces/libpq -Wl,--as-needed > -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags testlibpq.o -o > testlibpq -lpq > > So I added an explicit rule to rearrange the flags: > > gcc testlibpq.o -o testlibpq -L../../../src/port -L../../../src/common > -L../../../src/common -lpgcommon -L../../../src/port -lpgport > -L../../../src/interfaces/libpq -lpq -Wl,--as-needed > -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags > > Then the make command works as expected. This is my first time writing > a patch. Please let me know what you think! > > Thank you, > Happy new year! > Donald Dong
-- Donald Dong
explicit_make_rule_test_example_v1.patch
Description: Binary data