Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 461874 - sys-devel/crossdev: change build CFLAGS/etc... into BUILD_CFLAGS/etc... and generate clean/default CFLAGS in package.env
Summary: sys-devel/crossdev: change build CFLAGS/etc... into BUILD_CFLAGS/etc... and g...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: MIPS Linux
: High major
Assignee: Gentoo Crossdev team
URL:
Whiteboard:
Keywords:
Depends on: 448206
Blocks: crossdev-bugs 659766
  Show dependency tree
 
Reported: 2013-03-15 23:41 UTC by Markos Chandras (RETIRED)
Modified: 2021-11-06 04:41 UTC (History)
3 users (show)

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


Attachments
cross-mips64el-unknown-linux-gnu-info.log (cross-mips64el-unknown-linux-gnu-info.log,17.11 KB, text/plain)
2013-03-15 23:41 UTC, Markos Chandras (RETIRED)
Details
cross-mips64el-unknown-linux-gnu-glibc.log.xz (cross-mips64el-unknown-linux-gnu-glibc.log.xz,3.04 KB, application/octet-stream)
2013-03-15 23:41 UTC, Markos Chandras (RETIRED)
Details
crossdev script for multiple mips targets (crossdev-mips.sh,1.41 KB, text/plain)
2019-02-18 06:05 UTC, Joshua Kinard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markos Chandras (RETIRED) gentoo-dev 2013-03-15 23:41:01 UTC
Created attachment 342192 [details]
cross-mips64el-unknown-linux-gnu-info.log

See attached logs for more details

Command that fails: crossdev -A n64 -t mips64el-unknown-linux-gnu
Comment 1 Markos Chandras (RETIRED) gentoo-dev 2013-03-15 23:41:37 UTC
Created attachment 342194 [details]
cross-mips64el-unknown-linux-gnu-glibc.log.xz
Comment 2 SpanKY gentoo-dev 2013-04-05 19:48:53 UTC
as discussed on irc, our cross ebuilds atm attempt to filter the LDFLAGS/etc... settings and then use the result.  really what we want is for crossdev to set up TARGET_{C,LD,etc...}FLAGS like we do with TARGET_ABI atm.
Comment 3 Joshua Kinard gentoo-dev 2014-07-06 01:22:33 UTC
Any further update on this bug?

I found another problem related to using LTO on the host arch.  Since to use LTO properly, you have to include CFLAGS in LDFLAGS, and since glibc erroneously tries using the host's LDFLAGS value, it's passing incorrect arguments to the stage2 cross-compiler.  The problem is in glibc's configure script where it is using $ASFLAGS, $LDFLAGS, $CPPFLAGS, and $CFLAGS incorrectly for cross-builds, it looks.

Manually running this command at the shell gets me an o32-only glibc cross-build:
ASFLAGS="" LDFLAGS="-Wl,-z,now -Wl,-z,relro" CFLAGS="-O2 -pipe -march=mips4 -mtune=mips4 -fivopts -fforce-addr -fmodulo-sched" CPPFLAGS="-O2 -pipe -march=mips4 -mtune=mips4 -fivopts -fforce-addr -fmodulo-sched"

Crossdev needs to override these before invoking the stage3 portion so that glibc doesn't suck up the wrong arch flags and pass them to the cross-toolchain.  Otherwise, it's very difficult to sanely merge a stage3 or higher cross-toolchain.
Comment 4 Joshua Kinard gentoo-dev 2015-02-16 07:52:31 UTC
I love rediscovering bugs.  Especially when I was the last person to comment...

So, what are the chances we get this fixed sometime soon?
Comment 5 SpanKY gentoo-dev 2015-02-16 08:26:27 UTC
probably want to update crossdev to:
 - query current CFLAGS/CPPFLAGS/CXXFLAGS/LDFLAGS
 - save those in the env .conf file as BUILD_xxx
 - reset the flags to basic defaults (e.g. CFLAGS='-O2')
 - allow the user to set the flags with the existing --genv/etc... flags

then glibc should "just work" i think.
Comment 6 Joshua Kinard gentoo-dev 2015-02-16 08:35:16 UTC
(In reply to SpanKY from comment #5)
> probably want to update crossdev to:
>  - query current CFLAGS/CPPFLAGS/CXXFLAGS/LDFLAGS

+ ASFLAGS.


>  - save those in the env .conf file as BUILD_xxx
>  - reset the flags to basic defaults (e.g. CFLAGS='-O2')
>  - allow the user to set the flags with the existing --genv/etc... flags
> 
> then glibc should "just work" i think.

Sounds about right.  Been a few months since I ran into this, so I forgot all about it until I rebuilt my mips64 toolchain for the newer binutils/glibc/gdb set.  I wonder if this isn't something that should be bugged with glibc upstream, though, since I pointed out in my July 2014 comment that glibc's configure script is using the host LDFLAGS to pass to the cross-compiler?
Comment 7 Joshua Kinard gentoo-dev 2015-02-16 09:55:28 UTC
Looks like glibc isn't the only affected libc.  musl has similar problems that were fixed by overriding the various *FLAGS variables:

>>> Configuring source in /ramfs/portage/cross-mips-unknown-linux-musl/musl-1.1.6/work/musl-1.1.6 ...
mips-unknown-linux-musl-gcc
checking for C compiler... mips-unknown-linux-musl-gcc
checking whether C compiler works... no; compiler output follows:
mips-unknown-linux-musl-gcc: error: unrecognized argument in option '-march=corei7'
mips-unknown-linux-musl-gcc: note: valid arguments to '-march=' are: 10000 1004kc 1004kf 1004kf1_1 1004kf2_1 10k 12000 12k 14000 14k 16000 16k 2000 20kc 24kc 24kec 24kef 24kef1_1 24kef2_1 ...
[snip]
mips-unknown-linux-musl-gcc: error: unrecognized argument in option '-mtune=corei7'
mips-unknown-linux-musl-gcc: note: valid arguments to '-mtune=' are:
[snip]
mips-unknown-linux-musl-gcc: error: unrecognized command line option '-mfpmath=sse'
mips-unknown-linux-musl-gcc: error: unrecognized command line option '-msse'
mips-unknown-linux-musl-gcc: error: unrecognized command line option '-msse2'
mips-unknown-linux-musl-gcc: error: unrecognized command line option '-mssse3'
mips-unknown-linux-musl-gcc: error: unrecognized command line option '-msse4.1'
[snip]

Additionally, musl somehow invoked the HOST strip tool instead of a cross- variant.  Want a separate bug for that?
Comment 8 tt_1 2019-01-26 13:18:23 UTC
musl still sufers from this. 

How was this fixed for glibc? Maybe it's possible to expand the fix to musl?
Comment 9 Joshua Kinard gentoo-dev 2019-02-18 06:05:04 UTC
Created attachment 565696 [details]
crossdev script for multiple mips targets

(In reply to tt_1 from comment #8)
> musl still sufers from this. 
> 
> How was this fixed for glibc? Maybe it's possible to expand the fix to musl?

Not sure if it was ever fixed.  I resorted to crafting a shell script that manipulates the various export flags and it single-steps crossdev through all four stages.  Script is attached.  Just uncomment one kernel, binutils, gcc, and libc flavour/version of your liking.  Check the portage tree beforehand to see what the latest versions are and update the script as needed.

For updating an existing toolchain, I usually just wipe the existing toolchain out using 'crossdev -C <CHOST>', then use the script to re-install it.

I haven't tried a musl toolchain in some time, however, so no promises that it builds.  At the bottom of the script is a commented-out "stage2", which is used when stage3 or stage4 fails for unknown reasons.  stage2 is the bare-minimum I need for rolling kernels for MIPS machines.  So you can use that to see how far it gets or at least pin down the failure point.  Might shed some light on things.