Thread: [HACKERS] 10beta1/m68k: static assertion failed: "MAXALIGN too small to fitint32"
[HACKERS] 10beta1/m68k: static assertion failed: "MAXALIGN too small to fitint32"
From
Christoph Berg
Date:
Not sure if a lot of people still care about m68k, but it's still one of the unofficial Debian ports (it used to be the first non-x86 port done decades ago): gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security-fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=.-fstack-protector-strong -Wformat -Werror=format-security -I/usr/include/mit-krb5 -no-pie-I../../../../src/include -I/<<PKGBUILDDIR>>/build/../src/include -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/tcl8.6 -c -o slab.o /<<PKGBUILDDIR>>/build/../src/backend/utils/mmgr/slab.c In file included from /<<PKGBUILDDIR>>/build/../src/include/postgres.h:47:0, from /<<PKGBUILDDIR>>/build/../src/backend/utils/mmgr/slab.c:53: /<<PKGBUILDDIR>>/build/../src/backend/utils/mmgr/slab.c: In function 'SlabContextCreate': /<<PKGBUILDDIR>>/build/../src/include/c.h:753:7: error: static assertion failed: "MAXALIGN too small to fit int32" do { _Static_assert(condition,errmessage); } while(0) ^ /<<PKGBUILDDIR>>/build/../src/backend/utils/mmgr/slab.c:198:2: note: in expansion of macro 'StaticAssertStmt' StaticAssertStmt(MAXIMUM_ALIGNOF>= sizeof(int), ^~~~~~~~~~~~~~~~ <builtin>: recipe for target 'slab.o' failed make[5]: *** [slab.o] Error 1 The code there is: /** SlabContextCreate* Create a new Slab context.** parent: parent context, or NULL if top-level context* name: nameof context (for debugging --- string will be copied)* blockSize: allocation block size* chunkSize: allocation chunk size**The chunkSize may not exceed:* MAXALIGN_DOWN(SIZE_MAX) - MAXALIGN(sizeof(SlabBlock)) - SLAB_CHUNKHDRSZ**/ MemoryContext SlabContextCreate(MemoryContext parent, const char *name, Size blockSize, Size chunkSize) { int chunksPerBlock; Size fullChunkSize; Size freelistSize; SlabContext *slab; StaticAssertStmt(offsetof(SlabChunk, slab) +sizeof(MemoryContext) == MAXALIGN(sizeof(SlabChunk)), "padding calculation in SlabChunk is wrong"); /* otherwise the linked list inside freed chunk isn't guaranteed to fit */ StaticAssertStmt(MAXIMUM_ALIGNOF >= sizeof(int), "MAXALIGN too small to fit int32"); /* chunk, including SLAB header (both addresses nicely aligned) */ fullChunkSize = MAXALIGN(sizeof(SlabChunk) + MAXALIGN(chunkSize)); I don't have the pg_config.h file at hand, but the 9.6 version has this: /* The normal alignment of `double', in bytes. */ #define ALIGNOF_DOUBLE 2 /* The normal alignment of `int', in bytes. */ #define ALIGNOF_INT 2 /* The normal alignment of `long', in bytes. */ #define ALIGNOF_LONG 2 /* The normal alignment of `long long int', in bytes. */ #define ALIGNOF_LONG_LONG_INT 2 /* The normal alignment of `short', in bytes. */ #define ALIGNOF_SHORT 2 /* Define as the maximum alignment requirement of any C data type. */ #define MAXIMUM_ALIGNOF 2 I don't think anyone is actually going to run a PG server on m68k, but the same source package is building libpq5, which is not dispensable. Christoph
Re: [HACKERS] 10beta1/m68k: static assertion failed: "MAXALIGN toosmall to fit int32"
From
Heikki Linnakangas
Date:
On 05/17/2017 10:39 PM, Christoph Berg wrote: > Not sure if a lot of people still care about m68k, but it's still one > of the unofficial Debian ports (it used to be the first non-x86 port > done decades ago): > > gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute-Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=.-fstack-protector-strong -Wformat -Werror=format-security -I/usr/include/mit-krb5 -no-pie-I../../../../src/include -I/<<PKGBUILDDIR>>/build/../src/include -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/tcl8.6 -c -o slab.o /<<PKGBUILDDIR>>/build/../src/backend/utils/mmgr/slab.c > In file included from /<<PKGBUILDDIR>>/build/../src/include/postgres.h:47:0, > from /<<PKGBUILDDIR>>/build/../src/backend/utils/mmgr/slab.c:53: > /<<PKGBUILDDIR>>/build/../src/backend/utils/mmgr/slab.c: In function 'SlabContextCreate': > /<<PKGBUILDDIR>>/build/../src/include/c.h:753:7: error: static assertion failed: "MAXALIGN too small to fit int32" > do { _Static_assert(condition, errmessage); } while(0) > ^ > /<<PKGBUILDDIR>>/build/../src/backend/utils/mmgr/slab.c:198:2: note: in expansion of macro 'StaticAssertStmt' > StaticAssertStmt(MAXIMUM_ALIGNOF >= sizeof(int), > ^~~~~~~~~~~~~~~~ > <builtin>: recipe for target 'slab.o' failed > make[5]: *** [slab.o] Error 1 If that's all that prevents it from working, by all means let's fix it. I think this should do it, although I don't have a system to test it on: diff --git a/src/backend/utils/mmgr/slab.c b/src/backend/utils/mmgr/slab.c index 0fcfcb4c78..e59154ddda 100644 --- a/src/backend/utils/mmgr/slab.c +++ b/src/backend/utils/mmgr/slab.c @@ -194,9 +194,9 @@ SlabContextCreate(MemoryContext parent, MAXALIGN(sizeof(SlabChunk)), "padding calculation in SlabChunk is wrong"); - /* otherwise the linked list inside freed chunk isn't guaranteed to fit */ - StaticAssertStmt(MAXIMUM_ALIGNOF >= sizeof(int), - "MAXALIGN too small to fit int32"); + /* Make sure the linked list node fits inside a freed chunk */ + if (chunkSize < sizeof(int)) + chunkSize = sizeof(int); /* chunk, including SLAB header (both addresses nicely aligned) */ fullChunkSize = MAXALIGN(sizeof(SlabChunk) +MAXALIGN(chunkSize)); It adds a few instructions to check that on all platforms, unless the compiler can optimize that away, but this is not performance critical. I'll commit that, barring objections. If you can verify that it fixes the problem before that, that'd be great, otherwise I guess we'll find out some time after the commit. - Heikki
Re: [HACKERS] 10beta1/m68k: static assertion failed: "MAXALIGN toosmall to fit int32"
From
Christoph Berg
Date:
Re: Heikki Linnakangas 2017-05-18 <e0bfad8e-ec5d-28ee-ebbc-4670d465b3cf@iki.fi> > I'll commit that, barring objections. If you can verify that it fixes the > problem before that, that'd be great, otherwise I guess we'll find out some > time after the commit. Please go ahead, I don't think I have online access to a m68k machine. (It got demoted to an unofficial port some time ago and the old Debian porter machines got taken down). Thanks, Christoph
Re: [HACKERS] 10beta1/m68k: static assertion failed: "MAXALIGN toosmall to fit int32"
From
Andres Freund
Date:
On 2017-05-18 10:48:48 +0300, Heikki Linnakangas wrote: > If that's all that prevents it from working, by all means let's fix it. I > think this should do it, although I don't have a system to test it on: Yes, that's what I thought about doing too. > It adds a few instructions to check that on all platforms, unless the > compiler can optimize that away, but this is not performance critical. Yea, that seems fairly harmless. Context creation is much more heavyweight than those 2-3 instructions. > I'll commit that, barring objections. If you can verify that it fixes the > problem before that, that'd be great, otherwise I guess we'll find out some > time after the commit. lgtm. Thanks! Andres
Re: [HACKERS] 10beta1/m68k: static assertion failed: "MAXALIGN toosmall to fit int32"
From
Heikki Linnakangas
Date:
On 05/18/2017 12:31 PM, Christoph Berg wrote: > Re: Heikki Linnakangas 2017-05-18 <e0bfad8e-ec5d-28ee-ebbc-4670d465b3cf@iki.fi> >> I'll commit that, barring objections. If you can verify that it fixes the >> problem before that, that'd be great, otherwise I guess we'll find out some >> time after the commit. > > Please go ahead, I don't think I have online access to a m68k machine. > (It got demoted to an unofficial port some time ago and the old Debian > porter machines got taken down). Ok, pushed, let's see if the port machine likes it. - Heikki
Re: [HACKERS] 10beta1/m68k: static assertion failed: "MAXALIGN toosmall to fit int32"
From
Christoph Berg
Date:
Re: Heikki Linnakangas 2017-05-18 <5b9085c2-2c18-e5e3-c340-c07d11a9ccd3@iki.fi> > > Please go ahead, I don't think I have online access to a m68k machine. > > (It got demoted to an unofficial port some time ago and the old Debian > > porter machines got taken down). > > Ok, pushed, let's see if the port machine likes it. The build works now, thanks! https://people.debian.org/~glaubitz/postgresql-10_10~beta2-1+b2_m68k.build Christoph