Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 458720 - multilib inserts "-m64" into CFLAGS in cross toolchain
Summary: multilib inserts "-m64" into CFLAGS in cross toolchain
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-22 12:21 UTC by Benda Xu
Modified: 2013-04-06 18:12 UTC (History)
2 users (show)

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


Attachments
multilib.eclass.patch (multilib.eclass.patch,302 bytes, patch)
2013-02-22 14:33 UTC, Benda Xu
Details | Diff
common.ebilt.patch (common.eblit.patch,361 bytes, patch)
2013-02-22 14:34 UTC, Benda Xu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benda Xu gentoo-dev 2013-02-22 12:21:21 UTC
Cross emerging i686-pc-linux-gnu toolchain on amd64 fails with the following message.

 * Messages for package cross-i686-pc-linux-gnu/glibc-2.16.0:

 * Could not find a gcc that supports the __thread directive!
 * Please update your binutils/gcc and try again.
 * ERROR: cross-i686-pc-linux-gnu/glibc-2.16.0 failed (unpack phase):
 *   No __thread support in gcc!

By inspecting "ebuild --debug glibc-2.16.0.ebuild unpack", tc-has-tls fails because a "-m64" is injected into CC:

++ tc-has-tls -c i686-pc-linux-gnu                                                                                                           
++ local base=/dev/shm/portage/cross-i686-pc-linux-gnu/glibc-2.16.0/temp/test-tc-tls                                                         
++ cat                                                                                                                                       
++ local flags                                                                                                                               
++ case $1 in                                                                                                                                
++ flags=-c                                                                                                                                  
++ : -c                                                                                                                                      
++ [[ -c == -* ]]                                                                                                                            
++ shift                                                                                                                                     
+++ tc-getCC i686-pc-linux-gnu                                                                                                               
+++ tc-getPROG CC gcc i686-pc-linux-gnu                                                                                                      
+++ _tc-getPROG CHOST CC gcc i686-pc-linux-gnu                                                                                               
+++ local tuple=CHOST                                                                                                                        
+++ local v var vars=CC                                                                                                                      
+++ local prog=gcc                                                                                                                           
+++ var=CC                                                                                                                                   
+++ for v in '${vars}'
+++ [[ -n i686-pc-linux-gnu-gcc -m64 ]]
+++ export 'CC=i686-pc-linux-gnu-gcc -m64'
+++ CC='i686-pc-linux-gnu-gcc -m64'
+++ echo 'i686-pc-linux-gnu-gcc -m64'
+++ return 0                                                                                                                                 
++ i686-pc-linux-gnu-gcc -m64 -c /dev/shm/portage/cross-i686-pc-linux-gnu/glibc-2.16.0/temp/test-tc-tls.c -o /dev/shm/portage/cross-i686-pc-$
++ local ret=1
++ rm -f /dev/shm/portage/cross-i686-pc-linux-gnu/glibc-2.16.0/temp/test-tc-tls.c
++ return 1

Reproducible: Always
Comment 1 Benda Xu gentoo-dev 2013-02-22 12:50:03 UTC
the flag is introduced in setup_env in common.eblt, which unconditionally apply "-m64" (from host ABI) to any CC even in crosscompile.

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-libs/glibc/files/eblits/common.eblit?r1=1.12&r2=1.13

@vapier, could please have a look at this?

Attaching comment associated:

Always get multilib info via multilib_env and move the CFLAGS_abi value from that explicitly into CFLAGS (rather than letting gcc-config do it magicallyin the backend via the env).  This avoids ugly issues like distcc in a cross or multilib setup freaking out (#330423) as well as ccache pollution of wrong ELF types (such as #79519).  Further, it fixes multilib building for glibc targets where the configure script detects the desired multilib based purely on the compiler flags since the target is the same (e.g. mips64-xxx and n32 vs n64, and probably others).
Comment 2 Benda Xu gentoo-dev 2013-02-22 13:23:19 UTC
alternatively, the bug may be in multilib.eclass.

in multilib_env, if CTARGET=i686-* DEFAULT_ABI is set to "default", which later is replaced with "amd64", not "x86"
Comment 3 Benda Xu gentoo-dev 2013-02-22 14:12:57 UTC
for a amd64 profile, ABI and DEFAULT_ABI are hard-coded to "amd64". There is no chance for a crosscompile building environment to get its corrent ABI value.
Comment 4 Benda Xu gentoo-dev 2013-02-22 14:33:03 UTC
Created attachment 339700 [details, diff]
multilib.eclass.patch

override DEFAULT_ABI in profile for cross toolchains
Comment 5 Benda Xu gentoo-dev 2013-02-22 14:34:00 UTC
Created attachment 339702 [details, diff]
common.ebilt.patch

override ABI defined in profile when cross compiling
Comment 6 SpanKY gentoo-dev 2013-04-05 19:44:54 UTC
what version of crossdev are you using ?  this should be handled already.  when you first run `crossdev`, it'll calculate all the necessary ABI information and write it out to /etc/portage/env/cross-${CTARGET}/glibc.conf.  then your host settings do not matter.

`crossdev i686` works fine for me.