Re: [systemd-devel] [PATCH] configure: add -Wno-cast-align to CFLAGS

2013-07-16 Thread Lennart Poettering
On Mon, 15.07.13 19:55, Shawn (shawnland...@gmail.com) wrote:

> On Mon, Jul 15, 2013 at 7:26 PM, Lennart Poettering
> wrote:
> 
> > On Mon, 15.07.13 18:22, Shawn Landden (shawnland...@gmail.com) wrote:
> >
> > > these warnings on !x86 arches for good code are annoying, and
> > > there is no way to mark the offending code safe, so I guess we are
> > > just going to have to deal with the resulting problems as we
> > > come across them. Also, these warnings are present for armv6+armv7,
> > > when they moreso effect armv5.
> >
> > Hmm, can you elaborate on the particular places where this happens? I
> > have not been aware of any issues regarding this (not surprising since I
> > am a boring x86 user...)
> >
> Here is the full build log on armhf. I looked at the source for some of
> these about a year ago, after the udev merge. Basically, you allocate
> some type to 1-byte aligned, and then you cast it to a type that requries
> 4-bytes aligned, and on arches that do
> not support unaligned accesses, Bad Things (tm) happen. I ran systemd on
> armv5 for quite some time and never had problems, however, but fewer people
> are probably testing that now. (I don't have the hardware anymore)

Hmm, malloc() is guaranteed to pointers that are aligned to the maximum
alignment, so that part should safe.

I figure most of these gcc warnings are indeed non-issues, but I am
pretty sure we should individually fix or suppress them rather than just
turn off the warnings globally.

Usually issues like these can be fixed by replacing casts by unions, or
by decorating variables with alignment attributes. I am not sure what
the official way is to tell the compiler that a specific cast is
verified to be OK and that the compiler should shut up about it
though...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] configure: add -Wno-cast-align to CFLAGS

2013-07-15 Thread Zbigniew Jędrzejewski-Szmek
On Mon, Jul 15, 2013 at 07:55:57PM -0700, Shawn wrote:
> On Mon, Jul 15, 2013 at 7:26 PM, Lennart Poettering
> wrote:
> 
> > On Mon, 15.07.13 18:22, Shawn Landden (shawnland...@gmail.com) wrote:
> >
> > > these warnings on !x86 arches for good code are annoying, and
> > > there is no way to mark the offending code safe, so I guess we are
> > > just going to have to deal with the resulting problems as we
> > > come across them. Also, these warnings are present for armv6+armv7,
> > > when they moreso effect armv5.
> >
> > Hmm, can you elaborate on the particular places where this happens? I
> > have not been aware of any issues regarding this (not surprising since I
> > am a boring x86 user...)
> >
> Here is the full build log on armhf. I looked at the source for some of
> these about a year ago, after the udev merge. Basically, you allocate
> some type to 1-byte aligned, and then you cast it to a type that requries
> 4-bytes aligned, and on arches that do
> not support unaligned accesses, Bad Things (tm) happen. I ran systemd on
> armv5 for quite some time and never had problems, however, but fewer people
> are probably testing that now. (I don't have the hardware anymore)
malloc(3) says "functions return a pointer to the allocated memory
that is suitably aligned for any kind of variable", which means that
the beginning of the struct is maximally aligned, and then individual fields
are also aligned, so everything is OK. But when the pointer to the
field is cast to (char*) and back, the compiler thinks that the alignment
is random.

One gets the same stupid output with clang on amd64.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] configure: add -Wno-cast-align to CFLAGS

2013-07-15 Thread Lennart Poettering
On Mon, 15.07.13 18:22, Shawn Landden (shawnland...@gmail.com) wrote:

> these warnings on !x86 arches for good code are annoying, and
> there is no way to mark the offending code safe, so I guess we are
> just going to have to deal with the resulting problems as we
> come across them. Also, these warnings are present for armv6+armv7,
> when they moreso effect armv5.

Hmm, can you elaborate on the particular places where this happens? I
have not been aware of any issues regarding this (not surprising since I
am a boring x86 user...)

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] configure: add -Wno-cast-align to CFLAGS

2013-07-15 Thread Shawn Landden
these warnings on !x86 arches for good code are annoying, and
there is no way to mark the offending code safe, so I guess we are
just going to have to deal with the resulting problems as we
come across them. Also, these warnings are present for armv6+armv7,
when they moreso effect armv5.
---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index afbe8e9..709262e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,6 +129,7 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
 -Wno-unused-parameter \
 -Wno-missing-field-initializers \
 -Wno-unused-result \
+-Wno-cast-align \
 -Werror=overflow \
 -ffast-math \
 -fno-common \
-- 
1.8.3.2

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel