On 16/11/2023 09:46, Chris Johns wrote:
> Hello
> I thought I'd have a go at building Python 3.12. While ro-config step
> works (with the patch from 3.11), trying the build fails with a static
> assertion "incorrect cache size".
I remember quite some time ago (wow, nearly 10 years according to the
autobuilder log) having similar problems with harfbuzz and GCC 4. If you
look at the recipe in the autobuilder, you'll see a lot of the patches
are to add packing to structs. I remember it was quite tedious because
the structs tended to be nested so packing one affected another, but
eventually I got it working.
Looking at my local version that I'm using with GCC 10, I see that I am
not applying these patches, and IIRC, came to the conclusion that GCC
10 packed structs by default whereas GCC 4 didn't.
> From a look at the code, it seems to be related to the size of some
> structs .. for example
>
> typedef union {
> uint16_t cache;
> struct {
> uint8_t code;
> uint8_t arg;
> } op;
> } _Py_CODEUNIT;
> and
> typedef struct {
> uint16_t counter;
> uint16_t version[2];
> uint16_t index;
> } _PyAttrCache;
> The assert that INLINE_CACHE_ENTRIES_STORE_ATTR == 4
> So what is that doing?
> #define CACHE_ENTRIES(cache) (sizeof(cache)/sizeof(_Py_CODEUNIT))
> #define INLINE_CACHE_ENTRIES_STORE_ATTR CACHE_ENTRIES(_PyAttrCache)
> So from a naive point of view, it should be fine .. sizeof(_Py_CODEUNIT)
> is 2 bytes (a uniion of a 16 bit int or 2 8-bit ones),
> sizeof(_PyAttrCache) is 8 bytes (4 16-bit int (two plus two in the array).
> However, while sizeof(_PyAttrCache) is indeed 8, sizeof(_PyCODEUNIT) is
> 4 (I am guessing it's being rounded up to a word).
> I'm using gcc 4.7.4 (cross compiler). I have tried targetting a later
> CPU, and I did try setting the packed, aligned=2 on the _Py_CODEUNIT
> struct but that didn't seem to make any difference.
When you say you tried setting the packed, aligned=2, did you try:
typedef union {
uint16_t cache;
struct {
uint8_t code;
uint8_t arg;
} __attribute__((__packed__)) op;
} __attribute__((__packed__)) _Py_CODEUNIT;
typedef struct { } __attribute__((__packed__)) _PyAttrCache;
You have to pack the nested structs as well. That's what I had to do
with harfbuzz for GCC 4.
> Any other suggestions? Later gcc? Some other options? I guess python
> probably shouldn't be assuming the sizes, but I'm not sure about getting
> that changed :)
I suspect GCC 10 may do a better job as, like I say, harfbuzz seems to
work without patches to pack the structs. Admittedly, I didn't do any
actually testing, I just went off the fact that it built without the
static assertions failing and Webkit produced readable text!
> I'm not too worried if it means python 3.12 is limited to more modern
> mechines. 3.8 works on everything else.
Are you dynamic linking? The only issue with GCC 10 is we don't have a
point of distribution for the shared libraries. If you're static
linking then you don't have to worry about that.
Lee.
_______________________________________________
GCCSDK mailing list gcc@gccsdk.riscos.info
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK
No comments:
Post a Comment