Android: enable noreturn and returns_nonnull attributes

Submitted by Rob Herring on Dec. 5, 2017, 2:21 a.m.

Details

Message ID 20171205022123.8790-1-robh@kernel.org
State New
Headers show
Series "Android: enable noreturn and returns_nonnull attributes" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Rob Herring Dec. 5, 2017, 2:21 a.m.
Commit 94ca8e04adf6 ("spirv: Add vtn_fail and vtn_assert helpers") broke
Android builds which have -Werror enabled with the following errors:

external/mesa3d/src/compiler/spirv/spirv_to_nir.c:272:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
external/mesa3d/src/compiler/spirv/spirv_to_nir.c:810:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
...

The problem is the noreturn attribute is not enabled and we to define
HAVE_FUNC_ATTRIBUTE_NORETURN.

Auditing src/util/macros.h, we're also missing
HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL, so add it too.

Fixes: 94ca8e04adf6 ("spirv: Add vtn_fail and vtn_assert helpers")
Cc: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 Android.common.mk | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/Android.common.mk b/Android.common.mk
index f080d996a7d9..f905c5e697d0 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -57,6 +57,8 @@  LOCAL_CFLAGS += \
 	-DHAVE_FUNC_ATTRIBUTE_FORMAT \
 	-DHAVE_FUNC_ATTRIBUTE_PACKED \
 	-DHAVE_FUNC_ATTRIBUTE_ALIAS \
+	-DHAVE_FUNC_ATTRIBUTE_NORETURN \
+	-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL \
 	-DHAVE___BUILTIN_CTZ \
 	-DHAVE___BUILTIN_POPCOUNT \
 	-DHAVE___BUILTIN_POPCOUNTLL \

Comments

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>

On Mon, Dec 4, 2017 at 6:21 PM, Rob Herring <robh@kernel.org> wrote:

> Commit 94ca8e04adf6 ("spirv: Add vtn_fail and vtn_assert helpers") broke
> Android builds which have -Werror enabled with the following errors:
>
> external/mesa3d/src/compiler/spirv/spirv_to_nir.c:272:1: error: control
> may reach end of non-void function [-Werror,-Wreturn-type]
> external/mesa3d/src/compiler/spirv/spirv_to_nir.c:810:1: error: control
> may reach end of non-void function [-Werror,-Wreturn-type]
> ...
>
> The problem is the noreturn attribute is not enabled and we to define
> HAVE_FUNC_ATTRIBUTE_NORETURN.
>
> Auditing src/util/macros.h, we're also missing
> HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL, so add it too.
>
> Fixes: 94ca8e04adf6 ("spirv: Add vtn_fail and vtn_assert helpers")
> Cc: Jason Ekstrand <jason.ekstrand@intel.com>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  Android.common.mk | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/Android.common.mk b/Android.common.mk
> index f080d996a7d9..f905c5e697d0 100644
> --- a/Android.common.mk
> +++ b/Android.common.mk
> @@ -57,6 +57,8 @@ LOCAL_CFLAGS += \
>         -DHAVE_FUNC_ATTRIBUTE_FORMAT \
>         -DHAVE_FUNC_ATTRIBUTE_PACKED \
>         -DHAVE_FUNC_ATTRIBUTE_ALIAS \
> +       -DHAVE_FUNC_ATTRIBUTE_NORETURN \
> +       -DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL \
>         -DHAVE___BUILTIN_CTZ \
>         -DHAVE___BUILTIN_POPCOUNT \
>         -DHAVE___BUILTIN_POPCOUNTLL \
> --
> 2.14.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
On 5 December 2017 at 02:21, Rob Herring <robh@kernel.org> wrote:
> Commit 94ca8e04adf6 ("spirv: Add vtn_fail and vtn_assert helpers") broke
> Android builds which have -Werror enabled with the following errors:
>
> external/mesa3d/src/compiler/spirv/spirv_to_nir.c:272:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
> external/mesa3d/src/compiler/spirv/spirv_to_nir.c:810:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
> ...
>
> The problem is the noreturn attribute is not enabled and we to define
> HAVE_FUNC_ATTRIBUTE_NORETURN.
>
> Auditing src/util/macros.h, we're also missing
> HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL, so add it too.
>
> Fixes: 94ca8e04adf6 ("spirv: Add vtn_fail and vtn_assert helpers")
> Cc: Jason Ekstrand <jason.ekstrand@intel.com>
> Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>

The following shows the macros not set on Android. Feel free to check
if they're supported and toggle them on.

$ for i in `git grep "if.*def.*HAVE_FUNC_ATTRIBUTE_" origin/master  --
 | grep -o "HAVE_FUNC_[A-Z_]*" | sort -u`; do git grep $i
origin/master  | grep
-qi android || echo missing $i; done
missing HAVE_FUNC_ATTRIBUTE_CONST
missing HAVE_FUNC_ATTRIBUTE_MALLOC
missing HAVE_FUNC_ATTRIBUTE_NORETURN
missing HAVE_FUNC_ATTRIBUTE_PURE
missing HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL
missing HAVE_FUNC_ATTRIBUTE_VISIBILITY
missing HAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT
missing HAVE_FUNC_ATTRIBUTE_WEAK

-Emil
On Tue, Dec 5, 2017 at 5:56 AM, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> On 5 December 2017 at 02:21, Rob Herring <robh@kernel.org> wrote:
>> Commit 94ca8e04adf6 ("spirv: Add vtn_fail and vtn_assert helpers") broke
>> Android builds which have -Werror enabled with the following errors:
>>
>> external/mesa3d/src/compiler/spirv/spirv_to_nir.c:272:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
>> external/mesa3d/src/compiler/spirv/spirv_to_nir.c:810:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
>> ...
>>
>> The problem is the noreturn attribute is not enabled and we to define
>> HAVE_FUNC_ATTRIBUTE_NORETURN.
>>
>> Auditing src/util/macros.h, we're also missing
>> HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL, so add it too.
>>
>> Fixes: 94ca8e04adf6 ("spirv: Add vtn_fail and vtn_assert helpers")
>> Cc: Jason Ekstrand <jason.ekstrand@intel.com>
>> Signed-off-by: Rob Herring <robh@kernel.org>
> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
>
> The following shows the macros not set on Android. Feel free to check
> if they're supported and toggle them on.

I did this, but did another check of it.

> $ for i in `git grep "if.*def.*HAVE_FUNC_ATTRIBUTE_" origin/master  --
>  | grep -o "HAVE_FUNC_[A-Z_]*" | sort -u`; do git grep $i
> origin/master  | grep
> -qi android || echo missing $i; done
> missing HAVE_FUNC_ATTRIBUTE_CONST
> missing HAVE_FUNC_ATTRIBUTE_MALLOC
> missing HAVE_FUNC_ATTRIBUTE_NORETURN
> missing HAVE_FUNC_ATTRIBUTE_PURE
> missing HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL
> missing HAVE_FUNC_ATTRIBUTE_VISIBILITY
> missing HAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT

At least according to documentation for clang, this is the only other
one that is supported. So I turned it on too and pushed the commit.

> missing HAVE_FUNC_ATTRIBUTE_WEAK
>
> -Emil