Re: GCC8: fails to build when configured --with-cpu=xscale

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[Sorry for replying to myself & inserting Richard's reply - somehow his emails do not reach my inbox, so I had to copy it from the web archive of gcc-help@]

On 05/29/2018 11:16 PM, Alexey Neyman wrote:


On 05/26/2018 10:01 PM, Alexey Neyman wrote:
Hi,

I am seeing the following failure when building a crosstool-NG configuration which configures GCC for XScale CPU. The warning is:

cc1: warning: switch -mcpu=xscale conflicts with -march=armv5te switch

But during the build of libatomic, -Werror is thrown in, so the warning becomes an error.

GCC is configured with:

CC_FOR_BUILD='x86_64-build_pc-linux-gnu-gcc' CFLAGS='-O2 -g -pipe -I/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/buildtools/include ' CFLAGS_FOR_BUILD='-O2 -g -pipe -I/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/buildtools/include ' CXXFLAGS='-O2 -g -pipe -I/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/buildtools/include ' CXXFLAGS_FOR_BUILD='-O2 -g -pipe -I/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/buildtools/include ' LDFLAGS='-L/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/buildtools/lib -lstdc++ -lm' CFLAGS_FOR_TARGET='' CXXFLAGS_FOR_TARGET='' LDFLAGS_FOR_TARGET='' '/bin/bash' '/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/src/gcc/configure' '--build=x86_64-build_pc-linux-gnu' '--host=x86_64-build_pc-linux-gnu' '--target=armeb-unknown-linux-uclibcgnueabi' '--prefix=/home/avn/x-tools/armeb-unknown-linux-uclibcgnueabi' '--with-sysroot=/home/avn/x-tools/armeb-unknown-linux-uclibcgnueabi/armeb-unknown-linux-uclibcgnueabi/sysroot' '--enable-languages=c,c++' '--with-cpu=xscale' '--with-float=soft' '--with-pkgversion=crosstool-NG 1.23.0-392-gd274ab06-dirty' '--disable-sjlj-exceptions' '--enable-__cxa_atexit' '--disable-libmudflap' '--disable-libgomp' '--disable-libssp' '--disable-libquadmath' '--disable-libquadmath-support' '--disable-libsanitizer' '--disable-libmpx' '--with-gmp=/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/buildtools' '--with-mpfr=/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/buildtools' '--with-mpc=/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/buildtools' '--with-isl=/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/buildtools' '--enable-lto' '--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' '--enable-threads=posix' '--enable-target-optspace' '--enable-plugin' '--enable-gold' '--disable-nls' '--disable-multilib' '--with-local-prefix=/home/avn/x-tools/armeb-unknown-linux-uclibcgnueabi/armeb-unknown-linux-uclibcgnueabi/sysroot' '--enable-long-long'

Failing command is:

[ALL  ]    libtool: compile: /home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/build/build-cc-gcc-final/./gcc/xgcc -B/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/build/build-cc-gcc-final/./gcc/ -B/home/avn/x-tools/armeb-unknown-linux-uclibcgnueabi/armeb-unknown-linux-uclibcgnueabi/bin/ -B/home/avn/x-tools/armeb-unknown-linux-uclibcgnueabi/armeb-unknown-linux-uclibcgnueabi/lib/ -isystem /home/avn/x-tools/armeb-unknown-linux-uclibcgnueabi/armeb-unknown-linux-uclibcgnueabi/include -isystem /home/avn/x-tools/armeb-unknown-linux-uclibcgnueabi/armeb-unknown-linux-uclibcgnueabi/sys-include -DHAVE_CONFIG_H -I/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/src/gcc/libatomic/config/arm -I/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/src/gcc/libatomic/config/linux/arm -I/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/src/gcc/libatomic/config/posix -I/home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/src/gcc/libatomic -I. -Wall -Werror -pthread -g -O2 -g -Os -MT init.lo -MD -MP -MF .deps/init.Tpo -c /home/avn/work/ctng/crosstool-ng/.build/armeb-unknown-linux-uclibcgnueabi/src/gcc/libatomic/config/linux/arm/init.c -fPIC -DPIC -o .libs/init.o

The problem, as far as I can see, is that the driver executes cc1 with the flags defined in

#define OPTION_DEFAULT_SPECS \
  {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \
  {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
  {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}" }, \
  {"float", "%{!mfloat-abi=*:-mfloat-abi=%(VALUE)}" }, \
  {"fpu", "%{!mfpu=*:-mfpu=%(VALUE)}"}, \
  {"abi", "%{!mabi=*:-mabi=%(VALUE)}"}, \
  {"mode", "%{!marm:%{!mthumb:-m%(VALUE)}}"}, \
  {"tls", "%{!mtls-dialect=*:-mtls-dialect=%(VALUE)}"},

Which evaluates to:

-mcpu=xscale -mfloat-abi=soft -mtls-dialect=gnu -marm -march=armv5te

added to the arguments from the command line (as you may see, there were no -march= or -mcpu= in the original command).

Then, cc1 discovers that -mcpu=xscale and -march=armv5te are not exactly compatible:

(gdb) p arm_selected_cpu->common.isa_bits
$17 = {isa_bit_armv3m, isa_bit_mode32, isa_bit_notm, isa_bit_xscale, isa_bit_armv4, isa_bit_armv5e, isa_bit_armv5, isa_bit_thumb, isa_nobit <repeats 36 times>}
(gdb) p arm_selected_arch->common.isa_bits
$18 = {isa_bit_armv3m, isa_bit_mode32, isa_bit_notm, isa_bit_armv4, isa_bit_armv5e, isa_bit_armv5, isa_bit_thumb, isa_nobit <repeats 37 times>}

Because they differ in the presence of isa_bit_xscale (and that bit is not listed as a quirk that's ignored during comparison), cc1 complains.

What should be the fix for this?

Regards,
Alexey.

The problem is almost certainly that your build system is somehow
passing an explicit -mcpu=xscale during the build.
It does not. The command being invoked (that fails) is quoted above and it doesn't contain the -mcpu=xscale option.

Moreover, as you rightfully stated below, if the build system did pass this option explicitly, the driver wouldn't fall back to passing the default values for -mcpu and -march - and it is the default values that cause this issue.

You need to find out
where it is coming from and remove it (the configured default from
--with-cpu is never used when -march or -mcpu are explicitly on the
command line as it will be when that library is being built.

This rule:
#define OPTION_DEFAULT_SPECS \
  {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \
  {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
  {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}" }, \
  {"float", "%{!mfloat-abi=*:-mfloat-abi=%(VALUE)}" }, \
  {"fpu", "%{!mfpu=*:-mfpu=%(VALUE)}"}, \
  {"abi", "%{!mabi=*:-mabi=%(VALUE)}"}, \
  {"mode", "%{!marm:%{!mthumb:-m%(VALUE)}}"}, \
  {"tls", "%{!mtls-dialect=*:-mtls-dialect=%(VALUE)}"},

sets up the internal defaults.  Note the first two lines both check that
neither -march nor -mcpu are being passed explicitly before dropping in
the builtin value.
This is exactly what I am trying to explain: our the build system *does not* pass explicit -mcpu=xscale into the build, which is why the driver *does* pass the default values to cc1, which then causes this warning/error.

In fact, I can reproduce this with a very simple build system - in the attached script. You can place it in the directory with tarballs of GCC 8.1.0 and its pre-requisites:

-rw-r--r--  1 avn avn 20286700 May 29 22:17 binutils-2.30.tar.xz
-rwxr-xr-x  1 avn avn     1576 May 30 00:30 b.sh*
-rw-r--r--  1 avn avn 63372320 May 29 22:17 gcc-8.1.0.tar.xz
-rw-r--r--  1 avn avn  1946336 May 29 22:15 gmp-6.1.2.tar.xz
-rw-r--r--  1 avn avn  1515156 May 29 22:19 isl-0.19.tar.xz
-rw-r--r--  1 avn avn   701263 May 29 22:16 mpc-1.1.0.tar.gz
-rw-r--r--  1 avn avn  1412692 May 29 22:16 mpfr-4.0.1.tar.xz

After it builds everything, it will try to compile an empty file with the resulting compiler:

+ /home/avn/t/i/bin/arm-multilib-linux-uclibcgnueabi-gcc -c foo.c -Werror
cc1: error: switch -mcpu=xscale conflicts with -march=armv5te switch [-Werror]
cc1: all warnings being treated as errors

Regards,
Alexey.

Attachment: b.sh
Description: application/shellscript


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux