diff mbox

[U-Boot] dts/Makefile: Turn off system-/gcc-specific predefined macros

Message ID 1342184620-31448-1-git-send-email-hkronsto@frequentis.com
State Accepted
Headers show

Commit Message

Horst Kronstorfer July 13, 2012, 1:03 p.m. UTC
Add '-undef' to DTS_CPPFLAGS to avoid unwanted expansion of dts content
that matches system-specific or gcc-specific predefined macros.

Example: A number of PowerPC related *.dts files in the kernel define a
property named 'linux,network-index' which (w/o '-undef') is expanded to
'1,network-index' by the preprocessor because of '#define linux 1.'

With '-undef' in place only the standard predefined macros are visible:

 $ gcc -dM -E -undef - </dev/null
 #define __STDC_HOSTED__ 1
 #define __STDC__ 1

Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
---
 dts/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mike Frysinger July 19, 2012, 3:22 a.m. UTC | #1
On Friday 13 July 2012 09:03:40 Horst Kronstorfer wrote:
> Add '-undef' to DTS_CPPFLAGS to avoid unwanted expansion of dts content
> that matches system-specific or gcc-specific predefined macros.
> 
> Example: A number of PowerPC related *.dts files in the kernel define a
> property named 'linux,network-index' which (w/o '-undef') is expanded to
> '1,network-index' by the preprocessor because of '#define linux 1.'

i think you should use -ansi instead.  that's what we use in other places for 
the same reason.
-mike
Horst Kronstorfer July 24, 2012, 10:11 a.m. UTC | #2
On 07/19/2012 05:22 AM, Mike Frysinger wrote:
> On Friday 13 July 2012 09:03:40 Horst Kronstorfer wrote:
>> Add '-undef' to DTS_CPPFLAGS to avoid unwanted expansion of dts content
>> that matches system-specific or gcc-specific predefined macros.
>>
>> Example: A number of PowerPC related *.dts files in the kernel define a
>> property named 'linux,network-index' which (w/o '-undef') is expanded to
>> '1,network-index' by the preprocessor because of '#define linux 1.'
>
> i think you should use -ansi instead.  that's what we use in other places for
> the same reason.
> -mike
>

this would increase the probability of a name clash.

-h

>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
Mike Frysinger July 24, 2012, 3:28 p.m. UTC | #3
On Tuesday 24 July 2012 06:11:04 Horst Kronstorfer wrote:
> On 07/19/2012 05:22 AM, Mike Frysinger wrote:
> > On Friday 13 July 2012 09:03:40 Horst Kronstorfer wrote:
> >> Add '-undef' to DTS_CPPFLAGS to avoid unwanted expansion of dts content
> >> that matches system-specific or gcc-specific predefined macros.
> >> 
> >> Example: A number of PowerPC related *.dts files in the kernel define a
> >> property named 'linux,network-index' which (w/o '-undef') is expanded to
> >> '1,network-index' by the preprocessor because of '#define linux 1.'
> > 
> > i think you should use -ansi instead.  that's what we use in other places
> > for the same reason.
> 
> this would increase the probability of a name clash.

no idea what you're talking about.  have you actually looked at the output of 
`gcc -E -dD -ansi` ?
-mike
Horst Kronstorfer July 24, 2012, 7:38 p.m. UTC | #4
On 07/24/2012 05:28 PM, Mike Frysinger wrote:
> On Tuesday 24 July 2012 06:11:04 Horst Kronstorfer wrote:
>> On 07/19/2012 05:22 AM, Mike Frysinger wrote:
>>> On Friday 13 July 2012 09:03:40 Horst Kronstorfer wrote:
>>>> Add '-undef' to DTS_CPPFLAGS to avoid unwanted expansion of dts content
>>>> that matches system-specific or gcc-specific predefined macros.
>>>>
>>>> Example: A number of PowerPC related *.dts files in the kernel define a
>>>> property named 'linux,network-index' which (w/o '-undef') is expanded to
>>>> '1,network-index' by the preprocessor because of '#define linux 1.'
>>>
>>> i think you should use -ansi instead.  that's what we use in other places
>>> for the same reason.
>>
>> this would increase the probability of a name clash.
>
> no idea what you're talking about.  have you actually looked at the output of
> `gcc -E -dD -ansi` ?

$ gcc -E -dM -ansi - </dev/null | wc -l
229
$ gcc -E -dM -undef - </dev/null | wc -l
2

-h

> -mike
>
Mike Frysinger July 25, 2012, 4:06 p.m. UTC | #5
On Tuesday 24 July 2012 15:38:55 Horst Kronstorfer wrote:
> On 07/24/2012 05:28 PM, Mike Frysinger wrote:
> > On Tuesday 24 July 2012 06:11:04 Horst Kronstorfer wrote:
> >> On 07/19/2012 05:22 AM, Mike Frysinger wrote:
> >>> On Friday 13 July 2012 09:03:40 Horst Kronstorfer wrote:
> >>>> Add '-undef' to DTS_CPPFLAGS to avoid unwanted expansion of dts
> >>>> content that matches system-specific or gcc-specific predefined
> >>>> macros.
> >>>> 
> >>>> Example: A number of PowerPC related *.dts files in the kernel define
> >>>> a property named 'linux,network-index' which (w/o '-undef') is
> >>>> expanded to '1,network-index' by the preprocessor because of '#define
> >>>> linux 1.'
> >>> 
> >>> i think you should use -ansi instead.  that's what we use in other
> >>> places for the same reason.
> >> 
> >> this would increase the probability of a name clash.
> > 
> > no idea what you're talking about.  have you actually looked at the
> > output of `gcc -E -dD -ansi` ?
> 
> $ gcc -E -dM -ansi - </dev/null | wc -l
> 229
> $ gcc -E -dM -undef - </dev/null | wc -l
> 2

and ?  did you *look* at the output ?  they're all of the form __foo__.  do 
any device trees really use __foo__ names ?  i don't think so.
-mike
Horst Kronstorfer July 26, 2012, 7:06 a.m. UTC | #6
On 07/25/2012 06:06 PM, Mike Frysinger wrote:
> On Tuesday 24 July 2012 15:38:55 Horst Kronstorfer wrote:
>> On 07/24/2012 05:28 PM, Mike Frysinger wrote:
>>> On Tuesday 24 July 2012 06:11:04 Horst Kronstorfer wrote:
>>>> On 07/19/2012 05:22 AM, Mike Frysinger wrote:
>>>>> On Friday 13 July 2012 09:03:40 Horst Kronstorfer wrote:
>>>>>> Add '-undef' to DTS_CPPFLAGS to avoid unwanted expansion of dts
>>>>>> content that matches system-specific or gcc-specific predefined
>>>>>> macros.
>>>>>>
>>>>>> Example: A number of PowerPC related *.dts files in the kernel define
>>>>>> a property named 'linux,network-index' which (w/o '-undef') is
>>>>>> expanded to '1,network-index' by the preprocessor because of '#define
>>>>>> linux 1.'
>>>>>
>>>>> i think you should use -ansi instead.  that's what we use in other
>>>>> places for the same reason.
>>>>
>>>> this would increase the probability of a name clash.
>>>
>>> no idea what you're talking about.  have you actually looked at the
>>> output of `gcc -E -dD -ansi` ?
>>
>> $ gcc -E -dM -ansi - </dev/null | wc -l
>> 229
>> $ gcc -E -dM -undef - </dev/null | wc -l
>> 2
>
> and ?  did you *look* at the output ?  they're all of the form __foo__.

i already considered that.

> do any device trees really use __foo__ names ?  i don't think so.

is there any drawback using '-undef' in this particular case besides
"we use -ansi in other places for the same reason"?

-h

> -mike
>
Mike Frysinger July 26, 2012, 4:23 p.m. UTC | #7
On Thursday 26 July 2012 03:06:06 Horst Kronstorfer wrote:
> On 07/25/2012 06:06 PM, Mike Frysinger wrote:
> > On Tuesday 24 July 2012 15:38:55 Horst Kronstorfer wrote:
> >> On 07/24/2012 05:28 PM, Mike Frysinger wrote:
> >>> On Tuesday 24 July 2012 06:11:04 Horst Kronstorfer wrote:
> >>>> On 07/19/2012 05:22 AM, Mike Frysinger wrote:
> >>>>> On Friday 13 July 2012 09:03:40 Horst Kronstorfer wrote:
> >>>>>> Add '-undef' to DTS_CPPFLAGS to avoid unwanted expansion of dts
> >>>>>> content that matches system-specific or gcc-specific predefined
> >>>>>> macros.
> >>>>>> 
> >>>>>> Example: A number of PowerPC related *.dts files in the kernel
> >>>>>> define a property named 'linux,network-index' which (w/o '-undef')
> >>>>>> is expanded to '1,network-index' by the preprocessor because of
> >>>>>> '#define linux 1.'
> >>>>> 
> >>>>> i think you should use -ansi instead.  that's what we use in other
> >>>>> places for the same reason.
> >>>> 
> >>>> this would increase the probability of a name clash.
> >>> 
> >>> no idea what you're talking about.  have you actually looked at the
> >>> output of `gcc -E -dD -ansi` ?
> >> 
> >> $ gcc -E -dM -ansi - </dev/null | wc -l
> >> 229
> >> $ gcc -E -dM -undef - </dev/null | wc -l
> >> 2
> > 
> > and ?  did you *look* at the output ?  they're all of the form __foo__.
> 
> i already considered that.
> 
> > do any device trees really use __foo__ names ?  i don't think so.
> 
> is there any drawback using '-undef' in this particular case besides
> "we use -ansi in other places for the same reason"?

we use -ansi because it's more portable and has known behavior in the build 
system
-mike
Wolfgang Denk Aug. 10, 2012, 9:50 p.m. UTC | #8
Dear Horst Kronstorfer,

In message <1342184620-31448-1-git-send-email-hkronsto@frequentis.com> you wrote:
> Add '-undef' to DTS_CPPFLAGS to avoid unwanted expansion of dts content
> that matches system-specific or gcc-specific predefined macros.
> 
> Example: A number of PowerPC related *.dts files in the kernel define a
> property named 'linux,network-index' which (w/o '-undef') is expanded to
> '1,network-index' by the preprocessor because of '#define linux 1.'
> 
> With '-undef' in place only the standard predefined macros are visible:
> 
>  $ gcc -dM -E -undef - </dev/null
>  #define __STDC_HOSTED__ 1
>  #define __STDC__ 1
> 
> Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
> ---
>  dts/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/dts/Makefile b/dts/Makefile
index 402dfe1..3c6bc18 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -36,7 +36,7 @@  $(error Your architecture does not have device tree support enabled. \
 Please define CONFIG_ARCH_DEVICE_TREE))
 
 # We preprocess the device tree file provide a useful define
-DTS_CPPFLAGS := -DARCH_CPU_DTS=\"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi\"
+DTS_CPPFLAGS := -undef -DARCH_CPU_DTS=\"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi\"
 
 all:	$(obj).depend $(LIB)