@@ -2021,12 +2021,7 @@ fn add_env(builder: &Builder<'_>, cmd: &mut Command, target: TargetSelection) {
2021
2021
}
2022
2022
}
2023
2023
2024
- fn install_llvm_file (
2025
- builder : & Builder < ' _ > ,
2026
- source : & Path ,
2027
- destination : & Path ,
2028
- install_symlink : bool ,
2029
- ) {
2024
+ fn install_llvm_file ( builder : & Builder < ' _ > , source : & Path , destination : & Path ) {
2030
2025
if builder. config . dry_run ( ) {
2031
2026
return ;
2032
2027
}
@@ -2035,11 +2030,15 @@ fn install_llvm_file(
2035
2030
// If we have a symlink like libLLVM-18.so -> libLLVM.so.18.1, install the target of the
2036
2031
// symlink, which is what will actually get loaded at runtime.
2037
2032
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
- }
2033
+
2034
+ // Replace the symlink itself with an equivalent linker script. This is used by
2035
+ // download-ci-llvm and projects linking against librustc_driver.so. We don't use a
2036
+ // symlink, as these are not allowed inside rustup components.
2037
+ let link = t ! ( fs:: read_link( source) ) ;
2038
+ t ! ( std:: fs:: write(
2039
+ destination. join( source. file_name( ) . unwrap( ) ) ,
2040
+ format!( "INPUT({})" , link. display( ) )
2041
+ ) ) ;
2043
2042
} else {
2044
2043
builder. install ( & source, destination, 0o644 ) ;
2045
2044
}
@@ -2048,12 +2047,7 @@ fn install_llvm_file(
2048
2047
/// Maybe add LLVM object files to the given destination lib-dir. Allows either static or dynamic linking.
2049
2048
///
2050
2049
/// Returns whether the files were actually copied.
2051
- fn maybe_install_llvm (
2052
- builder : & Builder < ' _ > ,
2053
- target : TargetSelection ,
2054
- dst_libdir : & Path ,
2055
- install_symlink : bool ,
2056
- ) -> bool {
2050
+ fn maybe_install_llvm ( builder : & Builder < ' _ > , target : TargetSelection , dst_libdir : & Path ) -> bool {
2057
2051
// If the LLVM was externally provided, then we don't currently copy
2058
2052
// artifacts into the sysroot. This is not necessarily the right
2059
2053
// choice (in particular, it will require the LLVM dylib to be in
@@ -2102,7 +2096,7 @@ fn maybe_install_llvm(
2102
2096
} else {
2103
2097
PathBuf :: from ( file)
2104
2098
} ;
2105
- install_llvm_file ( builder, & file, dst_libdir, install_symlink ) ;
2099
+ install_llvm_file ( builder, & file, dst_libdir) ;
2106
2100
}
2107
2101
!builder. config . dry_run ( )
2108
2102
} else {
@@ -2117,7 +2111,7 @@ pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection,
2117
2111
// dynamically linked; it is already included into librustc_llvm
2118
2112
// statically.
2119
2113
if builder. llvm_link_shared ( ) {
2120
- maybe_install_llvm ( builder, target, & dst_libdir, false ) ;
2114
+ maybe_install_llvm ( builder, target, & dst_libdir) ;
2121
2115
}
2122
2116
}
2123
2117
@@ -2129,7 +2123,7 @@ pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection
2129
2123
// dynamically linked; it is already included into librustc_llvm
2130
2124
// statically.
2131
2125
if builder. llvm_link_shared ( ) {
2132
- maybe_install_llvm ( builder, target, & dst_libdir, false ) ;
2126
+ maybe_install_llvm ( builder, target, & dst_libdir) ;
2133
2127
}
2134
2128
}
2135
2129
@@ -2224,8 +2218,6 @@ impl Step for RustDev {
2224
2218
2225
2219
let mut tarball = Tarball :: new ( builder, "rust-dev" , & target. triple ) ;
2226
2220
tarball. set_overlay ( OverlayKind :: LLVM ) ;
2227
- // LLVM requires a shared object symlink to exist on some platforms.
2228
- tarball. permit_symlinks ( true ) ;
2229
2221
2230
2222
builder. ensure ( crate :: core:: build_steps:: llvm:: Llvm { target } ) ;
2231
2223
@@ -2266,7 +2258,7 @@ impl Step for RustDev {
2266
2258
// of `rustc-dev` to support the inherited `-lLLVM` when using the
2267
2259
// compiler libraries.
2268
2260
let dst_libdir = tarball. image_dir ( ) . join ( "lib" ) ;
2269
- maybe_install_llvm ( builder, target, & dst_libdir, true ) ;
2261
+ maybe_install_llvm ( builder, target, & dst_libdir) ;
2270
2262
let link_type = if builder. llvm_link_shared ( ) { "dynamic" } else { "static" } ;
2271
2263
t ! ( std:: fs:: write( tarball. image_dir( ) . join( "link-type.txt" ) , link_type) , dst_libdir) ;
2272
2264
0 commit comments