@@ -47,6 +47,10 @@ enum Commands {
4747 /// Precompile with debug and disable optimizations
4848 #[ arg( long) ]
4949 debug : bool ,
50+
51+ /// Disable address map and native unwind info for smaller binaries
52+ #[ arg( long) ]
53+ minimal : bool ,
5054 } ,
5155
5256 /// Check the Wasmtime version use to compile a AOT file
@@ -69,6 +73,7 @@ fn main() {
6973 output,
7074 component,
7175 debug,
76+ minimal,
7277 } => {
7378 let outfile = match output {
7479 Some ( s) => s,
@@ -86,7 +91,7 @@ fn main() {
8691 } else {
8792 println ! ( "Aot Compiling {} to {}" , input, outfile) ;
8893 }
89- let config = get_config ( debug) ;
94+ let config = get_config ( debug, minimal ) ;
9095 let engine = Engine :: new ( & config) . unwrap ( ) ;
9196 let bytes = std:: fs:: read ( & input) . unwrap ( ) ;
9297 let serialized = if component {
@@ -116,7 +121,7 @@ fn main() {
116121 }
117122 // load the file into wasmtime, check that it is aot compiled and extract the version of wasmtime used to compile it from its metadata
118123 let bytes = std:: fs:: read ( & file) . unwrap ( ) ;
119- let config = get_config ( debug) ;
124+ let config = get_config ( debug, false ) ;
120125 let engine = Engine :: new ( & config) . unwrap ( ) ;
121126 match Engine :: detect_precompiled ( & bytes) {
122127 Some ( pre_compiled) => {
@@ -163,7 +168,7 @@ fn main() {
163168}
164169
165170/// Returns a new `Config` for the Wasmtime engine with additional settings for AOT compilation.
166- fn get_config ( debug : bool ) -> Config {
171+ fn get_config ( debug : bool , minimal : bool ) -> Config {
167172 let mut config = Config :: new ( ) ;
168173 config. target ( "x86_64-unknown-none" ) . unwrap ( ) ;
169174
@@ -173,5 +178,10 @@ fn get_config(debug: bool) -> Config {
173178 config. cranelift_opt_level ( OptLevel :: None ) ;
174179 }
175180
181+ if minimal {
182+ config. generate_address_map ( false ) ;
183+ config. native_unwind_info ( false ) ;
184+ }
185+
176186 config
177187}
0 commit comments