Skip to contentSkip to conversation

perf tools: Kill off -Wcast-align

PATCH In review Paul Mundt 4 participants 9 messages Oct 26, 2009 – Oct 28, 2009 perf events

lore
Share & tools
lore

Paul Mundt

author
#0 lore raw

PATCH 1/1 perf tools: Kill off -Wcast-align

The present use of -Wcast-align causes the build to blow up on SH due to generating a "cast increases required alignment of target type" error on each invocation of list_for_each_entry().

It seems that this was previously reported and killed off in the ia64 support patch, but nothing seems to have happened with that. Presumably the same problem still remains there, too.

---

 tools/perf/Makefile |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/Makefile +1 -2
index 88c51b8..39a84be 100644
@@ -177,8 +177,7 @@ endif
 # Include saner warnings here, which can catch bugs:
 #
 
-EXTRA_WARNINGS := -Wcast-align
-EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat
+EXTRA_WARNINGS := -Wformat
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
#1 lore raw
Quoted 9 lines · Paul Mundt

The present use of -Wcast-align causes the build to blow up on SH due to generating a "cast increases required alignment of target type" error on each invocation of list_for_each_entry().

It seems that this was previously reported and killed off in the ia64 support patch, but nothing seems to have happened with that. Presumably the same problem still remains there, too.

Is this a GCC bug producing false positive warnings? The GCC manpage says:

-Wcast-align
Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a "char *" is cast to an "int *" on machines where integers can only be accessed at two- or four-byte boundaries.

Which looks moderately useful - if it works.

Ingo

author
#2 lore raw
Quoted 16 lines · Ingo Molnar
Quoted 9 lines · Paul Mundt

The present use of -Wcast-align causes the build to blow up on SH due to generating a "cast increases required alignment of target type" error on each invocation of list_for_each_entry().

It seems that this was previously reported and killed off in the ia64 support patch, but nothing seems to have happened with that. Presumably the same problem still remains there, too.

Is this a GCC bug producing false positive warnings? The GCC manpage says:

Quoted 8 lines

-Wcast-align
Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a "char *" is cast to an "int *" on machines where integers can only be accessed at two- or four-byte boundaries.

Which looks moderately useful - if it works.

Well, both ia64 and sh have hit this in the current compilers, and it doesn't seem to pose any code generation issues. In the areas where it is generated it seems to relate to 64-bit data types in the data structures, which in itself doesn't seem inherently problematic.

I'll submit a bug report to the GCC folks, but for the time being given that multiple architectures are hitting this and it doesn't seem to be causing any issues, it would be better to have this flag dropped.

#3 lore raw
Quoted 9 lines · Paul Mundt
Quoted 9 lines
Quoted 9 lines

The present use of -Wcast-align causes the build to blow up on SH due to generating a "cast increases required alignment of target type" error on each invocation of list_for_each_entry().

It seems that this was previously reported and killed off in the ia64 support patch, but nothing seems to have happened with that. Presumably the same problem still remains there, too.

Quoted 10 lines · Ingo Molnar
Quoted 10 lines

Is this a GCC bug producing false positive warnings? The GCC manpage says:

       -Wcast-align
           Warn whenever a pointer is cast such that the required alignment of the target is increased.  For example, warn if a "char *" is cast to an "int *" on machines where integers can only be accessed at two- or four-byte boundaries.

Which looks moderately useful - if it works.

Quoted 8 lines · Paul Mundt

Well, both ia64 and sh have hit this in the current compilers, and it doesn't seem to pose any code generation issues. In the areas where it is generated it seems to relate to 64-bit data types in the data structures, which in itself doesn't seem inherently problematic.

I'll submit a bug report to the GCC folks, but for the time being given that multiple architectures are hitting this and it doesn't seem to be causing any issues, it would be better to have this flag dropped.

Can we disable the flag for affected architectures but keep it enabled for x86?

#4 lore raw
Quoted 31 lines · Pekka Enberg
Quoted 9 lines · Paul Mundt
Quoted 9 lines
Quoted 9 lines

The present use of -Wcast-align causes the build to blow up on SH due to generating a "cast increases required alignment of target type" error on each invocation of list_for_each_entry().

It seems that this was previously reported and killed off in the ia64 support patch, but nothing seems to have happened with that. Presumably the same problem still remains there, too.

Quoted 10 lines · Ingo Molnar
Quoted 10 lines

Is this a GCC bug producing false positive warnings? The GCC manpage says:

       -Wcast-align
           Warn whenever a pointer is cast such that the required alignment of the target is increased.  For example, warn if a "char *" is cast to an "int *" on machines where integers can only be accessed at two- or four-byte boundaries.

Which looks moderately useful - if it works.

Quoted 6 lines · Paul Mundt

Well, both ia64 and sh have hit this in the current compilers, and it doesn't seem to pose any code generation issues. In the areas where it is generated it seems to relate to 64-bit data types in the data structures, which in itself doesn't seem inherently problematic.

