pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: tstellar@redhat.com, pgsql-bugs@lists.postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: BUG #16971: Incompatible datalayout errors with llvmjit
Date: Tue, 20 Apr 2021 12:29:37 -0700
Message-ID: <20210420192937.3zu4wpdemxwfvo4u@alap3.anarazel.de> (raw)
In-Reply-To: <16971-5d004d34742a3d35@postgresql.org>
References: <16971-5d004d34742a3d35@postgresql.org>

Hi,

Thanks to tgl for pointing me this thread...

On 2021-04-19 18:29:52 +0000, PG Bug reporting form wrote:
> In our Fedora builds, we are getting errors[1] in the postgresql tests due
> to incompatible datalayouts between the JIT engine and the LLVM modules
> being compiled.  The problem is that the JIT engine is being created with
> host specific CPU and features, while the datalayout for the compiled module
> is being taken from llvmjit_types.bc which is compiled without any specified
> CPU type or features.

It's very odd that features would change the data layout - analogizing
with plain C code that'd mean that you cannot link a binary compiled
with something like -mavx2 against a library compiled without. To me
this smells like a bug somewhere lower level.

Reformatting the error yields:
ERROR:  failed to JIT module: Added modules have incompatible data layouts:
E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-        a:8:16-n32:64 (module) vs
E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64 (jit)

The -v128:64 is about how to align vectors. Skimming the relevant LLVM
code I don't see why it'd be included in JIted code but not native code.

Just to be sure, I take
checking for llvm-config... /usr/bin/llvm-config
checking for clang... /usr/bin/clang
are for llvm & clang compiled from the same code?

I temporarily had access to s390x to debug an unrelated issue in the
past, and there I did hit this problem, but IIRC only because of clang
vs llvm version mismatches.

Unfortunately it is a bit hard to debug without access to a s390x
box... Can you provide that? If not I might ask the Debian folks for
access to one of their porter machines.

FWIW, the Debian s390x build seems to succeed at the moment:
https://buildd.debian.org/status/fetch.php?pkg=postgresql-13&arch=s390x&ver=13.2-1&stamp...


> One way to fix this would be to add -march=native to the %.bc rules in
> src/Makefile.global.in.  However, this will only work when the build system
> and the run system are the same.

> I think to fix this correctly, the llvmjit_types.bc file will need to be
> compiled when the JIT engine is initialized at runtime, so that it can use
> the same datalayout as the JIT engine.

That'd require headers to be present, which I don't think we should
require... And more importantly, it'd not go very far, because we also
have lot of other .bc files that will have the layout embedded (for
inlining functions/operators into JITed code). Which'd then require all
the source code to be present and to be compiled into bitcode. Not an,
uh, satisfying option.



> [1] https://kojipkgs.fedoraproject.org//work/tasks/2182/66082182/build.log

Random thing I noticed while scrolling through the log:
> configure: WARNING: unrecognized options: --disable-dependency-tracking

PG requires dependency tracking to be explicitly enabled, and it's a
different flag name (--enable-depend).

Greetings,

Andres Freund





view thread (4+ messages)  latest in thread

Message-ID: <20210420192937.3zu4wpdemxwfvo4u@alap3.anarazel.de>
Permalink:  ../20210420192937.3zu4wpdemxwfvo4u@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20210420192937.3zu4wpdemxwfvo4u@alap3.anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andres@anarazel.de, tgl@sss.pgh.pa.us
  Subject: Re: BUG #16971: Incompatible datalayout errors with llvmjit
  In-Reply-To: <20210420192937.3zu4wpdemxwfvo4u@alap3.anarazel.de>
  References: <16971-5d004d34742a3d35@postgresql.org> <20210420192937.3zu4wpdemxwfvo4u@alap3.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox