@@ -32,12 +32,15 @@ pub struct GccOutput {
3232impl  GccOutput  { 
3333    /// Install the required libgccjit library file(s) to the specified `path`. 
3434     pub  fn  install_to ( & self ,  builder :  & Builder < ' _ > ,  directory :  & Path )  { 
35-         let  dst = directory. join ( self . libgccjit . file_name ( ) . unwrap ( ) ) ; 
36-         builder. install ( & self . libgccjit ,  directory,  FileType :: NativeLibrary ) ; 
37-         // FIXME: try to remove the alias, it shouldn't be needed 
38-         // We just have to teach rustc_codegen_gcc to link to libgccjit.so directly, instead of 
39-         // linking to libgccjit.so.0. 
40-         create_lib_alias ( builder,  & dst) ; 
35+         // At build time, cg_gcc has to link to libgccjit.so (the unversioned symbol). 
36+         // However, at runtime, it will by default look for libgccjit.so.0. 
37+         // So when we install the built libgccjit.so file to the target `directory`, we add it there 
38+         // with the `.0` suffix. 
39+         let  mut  target_filename = self . libgccjit . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ; 
40+         target_filename. push_str ( ".0" ) ; 
41+ 
42+         let  dst = directory. join ( target_filename) ; 
43+         builder. copy_link ( & self . libgccjit ,  & dst,  FileType :: NativeLibrary ) ; 
4144    } 
4245} 
4346
@@ -74,23 +77,13 @@ impl Step for Gcc {
7477        } 
7578
7679        build_gcc ( & metadata,  builder,  target) ; 
77-         create_lib_alias ( builder,  & libgccjit_path) ; 
7880
7981        t ! ( metadata. stamp. write( ) ) ; 
8082
8183        GccOutput  {  libgccjit :  libgccjit_path } 
8284    } 
8385} 
8486
85- /// Creates a libgccjit.so.0 alias next to libgccjit.so if it does not 
86- /// already exist 
87- fn  create_lib_alias ( builder :  & Builder < ' _ > ,  libgccjit :  & PathBuf )  { 
88-     let  lib_alias = libgccjit. parent ( ) . unwrap ( ) . join ( "libgccjit.so.0" ) ; 
89-     if  !lib_alias. exists ( )  { 
90-         t ! ( builder. symlink_file( libgccjit,  lib_alias) ) ; 
91-     } 
92- } 
93- 
9487pub  struct  Meta  { 
9588    stamp :  BuildStamp , 
9689    out_dir :  PathBuf , 
@@ -137,7 +130,6 @@ fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<Pa
137130            } 
138131
139132            let  libgccjit = root. join ( "lib" ) . join ( "libgccjit.so" ) ; 
140-             create_lib_alias ( builder,  & libgccjit) ; 
141133            Some ( libgccjit) 
142134        } 
143135        PathFreshness :: HasLocalModifications  {  .. }  => { 
0 commit comments