* [patch] PR bootstrap/25672: Avoid CFLAGS in CFLAGS_FOR_TARGETS if cross-compiling
@ 2015-03-09 22:22 Aldy Hernandez
2015-03-10 6:35 ` Jeff Law
0 siblings, 1 reply; 3+ messages in thread
From: Aldy Hernandez @ 2015-03-09 22:22 UTC (permalink / raw)
To: gcc-patches, bonzini; +Cc: neroden, Alexandre Oliva, Ralf.Wildenhues
[-- Attachment #1: Type: text/plain, Size: 626 bytes --]
Hello gentlemen.
The problem here is that we pick up the system's CFLAGS and pass it down
to the target libraries. This causes havoc when, for instance, CFLAGS
is -march=x86-64 and the target is powerpc-linux.
I don't see in what scenario the toplevel shell's CFLAGS would be of any
use in the target libraries, so I've just avoided that code path altogether.
Tested by doing a cross-build from x86-64 to ppc64-linux-gnu in a
combined tree, and seeing if libgcc starts to build. Previously we
would fail while configuring GCC. Now, gcc builds fine, and the target
libraries start to build.
OK for mainline?
Aldy
[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 2002 bytes --]
commit f2d130b93f334c5c680761553624964f87594adf
Author: Aldy Hernandez <aldyh@redhat.com>
Date: Mon Mar 9 15:12:33 2015 -0700
PR bootstrap/25672
* configure.ac: Do not initialize CFLAGS_FOR_TARGET from CFLAGS if
cross-compiling. Similarly for CXX_FOR_TARGET.
* configure: Regenerate.
diff --git a/configure.ac b/configure.ac
index 00f7452..2a14c35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2319,28 +2319,36 @@ AC_SUBST(DEBUG_PREFIX_CFLAGS_FOR_TARGET)
# gcc) are built with "-O2 -g", so include those options when setting
# CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
if test "x$CFLAGS_FOR_TARGET" = x; then
- CFLAGS_FOR_TARGET=$CFLAGS
- case " $CFLAGS " in
- *" -O2 "*) ;;
- *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;;
- esac
- case " $CFLAGS " in
- *" -g "* | *" -g3 "*) ;;
- *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;;
- esac
+ if test "x${is_cross_compiler}" = xyes; then
+ CFLAGS_FOR_TARGET="-g -O2"
+ else
+ CFLAGS_FOR_TARGET=$CFLAGS
+ case " $CFLAGS " in
+ *" -O2 "*) ;;
+ *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;;
+ esac
+ case " $CFLAGS " in
+ *" -g "* | *" -g3 "*) ;;
+ *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;;
+ esac
+ fi
fi
AC_SUBST(CFLAGS_FOR_TARGET)
if test "x$CXXFLAGS_FOR_TARGET" = x; then
- CXXFLAGS_FOR_TARGET=$CXXFLAGS
- case " $CXXFLAGS " in
- *" -O2 "*) ;;
- *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;;
- esac
- case " $CXXFLAGS " in
- *" -g "* | *" -g3 "*) ;;
- *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;;
- esac
+ if test "x${is_cross_compiler}" = xyes; then
+ CXXFLAGS_FOR_TARGET="-g -O2"
+ else
+ CXXFLAGS_FOR_TARGET=$CXXFLAGS
+ case " $CXXFLAGS " in
+ *" -O2 "*) ;;
+ *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;;
+ esac
+ case " $CXXFLAGS " in
+ *" -g "* | *" -g3 "*) ;;
+ *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;;
+ esac
+ fi
fi
AC_SUBST(CXXFLAGS_FOR_TARGET)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] PR bootstrap/25672: Avoid CFLAGS in CFLAGS_FOR_TARGETS if cross-compiling
2015-03-09 22:22 [patch] PR bootstrap/25672: Avoid CFLAGS in CFLAGS_FOR_TARGETS if cross-compiling Aldy Hernandez
@ 2015-03-10 6:35 ` Jeff Law
2015-03-10 16:36 ` Aldy Hernandez
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2015-03-10 6:35 UTC (permalink / raw)
To: Aldy Hernandez, gcc-patches, bonzini
Cc: neroden, Alexandre Oliva, Ralf.Wildenhues
On 03/09/15 16:22, Aldy Hernandez wrote:
> Hello gentlemen.
>
> The problem here is that we pick up the system's CFLAGS and pass it down
> to the target libraries. This causes havoc when, for instance, CFLAGS
> is -march=x86-64 and the target is powerpc-linux.
>
> I don't see in what scenario the toplevel shell's CFLAGS would be of any
> use in the target libraries, so I've just avoided that code path
> altogether.
>
> Tested by doing a cross-build from x86-64 to ppc64-linux-gnu in a
> combined tree, and seeing if libgcc starts to build. Previously we
> would fail while configuring GCC. Now, gcc builds fine, and the target
> libraries start to build.
>
> OK for mainline?
>
> Aldy
>
> curr
>
>
> commit f2d130b93f334c5c680761553624964f87594adf
> Author: Aldy Hernandez<aldyh@redhat.com>
> Date: Mon Mar 9 15:12:33 2015 -0700
>
> PR bootstrap/25672
> * configure.ac: Do not initialize CFLAGS_FOR_TARGET from CFLAGS if
> cross-compiling. Similarly for CXX_FOR_TARGET.
> * configure: Regenerate.
I was wondering when someone would come across this oldie-but-goodie...
I'm sure someone, somewhere will complain that
make CFLAGS="whatever" isn't being passed down to the crossses as it has
been for the last two decades. And they'll be right.
But in the cross compiler case, I think it's reasonable to expect to
have to use CFLAGS_FOR_TARGET so that we have separation between the
host and target flags. One could easily want to compile the host with
one set of arguments and the target libraries with something completely
different.
And note that the various .mt files already use the _FOR_TARGET macros
to pass down additional flags rather than just CFLAGS or CXXFLAGS.
Are there any docs that need to change? I don't recall any offhand, but
if you could look prior to committing, it'd be appreciated.
OK for the trunk.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] PR bootstrap/25672: Avoid CFLAGS in CFLAGS_FOR_TARGETS if cross-compiling
2015-03-10 6:35 ` Jeff Law
@ 2015-03-10 16:36 ` Aldy Hernandez
0 siblings, 0 replies; 3+ messages in thread
From: Aldy Hernandez @ 2015-03-10 16:36 UTC (permalink / raw)
To: Jeff Law, gcc-patches, bonzini; +Cc: neroden, Alexandre Oliva, Ralf.Wildenhues
On 03/09/2015 11:35 PM, Jeff Law wrote:
> On 03/09/15 16:22, Aldy Hernandez wrote:
>> Hello gentlemen.
>>
>> The problem here is that we pick up the system's CFLAGS and pass it down
>> to the target libraries. This causes havoc when, for instance, CFLAGS
>> is -march=x86-64 and the target is powerpc-linux.
>>
>> I don't see in what scenario the toplevel shell's CFLAGS would be of any
>> use in the target libraries, so I've just avoided that code path
>> altogether.
>>
>> Tested by doing a cross-build from x86-64 to ppc64-linux-gnu in a
>> combined tree, and seeing if libgcc starts to build. Previously we
>> would fail while configuring GCC. Now, gcc builds fine, and the target
>> libraries start to build.
>>
>> OK for mainline?
>>
>> Aldy
>>
>> curr
>>
>>
>> commit f2d130b93f334c5c680761553624964f87594adf
>> Author: Aldy Hernandez<aldyh@redhat.com>
>> Date: Mon Mar 9 15:12:33 2015 -0700
>>
>> PR bootstrap/25672
>> * configure.ac: Do not initialize CFLAGS_FOR_TARGET from
>> CFLAGS if
>> cross-compiling. Similarly for CXX_FOR_TARGET.
>> * configure: Regenerate.
> I was wondering when someone would come across this oldie-but-goodie...
>
> I'm sure someone, somewhere will complain that
>
> make CFLAGS="whatever" isn't being passed down to the crossses as it has
> been for the last two decades. And they'll be right.
Well, considering this hasn't worked since 4.0.2, with a brief respite
in 4.4.0, I wouldn't worry too much. For that matter, setting
incompatible CFLAGS won't even survive a toplevel configure on trunk
right now. I doubt anyone is dependent on this feature :).
> But in the cross compiler case, I think it's reasonable to expect to
> have to use CFLAGS_FOR_TARGET so that we have separation between the
> host and target flags. One could easily want to compile the host with
> one set of arguments and the target libraries with something completely
> different.
>
> And note that the various .mt files already use the _FOR_TARGET macros
> to pass down additional flags rather than just CFLAGS or CXXFLAGS.
>
>
>
> Are there any docs that need to change? I don't recall any offhand, but
> if you could look prior to committing, it'd be appreciated.
Interestingly, there is nothing but a cursory reference to
CFLAGS_FOR_TARGET in our docs:
@code{BOOT_CFLAGS} does not apply to bootstrapped target libraries.
Since these are always compiled with the compiler currently being
bootstrapped, you can use @code{CFLAGS_FOR_TARGET} to modify their
compilation flags, as for non-bootstrapped target libraries.
Again, if the native compiler miscompiles the stage1 compiler, you may
need to work around this by avoiding non-working parts of the stage1
compiler. Use @code{STAGE1_TFLAGS} to this end.
Considering our entire cross-compilation section is actually quite
lacking, I'm going to just commit as is.
Thanks.
Aldy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-10 16:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09 22:22 [patch] PR bootstrap/25672: Avoid CFLAGS in CFLAGS_FOR_TARGETS if cross-compiling Aldy Hernandez
2015-03-10 6:35 ` Jeff Law
2015-03-10 16:36 ` Aldy Hernandez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).