@@ -32,12 +32,15 @@ pub struct GccOutput {
32
32
impl GccOutput {
33
33
/// Install the required libgccjit library file(s) to the specified `path`.
34
34
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 ) ;
41
44
}
42
45
}
43
46
@@ -74,23 +77,13 @@ impl Step for Gcc {
74
77
}
75
78
76
79
build_gcc ( & metadata, builder, target) ;
77
- create_lib_alias ( builder, & libgccjit_path) ;
78
80
79
81
t ! ( metadata. stamp. write( ) ) ;
80
82
81
83
GccOutput { libgccjit : libgccjit_path }
82
84
}
83
85
}
84
86
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
-
94
87
pub struct Meta {
95
88
stamp : BuildStamp ,
96
89
out_dir : PathBuf ,
@@ -137,7 +130,6 @@ fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<Pa
137
130
}
138
131
139
132
let libgccjit = root. join ( "lib" ) . join ( "libgccjit.so" ) ;
140
- create_lib_alias ( builder, & libgccjit) ;
141
133
Some ( libgccjit)
142
134
}
143
135
PathFreshness :: HasLocalModifications { .. } => {
0 commit comments