@@ -1027,6 +1027,11 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
1027
1027
"`-C save-temps` might not produce all requested temporary products \
1028
1028
when incremental compilation is enabled.") ] ,
1029
1029
"save all temporary output files during compilation" ) ,
1030
+ pgo_gen: Option <String > = ( None , parse_opt_string, [ TRACKED ] ,
1031
+ "Generate PGO profile data, to a given file, or to the default \
1032
+ location if it's empty.") ,
1033
+ pgo_use: String = ( String :: new( ) , parse_string, [ TRACKED ] ,
1034
+ "Use PGO profile data from the given profile file." ) ,
1030
1035
rpath: bool = ( false , parse_bool, [ UNTRACKED ] ,
1031
1036
"set rpath values in libs/exes" ) ,
1032
1037
overflow_checks: Option <bool > = ( None , parse_opt_bool, [ TRACKED ] ,
@@ -1801,6 +1806,13 @@ pub fn build_session_options_and_crate_config(
1801
1806
let mut codegen_units = cg. codegen_units ;
1802
1807
let mut disable_thinlto = false ;
1803
1808
1809
+ if cg. pgo_gen . is_some ( ) && !cg. pgo_use . is_empty ( ) {
1810
+ early_error (
1811
+ error_format,
1812
+ "options `-C pgo-gen` and `-C pgo-use` are exclussive" ,
1813
+ ) ;
1814
+ }
1815
+
1804
1816
// Issue #30063: if user requests llvm-related output to one
1805
1817
// particular path, disable codegen-units.
1806
1818
let incompatible: Vec < _ > = output_types
@@ -2824,6 +2836,14 @@ mod tests {
2824
2836
opts. cg . lto = Lto :: Fat ;
2825
2837
assert ! ( reference. dep_tracking_hash( ) != opts. dep_tracking_hash( ) ) ;
2826
2838
2839
+ opts = reference. clone ( ) ;
2840
+ opts. cg . pgo_gen = Some ( String :: from ( "abc" ) ) ;
2841
+ assert_ne ! ( reference. dep_tracking_hash( ) , opts. dep_tracking_hash( ) ) ;
2842
+
2843
+ opts = reference. clone ( ) ;
2844
+ opts. cg . pgo_use = String :: from ( "abc" ) ;
2845
+ assert_ne ! ( reference. dep_tracking_hash( ) , opts. dep_tracking_hash( ) ) ;
2846
+
2827
2847
opts = reference. clone ( ) ;
2828
2848
opts. cg . target_cpu = Some ( String :: from ( "abc" ) ) ;
2829
2849
assert ! ( reference. dep_tracking_hash( ) != opts. dep_tracking_hash( ) ) ;
0 commit comments