@@ -2021,18 +2021,39 @@ fn add_env(builder: &Builder<'_>, cmd: &mut Command, target: TargetSelection) {
2021
2021
}
2022
2022
}
2023
2023
2024
- fn install_llvm_file ( builder : & Builder < ' _ > , source : & Path , destination : & Path ) {
2024
+ fn install_llvm_file (
2025
+ builder : & Builder < ' _ > ,
2026
+ source : & Path ,
2027
+ destination : & Path ,
2028
+ install_symlink : bool ,
2029
+ ) {
2025
2030
if builder. config . dry_run ( ) {
2026
2031
return ;
2027
2032
}
2028
2033
2029
- builder. install ( source, destination, 0o644 ) ;
2034
+ if source. is_symlink ( ) {
2035
+ // If we have a symlink like libLLVM-18.so -> libLLVM.so.18.1, install the target of the
2036
+ // symlink, which is what will actually get loaded at runtime.
2037
+ builder. install ( & t ! ( fs:: canonicalize( source) ) , destination, 0o644 ) ;
2038
+ if install_symlink {
2039
+ // If requested, also install the symlink. This is used by download-ci-llvm.
2040
+ let full_dest = destination. join ( source. file_name ( ) . unwrap ( ) ) ;
2041
+ builder. copy ( & source, & full_dest) ;
2042
+ }
2043
+ } else {
2044
+ builder. install ( & source, destination, 0o644 ) ;
2045
+ }
2030
2046
}
2031
2047
2032
2048
/// Maybe add LLVM object files to the given destination lib-dir. Allows either static or dynamic linking.
2033
2049
///
2034
2050
/// Returns whether the files were actually copied.
2035
- fn maybe_install_llvm ( builder : & Builder < ' _ > , target : TargetSelection , dst_libdir : & Path ) -> bool {
2051
+ fn maybe_install_llvm (
2052
+ builder : & Builder < ' _ > ,
2053
+ target : TargetSelection ,
2054
+ dst_libdir : & Path ,
2055
+ install_symlink : bool ,
2056
+ ) -> bool {
2036
2057
// If the LLVM was externally provided, then we don't currently copy
2037
2058
// artifacts into the sysroot. This is not necessarily the right
2038
2059
// choice (in particular, it will require the LLVM dylib to be in
@@ -2081,7 +2102,7 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
2081
2102
} else {
2082
2103
PathBuf :: from ( file)
2083
2104
} ;
2084
- install_llvm_file ( builder, & file, dst_libdir) ;
2105
+ install_llvm_file ( builder, & file, dst_libdir, install_symlink ) ;
2085
2106
}
2086
2107
!builder. config . dry_run ( )
2087
2108
} else {
@@ -2096,7 +2117,7 @@ pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection,
2096
2117
// dynamically linked; it is already included into librustc_llvm
2097
2118
// statically.
2098
2119
if builder. llvm_link_shared ( ) {
2099
- maybe_install_llvm ( builder, target, & dst_libdir) ;
2120
+ maybe_install_llvm ( builder, target, & dst_libdir, false ) ;
2100
2121
}
2101
2122
}
2102
2123
@@ -2108,7 +2129,7 @@ pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection
2108
2129
// dynamically linked; it is already included into librustc_llvm
2109
2130
// statically.
2110
2131
if builder. llvm_link_shared ( ) {
2111
- maybe_install_llvm ( builder, target, & dst_libdir) ;
2132
+ maybe_install_llvm ( builder, target, & dst_libdir, false ) ;
2112
2133
}
2113
2134
}
2114
2135
@@ -2203,6 +2224,8 @@ impl Step for RustDev {
2203
2224
2204
2225
let mut tarball = Tarball :: new ( builder, "rust-dev" , & target. triple ) ;
2205
2226
tarball. set_overlay ( OverlayKind :: LLVM ) ;
2227
+ // LLVM requires a shared object symlink to exist on some platforms.
2228
+ tarball. permit_symlinks ( true ) ;
2206
2229
2207
2230
builder. ensure ( crate :: core:: build_steps:: llvm:: Llvm { target } ) ;
2208
2231
@@ -2243,7 +2266,7 @@ impl Step for RustDev {
2243
2266
// of `rustc-dev` to support the inherited `-lLLVM` when using the
2244
2267
// compiler libraries.
2245
2268
let dst_libdir = tarball. image_dir ( ) . join ( "lib" ) ;
2246
- maybe_install_llvm ( builder, target, & dst_libdir) ;
2269
+ maybe_install_llvm ( builder, target, & dst_libdir, true ) ;
2247
2270
let link_type = if builder. llvm_link_shared ( ) { "dynamic" } else { "static" } ;
2248
2271
t ! ( std:: fs:: write( tarball. image_dir( ) . join( "link-type.txt" ) , link_type) , dst_libdir) ;
2249
2272
0 commit comments