* [Buildroot] [PATCH] toolchain/external: fix wrapper by not passing conflicting flags
@ 2014-01-06 0:12 Yann E. MORIN
2014-01-06 16:07 ` Maxime Hadjinlian
0 siblings, 1 reply; 4+ messages in thread
From: Yann E. MORIN @ 2014-01-06 0:12 UTC (permalink / raw)
To: buildroot
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
In our wrapper, we forcibly add the -march=, -mcpu= and-mtune= flags
to the actual copmpiler, this in an attempt to always generate correct
and optimised code for the target.
But in some cases, the caller knows better than we do, and passes its
own set, or subset of those flags. In this case, some may conflict with
the ones we pass. The most prominent offender being the Linux kernel.
For example, on the ARM Rapsberry Pi, the Linux kernel will set the
-march=armv6 flag and no -mcpu= flag, but we pass -mcpu=arm1176jzf-s,
which conflicts:
drivers/scsi/scsi_trace.c:1:0: warning: switch -mcpu=arm1176jzf-s
conflicts with -march=armv6 switch
(and so for all the files the kernel compiles, pretty messy)
(note: arm1176jzf-s is not an armv6, it is an armv6zk. Yeah...)
To avoid this situation, we scan our commandline for any occurence of
the possibly conflicting flags. If none is found, then we add our owns.
If any is found, then we don't add any of our owns.
The idea behind this is that we trust the caller to know better than
we do what it is doing. Since the biggest, and sole so far, offender
is the Linux kernel, then this is a rather safe bet.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Peter Korsgaard <jacmet@uclibc.org>
Cc: Arnout Vandecappelle <arnout@mind.be>
---
.../toolchain-external/ext-toolchain-wrapper.c | 41 ++++++++++++++++------
1 file changed, 31 insertions(+), 10 deletions(-)
diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c
index d54f1f5..dd84a5d 100644
--- a/toolchain/toolchain-external/ext-toolchain-wrapper.c
+++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c
@@ -30,21 +30,17 @@ static char sysroot[PATH_MAX];
* that we only pass the predefined one to the real compiler if the inverse
* option isn't in the argument list.
* This specifies the worst case number of extra arguments we might pass
+ * Currently, we have:
+ * -mfloat-abi=
+ * -march=
+ * -mtune=
+ * -mcpu=
*/
-#define EXCLUSIVE_ARGS 1
+#define EXCLUSIVE_ARGS 4
static char *predef_args[] = {
path,
"--sysroot", sysroot,
-#ifdef BR_ARCH
- "-march=" BR_ARCH,
-#endif /* BR_ARCH */
-#ifdef BR_TUNE
- "-mtune=" BR_TUNE,
-#endif /* BR_TUNE */
-#ifdef BR_CPU
- "-mcpu=" BR_CPU,
-#endif
#ifdef BR_ABI
"-mabi=" BR_ABI,
#endif
@@ -157,6 +153,31 @@ int main(int argc, char **argv)
*cur++ = "-mfloat-abi=" BR_FLOAT_ABI;
#endif
+#if defined(BR2_ARCH) || \
+ defined(BR2_TUNE) || \
+ defined(BR2_CPU)
+ /* Add our -march/cpu/tune/abi flags, but only if none are
+ * already specified on the commandline
+ */
+ for (i = 1; i < argc; i++) {
+ if (!strncmp(argv[i], "-march=", strlen("-march=")) ||
+ !strncmp(argv[i], "-mtune=", strlen("-mtune=")) ||
+ !strncmp(argv[i], "-mcpu=", strlen("-mcpu=" )))
+ break;
+ }
+ if (i == argc) {
+#ifdef BR_ARCH
+ *cur++ = "-march=" BR_ARCH;
+#endif
+#ifdef BR_TUNE
+ *cur++ = "-mtune=" BR_TUNE;
+#endif
+#ifdef BR_CPU
+ *cur++ = "-mcpu=" BR_CPU;
+#endif
+ }
+#endif /* ARCH || TUNE || CPU */
+
/* append forward args */
memcpy(cur, &argv[1], sizeof(char *) * (argc - 1));
cur += argc - 1;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH] toolchain/external: fix wrapper by not passing conflicting flags
2014-01-06 0:12 [Buildroot] [PATCH] toolchain/external: fix wrapper by not passing conflicting flags Yann E. MORIN
@ 2014-01-06 16:07 ` Maxime Hadjinlian
2014-01-06 17:07 ` Yann E. MORIN
0 siblings, 1 reply; 4+ messages in thread
From: Maxime Hadjinlian @ 2014-01-06 16:07 UTC (permalink / raw)
To: buildroot
Hi all,
On Mon, Jan 6, 2014 at 1:12 AM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
>
> In our wrapper, we forcibly add the -march=, -mcpu= and-mtune= flags
> to the actual copmpiler, this in an attempt to always generate correct
> and optimised code for the target.
>
> But in some cases, the caller knows better than we do, and passes its
> own set, or subset of those flags. In this case, some may conflict with
> the ones we pass. The most prominent offender being the Linux kernel.
>
> For example, on the ARM Rapsberry Pi, the Linux kernel will set the
> -march=armv6 flag and no -mcpu= flag, but we pass -mcpu=arm1176jzf-s,
> which conflicts:
>
> drivers/scsi/scsi_trace.c:1:0: warning: switch -mcpu=arm1176jzf-s
> conflicts with -march=armv6 switch
>
> (and so for all the files the kernel compiles, pretty messy)
> (note: arm1176jzf-s is not an armv6, it is an armv6zk. Yeah...)
>
> To avoid this situation, we scan our commandline for any occurence of
> the possibly conflicting flags. If none is found, then we add our owns.
> If any is found, then we don't add any of our owns.
>
> The idea behind this is that we trust the caller to know better than
> we do what it is doing. Since the biggest, and sole so far, offender
> is the Linux kernel, then this is a rather safe bet.
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: Peter Korsgaard <jacmet@uclibc.org>
> Cc: Arnout Vandecappelle <arnout@mind.be>
> ---
> .../toolchain-external/ext-toolchain-wrapper.c | 41 ++++++++++++++++------
> 1 file changed, 31 insertions(+), 10 deletions(-)
>
> diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c
> index d54f1f5..dd84a5d 100644
> --- a/toolchain/toolchain-external/ext-toolchain-wrapper.c
> +++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c
> @@ -30,21 +30,17 @@ static char sysroot[PATH_MAX];
> * that we only pass the predefined one to the real compiler if the inverse
> * option isn't in the argument list.
> * This specifies the worst case number of extra arguments we might pass
> + * Currently, we have:
> + * -mfloat-abi=
> + * -march=
> + * -mtune=
> + * -mcpu=
> */
> -#define EXCLUSIVE_ARGS 1
> +#define EXCLUSIVE_ARGS 4
>
> static char *predef_args[] = {
> path,
> "--sysroot", sysroot,
> -#ifdef BR_ARCH
> - "-march=" BR_ARCH,
> -#endif /* BR_ARCH */
> -#ifdef BR_TUNE
> - "-mtune=" BR_TUNE,
> -#endif /* BR_TUNE */
> -#ifdef BR_CPU
> - "-mcpu=" BR_CPU,
> -#endif
> #ifdef BR_ABI
> "-mabi=" BR_ABI,
> #endif
> @@ -157,6 +153,31 @@ int main(int argc, char **argv)
> *cur++ = "-mfloat-abi=" BR_FLOAT_ABI;
> #endif
>
> +#if defined(BR2_ARCH) || \
> + defined(BR2_TUNE) || \
> + defined(BR2_CPU)
Shouldn't this be BR_* ?
> + /* Add our -march/cpu/tune/abi flags, but only if none are
> + * already specified on the commandline
> + */
> + for (i = 1; i < argc; i++) {
> + if (!strncmp(argv[i], "-march=", strlen("-march=")) ||
> + !strncmp(argv[i], "-mtune=", strlen("-mtune=")) ||
> + !strncmp(argv[i], "-mcpu=", strlen("-mcpu=" )))
> + break;
> + }
> + if (i == argc) {
> +#ifdef BR_ARCH
> + *cur++ = "-march=" BR_ARCH;
> +#endif
> +#ifdef BR_TUNE
> + *cur++ = "-mtune=" BR_TUNE;
> +#endif
> +#ifdef BR_CPU
> + *cur++ = "-mcpu=" BR_CPU;
> +#endif
> + }
> +#endif /* ARCH || TUNE || CPU */
> +
> /* append forward args */
> memcpy(cur, &argv[1], sizeof(char *) * (argc - 1));
> cur += argc - 1;
> --
> 1.8.1.2
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
After modifying to use BR instead of BR2 variable, your patch did what
was intended.
It suppressed all theses pesky messages while building the kernel.
I am currently doing a full build, will report once it's done.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH] toolchain/external: fix wrapper by not passing conflicting flags
2014-01-06 16:07 ` Maxime Hadjinlian
@ 2014-01-06 17:07 ` Yann E. MORIN
2014-01-06 17:36 ` Maxime Hadjinlian
0 siblings, 1 reply; 4+ messages in thread
From: Yann E. MORIN @ 2014-01-06 17:07 UTC (permalink / raw)
To: buildroot
On 2014-01-06 17:07 +0100, Maxime Hadjinlian spake thusly:
> On Mon, Jan 6, 2014 at 1:12 AM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > In our wrapper, we forcibly add the -march=, -mcpu= and-mtune= flags
> > to the actual copmpiler, this in an attempt to always generate correct
> > and optimised code for the target.
[--SNIP--]
> > @@ -157,6 +153,31 @@ int main(int argc, char **argv)
> > *cur++ = "-mfloat-abi=" BR_FLOAT_ABI;
> > #endif
> >
> > +#if defined(BR2_ARCH) || \
> > + defined(BR2_TUNE) || \
> > + defined(BR2_CPU)
> Shouldn't this be BR_* ?
Doh, yes indeed. Good catch. :-)
> After modifying to use BR instead of BR2 variable, your patch did what
> was intended.
> It suppressed all theses pesky messages while building the kernel.
>
> I am currently doing a full build, will report once it's done.
Thank you! :-)
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH] toolchain/external: fix wrapper by not passing conflicting flags
2014-01-06 17:07 ` Yann E. MORIN
@ 2014-01-06 17:36 ` Maxime Hadjinlian
0 siblings, 0 replies; 4+ messages in thread
From: Maxime Hadjinlian @ 2014-01-06 17:36 UTC (permalink / raw)
To: buildroot
It did build without any warnings in Linux, so far so good :).
On Mon, Jan 6, 2014 at 6:07 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> On 2014-01-06 17:07 +0100, Maxime Hadjinlian spake thusly:
>> On Mon, Jan 6, 2014 at 1:12 AM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>> > From: "Yann E. MORIN" <yann.morin.1998@free.fr>
>> > In our wrapper, we forcibly add the -march=, -mcpu= and-mtune= flags
>> > to the actual copmpiler, this in an attempt to always generate correct
>> > and optimised code for the target.
> [--SNIP--]
>> > @@ -157,6 +153,31 @@ int main(int argc, char **argv)
>> > *cur++ = "-mfloat-abi=" BR_FLOAT_ABI;
>> > #endif
>> >
>> > +#if defined(BR2_ARCH) || \
>> > + defined(BR2_TUNE) || \
>> > + defined(BR2_CPU)
>> Shouldn't this be BR_* ?
>
> Doh, yes indeed. Good catch. :-)
>
>> After modifying to use BR instead of BR2 variable, your patch did what
>> was intended.
>> It suppressed all theses pesky messages while building the kernel.
>>
>> I am currently doing a full build, will report once it's done.
>
> Thank you! :-)
>
> Regards,
> Yann E. MORIN.
>
> --
> .-----------------.--------------------.------------------.--------------------.
> | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
> | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
> | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
> | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
> '------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-06 17:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-06 0:12 [Buildroot] [PATCH] toolchain/external: fix wrapper by not passing conflicting flags Yann E. MORIN
2014-01-06 16:07 ` Maxime Hadjinlian
2014-01-06 17:07 ` Yann E. MORIN
2014-01-06 17:36 ` Maxime Hadjinlian
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.