Quoted 7 lines
Quoted 4 lines

I'll submit a bug report to the GCC folks, but for the time being given that multiple architectures are hitting this and it doesn't seem to be causing any issues, it would be better to have this flag dropped.

Can we disable the flag for affected architectures but keep it enabled for x86?

For now i've applied Paul's fix - x86 doesnt have such type restrictions and i dont remember this warning having flagged some real data structure alignment bug anywhere.

Ingo

#5 lore raw
In reply to Paul Mundt

From: Paul Mundt <[email protected]>
Date: Mon, 26 Oct 2009 18:47:30 +0900

Quoted 23 lines · Ingo Molnar
Quoted 22 lines · Paul Mundt
Quoted 10 lines

The present use of -Wcast-align causes the build to blow up on SH due to generating a "cast increases required alignment of target type" error on each invocation of list_for_each_entry().

It seems that this was previously reported and killed off in the ia64 support patch, but nothing seems to have happened with that. Presumably the same problem still remains there, too.

Is this a GCC bug producing false positive warnings? The GCC manpage says:

-Wcast-align
Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a "char *" is cast to an "int *" on machines where integers can only be accessed at two- or four-byte boundaries.

Quoted 6 lines
Quoted 2 lines

Which looks moderately useful - if it works.

Well, both ia64 and sh have hit this in the current compilers, and it doesn't seem to pose any code generation issues. In the areas where it is generated it seems to relate to 64-bit data types in the data structures, which in itself doesn't seem inherently problematic.

sparc64 hits this too when building 32-bit perf binary, the first thing I do after a pull is remove this warning option from the Makefile :-)

#6 lore raw
Quoted 28 lines · David Miller

From: Paul Mundt <[email protected]>
Date: Mon, 26 Oct 2009 18:47:30 +0900

Quoted 25 lines · Ingo Molnar
Quoted 24 lines · Paul Mundt
Quoted 10 lines

The present use of -Wcast-align causes the build to blow up on SH due to generating a "cast increases required alignment of target type" error on each invocation of list_for_each_entry().

It seems that this was previously reported and killed off in the ia64 support patch, but nothing seems to have happened with that. Presumably the same problem still remains there, too.

Is this a GCC bug producing false positive warnings? The GCC manpage says:

-Wcast-align
Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a "char *" is cast to an "int *" on machines where integers can only be accessed at two- or four-byte boundaries.

Which looks moderately useful - if it works.

Quoted 8 lines
Quoted 4 lines

Well, both ia64 and sh have hit this in the current compilers, and it doesn't seem to pose any code generation issues. In the areas where it is generated it seems to relate to 64-bit data types in the data structures, which in itself doesn't seem inherently problematic.

sparc64 hits this too when building 32-bit perf binary, the first thing I do after a pull is remove this warning option from the Makefile :-)

Generally if you run into such issues in Sparc let us know so we can fix it :-)

Paul's fix is queued up for Linus.

Ingo

#7 lore raw

From: Ingo Molnar <[email protected]>
Date: Tue, 27 Oct 2009 14:50:25 +0100

Quoted 2 lines

Generally if you run into such issues in Sparc let us know so we can fix it :-)

Sorry, I wanted to do a thorough analysis to make sure I understood why it was warning, but I was too busy to do so.

In the end the issue is the kernel list.h macros like list_entry(), and it would similarly trigger for things like container_of().

If you have a pointer to a structure with objects other than "long double" then cast it to a pointer to a structure that does have a "long double" in it, this increases the alignment of the type (from 8 to 16 bytes on sparc 32-bit).

#8 lore raw

[tip:perf/urgent] perf tools: Remove -Wcast-align

In reply to Paul Mundt
Commit-ID:  ec29b8d2af01912bb79adda8aeab4293539f29ac
Gitweb:     http://git.kernel.org/tip/ec29b8d2af01912bb79adda8aeab4293539f29ac
Author:     Paul Mundt <[email protected]>
AuthorDate: Mon, 26 Oct 2009 14:40:01 +0900
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 26 Oct 2009 09:43:06 +0100

perf tools: Remove -Wcast-align

The present use of -Wcast-align causes the build to blow up on SH due to generating a "cast increases required alignment of target type" error on each invocation of list_for_each_entry().

It seems that this was previously reported and killed off in the ia64 support patch, but nothing seems to have happened with that. Presumably the same problem still remains there, too.

LKML-Reference: <[email protected]>

---
 tools/perf/Makefile |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
tools/perf/Makefile +1 -2
index 46e877b..7e190d5 100644
@@ -177,8 +177,7 @@ endif
 # Include saner warnings here, which can catch bugs:
 #
 
-EXTRA_WARNINGS := -Wcast-align
-EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat
+EXTRA_WARNINGS := -Wformat
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k
 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow