This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Passing AM_CFLAGS to CC_FOR_BUILD compiler leads to errors when cross-compiling


binutils+AEA-sourceware.org

Hi all,+AKA-

I faced with an issue when I was cross-compiling binutils: build failed at configure step with the following error:
----------------------------------+AD4-8------------------------------------
cc1: error: unrecognized command line option +ACI--Wstack-usage+AD0-262144+ACI-
----------------------------------+AD4-8------------------------------------

When cross-compiling we have different compilers in CC and CC+AF8-FOR+AF8-BUILD variables,
as CC+AF8-FOR+AF8-BUILD is compiler for host when CC is compiler for target.+AKA-

But Makefile uses AM+AF8-CFLAGS to compile with CC+AF8-FOR+AF8-BUILD compiler, e. g. lines from binutils/Makefile.am 310:
----------------------------------+AD4-8------------------------------------
sysinfo.+AEA-OBJEXT+AEA-: sysinfo.c
+AKAAoACgAKAAoACgAKAAoA-if +AFs- -r sysinfo.c +AF0AOw- then +AFw-
+AKAAoACgAKAAoACgAKAAoACgAKAAJA-(CC+AF8-FOR+AF8-BUILD) -c -I. +ACQ-(AM+AF8-CFLAGS) +ACQ-(CFLAGS+AF8-FOR+AF8-BUILD) +ACQ-(NO+AF8-WERROR) sysinfo.c +ADs- +AFw-
+AKAAoACgAKAAoACgAKAAoA-else +AFw-
+AKAAoACgAKAAoACgAKAAoACgAKAAJA-(CC+AF8-FOR+AF8-BUILD) -c -I. +ACQ-(AM+AF8-CFLAGS) +ACQ-(CFLAGS+AF8-FOR+AF8-BUILD) +ACQ-(NO+AF8-WERROR) +ACQ-(srcdir)/sysinfo.c +ADs- +AFw-
+AKAAoACgAKAAoACgAKAAoA-fi
----------------------------------+AD4-8------------------------------------

AM+AF8-FLAGS are set up as WARN+AF8-CFLAGS +- ZLIBINC, line from binutils/Makefile.am 51:
----------------------------------+AD4-8------------------------------------
AM+AF8-CFLAGS +AD0- +ACQ-(WARN+AF8-CFLAGS) +ACQ-(ZLIBINC)
----------------------------------+AD4-8------------------------------------

While configure script verifies only CC compiler (CPP in fact but it is set to +ACIAJA-CC -E+ACI-) to be compatible with
GCC+AF8-WARN+AF8-FLAGS, e.g. verifying to be compatible with +ACI--Wstack-usage+ACI- option (binutils/configure: 11965):
----------------------------------+AD4-8------------------------------------
+ACM- Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
cat confdefs.h - +ADwAPABf-ACEOF +AD4-conftest.+ACQ-ac+AF8-ext
/+ACo- end confdefs.h.+AKAAoAAq-/
+AF8AXw-GNUC+AF8AXw-
+AF8-ACEOF
if (eval +ACIAJA-ac+AF8-cpp conftest.+ACQ-ac+AF8-ext+ACI-) 2+AD4AJg-5 +AHw-
+AKA- +ACQ-EGREP +ACIAXgBb-0-4+AF0AJAAi- +AD4-/dev/null 2+AD4AJg-1+ADs- then :

else
+AKA- GCC+AF8-WARN+AF8-CFLAGS+AD0AIgAk-GCC+AF8-WARN+AF8-CFLAGS -Wstack-usage+AD0-262144+ACI-
fi
----------------------------------+AD4-8------------------------------------

Where +ACQ-ac+AF8-cpp is '+ACQ-CPP +ACQ-CPPFLAGS'.

This behavior leads to unobvious errors: host compiler may doesn't have support of some options that are passed to both
host and target compilers. That exactly happened to me - I tried to cross-compile binutils-gdb for ARC. GCC - 6 is now
used for ARC, so +ACI--Wstack-usage+ACI- option was added to WARN+AF8-CLFAGS and then to AM+AF8-CFLAGS. But I have rather old compiler,
installed on my host and it doesn't support+AKAAIg--Wstack-usage+ACI-. So the failure occurred and I wasn't able to cross-compile
binutils on my host.+AKA-

Of course updating GCC to newer version solves the issue and you can say that we should use up-to-date GCC version but I
still think that all described above is a real issue and is needed to be solved.+AKA-

While debugging the problem I also found that some work had been already done: CCFLAGS and LDFLAGS were replaced with
CCFLAGS+AF8-FOR+AF8-BUILD and LDFLAGS+AF8-FOR+AF8-BUILD by the commit:
https://sourceware.org/git/gitweb.cgi?p+AD0-binutils-gdb.git+ADs-a+AD0-commit+ADs-h+AD0-791f39718a26c3fbedbd1f6a90956ecdfe03340a

But AM+AF8-CLFAGS remained intact.

So solutions could be either to have WARN+AF8-CFLAGS+AF8-FOR+AF8-BUILD or AM+AF8-CLFLAGS+AF8-FOR+AF8-BUILD variable with corresponding options
and verify CC+AF8-FOR+AF8-BUILD to be compatible with such options or just not to use AM+AF8-FLAGS with CC+AF8-FOR+AF8-BUILD compiler at all
as AM+AF8-FLAGS seems to be compatible only with CC compiler.

Any ideas or suggestions?

-- 
Best regards,
Vlad Zakharov +ADw-vzakhar+AEA-synopsys.com+AD4-


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]