how should I configure my buuild for i386-*linux*

Nick Alcock nick.alcock@oracle.com
Sat May 7 13:30:15 GMT 2022


On 4 May 2022, Vladimir Mezentsev via Binutils outgrape:

> On 5/3/22 16:42, Matthias Klose wrote:
>> On 04.05.22 01:31, Vladimir Mezentsev via Binutils wrote:
>>>   Hi,
>>>
>>>   If I am on x86_64-*-linux* and want to build the i386-*linux* libraries (for example, libopcodes or libbfd),
>>> how should I configure my buuild ?
>>>
>>> The same question is for the aarch64-*-linux* host.
>>
>> you could have a look at the Debian build logs, e.g. look for the amd64 build log which also builds the binutils for i686 and
>> aarch64 hosted on x86_64:
>>
>> https://buildd.debian.org/status/package.php?p=binutils
>> (click on the "Installed" cell for the amd64 build log, then search for --target=i686-linux-gnu and --target=aarch64-linux-gnu
>
>
> I can reproduce a problem in the gprofng build.
>
> But after this configuration:
>
> mkdir builddir-i386
> cd builddir-i386 \
>     && env CC="x86_64-linux-gnu-gcc" CXX="x86_64-linux-gnu-g++" \
>        DEB_TARGET_MULTIARCH=i386-linux-gnu  DEB_TARGET_MULTIARCH64=x86_64-linux-gnu DEB_TARGET_MULTIARCHX32=x86_64-linux-gnux32  \
> 	../configure \
> 	  --disable-silent-rules --enable-obsolete --enable-shared --enable-plugins --enable-threads --with-system-zlib --prefix=/usr --enable-deterministic-archives --disable-compressed-debug-sections --enable-new-dtags --disable-x86-used-note --with-gold-ldflags=-static-libstdc++ --build=x86_64-linux-gnu --host=x86_64-linux-gnu --with-pkgversion="GNU Binutils for Debian" --disable-werror --enable-initfini-array --enable-ld=default --enable-gold \
> 	  --enable-targets=x86_64-linux-gnu,x86_64-linux-gnux32,x86_64-pep \
> 	  --with-sysroot=/ \
> 	  --libdir=/usr/lib/i386-linux-gnu \
> 	  --enable-ld=default --enable-gold \
> 	  --target=i686-linux-gnu
>
>
> All binaries are the 64-bit binaries.
> -m32 is not passed to gcc.
>
> Is it expected ?

Since nothing is telling configure to run GCC with those flags, yes it
is. (IIRC, the sbuild tool that backs buildd.debian.org has special
magic to use the right compiler in this case: since you're not using
sbuild, that won't work for you.)

Thankfully the answer is pretty simple. Try configuring like this:

configure CC="gcc -m32" ...

where ... is your other usual configure flags. (And obviously run
configure like you usually do, ../configure or ../binutils-gdb/configure
or whatever. The important thing is the setting of CC.)

Using CC rather than CFLAGS ensures that every single invocation, even
those that use unusual flags for other reasons, passes -m32; passing CC
as a configure argument rather than just setting it in the environment
ensures that even if the configure script is auto-reinvoked it'll still
pick up the right flags.

-- 
NULL && (void)


More information about the Binutils mailing list