Skip to content

Commit 3e3dcb3

Browse files
committed
target triple
1 parent 0d7e89e commit 3e3dcb3

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ pub(crate) fn run_pass_manager(
660660
// in the enzyme differentiation pass.
661661
let enable_ad = config.autodiff.contains(&config::AutoDiff::Enable);
662662
let enable_gpu = config.offload.contains(&config::Offload::Enable);
663-
dbg!(&enable_gpu);
664663
let stage = if thin {
665664
write::AutodiffStage::PreAD
666665
} else {
@@ -676,6 +675,7 @@ pub(crate) fn run_pass_manager(
676675
}
677676

678677
if cfg!(llvm_enzyme) && enable_gpu && !thin {
678+
dbg!(&enable_gpu);
679679
let cx =
680680
SimpleCx::new(module.module_llvm.llmod(), &module.module_llvm.llcx, cgcx.pointer_size);
681681
crate::builder::gpu_offload::handle_gpu_code(cgcx, &cx);

compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::ffi::CString;
1+
use std::ffi::{CStr, CString};
22

33
use crate::builder::{SBuilder, UNNAMED};
44
use crate::common::AsCCharPtr;
@@ -29,6 +29,9 @@ pub(crate) fn gen_image_wrapper_module<'ll>(
2929
let ti8 = cx.type_i8();
3030
let dl_cstr = llvm::LLVMGetDataLayoutStr(old_cx.llmod);
3131
llvm::LLVMSetDataLayout(llmod, dl_cstr);
32+
let target_cstr = llvm::LLVMGetTarget(old_cx.llmod);
33+
let target = CStr::from_ptr(target_cstr).to_string_lossy().into_owned();
34+
llvm::LLVMSetTarget(llmod, target_cstr);
3235
// target triple = "x86_64-unknown-linux-gnu"
3336

3437
let mut entry_fields = [ti64, ti16, ti16, ti32, tptr, tptr, ti64, ti64, tptr];

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,9 @@ unsafe extern "C" {
10161016
) -> &Module;
10171017
pub(crate) fn LLVMCloneModule(M: &Module) -> &Module;
10181018

1019+
pub(crate) fn LLVMGetTarget(M: &Module) -> *const c_char;
1020+
pub(crate) fn LLVMSetTarget(M: &Module, Name: *const c_char);
1021+
10191022
/// Data layout. See Module::getDataLayout.
10201023
pub(crate) fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
10211024
pub(crate) fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);

0 commit comments

Comments
 (0)