Bug 693100 - libgs.so gets built with _start etc with gcc 4.5.3
Summary: libgs.so gets built with _start etc with gcc 4.5.3
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Build Process (show other bugs)
Version: 9.05
Hardware: PC Linux
: P4 major
Assignee: Chris Liddell (chrisl)
QA Contact: Bug traffic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-10 18:57 UTC by Brian Modra
Modified: 2014-02-17 04:47 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Modra 2012-06-10 18:57:12 UTC
When the libgs.so gets created, the -shared parameter is not passed, and so it gets built with _start etc.

The source was part of the gentoo package:app-text/ghostscript-gpl-9.05-r1

/bin/sh <./soobj/ldt.tr
rm -f ./sobin/libgs.so.9
ln -s libgs.so.9.04 ./sobin/libgs.so.9
rm -f ./sobin/libgs.so
ln -s libgs.so.9.04 ./sobin/libgs.so
x86_64-pc-linux-gnu-gcc  -DHAVE_MKSTEMP -DHAVE_FILE64 -DHAVE_MKSTEMP64 -DHAVE_FONTCONFIG  -DHAVE_SETLOCALE -DHAVE_SSE2  -DHAVE_BSWAP32 -DHAVE_BYTESl -Wstrict-prototypes -Wundef -Wmissing-declarations -Wmissing-prototypes -Wwrite-strings -Wno-strict-aliasing -Wdeclaration-after-statement -fno-bHAVE_STDINT_H -DGX_COLOR_INDEX_TYPE="unsigned long int" -O2 -pipe -DUSE_LIBPAPER -DGS_DEVS_SHARED -DGS_DEVS_SHARED_DIR=\"/usr/lib64/ghostscript/9.0e  -DWHICH_CMS="lcms" -g -o ./sobin/gsc ./psi/dxmainc.c \
-Wl,-O1 -Wl,--as-needed  -L./sobin -lgs
./psi/dxmainc.c: In function 'gsdll_stderr':
./psi/dxmainc.c:67:11: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result
./psi/dxmainc.c: In function 'gsdll_stdout':
./psi/dxmainc.c:59:11: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result
./sobin/libgs.so: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/crt1.o:(.text+0x0): first defined here
./sobin/libgs.so: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/crti.o:(.fini+0x0): first defined here
./sobin/libgs.so:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/crt1.o:(.rodata.cst4+0x0): first defined here
./sobin/libgs.so: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/crt1.o:(.data+0x0): first defined here
./sobin/libgs.so: In function `main':
(.text+0xf0): multiple definition of `main'
/var/tmp/portage/app-text/ghostscript-gpl-9.04-r4/temp/cc763RLo.o:/var/tmp/portage/app-text/ghostscript-gpl-9.04-r4/work/ghostscript-9.04/./psi/dxmned here
./sobin/libgs.so: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/crti.o:(.init+0x0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: error in ./sobin/libgs.so(.eh_frame); no .eh_frame_hdr table will be
collect2: ld returned 1 exit status
make[2]: *** [sobin/gsc] Error 1

(If I edit soobj/ldt.tr, and add the -shared parameter, and then all is happy)

My environment:
# uname -a
Linux ip-10-0-0-110 2.6.38-xen #1 SMP Mon Nov 21 08:14:43 GMT 2011 x86_64 Intel(R) Xeon(R) CPU E5645 @ 2.40GHz GenuineIntel GNU/Linux

# gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.5.3-r2/work/gcc-4.5.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --disable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/python --enable-checking=release --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.3-r2 p1.5, pie-0.4.7'
Thread model: posix
gcc version 4.5.3 (Gentoo 4.5.3-r2 p1.5, pie-0.4.7)

# emerge -s ghostscript-gpl
Searching...
[ Results for search key : ghostscript-gpl ]
[ Applications found : 1 ]

*  app-text/ghostscript-gpl
      Latest version available: 9.05-r1
      Latest version installed: [ Not Installed ]
      Size of files: 27,621 kB
      Homepage:      http://ghostscript.com/
      Description:   Ghostscript is an interpreter for the PostScript language and for PDF
      License:       GPL-3 CPL-1.0
Comment 1 Chris Liddell (chrisl) 2012-06-10 19:48:48 UTC
I don't have access to gcc 4.5.3 just now, but all the versions I have access to (4.2.1, 4.3.4 and 4.6.1) all build the shared library with the "-shared" option, I can't see any reason 4.5.3 would be any different. Especially since the option is defined in "base/unix-dll.mak", so is not dependant on any tests run by configure.

Could you post the contents of the file "./soobj/ldt.tr", please?
Comment 2 Hin-Tak Leung 2012-06-10 20:33:44 UTC
(In reply to comment #0)
> /bin/sh <./soobj/ldt.tr

A few lines before this, there should be 

 ./soobj/aux/echogs -w ./soobj/ldt.tr -n - gcc -shared -Wl,-soname=libgs.so.9 -o ./sobin/libgs.so.9.04
./soobj/aux/echogs -a ./soobj/ldt.tr -n -s ./soobj/gsromfs1.o ./soobj/gs.o -s
cat ./soobj/ld.tr >>./soobj/ldt.tr

These should put "-shared" right at the top of the ./soobj/ldt.tr

> rm -f ./sobin/libgs.so.9
> ln -s libgs.so.9.04 ./sobin/libgs.so.9
> rm -f ./sobin/libgs.so
> ln -s libgs.so.9.04 ./sobin/libgs.so
> x86_64-pc-linux-gnu-gcc  -DHAVE_MKSTEMP -DHAVE_FILE64 -DHAVE_MKSTEMP64
> -DHAVE_FONTCONFIG  -DHAVE_SETLOCALE -DHAVE_SSE2  -DHAVE_BSWAP32 -DHAVE_BYTESl
> -Wstrict-prototypes -Wundef -Wmissing-declarations -Wmissing-prototypes
> -Wwrite-strings -Wno-strict-aliasing -Wdeclaration-after-statement
> -fno-bHAVE_STDINT_H -DGX_COLOR_INDEX_TYPE="unsigned long int" -O2 -pipe
> -DUSE_LIBPAPER -DGS_DEVS_SHARED
> -DGS_DEVS_SHARED_DIR=\"/usr/lib64/ghostscript/9.0e  -DWHICH_CMS="lcms" -g -o
> ./sobin/gsc ./psi/dxmainc.c \
> -Wl,-O1 -Wl,--as-needed  -L./sobin -lgs
  ^^^^^^^^^^^^^^^^^^^^^^^

Please do not override the linker flag. In particular, I think "-Wl,--as-needed" is known not to work, so please do not do that. Have a search around old bug reports.
Comment 3 Brian Modra 2012-06-11 07:08:15 UTC
(In reply to comment #2)
> Please do not override the linker flag. In particular, I think
> "-Wl,--as-needed" is known not to work, so please do not do that.

It is a gentoo problem, so I'll report it to their bugzilla. Thanks for pointing me in the right direction.

I just used the gentoo portage system to install the package without any changes:
config.log:LDFLAGS='-Wl,-O1 -Wl,--as-needed'


./soobj/aux/echogs -w ./soobj/ldt.tr -n - x86_64-pc-linux-gnu-gcc -Wl,-O1 -Wl,--as-needed  -o ./sobin/libgs.so.9.04
./soobj/aux/echogs -a ./soobj/ldt.tr -n -s ./soobj/gsromfs0.o ./soobj/gs.o -s
cat ./soobj/ld.tr >>./soobj/ldt.tr
./soobj/aux/echogs -a ./soobj/ldt.tr -s - -ldl -lm  -lpaper -rdynamic -ldl -lfontconfig   -lfreetype   -lpthread -lm
if [ x != x ]; then LD_RUN_PATH=; export LD_RUN_PATH; fi; \
XCFLAGS= XINCLUDE= XLDFLAGS= XLIBDIRS= XLIBS= \
FEATURE_DEVS= DEVICE_DEVS= DEVICE_DEVS1= DEVICE_DEVS2= DEVICE_DEVS3= \
DEVICE_DEVS4= DEVICE_DEVS5= DEVICE_DEVS6= DEVICE_DEVS7= DEVICE_DEVS8= \
DEVICE_DEVS9= DEVICE_DEVS10= DEVICE_DEVS11= DEVICE_DEVS12= \
DEVICE_DEVS13= DEVICE_DEVS14= DEVICE_DEVS15= DEVICE_DEVS16= \
DEVICE_DEVS17= DEVICE_DEVS18= DEVICE_DEVS19= DEVICE_DEVS20= \
DEVICE_DEVS_EXTRA= \
/bin/sh <./soobj/ldt.tr
rm -f ./sobin/libgs.so.9
ln -s libgs.so.9.04 ./sobin/libgs.so.9
rm -f ./sobin/libgs.so
ln -s libgs.so.9.04 ./sobin/libgs.so

This is how ldt.tr looked before I added the -shared:

x86_64-pc-linux-gnu-gcc -Wl,-O1 -Wl,--as-needed -o ./sobin/libgs.so.9.05 ./soobj/gsromfs0.o ./soobj/gs.o ./soobj/gp_getnv.o \
./soobj/gp_upapr.o \
./soobj/gp_unix.o \
./soobj/gp_unifs.o \
./soobj/gp_unifn.o \
...
./soobj/gsrop.o \
./soobj/gp_strdl.o \
-llcms2 \
-ltiff \
-ljpeg \
-lpng \
-ljbig2dec \
-lz \
 -ldl -lm -lpaper -ltiff -rdynamic -ldl -lfontconfig -lfreetype -lpthread -lm
Comment 4 Chris Liddell (chrisl) 2012-06-11 07:12:19 UTC
Oops, I hit the commit button too quickly....

Thanks for confirming it's a Gentoo problem. I've closed this bug, but you can reopen it if there is any more fall-out related to it.