|
25 | 25 | #include "llvm/IR/Module.h" |
26 | 26 | #include "llvm/IR/Value.h" |
27 | 27 | #include "llvm/Object/COFFImportFile.h" |
28 | | -#include "llvm/Object/OffloadBinary.h" |
29 | 28 | #include "llvm/Remarks/RemarkFormat.h" |
30 | 29 | #include "llvm/Remarks/RemarkSerializer.h" |
31 | 30 | #include "llvm/Remarks/RemarkStreamer.h" |
|
36 | 35 | #include "llvm/Support/Signals.h" |
37 | 36 | #include "llvm/Support/Timer.h" |
38 | 37 | #include "llvm/Support/ToolOutputFile.h" |
39 | | -#include "llvm/Target/TargetMachine.h" |
40 | 38 | #include "llvm/Transforms/Utils/Cloning.h" |
41 | 39 | #include "llvm/Transforms/Utils/ValueMapper.h" |
42 | 40 | #include <iostream> |
43 | 41 |
|
| 42 | +// Some of the functions below rely on LLVM modules that may not always be |
| 43 | +// available. As such, we only try to build it in the first place, if |
| 44 | +// llvm.offload is enabled. |
| 45 | +#ifdef OFFLOAD |
| 46 | +#include "llvm/Object/OffloadBinary.h" |
| 47 | +#include "llvm/Target/TargetMachine.h" |
| 48 | +#endif |
| 49 | + |
44 | 50 | // for raw `write` in the bad-alloc handler |
45 | 51 | #ifdef _MSC_VER |
46 | 52 | #include <io.h> |
@@ -146,6 +152,10 @@ extern "C" void LLVMRustPrintStatistics(RustStringRef OutBuf) { |
146 | 152 | llvm::PrintStatistics(OS); |
147 | 153 | } |
148 | 154 |
|
| 155 | +// Some of the functions here rely on LLVM modules that may not always be |
| 156 | +// available. As such, we only try to build it in the first place, if |
| 157 | +// llvm.offload is enabled. |
| 158 | +#ifdef OFFLOAD |
149 | 159 | static Error writeFile(StringRef Filename, StringRef Data) { |
150 | 160 | Expected<std::unique_ptr<FileOutputBuffer>> OutputOrErr = |
151 | 161 | FileOutputBuffer::create(Filename, Data.size()); |
@@ -210,6 +220,7 @@ extern "C" void LLVMRustOffloadMapper(LLVMValueRef OldFn, LLVMValueRef NewFn) { |
210 | 220 | llvm::CloneFunctionChangeType::LocalChangesOnly, |
211 | 221 | returns); |
212 | 222 | } |
| 223 | +#endif |
213 | 224 |
|
214 | 225 | extern "C" LLVMValueRef LLVMRustGetNamedValue(LLVMModuleRef M, const char *Name, |
215 | 226 | size_t NameLen) { |
|
0 commit comments