Problem with Win32 pg_dump linking and symbols

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Cc: PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgreSQL(dot)org>
Subject: Problem with Win32 pg_dump linking and symbols
Date: 2004-10-05 16:35:15
Message-ID: 200410051635.i95GZFg11050@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers pgsql-hackers-win32

As some of you know, in the past few days I have tightened up the use of
libpgport so it is less prone to breakage from code changes. However,
in the cleanup, I found an unusual problem with linking pg_dump on
Win32. If I build pg_dump linking in libpgport and libpq, I get a
failure due to a duplicate symbol in both libraries:

gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -O1 -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align pg_dump.o common.o pg_dump_sort.o pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o pg_backup_files.o pg_backup_null.o pg_backup_tar.o dumputils.o ../../../src/backend/parser/keywords.o -L../../../src/interfaces/libpq -lpq -L../../../src/port -O1 -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align -lpgport -lwsock32 -lm -lws2_32 -o pg_dump.exe
../../../src/port/libpgport.a(pgstrcasecmp.o)(.text+0x2aa):pgstrcasecmp.c: multiple definition of `pg_tolower'
../../../src/interfaces/libpq/libpq.a(ds00154.o)(.text+0x0): first defined here
make: *** [pg_dump] Error 1

I have temporarily fixed this by adding a few lines to the pg_dump
makefile that explicitly link in port/exec.o:

# not sure why MinGW needs this but it prevents a link failure
ifeq ($(PORTNAME), win32)
EXTRA_OBJS += $(top_builddir)/src/port/exec.o
endif

port/exec.o was used in previous build but shouldn't be needed anymore
because a client-level build is already in libpgport.

The error report is right that the symbol exists in both libraries, but
psql also uses items from pgstrcasecmp.c (pg_tolower) and exec.c but
builds fine without using exec.o directly on the link line:

gcc -O2 -fno-strict-aliasing -Wall -Wmissing-prototypes -Wmissing-declarations -O1 -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align command.o common.o help.o input.o stringutils.o mainloop.o copy.o startup.o prompt.o variables.o large_obj.o print.o describe.o psqlscan.o tab-complete.o mbprint.o -L../../../src/interfaces/libpq -lpq -L../../../src/port -O1 -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align -lpgport -lwsock32 -lm -lws2_32 -o psql.exe

Any ideas on why this is happening? What are the rules for Win32
linkage? Doesn't it take the first matching library symbol? Can people
reproduce this failure? Why is pg_dump different from psql linkage?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Browse pgsql-hackers by date

  From Date Subject
Next Message Abhijit Menon-Sen 2004-10-05 16:59:41 Re: libpq and prepared statements progress for 8.0
Previous Message Stefan Kaltenbrunner 2004-10-05 16:27:43 Re: -HEAD build failure on OpenBSD 3.6-current/Sparc64

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Reini Urban 2004-10-05 17:45:50 win32 tablespace handing
Previous Message Reini Urban 2004-10-04 21:25:35 Re: open item: tablespace handing in pg_dump/pg_restore