@@ -32,6 +32,7 @@ struct Config<'a> {
32
32
verbose : bool ,
33
33
workspace : bool ,
34
34
jobs : Option < String > ,
35
+ arch : & ' a str ,
35
36
}
36
37
37
38
impl Default for Config < ' _ > {
@@ -56,6 +57,7 @@ impl Default for Config<'_> {
56
57
verbose : false ,
57
58
workspace : false ,
58
59
jobs : None ,
60
+ arch : "sbf" ,
59
61
}
60
62
}
61
63
}
@@ -527,6 +529,16 @@ fn build_sbf_package(config: &Config, target_directory: &Path, package: &cargo_m
527
529
debug ! ( "RUSTFLAGS={}" , & rustflags) ;
528
530
} ;
529
531
532
+ let mut target_rustflags = env:: var ( "CARGO_TARGET_SBF_SOLANA_SOLANA_RUSTFLAGS" )
533
+ . ok ( ) . unwrap_or_default ( ) ;
534
+ if config. arch == "sbfv2" {
535
+ target_rustflags = format ! ( "{} {}" , "-C target_cpu=sbfv2" , target_rustflags) ;
536
+ env:: set_var (
537
+ "CARGO_TARGET_SBF_SOLANA_SOLANA_RUSTFLAGS" ,
538
+ & target_rustflags,
539
+ ) ;
540
+ }
541
+
530
542
let cargo_build = PathBuf :: from ( "cargo" ) ;
531
543
let mut cargo_build_args = vec ! [
532
544
"+sbf" ,
@@ -535,6 +547,9 @@ fn build_sbf_package(config: &Config, target_directory: &Path, package: &cargo_m
535
547
"sbf-solana-solana" ,
536
548
"--release" ,
537
549
] ;
550
+ if config. arch == "sbfv2" {
551
+ cargo_build_args. push ( "-Zbuild-std=std,panic_abort" ) ;
552
+ }
538
553
if config. no_default_features {
539
554
cargo_build_args. push ( "--no-default-features" ) ;
540
555
}
@@ -818,6 +833,13 @@ fn main() {
818
833
. validator ( |val| val. parse :: < usize > ( ) . map_err ( |e| e. to_string ( ) ) )
819
834
. help ( "Number of parallel jobs, defaults to # of CPUs" ) ,
820
835
)
836
+ . arg (
837
+ Arg :: new ( "arch" )
838
+ . long ( "arch" )
839
+ . possible_values ( & [ "sbf" , "sbfv2" ] )
840
+ . default_value ( "sbf" )
841
+ . help ( "Build for the given SBF version" ) ,
842
+ )
821
843
. get_matches_from ( args) ;
822
844
823
845
let sbf_sdk: PathBuf = matches. value_of_t_or_exit ( "sbf_sdk" ) ;
@@ -854,6 +876,7 @@ fn main() {
854
876
verbose : matches. is_present ( "verbose" ) ,
855
877
workspace : matches. is_present ( "workspace" ) ,
856
878
jobs : matches. value_of_t ( "jobs" ) . ok ( ) ,
879
+ arch : matches. value_of ( "arch" ) . unwrap ( ) ,
857
880
} ;
858
881
let manifest_path: Option < PathBuf > = matches. value_of_t ( "manifest_path" ) . ok ( ) ;
859
882
build_sbf ( config, manifest_path) ;
0 commit comments