Re: [PATCH] Enable using llvm jitlink as an alternative llvm jit linker of old Rtdyld.

From: Andres Freund <andres(at)anarazel(dot)de>
To: Alex Fan <alex(dot)fan(dot)q(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, thomas(dot)munro(at)gmail(dot)com, "geidav(dot)pg(at)gmail(dot)com" <geidav(dot)pg(at)gmail(dot)com>, "luc(at)swarm64(dot)com" <luc(at)swarm64(dot)com>
Subject: Re: [PATCH] Enable using llvm jitlink as an alternative llvm jit linker of old Rtdyld.
Date: 2022-12-25 12:01:53
Message-ID: 20221225120153.vifxa5t2ezr3weqb@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2022-11-23 21:13:04 +1100, Alex Fan wrote:
> > @@ -241,6 +246,40 @@ llvm_mutable_module(LLVMJitContext *context)
> > context->module = LLVMModuleCreateWithName("pg");
> > LLVMSetTarget(context->module, llvm_triple);
> > LLVMSetDataLayout(context->module, llvm_layout);
> > +#ifdef __riscv
> > +#if __riscv_xlen == 64
> > +#ifdef __riscv_float_abi_double
> > + abiname = "lp64d";
> > +#elif defined(__riscv_float_abi_single)
> > + abiname = "lp64f";
> > +#else
> > + abiname = "lp64";
> > +#endif
> > +#elif __riscv_xlen == 32
> > +#ifdef __riscv_float_abi_double
> > + abiname = "ilp32d";
> > +#elif defined(__riscv_float_abi_single)
> > + abiname = "ilp32f";
> > +#else
> > + abiname = "ilp32";
> > +#endif
> > +#else
> > + elog(ERROR, "unsupported riscv xlen %d", __riscv_xlen);
> > +#endif
> > + /*
> > + * set this manually to avoid llvm defaulting to soft
> > float and
> > + * resulting in linker error: `can't link double-float
> > modules
> > + * with soft-float modules`
> > + * we could set this for TargetMachine via MCOptions, but
> > there
> > + * is no C API for it
> > + * ref:

I think this is something that should go into the llvm code, rather than
postgres.

> > @@ -820,16 +861,21 @@ llvm_session_initialize(void)
> > elog(DEBUG2, "LLVMJIT detected CPU \"%s\", with features \"%s\"",
> > cpu, features);
> >
> > +#ifdef __riscv
> > + reloc=LLVMRelocPIC;
> > + codemodel=LLVMCodeModelMedium;
> > +#endif

Same.

> > +#ifdef USE_JITLINK
> > +/*
> > + * There is no public C API to create ObjectLinkingLayer for JITLINK,
> > create our own
> > + */
> > +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::orc::ExecutionSession,
> > LLVMOrcExecutionSessionRef)
> > +DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::orc::ObjectLayer,
> > LLVMOrcObjectLayerRef)

I recommend proposing a patch for adding such an API to LLVM.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2022-12-25 13:01:36 Re: daitch_mokotoff module
Previous Message Dilip Kumar 2022-12-25 11:25:26 Re: Improve WALRead() to suck data directly from WAL buffers when possible