Skip to content

Commit

Permalink
Fix builds for LLVM
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Aug 21, 2023
1 parent 958c42f commit ad33b8d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
9 changes: 6 additions & 3 deletions llvm/samples/llvm/OrcJit.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
*/

import org.bytedeco.javacpp.IntPointer;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.LongPointer;
import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.PointerPointer;
import org.bytedeco.libffi.ffi_cif;
import org.bytedeco.llvm.global.LLVM;
import org.bytedeco.llvm.LLVM.LLVMBasicBlockRef;
import org.bytedeco.llvm.LLVM.LLVMBuilderRef;
import org.bytedeco.llvm.LLVM.LLVMContextRef;
Expand Down Expand Up @@ -90,22 +92,23 @@ public static void main(String[] args) {
// Stage 3: Execute using OrcJIT
LLVMOrcLLJITRef jit = new LLVMOrcLLJITRef();
LLVMOrcLLJITBuilderRef jitBuilder = LLVMOrcCreateLLJITBuilder();
Loader.loadGlobal(Loader.load(LLVM.class));
if ((err = LLVMOrcCreateLLJIT(jit, jitBuilder)) != null) {
System.err.println("Failed to create LLJIT: " + LLVMGetErrorMessage(err));
System.err.println("Failed to create LLJIT: " + LLVMGetErrorMessage(err).getString());
LLVMConsumeError(err);
return;
}

LLVMOrcJITDylibRef mainDylib = LLVMOrcLLJITGetMainJITDylib(jit);
if ((err = LLVMOrcLLJITAddLLVMIRModule(jit, mainDylib, threadModule)) != null) {
System.err.println("Failed to add LLVM IR module: " + LLVMGetErrorMessage(err));
System.err.println("Failed to add LLVM IR module: " + LLVMGetErrorMessage(err).getString());
LLVMConsumeError(err);
return;
}

final LongPointer res = new LongPointer(1);
if ((err = LLVMOrcLLJITLookup(jit, res, "sum")) != null) {
System.err.println("Failed to look up 'sum' symbol: " + LLVMGetErrorMessage(err));
System.err.println("Failed to look up 'sum' symbol: " + LLVMGetErrorMessage(err).getString());
LLVMConsumeError(err);
return;
}
Expand Down
13 changes: 4 additions & 9 deletions llvm/src/gen/java/org/bytedeco/llvm/global/LLVM.java
Original file line number Diff line number Diff line change
Expand Up @@ -10414,12 +10414,7 @@ public static native LLVMErrorRef LLVMOrcCreateDynamicLibrarySearchGeneratorForP
* THIS API IS EXPERIMENTAL AND LIKELY TO CHANGE IN THE NEAR FUTURE!
*
*/
public static native LLVMErrorRef LLVMOrcCreateStaticLibrarySearchGeneratorForPath(
@ByPtrPtr LLVMOrcDefinitionGeneratorRef Result, LLVMOrcObjectLayerRef ObjLayer,
@Cast("const char*") BytePointer FileName, @Cast("const char*") BytePointer TargetTriple);
public static native LLVMErrorRef LLVMOrcCreateStaticLibrarySearchGeneratorForPath(
@Cast("LLVMOrcDefinitionGeneratorRef*") PointerPointer Result, LLVMOrcObjectLayerRef ObjLayer,
String FileName, String TargetTriple);


/**
* Create a ThreadSafeContext containing a new LLVMContext.
Expand Down Expand Up @@ -11563,16 +11558,16 @@ public static native void LLVMPassBuilderOptionsSetInlinerThreshold(
// #include "llvm/ExecutionEngine/ExecutionEngine.h"
// #include "llvm/Target/TargetMachine.h"
// #include "llvm/Transforms/IPO.h"
// #include "llvm/Transforms/IPO/PassManagerBuilder.h"
//#include "llvm/Transforms/IPO/PassManagerBuilder.h"
// #include "llvm/IR/Verifier.h"
// #include "llvm/IR/LegacyPassManager.h"
// #include "llvm/CodeGen/TargetPassConfig.h"
// #include "llvm/MC/TargetRegistry.h"
// #include "llvm/Analysis/TargetLibraryInfo.h"
// #include "llvm/Analysis/TargetTransformInfo.h"
// #include "llvm/MC/SubtargetFeature.h"
//#include "llvm/MC/SubtargetFeature.h"
// #include "llvm/Pass.h"
// #include "llvm-c/Transforms/PassManagerBuilder.h"
//#include "llvm-c/Transforms/PassManagerBuilder.h"
// #include "llvm-c/Types.h"
// #include "llvm-c/Error.h"

Expand Down
2 changes: 1 addition & 1 deletion llvm/src/main/java/org/bytedeco/llvm/presets/LLVM.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,6 @@ public void map(InfoMap infoMap) {
.put(new Info("defined(_MSC_VER) && !defined(inline)", "GPU_CODEGEN").define(false))
.put(new Info("LLVMErrorTypeId").annotations("@Const").valueTypes("LLVMErrorTypeId"))
.put(new Info("llvm::raw_ostream").cast().pointerTypes("Pointer"))
.put(new Info("LLVMOrcObjectLayerAddObjectFileWithRT").skip());
.put(new Info("LLVMOrcObjectLayerAddObjectFileWithRT", "LLVMOrcCreateStaticLibrarySearchGeneratorForPath").skip());
}
}

0 comments on commit ad33b8d

Please sign in to comment.