@@ -38,11 +38,11 @@ impl flags::Dist {
3838// A hack to make VS Code prefer nightly over stable.
3939format ! ( "{VERSION_NIGHTLY}.{patch_version}" )
4040} ;
41- dist_server ( sh, & format ! ( "{version}-standalone" ) , & target, allocator) ?;
41+ dist_server ( sh, & format ! ( "{version}-standalone" ) , & target, allocator, self . zig ) ?;
4242let release_tag = if stable { date_iso ( sh) ? } else { "nightly" . to_owned ( ) } ;
4343dist_client ( sh, & version, & release_tag, & target) ?;
4444} else {
45- dist_server ( sh, "0.0.0-standalone" , & target, allocator) ?;
45+ dist_server ( sh, "0.0.0-standalone" , & target, allocator, self . zig ) ?;
4646}
4747Ok ( ( ) )
4848}
@@ -83,6 +83,7 @@ fn dist_server(
8383release : & str ,
8484target : & Target ,
8585allocator : Malloc ,
86+ zig : bool ,
8687) -> anyhow:: Result < ( ) > {
8788let _e = sh. push_env ( "CFG_RELEASE" , release) ;
8889let _e = sh. push_env ( "CARGO_PROFILE_RELEASE_LTO" , "thin" ) ;
@@ -92,13 +93,14 @@ fn dist_server(
9293// * on Linux, this blows up the binary size from 8MB to 43MB, which is unreasonable.
9394// let _e = sh.push_env("CARGO_PROFILE_RELEASE_DEBUG", "1");
9495
95- if target. name . contains ( "-linux-" ) {
96- env :: set_var ( "CC" , "clang" ) ;
97- }
98-
99- let target_name = & target . name ;
96+ let linux_target = target. is_linux ( ) ;
97+ let target_name = match & target . libc_suffix {
98+ Some ( libc_suffix ) if zig => format ! ( "{}.{libc_suffix}" , target . name ) ,
99+ _ => target . name . to_owned ( ) ,
100+ } ;
100101let features = allocator. to_features ( ) ;
101- cmd ! ( sh, "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target_name} {features...} --release" ) . run ( ) ?;
102+ let command = if linux_target && zig { "zigbuild" } else { "build" } ;
103+ cmd ! ( sh, "cargo {command} --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target_name} {features...} --release" ) . run ( ) ?;
102104
103105let dst = Path :: new ( "dist" ) . join ( & target. artifact_name ) ;
104106if target_name. contains ( "-windows-" ) {
@@ -156,6 +158,7 @@ fn zip(src_path: &Path, symbols_path: Option<&PathBuf>, dest_path: &Path) -> any
156158
157159struct Target {
158160name : String ,
161+ libc_suffix : Option < String > ,
159162server_path : PathBuf ,
160163symbols_path : Option < PathBuf > ,
161164artifact_name : String ,
@@ -177,6 +180,10 @@ impl Target {
177180}
178181}
179182} ;
183+ let ( name, libc_suffix) = match name. split_once ( '.' ) {
184+ Some ( ( l, r) ) => ( l. to_owned ( ) , Some ( r. to_owned ( ) ) ) ,
185+ None => ( name, None ) ,
186+ } ;
180187let out_path = project_root. join ( "target" ) . join ( & name) . join ( "release" ) ;
181188let ( exe_suffix, symbols_path) = if name. contains ( "-windows-" ) {
182189( ".exe" . into ( ) , Some ( out_path. join ( "rust_analyzer.pdb" ) ) )
@@ -185,7 +192,11 @@ impl Target {
185192} ;
186193let server_path = out_path. join ( format ! ( "rust-analyzer{exe_suffix}" ) ) ;
187194let artifact_name = format ! ( "rust-analyzer-{name}{exe_suffix}" ) ;
188- Self { name, server_path, symbols_path, artifact_name }
195+ Self { name, libc_suffix, server_path, symbols_path, artifact_name }
196+ }
197+
198+ fn is_linux ( & self ) -> bool {
199+ self . name . contains ( "-linux-" )
189200}
190201}
191202
0 commit comments