On Sat, Oct 21, 2023 at 7:08 PM Andres Freund <and...@anarazel.de> wrote: > I've attached a patch revision that I spent the last couple hours working > on. It's very very roughly based on a patch Tom Stellard had written (which I > think a few rpm packages use). But instead of encoding details about specific > layout details, I made the code check if the data layout works and fall back > to the cpu / features used for llvmjit_types.bc. This way it's not s390x > specific, future odd architecture behaviour would "automatically" be handled > the same
The explanation makes sense and this seems like a solid plan to deal with it. I didn't try on a s390x, but I tested locally on our master branch with LLVM 7, 10, 17, 18, and then I hacked your patch to take the fallback path as if a layout mismatch had been detected, and it worked fine: 2023-10-22 11:49:55.663 NZDT [12000] DEBUG: detected CPU "skylake", with features "...", resulting in layout "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 2023-10-22 11:49:55.664 NZDT [12000] DEBUG: detected CPU / features yield incompatible data layout, using values from module instead 2023-10-22 11:49:55.664 NZDT [12000] DETAIL: module CPU "x86-64", features "...", resulting in layout "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + To deal with that, check if data layouts match during JIT initialization. If + the runtime detected cpu / features result in a different layout, try if the + cpu/features recorded in in llvmjit_types.bc work. s|try |check | s| in in | in | + errmsg_internal("could not determine working CPU / feature comination for JIT compilation"), s|comination|combination| s| / |/|g