@@ -4,6 +4,7 @@ use std::num::{IntErrorKind, NonZero};
4
4
use std:: path:: PathBuf ;
5
5
use std:: str;
6
6
7
+ use rustc_abi:: Align ;
7
8
use rustc_data_structures:: fx:: FxIndexMap ;
8
9
use rustc_data_structures:: profiling:: TimePassesFormat ;
9
10
use rustc_data_structures:: stable_hasher:: Hash64 ;
@@ -453,6 +454,7 @@ mod desc {
453
454
pub ( crate ) const parse_wasm_c_abi: & str = "`legacy` or `spec`" ;
454
455
pub ( crate ) const parse_mir_include_spans: & str =
455
456
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)" ;
457
+ pub ( crate ) const parse_align: & str = "a number that is a power of 2 between 1 and 2^29" ;
456
458
}
457
459
458
460
pub mod parse {
@@ -1521,6 +1523,21 @@ pub mod parse {
1521
1523
1522
1524
true
1523
1525
}
1526
+
1527
+ pub ( crate ) fn parse_align ( slot : & mut Option < Align > , v : Option < & str > ) -> bool {
1528
+ let mut bytes = 0u64 ;
1529
+ if !parse_number ( & mut bytes, v) {
1530
+ return false ;
1531
+ }
1532
+
1533
+ let Ok ( align) = Align :: from_bytes ( bytes) else {
1534
+ return false ;
1535
+ } ;
1536
+
1537
+ * slot = Some ( align) ;
1538
+
1539
+ true
1540
+ }
1524
1541
}
1525
1542
1526
1543
options ! {
@@ -1876,6 +1893,8 @@ options! {
1876
1893
"gather metadata statistics (default: no)" ) ,
1877
1894
metrics_dir: Option <PathBuf > = ( None , parse_opt_pathbuf, [ UNTRACKED ] ,
1878
1895
"the directory metrics emitted by rustc are dumped into (implicitly enables default set of metrics)" ) ,
1896
+ min_function_alignment: Option <Align > = ( None , parse_align, [ TRACKED ] ,
1897
+ "align all functions to at least this many bytes. Must be a power of 2" ) ,
1879
1898
mir_emit_retag: bool = ( false , parse_bool, [ TRACKED ] ,
1880
1899
"emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
1881
1900
(default: no)") ,
0 commit comments