[Bug 257132] clang 12.0.1 fails to cross-compile kern_mbuf - amd64 host, i386 target

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 12 Jul 2021 18:36:20 +0000
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257132

--- Comment #3 from Dimitry Andric <dim_at_FreeBSD.org> ---
It turns out that this is due some code generated in $OBJDIR/offset.inc, during
an amd64 to i386 cross-build:

# 33 "/usr/src/sys/sys/kpilite.h"
# 1 "./offset.inc" 1
#ifndef _OFFSET_INC_
#define _OFFSET_INC_
#if 0 /* disabled by -frewrite-includes */
#if !defined(GENOFFSET) && (!defined(KLD_MODULE) || defined(KLD_TIED))
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 4 "./offset.inc"
struct thread_lite {
        u_char  pad_td_priority[0x27e - 0];
        u_char  td_priority;
        u_char  pad_td_critnest[0x30c - (0x27e + sizeof(u_char))];
        u_int   td_critnest;
        u_char  pad_td_owepreempt[0xb8 - (0x30c + sizeof(u_int))];
        u_char  td_owepreempt;
        u_char  pad_td_pinned[0xd8 - (0xb8 + sizeof(u_char))];
        int     td_pinned;
};
#endif

E.g. this defines tpad_td_owepreempt as a negative size:

27: error: array is too large (18446744073709551016 elements)
        u_char  pad_td_owepreempt[0xb8 - (0x30c + sizeof(u_int))];
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For some reason, generating this offset.inc file on a native i386 build results
in a very different struct:

struct thread_lite {
        u_char  pad_td_owepreempt[0xb8 - 0];
        u_char  td_owepreempt;
        u_char  pad_td_pinned[0xd8 - (0xb8 + sizeof(u_char))];
        int     td_pinned;
        u_char  pad_td_priority[0x27e - (0xd8 + sizeof(int))];
        u_char  td_priority;
        u_char  pad_td_critnest[0x30c - (0x27e + sizeof(u_char))];
        u_int   td_critnest;
};

-- 
You are receiving this mail because:
You are the assignee for the bug.
Received on Mon Jul 12 2021 - 18:36:20 UTC

Original text of this message