Gentoo Archives: gentoo-user

From: Fernando Rodriguez <frodriguez.developer@×××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Will a 64-bit-no-multilib machine cross-compile 32-bit code?
Date: Thu, 19 Mar 2015 05:13:16
Message-Id: 6701997.ATxEyus6A8@navi
In Reply to: Re: [gentoo-user] Will a 64-bit-no-multilib machine cross-compile 32-bit code? by Walter Dnes
1 On Thursday, March 19, 2015 12:20:26 AM Walter Dnes wrote:
2 > On Wed, Mar 18, 2015 at 10:27:05PM -0400, Fernando Rodriguez wrote
3 > > On Wednesday, March 18, 2015 9:56:12 PM Walter Dnes wrote:
4 > > > My situation...
5 > > >
6 > > > * I've dug up my ancient netbook, and got Gentoo re-installed on it
7 > > > * The cpu is a dual-core Intel(R) Atom(TM) CPU Z520
8 > > > * It's 32-bit only; YES!
9 > > > * Compiling just the Seamonkey binary (ignoring its dependancies) took
10 > > > 14 hours
11 > > >
12 > > > I obviously want to offload compiling to another machine. As per the
13 > > > subject, will a 64-bit no-multilb install be able to cross compile
14 > > > 32-bit code?
15 > >
16 > > I've done it with distcc by adding the -m32 option to cflags. I used a
17 script
18 > > (named after the compiler on the gentoo box) to call the compiler with the
19 -
20 > > m32 flag and placed on the PATH environment (just for the distccd service)
21 > > before anything else and it worked. I got a 64 bit arch box to compile for
22 a
23 > > 32 bit gentoo (not nearly as fast as compiling locally on the arch box but
24 > > much faster than the gentoo box). It should work similarly with other
25 cross-
26 > > compile scenarios.
27 >
28 > Thanks. I'll probably be back with a bunch of questions. As a matter
29 > of fact, I already have one. The docs say that it does not work if the
30 > "-march=native" cflag is used. It says to use the output of...
31 >
32 > gcc -march=native -E -v - </dev/null 2>&1 | grep cc1
33 >
34 > ...omitting "/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.3/cc1 -E -quiet -v -"
35 > I presume. So on the 64-bit host, I would go from...
36 >
37 > CFLAGS="-O2 -march=native -mfpmath=sse -fomit-frame-pointer -pipe -fno-
38 unwind-tables -fno-asynchronous-unwind-tables"
39 >
40 > ...to...
41 >
42 > CFLAGS="-O2 -march=core2 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mno-
43 popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-
44 tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -
45 mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -
46 mno-xsave -mno-xsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64
47 --param l2-cache-size=2048 -mtune=core2 -fstack-protector -mfpmath=sse -fomit-
48 frame-pointer -pipe -fno-unwind-tables -fno-asynchronous-unwind-tables"
49 >
50 > And on the target (netbook), I'd go to...
51 >
52 > CFLAGS="-O2 -march=atom -mno-cx16 -msahf -mmovbe -mno-aes -mno-pclmul -mno-
53 popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-
54 tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -
55 mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -
56 mno-xsave -mno-xsaveopt --param l1-cache-size=24 --param l1-cache-line-size=64
57 --param l2-cache-size=512 -mtune=atom -fstack-protector -mfpmath=sse -fomit-
58 frame-pointer -pipe -fno-unwind-tables -fno-asynchronous-unwind-tables"
59 >
60 > Is that correct (assuming that's my output)?
61
62 The CFLAGS on the host won't be used so you don't need to change them. Now on
63 the host create scripts with the exact full name of the compiler on the target
64 and make distccd can find them (either put them on /usr/bin or make sure to add
65 it's path to the PATH environment var for distccd, if you're using openrc I'm
66 not sure if the init scripts allow it so you may have to start it manually or
67 modify the scripts) and have them exec gcc with the -m32 switch. Make sure you
68 have the same version of gcc selected on both boxes.
69
70
71 --
72 Fernando Rodriguez