public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH 0/1] Fix target cflags for gcc cross builds
@ 2016-01-14 21:04 Peter Seebach
  2016-01-14 21:04 ` [PATCH 1/1] Use TUNE_CCARGS for target compilation Peter Seebach
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Seebach @ 2016-01-14 21:04 UTC (permalink / raw)
  To: openembedded-core

In some cases, CFLAGS_FOR_TARGET may need to have tune-specific compiler
flags, particularly if you're trying to build a multilib compiler which
won't automatically pick the right ABI, bit size, etc. by default if
invoked without them. After some experimentation and thought, I concluded
that cross gcc should use these in CFLAGS_FOR_TARGET, but crosssdk shouldn't.
This appears to work, at least for the reasonably obvious cases.

We did this back in November, and I thought I submitted it then, but
apparently the email never made it out. Rebased against current master.

The following changes since commit 541315d6c56df6448f64c262f99d43d5c1e9400b:

  update_font_cache: only scan system font directories (2016-01-11 23:23:18 +0000)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib seebs/gcc_target_args
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=seebs/gcc_target_args

Peter Seebach (1):
  Use TUNE_CCARGS for target compilation

 meta/classes/crosssdk.bbclass                      | 4 ++++
 meta/recipes-devtools/gcc/gcc-configure-common.inc | 2 +-
 meta/recipes-devtools/gcc/gcc-cross.inc            | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.3.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/1] Use TUNE_CCARGS for target compilation
  2016-01-14 21:04 [PATCH 0/1] Fix target cflags for gcc cross builds Peter Seebach
@ 2016-01-14 21:04 ` Peter Seebach
  2016-01-14 21:24   ` Andre McCurdy
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Seebach @ 2016-01-14 21:04 UTC (permalink / raw)
  To: openembedded-core

The initial gcc configuration is using TARGET_CFLAGS, but this is
probably not what is intended, because TARGET_CFLAGS doesn't include
any architecture-specific flags.

For PPC64, it's possible to end up with gcc configured to pass -a64 to
the assembler, but be itself getting invoked without -m64, which can result
in alignment problems in generated code. Solution: Instead of setting
CFLAGS_FOR_TARGET to TARGET_CFLAGS, set it to TARGET_CFLAGS + TUNE_CCARGS.

However, for crosssdk cases, we need to prevent that from having any
effect; this can be done by emptying out the TUNE_*ARGS flags in the
crosssdk bbclass, because there is no "target tune" in crosssdk cases.

Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
---
 meta/classes/crosssdk.bbclass                      | 4 ++++
 meta/recipes-devtools/gcc/gcc-configure-common.inc | 2 +-
 meta/recipes-devtools/gcc/gcc-cross.inc            | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/meta/classes/crosssdk.bbclass b/meta/classes/crosssdk.bbclass
index 7315c38..ccff3ce 100644
--- a/meta/classes/crosssdk.bbclass
+++ b/meta/classes/crosssdk.bbclass
@@ -6,6 +6,10 @@ PACKAGE_ARCH = "${SDK_ARCH}"
 python () {
 	# set TUNE_PKGARCH to SDK_ARCH
 	d.setVar('TUNE_PKGARCH', d.getVar('SDK_ARCH', True))
+	# We're not running a 'target', so clear these...
+	d.setVar('TUNE_CCARGS', '')
+	d.setVar('TUNE_LDARGS', '')
+	d.setVar('TUNE_ASARGS', '')
 }
 
 STAGING_DIR_TARGET = "${STAGING_DIR}/${SDK_ARCH}-${SDKPKGSUFFIX}${SDK_VENDOR}-${SDK_OS}"
diff --git a/meta/recipes-devtools/gcc/gcc-configure-common.inc b/meta/recipes-devtools/gcc/gcc-configure-common.inc
index 45b3f15..4b4d91d 100644
--- a/meta/recipes-devtools/gcc/gcc-configure-common.inc
+++ b/meta/recipes-devtools/gcc/gcc-configure-common.inc
@@ -120,7 +120,7 @@ do_configure () {
 	export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}"
 	export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
 	export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}"
-	export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
+	export CFLAGS_FOR_TARGET="${TARGET_CFLAGS} ${TUNE_CCARGS}"
 	export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
 	export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
 	export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
diff --git a/meta/recipes-devtools/gcc/gcc-cross.inc b/meta/recipes-devtools/gcc/gcc-cross.inc
index aa10633..b6020a4 100644
--- a/meta/recipes-devtools/gcc/gcc-cross.inc
+++ b/meta/recipes-devtools/gcc/gcc-cross.inc
@@ -43,7 +43,7 @@ do_compile () {
 	export LD_FOR_TARGET="${TARGET_SYS}-ld"
 	export NM_FOR_TARGET="${TARGET_SYS}-nm"
 	export CC_FOR_TARGET="${CCACHE} ${TARGET_SYS}-gcc"
-	export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
+	export CFLAGS_FOR_TARGET="${TARGET_CFLAGS} ${TUNE_CCARGS}"
 	export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
 	export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
 	export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
-- 
2.3.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] Use TUNE_CCARGS for target compilation
  2016-01-14 21:04 ` [PATCH 1/1] Use TUNE_CCARGS for target compilation Peter Seebach
@ 2016-01-14 21:24   ` Andre McCurdy
  2016-01-14 21:27     ` Peter Seebach
  2016-01-14 21:29     ` Mark Hatle
  0 siblings, 2 replies; 5+ messages in thread
From: Andre McCurdy @ 2016-01-14 21:24 UTC (permalink / raw)
  To: Peter Seebach; +Cc: OE Core mailing list

Hi Peter,

On Thu, Jan 14, 2016 at 1:04 PM, Peter Seebach
<peter.seebach@windriver.com> wrote:
> The initial gcc configuration is using TARGET_CFLAGS, but this is
> probably not what is intended, because TARGET_CFLAGS doesn't include
> any architecture-specific flags.

I think the current behaviour is deliberate, in order to try to make
it possible to reuse gcc binaries across builds for machines with
different CPU tuning flags.

See the comments associated with this commit from 2014, which
effectively makes all ARM toolchains default to soft float (instead of
defaulting to fpu calling convention of the target machine).

  http://git.openembedded.org/openembedded-core/commit/?id=ce1f3fd20d81545d6d5dfc68f86f9fddf8ac9bbf

> For PPC64, it's possible to end up with gcc configured to pass -a64 to
> the assembler, but be itself getting invoked without -m64, which can result
> in alignment problems in generated code. Solution: Instead of setting
> CFLAGS_FOR_TARGET to TARGET_CFLAGS, set it to TARGET_CFLAGS + TUNE_CCARGS.

Could that PPC64 issue be solved in the same way that the default arch
is set in gcc-configure-common.inc for the various MIPS targets?

  EXTRA_OECONF_append_mips64 = " --with-abi=64 --with-arch-64=mips64
--with-tune-64=mips64"
  EXTRA_OECONF_append_mips64el = " --with-abi=64 --with-arch-64=mips64
--with-tune-64=mips64"
  EXTRA_OECONF_append_mips64n32 = " --with-abi=64
--with-arch-64=mips64 --with-tune-64=mips64"
  EXTRA_OECONF_append_mips64eln32 = " --with-abi=64
--with-arch-64=mips64 --with-tune-64=mips64"


> However, for crosssdk cases, we need to prevent that from having any
> effect; this can be done by emptying out the TUNE_*ARGS flags in the
> crosssdk bbclass, because there is no "target tune" in crosssdk cases.
>
> Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
> ---
>  meta/classes/crosssdk.bbclass                      | 4 ++++
>  meta/recipes-devtools/gcc/gcc-configure-common.inc | 2 +-
>  meta/recipes-devtools/gcc/gcc-cross.inc            | 2 +-
>  3 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/crosssdk.bbclass b/meta/classes/crosssdk.bbclass
> index 7315c38..ccff3ce 100644
> --- a/meta/classes/crosssdk.bbclass
> +++ b/meta/classes/crosssdk.bbclass
> @@ -6,6 +6,10 @@ PACKAGE_ARCH = "${SDK_ARCH}"
>  python () {
>         # set TUNE_PKGARCH to SDK_ARCH
>         d.setVar('TUNE_PKGARCH', d.getVar('SDK_ARCH', True))
> +       # We're not running a 'target', so clear these...
> +       d.setVar('TUNE_CCARGS', '')
> +       d.setVar('TUNE_LDARGS', '')
> +       d.setVar('TUNE_ASARGS', '')
>  }
>
>  STAGING_DIR_TARGET = "${STAGING_DIR}/${SDK_ARCH}-${SDKPKGSUFFIX}${SDK_VENDOR}-${SDK_OS}"
> diff --git a/meta/recipes-devtools/gcc/gcc-configure-common.inc b/meta/recipes-devtools/gcc/gcc-configure-common.inc
> index 45b3f15..4b4d91d 100644
> --- a/meta/recipes-devtools/gcc/gcc-configure-common.inc
> +++ b/meta/recipes-devtools/gcc/gcc-configure-common.inc
> @@ -120,7 +120,7 @@ do_configure () {
>         export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}"
>         export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
>         export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}"
> -       export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
> +       export CFLAGS_FOR_TARGET="${TARGET_CFLAGS} ${TUNE_CCARGS}"
>         export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
>         export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
>         export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
> diff --git a/meta/recipes-devtools/gcc/gcc-cross.inc b/meta/recipes-devtools/gcc/gcc-cross.inc
> index aa10633..b6020a4 100644
> --- a/meta/recipes-devtools/gcc/gcc-cross.inc
> +++ b/meta/recipes-devtools/gcc/gcc-cross.inc
> @@ -43,7 +43,7 @@ do_compile () {
>         export LD_FOR_TARGET="${TARGET_SYS}-ld"
>         export NM_FOR_TARGET="${TARGET_SYS}-nm"
>         export CC_FOR_TARGET="${CCACHE} ${TARGET_SYS}-gcc"
> -       export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
> +       export CFLAGS_FOR_TARGET="${TARGET_CFLAGS} ${TUNE_CCARGS}"
>         export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
>         export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
>         export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
> --
> 2.3.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] Use TUNE_CCARGS for target compilation
  2016-01-14 21:24   ` Andre McCurdy
