[systemd-devel] Build warnings for ARM due to -Wcast-align
Daniel P. Berrange
berrange at redhat.com
Thu Feb 20 08:28:36 PST 2014
On Thu, Feb 20, 2014 at 05:21:22PM +0100, Lennart Poettering wrote:
> On Thu, 20.02.14 17:03, Daniel Mack (daniel at zonque.org) wrote:
>
> > Hi,
> >
> > When cross-compiling the current git HEAD for ARM using gcc 4.8.2, I see
> > ~160 warnings similar to this one:
> >
> > src/core/unit.c: In function 'unit_get_exec_runtime':
> > src/core/unit.c:2851:17: warning: cast increases required alignment of
> > target type [-Wcast-align]
> > return *(ExecRuntime**) ((uint8_t*) u + offset);
> > ^
> >
> > The full build log is here:
> >
> > http://paste.fedoraproject.org/78944/92912005
> >
> > Unaligned memory access is indeed unsupported by some older instruction
> > cores. The kernel can fix up in situations where such unaligned access
> > occurs, but that's of course expensive and slow.
> >
> > However, systemd does not actually do unaligned memory access at runtime
> > (at least I haven't seen any when booting up PXA3xx hardware). The
> > warning is simply about the type of pointer arithmetic that casts to and
> > from uint8_t*.
> >
> > And because it's practically impossible to fix the things the compiler
> > complains about here anyway, I propose removing -Wcast-align from the
> > CFLAGS in configure.ac.
> >
> > Any opinions?
>
> I am fine with that. I am personally only running things on x86, so it
> never showed up for me. The usual solution for cast issues is to use
> some union-based type conversion, but in the case above this is not
> really nicely possible. Hence, let's drop it, unless somebody has a
> better solution...
I think cast align warnings are fairly useful since many things it
can show turn out to be genuine bugs, so not entirely desirable to
disable them altogether. In libvirt we just mark the few cases which
are false positives with a pragma
#define VIR_WARNINGS_NO_CAST_ALIGN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wcast-align\"")
#define VIR_WARNINGS_RESET \
_Pragma ("GCC diagnostic pop")
And then just mark it thus
VIR_WARNINGS_NO_CAST_ALIGN
...code with false positive
VIR_WARNINGS_RESET
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the systemd-devel
mailing list