MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / invoke_rustc

Function invoke_rustc

crates/cuda_builder/src/lib.rs:373–508  ·  view source on GitHub ↗
(builder: &CudaBuilder)

Source from the content-addressed store, hash-verified

371}
372
373fn invoke_rustc(builder: &CudaBuilder) -> Result<PathBuf, CudaBuilderError> {
374 // see https://github.com/EmbarkStudios/rust-gpu/blob/main/crates/spirv-builder/src/lib.rs#L385-L392
375 // on what this does
376 let rustc_codegen_nvvm = find_rustc_codegen_nvvm();
377
378 let new_path = get_new_path_var();
379
380 let mut rustflags = vec![format!(
381 "-Zcodegen-backend={}",
382 rustc_codegen_nvvm.display(),
383 )];
384
385 if let Some(emit) = &builder.emit {
386 let string = match emit {
387 EmitOption::LlvmIr => "llvm-ir",
388 EmitOption::Bitcode => "llvm-bc",
389 };
390 rustflags.push(format!("--emit={}", string));
391 }
392
393 let mut llvm_args = vec![NvvmOption::Arch(builder.arch).to_string()];
394
395 if !builder.nvvm_opts {
396 llvm_args.push("-opt=0".to_string());
397 }
398
399 if builder.ftz {
400 llvm_args.push("-ftz=1".to_string());
401 }
402
403 if builder.fast_sqrt {
404 llvm_args.push("-prec-sqrt=0".to_string());
405 }
406
407 if builder.fast_div {
408 llvm_args.push("-prec-div=0".to_string());
409 }
410
411 if !builder.fma_contraction {
412 llvm_args.push("-fma=0".to_string());
413 }
414
415 if builder.override_libm {
416 llvm_args.push("--override-libm".to_string());
417 }
418
419 if builder.debug != DebugInfo::None {
420 let (nvvm_flag, rustc_flag) = builder.debug.into_nvvm_and_rustc_options();
421 llvm_args.push(nvvm_flag);
422 rustflags.push(rustc_flag);
423 }
424
425 let llvm_args = llvm_args.join(" ");
426 if !llvm_args.is_empty() {
427 rustflags.push(["-Cllvm-args=", &llvm_args].concat());
428 }
429
430 let target = if builder.nvptx_32 {

Callers 1

buildMethod · 0.85

Calls 11

find_rustc_codegen_nvvmFunction · 0.85
get_new_path_varFunction · 0.85
newFunction · 0.85
dylib_path_envvarFunction · 0.85
get_last_artifactFunction · 0.85
pushMethod · 0.45
is_emptyMethod · 0.45
popMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected