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