[Mesa-dev] [PATCH] mesa: Remove C++11 narrowing warnings
Eric Anholt
eric at anholt.net
Tue Aug 21 22:33:32 PDT 2012
Chad Versace <chad.versace at linux.intel.com> writes:
> On 08/20/2012 02:17 PM, Matt Turner wrote:
>> On Mon, Aug 20, 2012 at 1:52 PM, Chad Versace
>> <chad.versace at linux.intel.com> wrote:
>>> Add -Wno-narrowing to CXXFLAGS if gcc supports it.
>>>
>>> This removes warnings of the form
>>> warning: narrowing conversion of X from 'int' to 'float' inside { } is
>>> ill-formed in C++11 [-Wnarrowing]
>>> in ff_fragment_shader.cpp and gen6_blorp.cpp. When building i965,
>>> I observed no other difference in the build output.
>>>
>>> CC: Kenneth Graunke <kenneth at whitecape.org>
>>> CC: Matthew Turner <matts88 at gmail.com>
>>> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
>>> ---
>>> configure.ac | 13 ++++++++++++-
>>> 1 file changed, 12 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/configure.ac b/configure.ac
>>> index fcfe085..89b8fe7 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -219,7 +219,17 @@ if test "x$GXX" = xyes; then
>>> [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
>>> AC_LANG_POP([C++])
>>>
>>> - # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
>>> + # Enable -Wno-narrowing if using a gcc that supports it.
>>> + save_CXXFLAGS="$CXXFLAGS"
>>> + WNO_NARROWING_CXXFLAGS="-Wno-narrowing"
>>> + AC_MSG_CHECKING([whether $CXX supports $WNO_NARROWING_CXXFLAGS])
>>> + CXXFLAGS="$CXXFLAGS $WNO_NARROWING_CXXFLAGS"
>>> + AC_LANG_PUSH([C++])
>>> + AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
>>> + [WNO_NARROWING_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
>>> + AC_LANG_POP([C++])
>>> +
>>> + # Restore CXXFLAGS. The flags probed above are added where needed.
>>> CXXFLAGS=$save_CXXFLAGS
>>>
>>> # Work around aliasing bugs - developers should comment this out
>>> @@ -244,6 +254,7 @@ esac
>>>
>>> AC_SUBST([VISIBILITY_CFLAGS])
>>> AC_SUBST([VISIBILITY_CXXFLAGS])
>>> +AC_SUBST([WNO_NARROWING_CXXFLAGS])
>>>
>>> dnl
>>> dnl Hacks to enable 32 or 64 bit build
>>> --
>>> 1.7.11.4
>>
>> I can't see how the VISIBILITY_CFLAGS are getting added to the build.
>> It looks like we somehow lost their uses -- which means the narrowing
>> flag also isn't being added to the build. To do this you either add it
>> to the Makefile.am's (via AM_CXXFLAGS) or directly to CXXFLAGS.
>
> I also don't see how the VISIBILITY_CFLAGS are getting added, but that's just
> due to me not understanding autoconf at all. However, I've verified by building
> with `env V=1 make` that -fivisibility=hidden and -Wno-narrowing do appear in
> the gcc invocations.
>
>> I think we're doing the right thing here and setting the flags in
>> their own variables (as opposed to appending to C(XX)FLAGS). The
>> automake manual recommends this:
>> http://www.gnu.org/software/automake/manual/automake.html#User-Variables
Are you sure you didn't just happen to notice an fvisibility=hidden in
one of the few places that it's happening due to configs/current being
included? The failure to include it appears to be a major oversight in
the automake conversion, one that makes the whole separate libdricore
build pointless!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120821/adb188a6/attachment.pgp>
More information about the mesa-dev
mailing list