Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 511548 - >=cross-sh*-unknown-linux-gnu/gcc-4.5: sysroot_suffix_spec breaks sysroot even when matching the default
Summary: >=cross-sh*-unknown-linux-gnu/gcc-4.5: sysroot_suffix_spec breaks sysroot eve...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: sh Linux
: Normal normal
Assignee: Gentoo Crossdev team
URL: https://gcc.gnu.org/bugzilla/show_bug...
Whiteboard:
Keywords:
Depends on:
Blocks: crossdev-bugs
  Show dependency tree
 
Reported: 2014-05-26 15:12 UTC by Manuel Lauss
Modified: 2018-04-14 12:36 UTC (History)
1 user (show)

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 Manuel Lauss 2014-05-26 15:12:23 UTC
a cross-sh4 toolchain, created with "crossdev -t sh4-unknown-linux-gnu"
no longer links to libc when cpu subtype and endianness parameters are supplied:

sh4-unknown-linux-gnu-gcc -o test -O2 -m4 -ml test.c
/usr/libexec/gcc/sh4-unknown-linux-gnu/ld: cannot find crt1.o: No such file or directory
/usr/libexec/gcc/sh4-unknown-linux-gnu/ld: cannot find crti.o: No such file or directory

Omitting the "-m4 -ml" parameters (optimize for little-endian plain SH4 with FPU) results in a successful link.

I've was able to build a complete rootfs with the above CFLAGS when I last played with SH4 (around 2010), so I guess something broke in the meantime.


