Skip to content

Commit ee2e46a

Browse files
alessandrodLucasSte
authored andcommitted
[SOL] use codegen-units=1 by default for SBF
1 parent fc3d252 commit ee2e46a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

compiler/rustc_session/src/session.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,21 @@ impl Session {
875875
// As a result 16 was chosen here! Mostly because it was a power of 2
876876
// and most benchmarks agreed it was roughly a local optimum. Not very
877877
// scientific.
878-
CodegenUnits::Default(16)
878+
879+
if self.target.options.vendor == "solana" {
880+
// Default to 1 for SBF programs. It makes a huge difference in
881+
// terms of generated code size for us
882+
// (https://github.com/rust-lang/rust/issues/47745) and compilation
883+
// time isn't a huge concern (programs tend to be small). It's still
884+
// possible to override this from the command line or from cargo
885+
// profiles.
886+
//
887+
// Note that we don't set default_codegen_units in the target
888+
// definition as that would break incremental compilation.
889+
CodegenUnits::Default(1)
890+
} else {
891+
CodegenUnits::Default(16)
892+
}
879893
}
880894

881895
pub fn teach(&self, code: ErrCode) -> bool {

0 commit comments

Comments
 (0)