Opened 4 years ago

Closed 4 years ago

#8277 closed defect (invalid)

i686 build target fails test on x86_64 toolchain

Reported by: Nicolas Chauvet Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug: Building for x86 32bit fails using a x86_64 gcc toolchain
How to reproduce:

I'm trying to build ffmpeg for x86 32bit using the following flags:
--arch=i686 --optflags='\''-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m32 -march=i686 -mtune=generic -msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'\'' --extra-ldflags='\''-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld  '\'' --extra-cflags='\'' '\'' -

The compiler is x86_64 (on a Fedora 31 userspace).
The needed devel packages are installed as i686 (specially glibc-devel.i686)

Unfortunately the ./configure script is failing with:
BEGIN /tmp/ffconf.i01hvFDS/test.c
    1	int main(void){ return 0; }
END /tmp/ffconf.i01hvFDS/test.c
gcc -march=i686 -c -o /tmp/ffconf.i01hvFDS/test.o /tmp/ffconf.i01hvFDS/test.c
cc1: error: CPU you selected does not support x86-64 instruction set
C compiler test failed.

This is because the configure test is not passing the -m32 flag while testing to produce a binary.
Using -m32 on the compilation line allows to produce a valid test.o

Change History (2)

comment:1 by Nicolas Chauvet, 4 years ago

As a side note, I guess it will become more common to use a x86_64 toolchain to produce x86 32bit binaries. Specially as RHEL8 (and even CentOS8) will not provide a x86 32bit userspace anymore.

RHEL8 still provide 32bit "compat" libraries, but compiled with -march=x86_64 -m32 (as found as the default cflags for i686 rpm target_cpu). So this i686 build will mandate a x86_64 userspace.

comment:2 by Carl Eugen Hoyos, 4 years ago

Resolution: invalid
Status: newclosed

This is an invalid usage of the configure script (the error is correct), arch is not meant to request a target but to tell the configure script the target architecture if it cannot be detected. Use the cc option to pass the necessary flags.
Unrelated: The optflags option is a debug option that can also easily break configure, you should avoid using it.

Note: See TracTickets for help on using tickets.