Skip to contentSkip to conversation

Clang tools build

DISCUSSION Andrew Cooper 2 participants 3 messages Feb 12, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

Now that Clang 3.5 can build the hypervisor, I was just preparing a patch to README, and encountered this:

In file included from xc_altp2m.c:23:
In file included from ./xc_private.h:35:
In file included from ./include/xenctrl.h:53:
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:203:47:
error: 'aligned' attribute ignored when parsing type [-Werror,-Wignored-attributes]

    __align8__ uint64_t evtchn_pending[sizeof(__align8__ uint64_t) * 8];
                                              ^~~~~~~~~~
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:13:36:
note: expanded from macro '__align8__'
# define __align8__ __attribute__((aligned (8)))
                                   ^~~~~~~~~~~
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:204:44:
error: 'aligned' attribute ignored when parsing type
[-Werror,-Wignored-attributes]
    __align8__ uint64_t evtchn_mask[sizeof(__align8__ uint64_t) * 8];
                                           ^~~~~~~~~~
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:13:36:
note: expanded from macro '__align8__'
# define __align8__ __attribute__((aligned (8)))
                                   ^~~~~~~~~~~
2 errors generated.

In this case, Clang is complaining that the alignment attribute is wrong for uint64_t. This is correct for 64bit compilations, but wrong for 32bit. On the other hand, I am not sure whether it is sensible to do a blanket disable of -Wignored-attributes.

Thoughts?

~Andrew

#1 lore raw
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 12.02.16 at 16:25, <[email protected]> wrote:

Hello,

Now that Clang 3.5 can build the hypervisor, I was just preparing a patch to README, and encountered this:

In file included from xc_altp2m.c:23:
In file included from ./xc_private.h:35:
In file included from ./include/xenctrl.h:53:
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:203:47:
error: 'aligned' attribute ignored when parsing type [-Werror,-Wignored-attributes]

    __align8__ uint64_t evtchn_pending[sizeof(__align8__ uint64_t) * 8];
                                              ^~~~~~~~~~
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:13:36:
note: expanded from macro '__align8__'
# define __align8__ __attribute__((aligned (8)))
                                   ^~~~~~~~~~~
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:204:44:
error: 'aligned' attribute ignored when parsing type
[-Werror,-Wignored-attributes]
    __align8__ uint64_t evtchn_mask[sizeof(__align8__ uint64_t) * 8];
                                           ^~~~~~~~~~
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:13:36:
note: expanded from macro '__align8__'
# define __align8__ __attribute__((aligned (8)))
                                   ^~~~~~~~~~~
2 errors generated.
Quoted 3 lines

In this case, Clang is complaining that the alignment attribute is wrong for uint64_t. This is correct for 64bit compilations, but wrong for 32bit.

If it only complains about it when used as operand to sizeof() I think it's correctly saying so.

Quoted 2 lines

On the other hand, I am not sure whether it is sensible to do a
blanket disable of -Wignored-attributes.

I agree it's not ideal, but I see no alternative, and I'm not sure there are many cases where a legitimately ignored attribute would be a problem (leaving as a potential issue only cases where the compiler wrongly ignores one).

Jan

#2 lore raw
Quoted 29 lines · Jan Beulich
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 12.02.16 at 16:25, <[email protected]> wrote:

Hello,

Now that Clang 3.5 can build the hypervisor, I was just preparing a patch to README, and encountered this:

In file included from xc_altp2m.c:23:
In file included from ./xc_private.h:35:
In file included from ./include/xenctrl.h:53:
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:203:47:
error: 'aligned' attribute ignored when parsing type [-Werror,-Wignored-attributes]

    __align8__ uint64_t evtchn_pending[sizeof(__align8__ uint64_t) * 8];
                                              ^~~~~~~~~~
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:13:36:
note: expanded from macro '__align8__'
# define __align8__ __attribute__((aligned (8)))
                                   ^~~~~~~~~~~
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:204:44:
error: 'aligned' attribute ignored when parsing type
[-Werror,-Wignored-attributes]
    __align8__ uint64_t evtchn_mask[sizeof(__align8__ uint64_t) * 8];
                                           ^~~~~~~~~~
/local/xen.git/tools/libxc/../../tools/include/xen/foreign/x86_64.h:13:36:
note: expanded from macro '__align8__'
# define __align8__ __attribute__((aligned (8)))
                                   ^~~~~~~~~~~
2 errors generated.
Quoted 5 lines
Quoted 3 lines

In this case, Clang is complaining that the alignment attribute is wrong for uint64_t. This is correct for 64bit compilations, but wrong for 32bit.

If it only complains about it when used as operand to sizeof() I think it's correctly saying so.

Turns out that a fix^W gross hack of

(quoted diff) +0 -0

b/tools/include/xen-foreign/Makefile
index 80a446a..d9f68cd 100644

tools/include/xen-foreign/Makefile +0 -0
@@ -35,6 +35,7 @@ x86_32.h: mkheader.py structs.py

$(ROOT)/arch-x86/xen-x86_32.h $(ROOT)/arch-x86/

x86_64.h: mkheader.py structs.py $(ROOT)/arch-x86/xen-x86_64.h
$(ROOT)/arch-x86/xen.h $(ROOT)/xen.h

        $(PYTHON) $< $* $@ $(filter %.h,$^)

+ sed 's/(__align8__ uint64_t)/(uint64_t)/g' -i $@

checker.c: mkchecker.py structs.py

        $(PYTHON) $< $@ $(architectures)

Does indeed fix the build. There are problems with sizeof(), and later, an explicit (__align8__ uint64_t) cast.

Unfortunately, mkheader is doing dumb translation, and I don't fancy teaching it how to parse C. I will see if there is something neater I can do as a solution.

Also, further real issues have surfaces, so I will have to submit a series cleaning up the tools/ compile with Clang.

~Andrew