Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 378905 - changeset 59844 toolchain.eclass update in Prefix breaks itself on aix
Summary: changeset 59844 toolchain.eclass update in Prefix breaks itself on aix
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: PPC AIX
: Normal major (vote)
Assignee: Gentoo Prefix
URL: http://overlays.gentoo.org/proj/alt/c...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-12 12:35 UTC by Benda Xu
Modified: 2011-08-13 07:55 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benda Xu gentoo-dev 2011-08-12 12:35:25 UTC
The changeset of 59844 on 08/10/2011 by grobian[1] introduced libc_has_ssp() during the toolchain.eclass inherit flow.

However, ld on aix-5.2.0 (with its native-cctools wrapper), does not support -verbose option well. (see lines 564-567 at [2])

This results in failing of inheriting toolchain:

$ emerge gcc

 * IMPORTANT: 1 news items need reading for repository 'gentoo_prefix'.
 * Use eselect news to read news items.

Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) sys-devel/gcc-4.2.4-r01.3
 * EbuildProcess received strange poll event: 16384

 * gcc-4.2.4.tar.bz2 RMD160 SHA1 SHA256 size ;-) ...                                                                                  [ ok ]
 * gcc-4.2.4-uclibc-patches-1.0.tar.bz2 RMD160 SHA1 SHA256 size ;-) ...                                                               [ ok ]
 * gcc-4.2.4-patches-1.1.tar.bz2 RMD160 SHA1 SHA256 size ;-) ...                                                                      [ ok ]
 * ERROR: sys-devel/gcc-4.2.4-r01.3 failed (setup phase):
 *   Unable to find a libc !?
 *
 * Call stack:
 *          ebuild.sh, line   62:  Called call-ebuildshell 'pkg_setup'
 *          ebuild.sh, line 2006:  Called pkg_setup
 *          ebuild.sh, line 1458:  Called toolchain_pkg_setup
 *   toolchain.eclass, line   20:  Called gcc_pkg_setup
 *   toolchain.eclass, line  827:  Called want_libssp
 *   toolchain.eclass, line  500:  Called libc_has_ssp
 *   toolchain.eclass, line  569:  Called die
 * The specific snippet of code:
 *    [[ -z ${libc_file} ]] && die "Unable to find a libc !?"
 *
 * If you need support, post the output of 'emerge --info =sys-devel/gcc-4.2.4-r01.3',
 * the complete build log and the output of 'emerge -pqv =sys-devel/gcc-4.2.4-r01.3'.
 * The complete build log is located at '/export/ntc07/work/benda/gentoo/var/tmp/portage/sys-devel/gcc-4.2.4-r01.3/temp/build.log'.
 * The ebuild environment file is located at '/export/ntc07/work/benda/gentoo/var/tmp/portage/sys-devel/gcc-4.2.4-r01.3/temp/die.env'.
 * S: '/export/ntc07/work/benda/gentoo/var/tmp/portage/sys-devel/gcc-4.2.4-r01.3/work/gcc-4.2.4'
 * EbuildProcess received strange poll event: 16384

 * MiscFunctionsProcess received strange poll event: 16384


The die message is from line 569 of [2].

1. http://overlays.gentoo.org/proj/alt/changeset/59844/trunk/prefix-overlay/eclass/toolchain.eclass
2. http://overlays.gentoo.org/proj/alt/browser/trunk/prefix-overlay/eclass/toolchain.eclass?rev=59844

Reproducible: Always

Actual Results:  
On aix-5.2, both native-cctools ld wrapper in Prefix and /usr/bin/ld give the same behavior regarding --verbose

$ gcc  -Wl,-verbose libctest.c -o libctest
$ ./libctest
Could not load program ./libctest:
        The program does not have an entry point or
          the o_snentry field in the auxiliary header is invalid.
Examine file headers with the 'dump -ohv' command.

Without -verbose works:
$ gcc  libctest.c -o libctest
$ ./libctest
(no outputs as expected)

$ cat libctest.c 
int main(){}
Comment 1 Benda Xu gentoo-dev 2011-08-12 12:37:15 UTC
$ emerge --info
Portage 2.2.01.19011-prefix (prefix/aix/5.2.0.0/ppc, gcc-4.2.4, unavailable, 2 00393D2D4C00)
=================================================================
System uname: AIX-2-00393D2D4C00-32bit
Timestamp of tree: Thu, 11 Aug 2011 16:38:38 +0000
app-shells/bash:      4.2_p10
dev-lang/python:      2.7.2::neutrino
dev-util/pkgconfig:   0.25-r2
sys-devel/autoconf:   2.68
sys-devel/automake:   1.11.1
sys-devel/gcc:        4.2.4-r01.3
sys-devel/gcc-config: 1.4.1-r00.2
sys-devel/libtool:    2.4-r01.1
sys-devel/make:       3.82
Repositories: gentoo_prefix neutrino
Installed sets: 
ACCEPT_KEYWORDS="~ppc-aix"
ACCEPT_LICENSE="* -@EULA"
CBUILD="powerpc-ibm-aix5.2.0.0"
CFLAGS="-O2 -mcpu=power4 -mtune=power4"
CHOST="powerpc-ibm-aix5.2.0.0"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/portage /etc/terminfo"
CXXFLAGS="-O2 -mcpu=power4 -mtune=power4"
DISTDIR="/export/ntc07/work/benda/gentoo/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs collision-protect distlocks ebuild-locks fixlafiles fixpackages news nostrip parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C"
LDFLAGS=""
MAKEOPTS="-j4"
PKGDIR="/export/ntc07/work/benda/gentoo/usr/portage/packages"
PORTAGE_CONFIGROOT="/export/ntc07/work/benda/gentoo/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/export/ntc07/work/benda/gentoo/var/tmp"
PORTDIR="/export/ntc07/work/benda/gentoo/usr/portage"
PORTDIR_OVERLAY="/export/ntc07/work/benda/gentoo/usr/local/portage/neutrino"
SYNC="rsync://rsync.prefix.freens.org/gentoo-portage-prefix"
USE="cracklib cxx modules ncurses nls ppc-aix prefix readline ssl unicode zlib" 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="braindump flow karbon kexi kpresenter krita tables words" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="AIX" 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" KERNEL="AIX" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" 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, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Fabian Groffen gentoo-dev 2011-08-12 12:46:57 UTC
we're on the alias, don't worry
Comment 3 Benda Xu gentoo-dev 2011-08-12 12:49:05 UTC
The line 567 depends on output format of ld -verbose. Is it a GNU ld
specific trick?

<quote line=567>
local libc_file=$(awk '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 ==
"succeeded")) LIBC = $4; }; END {print LIBC}' "${T}"/libctest.log)
</quote>
Comment 4 Fabian Groffen gentoo-dev 2011-08-12 12:57:09 UTC
does AIX' libc (or any other default lib) have ssp stuff in there? (I expect no)
Comment 5 Fabian Groffen gentoo-dev 2011-08-12 13:00:04 UTC
(In reply to comment #3)
> The line 567 depends on output format of ld -verbose. Is it a GNU ld
> specific trick?
> 
> <quote line=567>
> local libc_file=$(awk '/attempt to open/ { if (($4 ~ /\/libc\.so/) && ($5 ==
> "succeeded")) LIBC = $4; }; END {print LIBC}' "${T}"/libctest.log)
> </quote>

I think so yes.  It simply tries to get the location of the libc in use for the current target.  Perhaps GCC has one of those -print-xxx commands for that, for easier use.
Comment 6 Fabian Groffen gentoo-dev 2011-08-12 13:01:06 UTC
does

  gcc -print-file-name=libc.so

