Re: [PATCH] Enable using llvm jitlink as an alternative llvm jit linker of old Rtdyld. - Mailing list pgsql-hackers

From Andres Freund
Subject Re: [PATCH] Enable using llvm jitlink as an alternative llvm jit linker of old Rtdyld.
Date
Msg-id 20221225120153.vifxa5t2ezr3weqb@alap3.anarazel.de
Whole thread Raw
In response to Re: [PATCH] Enable using llvm jitlink as an alternative llvm jit linker of old Rtdyld.  (Alex Fan <alex.fan.q@gmail.com>)
Responses Re: [PATCH] Enable using llvm jitlink as an alternative llvm jit linker of old Rtdyld.  (Alex Fan <alex.fan.q@gmail.com>)
List 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



pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: Improve WALRead() to suck data directly from WAL buffers when possible
Next
From: Alvaro Herrera
Date:
Subject: Re: daitch_mokotoff module