Обсуждение: BUG #4731: compile with -fast fails on ld: duplicate symbol _PGP_S2K_TYPE in pgp.o and pgp-mpi-openssl.o

Поиск
Список
Период
Сортировка
The following bug has been logged online:

Bug reference:      4731
Logged by:          Ceriel Jacobs
Email address:      cerieljacobs@gmail.com
PostgreSQL version: 8.3.7
Operating system:   OS X 10.5.6
Description:        compile with -fast fails on ld: duplicate symbol
_PGP_S2K_TYPE in pgp.o and pgp-mpi-openssl.o
Details:

Compilation fails on:
/usr/bin/gcc-4.2 -no-cpp-precomp -fast -march=nocona -isysroot
/Developer/SDKs/MacOSX10.5.sdk -arch x86_64 -Wall -Wmissing-prototypes
-Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels
-fno-strict-aliasing -fwrapv  -bundle -multiply_defined suppress  pgcrypto.o
px.o px-hmac.o px-crypt.o crypt-gensalt.o crypt-blowfish.o crypt-des.o
crypt-md5.o openssl.o pgp-mpi-openssl.o mbuf.o pgp.o pgp-armor.o pgp-cfb.o
pgp-compress.o pgp-decrypt.o pgp-encrypt.o pgp-info.o pgp-mpi.o pgp-pubdec.o
pgp-pubenc.o pgp-pubkey.o pgp-s2k.o pgp-pgsql.o  -L../../src/port
-L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -bundle_loader
../../src/backend/postgres  -lcrypto -lz -o libpgcrypto.0.0.so
ld: duplicate symbol _PGP_S2K_TYPE in pgp.o and pgp-mpi-openssl.o
collect2: ld returned 1 exit status
gnumake: *** [libpgcrypto.0.0.so] Error 1

Environment:
Processor: core2duo (64-bit)
GCC: i686-apple-darwin9-gcc-4.2.1

-fast  =  -O3
          -fomit-frame-pointer
          -fstrict-aliasing
          -momit-leaf-frame-pointer
          -fno-tree-pre
          -falign-loops

When only specifying -O3, compilation succeeds.
"Ceriel Jacobs" <cerieljacobs@gmail.com> writes:
> ld: duplicate symbol _PGP_S2K_TYPE in pgp.o and pgp-mpi-openssl.o

I think at bottom that's a compiler/linker bug which you should mention
to Apple.  However, I see what is causing it: pgp.h contains

enum
{
    PGP_S2K_SIMPLE = 0,
    PGP_S2K_SALTED = 1,
    PGP_S2K_ISALTED = 3
} PGP_S2K_TYPE;

I think what was meant was

enum PGP_S2K_TYPE
{
    PGP_S2K_SIMPLE = 0,
    PGP_S2K_SALTED = 1,
    PGP_S2K_ISALTED = 3
};

because what the first one is doing is defining a global variable
that is of an anonymous enum type.

Marko, am I right that this is just a syntax mistake, and not
intentional creation of a variable?  There are several occurrences
of the pattern in pgp.h.

            regards, tom lane
Marko Kreen <markokr@gmail.com> writes:
> On 3/25/09, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Marko, am I right that this is just a syntax mistake, and not
>> intentional creation of a variable?  There are several occurrences
>> of the pattern in pgp.h.

> Yes, it's syntax bug.  Should I send patch?

No need, I think I can figure it out ;-)

            regards, tom lane
On 3/25/09, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Ceriel Jacobs" <cerieljacobs@gmail.com> writes:
>  > ld: duplicate symbol _PGP_S2K_TYPE in pgp.o and pgp-mpi-openssl.o
>
>  I think at bottom that's a compiler/linker bug which you should mention
>  to Apple.  However, I see what is causing it: pgp.h contains
>
>  enum
>  {
>         PGP_S2K_SIMPLE = 0,
>         PGP_S2K_SALTED = 1,
>         PGP_S2K_ISALTED = 3
>  } PGP_S2K_TYPE;
>
>  I think what was meant was
>
>  enum PGP_S2K_TYPE
>  {
>         PGP_S2K_SIMPLE = 0,
>         PGP_S2K_SALTED = 1,
>         PGP_S2K_ISALTED = 3
>  };
>
>  because what the first one is doing is defining a global variable
>  that is of an anonymous enum type.

Eh, it's silly mistake indeed.

>  Marko, am I right that this is just a syntax mistake, and not
>  intentional creation of a variable?  There are several occurrences
>  of the pattern in pgp.h.

Yes, it's syntax bug.  Should I send patch?

--
marko