work for you?
Comment 7 Benda Xu gentoo-dev 2011-08-12 13:04:45 UTC
(In reply to comment #6)
> does
> 
>   gcc -print-file-name=libc.so
> 
> work for you?

Yes, it works, even with gcc-2.9 outside Prefix.


(In reply to comment #4)

I have no idea. ssp seems to be introduced by an IBM guy according to 

http://en.wikipedia.org/wiki/Buffer_overflow_protection#GCC_Stack-Smashing_Protector_.28ProPolice.29
Comment 9 Benda Xu gentoo-dev 2011-08-12 13:18:57 UTC
(In reply to comment #8)
> please try
> 
> http://overlays.gentoo.org/proj/alt/changeset/59852/trunk/prefix-overlay/eclass/toolchain.eclass

The output of gcc -print-file-name=libc.so is "libc.so\n" instead of "libc.so".
Comment 10 Fabian Groffen gentoo-dev 2011-08-12 13:21:02 UTC
hmmm, so it doesn't work, gcc doesn't know where your libc is.  Do you know where it is?  Is there a /lib/libc.so?  Or is there only a libc.a?  Hoes does AIX work in this respect?
Comment 11 Fabian Groffen gentoo-dev 2011-08-12 13:22:04 UTC
oh my... is it libC.a?
Comment 12 Fabian Groffen gentoo-dev 2011-08-12 13:24:34 UTC
ok, more googling indicates that you probably only have a libc.a.

What does
  gcc -print-file-name=libc.a
return?

(I don't want "libc.a", I want a full path)
Comment 13 Benda Xu gentoo-dev 2011-08-12 13:27:56 UTC
(In reply to comment #12)
> ok, more googling indicates that you probably only have a libc.a.
> 
> What does
>   gcc -print-file-name=libc.a
> return?


(In reply to comment #10)
> hmmm, so it doesn't work, gcc doesn't know where your libc is.  Do you know
> where it is?  Is there a /lib/libc.so?  Or is there only a libc.a?  Hoes does
> AIX work in this respect?

$ gcc -print-file-name=libc.a
/lib/libc.a
$ gcc -print-file-name=libc.so
libc.so

Oh yeah, there is no libc.so.
Comment 14 Benda Xu gentoo-dev 2011-08-12 13:29:54 UTC
Their true location is /usr/ccs/lib/libc.a

$ ls -l /lib/libc.a
lrwxrwxrwx   1 bin      bin              19 May 17 2005  /lib/libc.a -> /usr/ccs/lib/libc.a
$ ls -l /usr/lib/libc.a
lrwxrwxrwx   1 bin      bin              19 May 17 2005  /usr/lib/libc.a -> /usr/ccs/lib/libc.a
Comment 15 Fabian Groffen gentoo-dev 2011-08-12 13:37:37 UTC
do you have a tool called "readelf" on AIX, and if you do, what's the output of

readelf -s /lib/libc.a
Comment 16 Markus Duft (RETIRED) gentoo-dev 2011-08-12 13:46:51 UTC
AIX is COFF, not ELF, so readelf won't help much, i guess. Also libc.a is ok, as it contains both the static and the shared objects (the shared lib is in libc.a(shr.o)).

you can use the "dump" command from AIX to further inspect libc. what information are you interested in exactly? i can have a look on our aix :)
Comment 17 Fabian Groffen gentoo-dev 2011-08-12 13:49:49 UTC
Well, if you can, please check if there is any stack check guard stuff (like the func from toolchain.eclass checks for) in the libc.  I don't think so, hence it's perhaps easier to just do a CTARGET check in that function and assume SSP joy is only in libc possibly on Linux, so we want GCC to build its own libssp on all other platforms.

Now I think of it, perhaps Darwin has it in it's libSystem too, but that would be an easy exception.
Comment 18 Markus Duft (RETIRED) gentoo-dev 2011-08-12 13:58:23 UTC
i'm not exactly the AIX expert here (haubi's on vacation :)), but IIRC, gcc does not support ssp on AIX officially, but libssp builds if one forces gcc to do so. AFAICT the library is ABI incompatible (!) with AIX, but works nevertheless (in most of the cases...?).

nevertheless i did have a look at libc, and watched out for *stack* symbols (like __stack_chk_fail), but there are none, so: no libc has no stack smashing protection code.

hth.
Comment 20 Benda Xu gentoo-dev 2011-08-13 07:55:49 UTC
(In reply to comment #19)
> Thanks Markus, new attempt:
> 
> http://overlays.gentoo.org/proj/alt/changeset/59853/trunk/prefix-overlay/eclass/toolchain.eclass

Verified to work under aix.