Reproducible: Always
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2014-05-26 15:22:36 UTC
Please post your `(cross-)emerge --info' output in a comment.
Comment 2 Manuel Lauss 2014-05-26 15:34:08 UTC
binutils-9999 from 20140522,
gcc-4.9.0
glibc-2.19

Portage 2.2.10 (embedded, gcc-4.9.0, unavailable, 3.15.0-rc6-00001-gd778825-dirty x86_64)
=================================================================
System uname: Linux-3.15.0-rc6-00001-gd778825-dirty-x86_64-AMD_Phenom-tm-_II_X6_1090T_Processor-with-gentoo-2.2
KiB Mem:     8159188 total,   3707012 free
KiB Swap:    2097148 total,   2097148 free
Timestamp of tree: Mon, 26 May 2014 08:15:01 +0000
ld GNU ld (GNU Binutils) 2.24.51.20140522
distcc 3.1 x86_64-pc-linux-gnu [disabled]
ccache version 3.1.9 [disabled]
Repositories: gentoo x11 mano
ACCEPT_KEYWORDS="sh ~sh"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-Os -pipe  -fomit-frame-pointer"
CHOST="sh4-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.5/ext-active/ /etc/php/cgi-php5.5/ext-active/ /etc/php/cli-php5.5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-Os -pipe  -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--quiet-build=n"
FCFLAGS="-Os -pipe"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news nodoc noinfo noman parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-Os -pipe"
GENTOO_MIRRORS="http://gentoo.inode.at"
LANG="C"
LDFLAGS=""
MAKEOPTS="-j6"
PKGDIR="/usr/sh4-unknown-linux-gnu/packages/"
PORTAGE_CONFIGROOT="/usr/sh4-unknown-linux-gnu/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/usr/sh4-unknown-linux-gnu/tmp/"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/x11 /etc/portage/overlay"
USE="bindist kdrive make-symlinks minimal multicall sh zlib" INPUT_DEVICES="evdev mouse keyboard tslib" KERNEL="linux" LINGUAS="en" USERLAND="GNU" VIDEO_CARDS="fbdev"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, SYNC, USE_PYTHON
Comment 3 SpanKY gentoo-dev 2014-06-01 22:09:11 UTC
using -m4 with a gcc configured for sh4-unknown-linux-gnu is redundant, but it should still work

the sysroot_suffix_spec is getting in the way here ...
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2018-04-07 13:26:52 UTC
Still happens.

Diff output of
    $ sh4-unknown-linux-gnu-gcc -o test -O2     a.c -v -Wl,--verbose # ok
    $ sh4-unknown-linux-gnu-gcc -o test -O2 -m4 a.c -v -Wl,--verbose # bad

...

-LIBRARY_PATH=/usr/lib/gcc/sh4-unknown-linux-gnu/7.2.0/:/usr/lib/gcc/sh4-unknown-linux-gnu/7.2.0/../../../../sh4-unknown-linux-gnu/lib/:/usr/sh4-unknown-linux-gnu/lib/:/usr/sh4-unknown-linux-gnu/usr/lib/
+LIBRARY_PATH=/usr/lib/gcc/sh4-unknown-linux-gnu/7.2.0/:/usr/lib/gcc/sh4-unknown-linux-gnu/7.2.0/../../../../sh4-unknown-linux-gnu/lib/

...

-attempt to open /usr/sh4-unknown-linux-gnu/usr/lib/Scrt1.o succeeded
-/usr/sh4-unknown-linux-gnu/usr/lib/Scrt1.o
-attempt to open /usr/sh4-unknown-linux-gnu/usr/lib/crti.o succeeded
-/usr/sh4-unknown-linux-gnu/usr/lib/crti.o
+attempt to open Scrt1.o failed
+attempt to open crti.o failed

$SYSROOT/usr/lib/ got lost from LIBRARY_PATH here.
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2018-04-07 13:52:50 UTC
sh is one of targets that supports multilib:
    https://github.com/gcc-mirror/gcc/blob/master/gcc/config.gcc#L2829

(sh4-* defaults to single ABI, -m4-nofpu?).
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2018-04-12 19:59:49 UTC
Now I understand Mike's comment about SYSROOT_SUFFIX_SPEC better.

sysroot suffix is part of spec generated based on sh4 multilib layout here:

gcc/gcc $ rm sysroot-suffix.h 

gcc/gcc $ make sysroot-suffix.h
Makefile:2632: warning: overriding recipe for target 'gt-sh.h'
../../gcc/gcc/config/sh/t-sh:93: warning: ignoring old recipe for target 'gt-sh.h'
/bin/sh ../../gcc/gcc/config/print-sysroot-suffix.sh \
  "=! m1=!m1 /m1=!/m1 m2a=!m2a /m2a=!/m2a m2a-nofpu=!m2a-nofpu /m2a-nofpu=!/m2a-nofpu m2a-single-only=!m2a-single-only /m2a-single-only=!/m2a-single-only m2a-single=!m2a-single /m2a-single=!/m2a-single m2e=!m2e /m2e=!/m2e m2=!m2 /m2=!/m2 m3e=!m3e /m3e=!/m3e m3=!m3 /m3=!/m3 m4-nofpu=!m4-nofpu /m4-nofpu=!/m4-nofpu m4-single-only=!m4-single-only /m4-single-only=!/m4-single-only m4-single=!m4-single /m4-single=!/m4-single m4=!m4 /m4=!/m4 m4a-nofpu=!m4a-nofpu /m4a-nofpu=!/m4a-nofpu m4a-single-only=!m4a-single-only /m4a-single-only=!/m4a-single-only m4a-single=!m4a-single /m4a-single=!/m4a-single m4a=!m4a /m4a=!/m4a m4al=!m4al /m4al=!/m4al" " m4" \
  "" "" > tmp-sysroot-suffix.h
mv tmp-sysroot-suffix.h sysroot-suffix.h

gcc/gcc $ cat sysroot-suffix.h
#undef SYSROOT_SUFFIX_SPEC
#define SYSROOT_SUFFIX_SPEC "" \
"%{m4:/m4;" \
":}"

AFAIU this translates to:
- if -m4 option is passed explicitly then append /m4 to $SYSROOT
- otherwise prepend nothing

Thus it's print-sysroot-suffix.sh arguments that are at fault (whitespace in '" m4"'?) ot lack of OTHER_ENDIAN set in
    gcc/config/sh/t-sh:OTHER_ENDIAN = $(word 2,$(TM_ENDIAN_CONFIG))

Let's see which works first.
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2018-04-12 20:17:29 UTC
Here is the minimal call of how match happens:

bash ../../gcc/gcc/config/print-sysroot-suffix.sh   'm4=!m4' 'm4'   '' ''
#undef SYSROOT_SUFFIX_SPEC
#define SYSROOT_SUFFIX_SPEC "" \
"%{m4:/m4;" \
":}"

What has the knowledge that default is 'm4' and it should be filtered out?
Comment 8 Larry the Git Cow gentoo-dev 2018-04-14 12:36:45 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=49d0cca0f886e06d54896ae70b5d24a364ef17e3

commit 49d0cca0f886e06d54896ae70b5d24a364ef17e3
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-04-14 12:36:15 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-04-14 12:36:15 +0000

    sys-devel/gcc: bump patchset of 7.3.0 up to 1.2, bug #511548
    
    Single new patch:
    + 92_all_sh-drop-sysroot-suffix.patch : drop sysroot-suffix
    
    Reported-by: Manuel Lauss
    Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42947
    Closes: https://bugs.gentoo.org/511548
    Package-Manager: Portage-2.3.28, Repoman-2.3.9

 sys-devel/gcc/Manifest            |  1 +
 sys-devel/gcc/gcc-7.3.0-r2.ebuild | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)