bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] {md5,sha1,sha256,sha512,sm3}-stream: avoid duplicate symbols


From: Jan Palus
Subject: Re: [PATCH] {md5,sha1,sha256,sha512,sm3}-stream: avoid duplicate symbols
Date: Sun, 17 Nov 2024 18:04:52 +0100
User-agent: NeoMutt/20241114

On 17.11.2024 15:53, Bruno Haible wrote:
> Jan Palus wrote:
> > Fixes linking ie:
> > mold: error: duplicate symbol: ../lib/.libs/libgnu.a(libgnu_la-md5.o): 
> > ../lib/.libs/libgnu.a(libgnu_la-md5-stream.o): md5_init_ctx
> 
> How to reproduce the problem?
> 1) Which package did you build?
> 2) On which platform?
> 3) With which values for CC, CPPFLAGS, CFLAGS, LDFLAGS?
> 4) With which configure options?
> 5) Do you get the same link error also when using GNU ld instead of 'mold'?

The error was spotted when building lftp on Linux which uses
-Wl,--whole-archive that appears to trigger the behavior.

I was able to reproduce it with just gnulib:

cd gnulib
./gnulib-tool --create-testdir --dir=build crypto/md5
cd build
./configure --with-openssl=yes
make
cd gltests

GNU ld:

$ gcc -fuse-ld=bfd -o test-md5-buffer test-md5-buffer.o -Wl,--whole-archive 
../gllib/libgnu.a -Wl,-no-whole-archive -lcrypto
/usr/bin/ld.bfd: ../gllib/libgnu.a(md5.o): in function `md5_init_ctx':
/.../gnulib/build/gllib/md5.c:81: multiple definition of `md5_init_ctx'; 
../gllib/libgnu.a(md5-stream.o):/.../gnulib/build/gllib/md5-stream.c:81: first 
defined here
/usr/bin/ld.bfd: ../gllib/libgnu.a(md5.o): in function `md5_process_bytes':
/.../gnulib/build/gllib/md5.c:87: multiple definition of `md5_process_bytes'; 
../gllib/libgnu.a(md5-stream.o):/.../gnulib/build/gllib/md5-stream.c:87: first 
defined here
/usr/bin/ld.bfd: ../gllib/libgnu.a(md5.o): in function `md5_process_block':
/.../gnulib/build/gllib/md5.c:90: multiple definition of `md5_process_block'; 
../gllib/libgnu.a(md5-stream.o):/.../gnulib/build/gllib/md5-stream.c:90: first 
defined here
/usr/bin/ld.bfd: ../gllib/libgnu.a(md5.o): in function `md5_finish_ctx':
/.../gnulib/build/gllib/md5.c:96: multiple definition of `md5_finish_ctx'; 
../gllib/libgnu.a(md5-stream.o):/.../gnulib/build/gllib/md5-stream.c:96: first 
defined here
/usr/bin/ld.bfd: ../gllib/libgnu.a(md5.o): in function `md5_buffer':
/.../gnulib/build/gllib/md5.c:100: multiple definition of `md5_buffer'; 
../gllib/libgnu.a(md5-stream.o):/.../gnulib/build/gllib/md5-stream.c:100: first 
defined here
/usr/bin/ld.bfd: ../gllib/libgnu.a(md5.o): in function `md5_read_ctx':
/.../gnulib/build/gllib/md5.c:104: multiple definition of `md5_read_ctx'; 
../gllib/libgnu.a(md5-stream.o):/.../gnulib/build/gllib/md5-stream.c:104: first 
defined here
collect2: error: ld returned 1 exit status

mold:

$ gcc -fuse-ld=mold -o test-md5-buffer test-md5-buffer.o -Wl,--whole-archive 
../gllib/libgnu.a -Wl,-no-whole-archive -lcrypto                                
            
mold: error: duplicate symbol: ../gllib/libgnu.a(md5.o): 
../gllib/libgnu.a(md5-stream.o): md5_init_ctx
mold: error: duplicate symbol: ../gllib/libgnu.a(md5.o): 
../gllib/libgnu.a(md5-stream.o): md5_process_bytes
mold: error: duplicate symbol: ../gllib/libgnu.a(md5.o): 
../gllib/libgnu.a(md5-stream.o): md5_process_block
mold: error: duplicate symbol: ../gllib/libgnu.a(md5.o): 
../gllib/libgnu.a(md5-stream.o): md5_finish_ctx
mold: error: duplicate symbol: ../gllib/libgnu.a(md5.o): 
../gllib/libgnu.a(md5-stream.o): md5_buffer
mold: error: duplicate symbol: ../gllib/libgnu.a(md5.o): 
../gllib/libgnu.a(md5-stream.o): md5_read_ctx
collect2: error: ld returned 1 exit status

lld:

$ gcc -fuse-ld=lld -o test-md5-buffer test-md5-buffer.o -Wl,--whole-archive 
../gllib/libgnu.a -Wl,-no-whole-archive -lcrypto                                
            
ld.lld: error: duplicate symbol: md5_init_ctx
>>> defined at gl_openssl.h:81 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:81)
>>>            md5-stream.o:(md5_init_ctx) in archive ../gllib/libgnu.a
>>> defined at gl_openssl.h:81 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:81)
>>>            md5.o:(.text+0x0) in archive ../gllib/libgnu.a

ld.lld: error: duplicate symbol: md5_process_bytes
>>> defined at gl_openssl.h:87 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:87)
>>>            md5-stream.o:(md5_process_bytes) in archive ../gllib/libgnu.a
>>> defined at gl_openssl.h:87 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:87)
>>>            md5.o:(.text+0x4) in archive ../gllib/libgnu.a

ld.lld: error: duplicate symbol: md5_process_block
>>> defined at gl_openssl.h:90 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:90)
>>>            md5-stream.o:(md5_process_block) in archive ../gllib/libgnu.a
>>> defined at gl_openssl.h:90 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:90)
>>>            md5.o:(.text+0x20) in archive ../gllib/libgnu.a

ld.lld: error: duplicate symbol: md5_finish_ctx
>>> defined at gl_openssl.h:96 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:96)
>>>            md5-stream.o:(md5_finish_ctx) in archive ../gllib/libgnu.a
>>> defined at gl_openssl.h:96 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:96)
>>>            md5.o:(.text+0x40) in archive ../gllib/libgnu.a

ld.lld: error: duplicate symbol: md5_buffer
>>> defined at gl_openssl.h:100 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:100)
>>>            md5-stream.o:(md5_buffer) in archive ../gllib/libgnu.a
>>> defined at gl_openssl.h:100 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:100)
>>>            md5.o:(.text+0x6C) in archive ../gllib/libgnu.a

ld.lld: error: duplicate symbol: md5_read_ctx
>>> defined at gl_openssl.h:104 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:104)
>>>            md5-stream.o:(md5_read_ctx) in archive ../gllib/libgnu.a
>>> defined at gl_openssl.h:104 
>>> (/home/users/jan/devel/gnulib/build/gllib/gl_openssl.h:104)
>>>            md5.o:(.text+0x70) in archive ../gllib/libgnu.a
collect2: error: ld returned 1 exit status



reply via email to

[Prev in Thread] Current Thread [Next in Thread]