Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 37437 - libsandbox Makefile problematic for cross-compiling (CC=gcc)
Summary: libsandbox Makefile problematic for cross-compiling (CC=gcc)
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Sandbox (show other bugs)
Hardware: Sparc Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-06 17:22 UTC by Troy Farrell
Modified: 2004-04-11 16:55 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 Troy Farrell 2004-01-06 17:22:33 UTC
The libsandbox Makefile uses CC=gcc instead of using the CC variable which (in my setup) is set in /etc/make.conf to 'sparc-unknown-linux-gnu-gcc'.  This is a problem because I use distcc to cross-compile.  When the Makefile uses gcc instead of sparc-unknown-linux-gnu-gcc, the build fails because my x86 box compiles the code using gcc aka i686-pc-linux-gnu-gcc and we all know that the two use different binary code.  My experience is documented in this forum thread:

http://forums.gentoo.org/viewtopic.php?t=119788

Reproducible: Always
Steps to Reproduce:
On the PC:
1. Build a cross-compile toolchain
2. Install distcc and start distccd
On the sparc:
3. Install distcc and add the PC as a compile slave.
4. Add the following lines to /etc/make.conf (doesn't matter since the libsandbox Makefile ignores them):
CHOST="sparc-unknown-linux-gnu"
CC=${CHOST}-gcc
CXX=${CHOST}-g++
FEATURES="distcc"
3. try to emerge portage like a stage one install:
# USE="-* build" emerge portage"
Actual Results:  
>>> md5 src_uri ;-) portage-2.0.49-r21.tar.bz2
>>> Unpacking source...
>>> Unpacking portage-2.0.49-r21.tar.bz2 to /var/tmp/portage/portage-2.0.49-r21/work
>>> Source unpacked.
./create-localdecls
Checking truncate argument type... off_t
Checking libc version... libc.so.6
Checking glibc subversion...
gcc -Wall -c -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT libsandbox.c
gcc -Wall -c -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT sandbox_futils.c
gcc libsandbox.o sandbox_futils.o -shared -fPIC -ldl -lc -o libsandbox.so
-nostdlib -lgcc
/usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.2.3/../../../../sparc-unknown-linux-gnu/bin/ld:
libsandbox.o: Relocation in generic ELF (EM: 3)
libsandbox.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
distcc[4850] ERROR: compile on localhost failed
make: *** [libsandbox.so] Error 1
...

Expected Results:  
It should have (and would have) compiled.  The lines which read gcc should have
said 'sparc-unknown-linux-gnu-gcc' instead.

I have edited the Makefile and replaced
CC=gcc
with
CC=sparc-unknown-linux-gnu-gcc
and everything works as expected.  Unfortunately, I don't know how to make the
Makefile inherit the data from make.conf...
Comment 1 Alexander Gabert (RETIRED) gentoo-dev 2004-03-03 06:04:48 UTC
Dear Troy,

its normally set via environment variable CC=...

you can do "env" and "env-update" and grep -r for "CC" in the /etc directory.

If you want to help, you can set CC explicitly there to the cross compiler.

It would also be of great help where else this invocation of CC is preventing cross proper compiling of the important parts of the system.

thank you,

Alex
Comment 2 Nicholas Jones (RETIRED) gentoo-dev 2004-03-20 14:46:14 UTC
Azarah, Anyone: Any idea how to quick fix this?

Sandbox sets CC=gcc in the Makefile... How do we make it
use the environment if it's set, and then default to gcc?
Comment 3 Nicholas Jones (RETIRED) gentoo-dev 2004-04-11 00:35:37 UTC
This is fixed in stable, btw.

CC ?= gcc
Comment 4 Troy Farrell 2004-04-11 16:55:39 UTC
Looks fixed to me.
Thanks!