@@ -1885,6 +1885,34 @@ impl Step for HashSign {
1885
1885
}
1886
1886
}
1887
1887
1888
+ // Maybe add libLLVM.so to the lib-dir. It will only have been built if
1889
+ // LLVM tools are linked dynamically.
1890
+ // Note: This function does no yet support Windows but we also don't support
1891
+ // linking LLVM tools dynamically on Windows yet.
1892
+ fn maybe_install_llvm_dylib ( builder : & Builder ,
1893
+ target : Interned < String > ,
1894
+ image : & Path ) {
1895
+ let src_libdir = builder
1896
+ . llvm_out ( target)
1897
+ . join ( "lib" ) ;
1898
+
1899
+ // Usually libLLVM.so is a symlink to something like libLLVM-6.0.so.
1900
+ // Since tools link to the latter rather than the former, we have to
1901
+ // follow the symlink to find out what to distribute.
1902
+ let llvm_dylib_path = src_libdir. join ( "libLLVM.so" ) ;
1903
+ if llvm_dylib_path. exists ( ) {
1904
+ let llvm_dylib_path = llvm_dylib_path. canonicalize ( ) . unwrap_or_else ( |e| {
1905
+ panic ! ( "dist: Error calling canonicalize path `{}`: {}" ,
1906
+ llvm_dylib_path. display( ) , e) ;
1907
+ } ) ;
1908
+
1909
+ let dst_libdir = image. join ( "lib" ) ;
1910
+ t ! ( fs:: create_dir_all( & dst_libdir) ) ;
1911
+
1912
+ builder. install ( & llvm_dylib_path, & dst_libdir, 0o644 ) ;
1913
+ }
1914
+ }
1915
+
1888
1916
#[ derive( Clone , Debug , Eq , Hash , PartialEq ) ]
1889
1917
pub struct LlvmTools {
1890
1918
pub stage : u32 ,
@@ -1929,18 +1957,18 @@ impl Step for LlvmTools {
1929
1957
drop ( fs:: remove_dir_all ( & image) ) ;
1930
1958
1931
1959
// Prepare the image directory
1932
- let bindir = builder
1960
+ let src_bindir = builder
1933
1961
. llvm_out ( target)
1934
1962
. join ( "bin" ) ;
1935
- let dst = image. join ( "lib/rustlib" )
1936
- . join ( target)
1937
- . join ( "bin" ) ;
1938
- t ! ( fs:: create_dir_all( & dst) ) ;
1963
+ let dst_bindir = image. join ( "bin" ) ;
1964
+ t ! ( fs:: create_dir_all( & dst_bindir) ) ;
1939
1965
for tool in LLVM_TOOLS {
1940
- let exe = bindir . join ( exe ( tool, & target) ) ;
1941
- builder. install ( & exe, & dst , 0o755 ) ;
1966
+ let exe = src_bindir . join ( exe ( tool, & target) ) ;
1967
+ builder. install ( & exe, & dst_bindir , 0o755 ) ;
1942
1968
}
1943
1969
1970
+ maybe_install_llvm_dylib ( builder, target, & image) ;
1971
+
1944
1972
// Prepare the overlay
1945
1973
let overlay = tmp. join ( "llvm-tools-overlay" ) ;
1946
1974
drop ( fs:: remove_dir_all ( & overlay) ) ;
@@ -2025,7 +2053,6 @@ impl Step for Lldb {
2025
2053
let dst = image. join ( "lib" ) ;
2026
2054
t ! ( fs:: create_dir_all( & dst) ) ;
2027
2055
for entry in t ! ( fs:: read_dir( & libdir) ) {
2028
- // let entry = t!(entry);
2029
2056
let entry = entry. unwrap ( ) ;
2030
2057
if let Ok ( name) = entry. file_name ( ) . into_string ( ) {
2031
2058
if name. starts_with ( "liblldb." ) && !name. ends_with ( ".a" ) {
@@ -2060,6 +2087,9 @@ impl Step for Lldb {
2060
2087
}
2061
2088
}
2062
2089
2090
+ // Copy libLLVM.so to the lib dir as well, if needed.
2091
+ maybe_install_llvm_dylib ( builder, target, & image) ;
2092
+
2063
2093
// Prepare the overlay
2064
2094
let overlay = tmp. join ( "lldb-overlay" ) ;
2065
2095
drop ( fs:: remove_dir_all ( & overlay) ) ;
0 commit comments