@@ -37,8 +37,9 @@ use rustc_target::spec::{
3737use crate :: code_stats:: CodeStats ;
3838pub use crate :: code_stats:: { DataTypeKind , FieldInfo , FieldKind , SizeKind , VariantInfo } ;
3939use 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 ,
4243} ;
4344use crate :: parse:: { add_feature_diagnostics, ParseSess } ;
4445use crate :: search_paths:: { PathKind , SearchPath } ;
@@ -1300,6 +1301,26 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
13001301 . emit_err ( errors:: SplitDebugInfoUnstablePlatform { debuginfo : sess. split_debuginfo ( ) } ) ;
13011302 }
13021303
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+
13031324 if sess. opts . unstable_opts . instrument_xray . is_some ( ) && !sess. target . options . supports_xray {
13041325 sess. dcx ( ) . emit_err ( errors:: InstrumentationNotSupported { us : "XRay" . to_string ( ) } ) ;
13051326 }
0 commit comments