@@ -783,9 +783,8 @@ pub(crate) unsafe fn llvm_optimize(
783783 module. module_llvm . tm . raw ( ) ,
784784 device_out_c. as_ptr ( ) ,
785785 ) ;
786- assert ! ( ok, "LLVMRustBundleImages (device -> host.out) failed" ) ;
787- if !device_out. exists ( ) {
788- panic ! ( "BundleImages failed, `host.out` was not created!" ) ;
786+ if !ok || !device_out. exists ( ) {
787+ dcx. emit_err ( crate :: errors:: OffloadBundleImagesFailed ) ;
789788 }
790789 }
791790 }
@@ -803,15 +802,16 @@ pub(crate) unsafe fn llvm_optimize(
803802 {
804803 let device_pathbuf = PathBuf :: from ( device_path) ;
805804 if device_pathbuf. is_relative ( ) {
806- panic ! ( "Absolute path is needed" ) ;
805+ dcx . emit_err ( crate :: errors :: OffloadWithoutAbsPath ) ;
807806 } else if device_pathbuf
808807 . file_name ( )
809808 . and_then ( |n| n. to_str ( ) )
810809 . is_some_and ( |n| n != "host.out" )
811810 {
812- panic ! ( "Need path to the host.out file" ) ;
811+ dcx. emit_err ( crate :: errors:: OffloadWrongFileName ) ;
812+ } else if !device_pathbuf. exists ( ) {
813+ dcx. emit_err ( crate :: errors:: OffloadNonexistingPath ) ;
813814 }
814- assert ! ( device_pathbuf. exists( ) ) ;
815815 let host_path = cgcx. output_filenames . path ( OutputType :: Object ) ;
816816 let host_dir = host_path. parent ( ) . unwrap ( ) ;
817817 let out_obj = host_dir. join ( "host.o" ) ;
@@ -823,7 +823,9 @@ pub(crate) unsafe fn llvm_optimize(
823823 let llmod2 = llvm:: LLVMCloneModule ( module. module_llvm . llmod ( ) ) ;
824824 let ok =
825825 unsafe { llvm:: LLVMRustOffloadEmbedBufferInModule ( llmod2, host_out_c. as_ptr ( ) ) } ;
826- assert ! ( ok, "LLVMRustOffloadEmbedBufferInModule failed" ) ;
826+ if !ok {
827+ dcx. emit_err ( crate :: errors:: OffloadEmbedFailed ) ;
828+ }
827829 write_output_file (
828830 dcx,
829831 module. module_llvm . tm . raw ( ) ,
@@ -835,10 +837,6 @@ pub(crate) unsafe fn llvm_optimize(
835837 & cgcx. prof ,
836838 true ,
837839 ) ;
838- if !out_obj. exists ( ) {
839- dbg ! ( "{:?} does not exist!" , out_obj) ;
840- panic ! ( "FinalizeOffload failed!" ) ;
841- }
842840 // We ignore cgcx.save_temps here and unconditionally always keep our `host.out` artifact.
843841 // Otherwise, recompiling the host code would fail since we deleted that device artifact
844842 // in the previous host compilation, which would be confusing at best.
0 commit comments