Skip to content

Commit e33a8e9

Browse files
committed
limit -Zmin-function-alignment to at most 8192 bytes
Higher alignments are not supported in COFF
1 parent df4ad9e commit e33a8e9

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

compiler/rustc_session/src/options.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ mod desc {
811811
pub(crate) const parse_wasm_c_abi: &str = "`spec`";
812812
pub(crate) const parse_mir_include_spans: &str =
813813
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)";
814-
pub(crate) const parse_align: &str = "a number that is a power of 2 between 1 and 2^29";
814+
pub(crate) const parse_align: &str = "a number that is a power of 2 between 1 and 8192";
815815
}
816816

817817
pub mod parse {
@@ -1925,6 +1925,12 @@ pub mod parse {
19251925
return false;
19261926
}
19271927

1928+
// Limit the alignment to 8192 (i.e. 0x2000, or 1 << 13) bytes. It is the highest function
1929+
// alignment that works on all target platforms. COFF does not support higher alignments.
1930+
if bytes > 8192 {
1931+
return false;
1932+
}
1933+
19281934
let Ok(align) = Align::from_bytes(bytes) else {
19291935
return false;
19301936
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: incorrect value `3` for unstable option `min-function-alignment` - a number that is a power of 2 between 1 and 8192 was expected
2+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ revisions: too-high not-power-of-2
2+
//
3+
//@ [too-high] compile-flags: -Zmin-function-alignment=16384
4+
//@ [not-power-of-2] compile-flags: -Zmin-function-alignment=3
5+
6+
//~? ERROR a number that is a power of 2 between 1 and 8192 was expected
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: incorrect value `16384` for unstable option `min-function-alignment` - a number that is a power of 2 between 1 and 8192 was expected
2+

0 commit comments

Comments
 (0)