Re: Preliminary results - was: Re: Question on BIGGEST_ALIGNMENT in GCC on NetBSD/m68k
"Arnd Bergmann" <[email protected]> Wed, 07 Jan 2026 09:19:59 +0100
| Newsgroups | gmane.linux.ports.m68k,gmane.os.netbsd.ports.m68k,gmane.linux.debian.ports.68k |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jan 6, 2026, at 20:31, Geert Uytterhoeven wrote: > On Tue, 6 Jan 2026 at 16:38, Arnd Bergmann <[email protected]> wrote: >> On Tue, Jan 6, 2026, at 14:40, John Paul Adrian Glaubitz wrote: >> > On Tue, 2026-01-06 at 14:34 +0100, Kolbj=C3=B8rn Barmen wrote: >> The diffstat is >> >> 407 files changed, 2433 insertions(+), 754 deletions(-) >> >> and I think this touches around 1500 structures, though >> most files only have a single one. > > Thanks, this seems to work fine for atari_defconfig, and generates > the exact same code as before. Ok, good. The more interesting bit then is what happens when you actually turn on -malign-int for the kernel itself. There are many drivers that change behavior, but mostly this is going to be a fix rather than a regression. As far as I can tell, this change is all that should be needed for atari: diff --git a/arch/m68k/include/asm/atarihw.h b/arch/m68k/include/asm/ata= rihw.h index 9a038a3edb83..467005598fc6 100644 --- a/arch/m68k/include/asm/atarihw.h +++ b/arch/m68k/include/asm/atarihw.h @@ -334,7 +334,7 @@ struct TT_DMA { u_char dma_cnt_lmd; u_char char_dummy7; u_char dma_cnt_lo; - u_long dma_restdata; + u_long dma_restdata __packed; u_short dma_ctrl; }; #define tt_scsi_dma ((*(volatile struct TT_DMA *)TT_SCSI_DMA_BAS)) @@ -417,13 +417,13 @@ struct BLITTER u_short halftone[16]; u_short src_x_inc; u_short src_y_inc; - u_long src_address; + u_long src_address __packed; u_short endmask1; u_short endmask2; u_short endmask3; u_short dst_x_inc; u_short dst_y_inc; - u_long dst_address; + u_long dst_address __packed; u_short wd_per_line; u_short ln_per_bb; u_short hlf_op_reg; diff --git a/arch/m68k/include/asm/openprom.h b/arch/m68k/include/asm/op= enprom.h index 6456ba40a946..741e83d76ff2 100644 --- a/arch/m68k/include/asm/openprom.h +++ b/arch/m68k/include/asm/openprom.h @@ -78,7 +78,7 @@ struct linux_arguments_v0 { int dev_partition; char *kernel_file_name; void *aieee1; /* XXX */ -}; +} __packed; =20 /* V2 and up boot things. */ struct linux_bootargs_v2 { > However, m68k allmodconfig fails with: > > In file included from tools/include/nolibc/nolibc.h:97, > from tools/include/nolibc/stddef.h:8, > from ./usr/include/scsi/fc/fc_els.h:14, > from <command-line>: > tools/include/nolibc/types.h:120:1: error: padding struct size to > alignment boundary with 1 bytes [-Werror=3Dpadded] > 120 | }; > | ^ > cc1: all warnings being treated as errors > make[4]: *** [usr/include/Makefile:85: > usr/include/scsi/fc/fc_els.hdrtest] Error 1 > > This is due to struct linux_dirent64 in tools/include/nolibc/types.h. > The same definition in include/linux/dirent.h doesn't cause issues. I left out the nolibc changes, as Thomas Wei=C3=9Fschuh has already posted patches to remove the dependency entirely. This is what I use for testing with nolibc at the moment: diff --git a/tools/include/nolibc/netinet/in.h b/tools/include/nolibc/ne= tinet/in.h new file mode 100644 index 000000000000..a6a1b19f5242 --- /dev/null +++ b/tools/include/nolibc/netinet/in.h @@ -0,0 +1 @@ +#include <linux/in.h> diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h index 392f4dd94158..3fe83a4f7a2d 100644 --- a/tools/include/nolibc/std.h +++ b/tools/include/nolibc/std.h @@ -25,7 +25,7 @@ typedef unsigned int mode_t; typedef signed int pid_t; typedef unsigned int uid_t; typedef unsigned int gid_t; -typedef unsigned long nlink_t; +typedef unsigned int nlink_t; typedef int64_t off_t; typedef signed long blksize_t; typedef signed long blkcnt_t; diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib= .h index f184e108ed0a..497cbe1b5dba 100644 --- a/tools/include/nolibc/stdlib.h +++ b/tools/include/nolibc/stdlib.h @@ -19,6 +19,7 @@ =20 struct nolibc_heap { size_t len; + char __pad[__alignof__(struct {} __attribute__((__aligned__))) - __ali= gnof__(size_t)]; char user_p[] __attribute__((__aligned__)); }; =20 diff --git a/tools/include/nolibc/sys/socket.h b/tools/include/nolibc/sy= s/socket.h new file mode 100644 index 000000000000..1d97008308ea --- /dev/null +++ b/tools/include/nolibc/sys/socket.h @@ -0,0 +1,26 @@ +#include "../nolibc.h" + +#ifndef _NOLIBC_SYS_SOCKET_H +#define _NOLIBC_SYS_SOCKET_H + +#include <linux/socket.h> + +typedef __kernel_sa_family_t sa_family_t; + +/* + * 1003.1g requires sa_family_t and that sa_data is char. + */ + +struct sockaddr { + sa_family_t sa_family; /* address family, AF_xxx */ +#ifdef __clang__ + char sa_data[14]; /* prevent -Wgnu-variable-sized-type-not-at-end war= ning */ +#else + union { + char sa_data_min[14]; /* Minimum 14 bytes of protocol address */ + __DECLARE_FLEX_ARRAY(char, sa_data); + }; +#endif +}; + +#endif diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 470a5f77bc0f..a3193424e818 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -10,6 +10,8 @@ #ifndef _NOLIBC_TYPES_H #define _NOLIBC_TYPES_H =20 +#include <linux/types.h> + #include "std.h" #include <linux/mman.h> #include <linux/stat.h> @@ -116,7 +118,10 @@ struct linux_dirent64 { int64_t d_off; unsigned short d_reclen; unsigned char d_type; - char d_name[]; + union { + char __pad[5]; + __DECLARE_FLEX_ARRAY(char, d_name); + }; }; =20 /* The format of the struct as returned by the libc to the application,= which @@ -124,8 +129,8 @@ struct linux_dirent64 { */ struct stat { dev_t st_dev; /* ID of device containing file */ - ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ + ino_t st_ino; /* inode number */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ >> --- a/usr/include/Makefile >> +++ b/usr/include/Makefile >> @@ -6,7 +6,10 @@ >> # >> # -std=3Dc90 (equivalent to -ansi) catches the violation of those. >> # We cannot go as far as adding -Wpedantic since it emits too many w= arnings. >> -UAPI_CFLAGS :=3D -std=3Dc90 -Werror=3Dimplicit-function-declaration >> +UAPI_CFLAGS :=3D -std=3Dc90 -Werror=3Dimplicit-function-declaration = -Werror=3Dpadded >> + >> +# when cross-compiling with a minimal toolchain, use nolibc headers >> +UAPI_CFLAGS +=3D -I$(srctree)/tools/include/nolibc/ > > Without the rest of the patch, this line on its own is already causing > various allmodconfig failures for me: > > In file included from /usr/m68k-linux-gnu/include/sys/socket.h:26, > from usr/include/linux/if.h:28, > from ./usr/include/linux/netfilter_bridge/ebtable= s.h:17, > from <command-line>: > /usr/m68k-linux-gnu/include/bits/types/struct_iovec.h:26:8: error: > redefinition of =E2=80=98struct iovec=E2=80=99 This should also be addressed by either my nolibc change or Thomas' uapi cleanup. > Dropping this line made the linux_dirent64 issue go away, and revealed > a few more missing pieces, so here is a gmail-whitespace-damaged patch: > > diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h > index 70eece6aa30e9306..4c10f5402d77757d 100644 > --- a/include/uapi/linux/xfrm.h > +++ b/include/uapi/linux/xfrm.h > @@ -27,7 +27,9 @@ struct xfrm_id { > xfrm_address_t daddr; > __be32 spi; > __u8 proto; > -}; > + __uapi_arch_pad8; > + __uapi_arch_pad16; > +} __uapi_arch_align; > > struct xfrm_sec_ctx { > __u8 ctx_doi; > @@ -255,6 +257,7 @@ struct xfrm_user_tmpl { > __u8 mode; > __u8 share; > __u8 optional; > + __uapi_arch_pad8; > __u32 aalgos; > __u32 ealgos; > __u32 calgos; > Right, I missed this one because I had another patch in my test tree that did a similar change but wasn't part of the padding series.: https://lore.kernel.org/all/[email protected]/ Arnd