@ 2016-01-14 21:27     ` Peter Seebach
  2016-01-14 21:29     ` Mark Hatle
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Seebach @ 2016-01-14 21:27 UTC (permalink / raw)
  To: Andre McCurdy; +Cc: OE Core mailing list

On Thu, 14 Jan 2016 13:24:22 -0800
Andre McCurdy <armccurdy@gmail.com> wrote:

> Could that PPC64 issue be solved in the same way that the default arch
> is set in gcc-configure-common.inc for the various MIPS targets?

Huh. That might be a better choice. I hadn't noticed that default arch
selection thing. It would make sense to use that. I'll give it a look and see
whether it works.

-s
-- 
Listen, get this.  Nobody with a good compiler needs to be justified.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] Use TUNE_CCARGS for target compilation
  2016-01-14 21:24   ` Andre McCurdy
  2016-01-14 21:27     ` Peter Seebach
@ 2016-01-14 21:29     ` Mark Hatle
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Hatle @ 2016-01-14 21:29 UTC (permalink / raw)
  To: openembedded-core

On 1/14/16 3:24 PM, Andre McCurdy wrote:
> Hi Peter,
> 
> On Thu, Jan 14, 2016 at 1:04 PM, Peter Seebach
> <peter.seebach@windriver.com> wrote:
>> The initial gcc configuration is using TARGET_CFLAGS, but this is
>> probably not what is intended, because TARGET_CFLAGS doesn't include
>> any architecture-specific flags.
> 
> I think the current behaviour is deliberate, in order to try to make
> it possible to reuse gcc binaries across builds for machines with
> different CPU tuning flags.
> 
> See the comments associated with this commit from 2014, which
> effectively makes all ARM toolchains default to soft float (instead of
> defaulting to fpu calling convention of the target machine).
> 
>   http://git.openembedded.org/openembedded-core/commit/?id=ce1f3fd20d81545d6d5dfc68f86f9fddf8ac9bbf
> 
>> For PPC64, it's possible to end up with gcc configured to pass -a64 to
>> the assembler, but be itself getting invoked without -m64, which can result
>> in alignment problems in generated code. Solution: Instead of setting
>> CFLAGS_FOR_TARGET to TARGET_CFLAGS, set it to TARGET_CFLAGS + TUNE_CCARGS.
> 
> Could that PPC64 issue be solved in the same way that the default arch
> is set in gcc-configure-common.inc for the various MIPS targets?
> 
>   EXTRA_OECONF_append_mips64 = " --with-abi=64 --with-arch-64=mips64
> --with-tune-64=mips64"
>   EXTRA_OECONF_append_mips64el = " --with-abi=64 --with-arch-64=mips64
> --with-tune-64=mips64"
>   EXTRA_OECONF_append_mips64n32 = " --with-abi=64
> --with-arch-64=mips64 --with-tune-64=mips64"
>   EXTRA_OECONF_append_mips64eln32 = " --with-abi=64
> --with-arch-64=mips64 --with-tune-64=mips64"

The issue Peter was working on is specific to building something that runs on
the host.  (or the hostsdk machine).

The problem is, if you are building for a target that say needs -mpowerpc.  That
won't work when you pass it to the compiler building an x86_64 target binary.

So in the crosssdk case (host to -sdk- target) we clear the TUNE_*ARGS since
they are not relevant.

Then int he main gcc setup, we manually setup the target CCFLAGS to include the
tune elements so when NOT in the crosssdk, they will be properly included and
build the -target- pieces with the correct options.  (target pieces such as the
.o files gcc needs to produce.)

--Mark

> 
>> However, for crosssdk cases, we need to prevent that from having any
>> effect; this can be done by emptying out the TUNE_*ARGS flags in the
>> crosssdk bbclass, because there is no "target tune" in crosssdk cases.
>>
>> Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
>> ---
>>  meta/classes/crosssdk.bbclass                      | 4 ++++
>>  meta/recipes-devtools/gcc/gcc-configure-common.inc | 2 +-
>>  meta/recipes-devtools/gcc/gcc-cross.inc            | 2 +-
>>  3 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/meta/classes/crosssdk.bbclass b/meta/classes/crosssdk.bbclass
>> index 7315c38..ccff3ce 100644
>> --- a/meta/classes/crosssdk.bbclass
>> +++ b/meta/classes/crosssdk.bbclass
>> @@ -6,6 +6,10 @@ PACKAGE_ARCH = "${SDK_ARCH}"
>>  python () {
>>         # set TUNE_PKGARCH to SDK_ARCH
>>         d.setVar('TUNE_PKGARCH', d.getVar('SDK_ARCH', True))
>> +       # We're not running a 'target', so clear these...
>> +       d.setVar('TUNE_CCARGS', '')
>> +       d.setVar('TUNE_LDARGS', '')
>> +       d.setVar('TUNE_ASARGS', '')
>>  }
>>
>>  STAGING_DIR_TARGET = "${STAGING_DIR}/${SDK_ARCH}-${SDKPKGSUFFIX}${SDK_VENDOR}-${SDK_OS}"
>> diff --git a/meta/recipes-devtools/gcc/gcc-configure-common.inc b/meta/recipes-devtools/gcc/gcc-configure-common.inc
>> index 45b3f15..4b4d91d 100644
>> --- a/meta/recipes-devtools/gcc/gcc-configure-common.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-configure-common.inc
>> @@ -120,7 +120,7 @@ do_configure () {
>>         export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}"
>>         export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
>>         export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}"
>> -       export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
>> +       export CFLAGS_FOR_TARGET="${TARGET_CFLAGS} ${TUNE_CCARGS}"
>>         export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
>>         export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
>>         export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
>> diff --git a/meta/recipes-devtools/gcc/gcc-cross.inc b/meta/recipes-devtools/gcc/gcc-cross.inc
>> index aa10633..b6020a4 100644
>> --- a/meta/recipes-devtools/gcc/gcc-cross.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-cross.inc
>> @@ -43,7 +43,7 @@ do_compile () {
>>         export LD_FOR_TARGET="${TARGET_SYS}-ld"
>>         export NM_FOR_TARGET="${TARGET_SYS}-nm"
>>         export CC_FOR_TARGET="${CCACHE} ${TARGET_SYS}-gcc"
>> -       export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
>> +       export CFLAGS_FOR_TARGET="${TARGET_CFLAGS} ${TUNE_CCARGS}"
>>         export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
>>         export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
>>         export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
>> --
>> 2.3.1
>>
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-14 21:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14 21:04 [PATCH 0/1] Fix target cflags for gcc cross builds Peter Seebach
2016-01-14 21:04 ` [PATCH 1/1] Use TUNE_CCARGS for target compilation Peter Seebach
2016-01-14 21:24   ` Andre McCurdy
2016-01-14 21:27     ` Peter Seebach
2016-01-14 21:29     ` Mark Hatle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox