@@ -37,8 +37,9 @@ use rustc_target::spec::{
37
37
use crate :: code_stats:: CodeStats ;
38
38
pub use crate :: code_stats:: { DataTypeKind , FieldInfo , FieldKind , SizeKind , VariantInfo } ;
39
39
use crate :: config:: {
40
- self , CoverageLevel , CrateType , ErrorOutputType , FunctionReturn , Input , InstrumentCoverage ,
41
- OptLevel , OutFileName , OutputType , RemapPathScopeComponents , SwitchWithOptPath ,
40
+ self , CoverageLevel , CrateType , DebugInfo , ErrorOutputType , FunctionReturn , Input ,
41
+ InstrumentCoverage , OptLevel , OutFileName , OutputType , RemapPathScopeComponents ,
42
+ SwitchWithOptPath ,
42
43
} ;
43
44
use crate :: parse:: { add_feature_diagnostics, ParseSess } ;
44
45
use crate :: search_paths:: { PathKind , SearchPath } ;
@@ -1300,6 +1301,26 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
1300
1301
. emit_err ( errors:: SplitDebugInfoUnstablePlatform { debuginfo : sess. split_debuginfo ( ) } ) ;
1301
1302
}
1302
1303
1304
+ if sess. opts . unstable_opts . embed_source {
1305
+ let dwarf_version =
1306
+ sess. opts . unstable_opts . dwarf_version . unwrap_or ( sess. target . default_dwarf_version ) ;
1307
+
1308
+ let uses_llvm_backend =
1309
+ matches ! ( sess. opts. unstable_opts. codegen_backend. as_deref( ) , None | Some ( "llvm" ) ) ;
1310
+
1311
+ if dwarf_version < 5 {
1312
+ sess. dcx ( ) . emit_warn ( errors:: EmbedSourceInsufficientDwarfVersion { dwarf_version } ) ;
1313
+ }
1314
+
1315
+ if sess. opts . debuginfo == DebugInfo :: None {
1316
+ sess. dcx ( ) . emit_warn ( errors:: EmbedSourceRequiresDebugInfo ) ;
1317
+ }
1318
+
1319
+ if !uses_llvm_backend {
1320
+ sess. dcx ( ) . emit_warn ( errors:: EmbedSourceRequiresLLVMBackend ) ;
1321
+ }
1322
+ }
1323
+
1303
1324
if sess. opts . unstable_opts . instrument_xray . is_some ( ) && !sess. target . options . supports_xray {
1304
1325
sess. dcx ( ) . emit_err ( errors:: InstrumentationNotSupported { us : "XRay" . to_string ( ) } ) ;
1305
1326
}
0 commit comments