Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 420641

Summary: app-text/ghostscript-gpl-9.05-r1 - libgs.so gets built with _start etc
Product: Gentoo Linux Reporter: Brian Modra <epailty>
Component: [OLD] PrintingAssignee: Printing Team <printing>
Status: RESOLVED DUPLICATE    
Severity: normal CC: tomk
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Brian Modra 2012-06-11 07:49:39 UTC
When the libgs.so gets created, the -shared parameter is not passed, and so it
gets built with _start etc.

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

The problem is that the configure is called and passed -Wl,--as-needed

...
./soobj/aux/echogs -w ./soobj/ldt.tr -n - x86_64-pc-linux-gnu-gcc -Wl,-O1 -Wl,--as-needed -Wl,--no-as-needed   -o ./sobin/libgs.so.9.05
./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 -ltiff   -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.05 ./sobin/libgs.so.9
rm -f ./sobin/libgs.so
ln -s libgs.so.9.05 ./sobin/libgs.so
x86_64-pc-linux-gnu-gcc  -DHAVE_MKSTEMP -DHAVE_FILE64 -DHAVE_MKSTEMP64 -DHAVE_FONTCONFIG  -DHAVE_SETLOCALE -DHAVE_SSE2  -DHAVE_BSWAP32 -DHAVE_BYTESWAP_H -fPIC  -O2 -Wall -Wstrict-prototypes -Wundef -Wmissing-declarations -Wmissing-prototypes -Wwrite-strings -Wno-strict-aliasing -Wdeclaration-after-statement -fno-builtin -fno-common -DHAVE_STDINT_H=1 -DHAVE_SYS_TIME_H=1 -DGX_COLOR_INDEX_TYPE="unsigned long int" -O2 -pipe -DUSE_LIBPAPER   -DGS_DEVS_SHARED -DGS_DEVS_SHARED_DIR=\"/usr/lib64/ghostscript/9.05\"  -I./soobj -I./base  -DWHICH_CMS="lcms2" -g -o ./sobin/gsc ./psi/dxmainc.c \
-Wl,-O1 -Wl,--as-needed -Wl,--no-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.05-r1/temp/ccFVWcuH.o:/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/work/ghostscript-9.05/./psi/dxmainc.c:75: first defined 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 created.
collect2: ld returned 1 exit status
make[2]: *** [sobin/gsc] Error 1
make[2]: Leaving directory `/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/work/ghostscript-9.05'
make[1]: *** [so-subtarget] Error 2
make[1]: Leaving directory `/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/work/ghostscript-9.05'
make: *** [so] Error 2
emake failed
 * ERROR: app-text/ghostscript-gpl-9.05-r1 failed (compile phase):
 *   emake failed
 *
 * Call stack:
 *     ebuild.sh, line  85:  Called src_compile
 *   environment, line 3256:  Called die
 * The specific snippet of code:
 *       emake -j1 so all || die "emake failed";
 *
 * If you need support, post the output of 'emerge --info =app-text/ghostscript-gpl-9.05-r1',
 * the complete build log and the output of 'emerge -pqv =app-text/ghostscript-gpl-9.05-r1'.
/usr/lib64/portage/bin/isolated-functions.sh: line 214: wait: `emake failed': not a pid or valid job spec
 * The complete build log is located at '/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/temp/environment'.
 * S: '/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/work/ghostscript-9.05'

>>> Failed to emerge app-text/ghostscript-gpl-9.05-r1, Log file:

>>>  '/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/temp/build.log'

 * Messages for package app-text/ghostscript-gpl-9.05-r1:

 * ERROR: app-text/ghostscript-gpl-9.05-r1 failed (compile phase):
 *   emake failed
 *
 * Call stack:
 *     ebuild.sh, line  85:  Called src_compile
 *   environment, line 3256:  Called die
 * The specific snippet of code:
 *       emake -j1 so all || die "emake failed";
 *
 * If you need support, post the output of 'emerge --info =app-text/ghostscript-gpl-9.05-r1',
 * the complete build log and the output of 'emerge -pqv =app-text/ghostscript-gpl-9.05-r1'.
 * The complete build log is located at '/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/temp/environment'.
 * S: '/var/tmp/portage/app-text/ghostscript-gpl-9.05-r1/work/ghostscript-9.05'

 * IMPORTANT: 3 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

 # eselect news read 2
2010-08-01-as-needed-default
  Title                     --as-needed enabled in default profiles
  Author                    Tomáš Chvátal <scarabeus@gentoo.org>
  Posted                    2010-08-01
  Revision                  1

-Wl,--as-needed has been added to the default profile's LDFLAGS.

This option optimizes the linking process, only linking binaries to
libraries that are truly needed. This way, fewer libraries are loaded
at runtime and fewer packages need to be rebuilt after library updates.

To take advantage of the new default you can either rebuild world now
or just allow the system to migrate incrementally as it updates.

Please note that setting LDFLAGS="<your flags>" in your make.conf will
override the profile defaults. If you want to add additional LDFLAGS
it is recommended to use LDFLAGS="${LDFLAGS} <your flags>" instead to
avoid this.

For more information on --as-needed, read [1].

[1] http://www.gentoo.org/proj/en/qa/asneeded.xml

This needs to be overridden for ghostscript-gpl

I tried adding "append-ldflags $(no-as-needed)" to the emake, (and I hacked the Manifest so it was happy)

pkg_setup() {
        if use bindist && use djvu; then
                ewarn "You have bindist in your USE, djvu support will NOT be compiled!"
                ewarn "See http://djvu.sourceforge.net/gsdjvu/COPYING for details on licensing issues."
        fi
        append-ldflags $(no-as-needed)
}

... but then it does this:

./soobj/aux/echogs -w ./soobj/ldt.tr -n - x86_64-pc-linux-gnu-gcc -Wl,-O1 -Wl,--as-needed -Wl,--no-as-needed   -o ./sobin/libgs.so.9.05
./soobj/aux/echogs -a ./soobj/ldt.tr -n -s ./soobj/gsromfs0.o ./soobj/gs.o -s


If I set LDFLAGS in /etc/make.conf, then ghostscript compiles OK.

See also:
http://bugs.ghostscript.com/show_bug.cgi?id=693100
Comment 1 Brian Modra 2012-06-11 08:04:26 UTC
A correction, setting LDFLAGS in /etc/make.conf did not work
It still sets up ldr.tr incorrectly - with -as-needed and without -shared
Comment 2 Rafał Mużyło 2012-06-11 10:00:10 UTC
'-Wl,--as-needed' is by no means a problem.
./soobj/aux/echogs -w ./soobj/ldt.tr -n - i686-pc-linux-gnu-gcc -Wl,-O1 -Wl,--
as-needed -Wl,--sort-common -Wl,-z,relro   -shared -Wl,-soname=libgs.so.9 -o .
/sobin/libgs.so.9.05
...
i686-pc-linux-gnu-gcc -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -Wl,-z,relro   -shared -Wl,-soname=libgs.so.9 -shared -o ./soobj/X11.so ./soobj/gdevxalt.o ./soobj/gdevx.o ./soobj/gdevxcmp.o ./soobj/gdevxini.o ./soobj/gdevxres.o ./soobj/gsparamx.o -L/usr/X11R6/lib -lXt -lSM -lICE -lXext -lX11

Try searching for the problem where it actually is.
Start with attaching your 'emerge --info' and posting 'emerge -1pv app-text/ghostscript-gpl'.

...on the other hand, attach full build log from *before* you've started tinkering with the ebuild.
Comment 3 Brian Modra 2012-06-12 08:30:47 UTC
# emerge -1pv app-text/ghostscript-gpl

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] app-text/ghostscript-gpl-9.05-r1  USE="cups -X -bindist -dbus -djvu -gtk -idn -jpeg2k -static-libs" LINGUAS="-ja -ko -zh_CN -zh_TW" 0 kB

Total: 1 package (1 new), Size of downloads: 0 kB

 * IMPORTANT: 2 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.




# emerge --info
Portage 2.1.10.49 (default/linux/amd64/10.0, gcc-4.5.3, glibc-2.14.1-r3, 2.6.38-xen x86_64)
=================================================================
System uname: Linux-2.6.38-xen-x86_64-Intel-R-_Xeon-R-_CPU_E5645_@_2.40GHz-with-gentoo-2.1
Timestamp of tree: Sun, 10 Jun 2012 08:00:01 +0000
app-shells/bash:          4.2_p20
dev-lang/python:          2.7.2-r3, 3.1.4-r3, 3.2.3
dev-util/cmake:           2.8.7-r5
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.68
sys-devel/automake:       1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r2
sys-devel/gcc-config:     1.6
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 3.1 (virtual/os-headers)
sys-libs/glibc:           2.14.1-r3
Repositories: gentoo
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -O2 -pipe"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acl amd64 berkdb bzip2 cli cracklib crypt cups cxx dri fortran gdbm gpm iconv ipv6 mmx modules mudflap multilib ncurses nls nptl openmp pam pcre pppd readline session sse sse2 ssl tcpd unicode xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" PHP_TARGETS="php5-3" PYTHON_TARGETS="python3_2 python2_7" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga neomagic nouveau nv r128 radeon savage sis tdfx trident vesa via vmware dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 4 Andreas K. Hüttel archtester gentoo-dev 2013-03-24 20:16:07 UTC
Thanks for the analysis. This is actually a duplicate report, but your information is very useful.

*** This bug has been marked as a duplicate of bug 383447 ***