@@ -51,6 +51,35 @@ impl GccOutput {
5151 t ! ( fs:: create_dir_all( & dest_dir) ) ;
5252 let dst = dest_dir. join ( target_filename) ;
5353 builder. copy_link ( & actual_libgccjit_path, & dst, FileType :: NativeLibrary ) ;
54+
55+ if let Some ( ref path) = builder. config . libgccjit_libs_dir {
56+ let host_target = builder. config . host_target . triple ;
57+
58+ let source = path. join ( host_target) ;
59+ let dst = directory;
60+
61+ let targets = builder. config . targets . iter ( )
62+ . map ( |target| target. triple )
63+ . chain ( std:: iter:: once ( host_target) ) ;
64+
65+ for target in targets {
66+ let source = source. join ( target) . join ( & target_filename) ;
67+ // To support symlinks in libgccjit-libs-dir, we have to resolve it first,
68+ // otherwise we'd create a symlink to a symlink, which wouldn't work.
69+ let actual_libgccjit_path = t ! (
70+ source. canonicalize( ) ,
71+ format!( "Cannot find libgccjit at {}" , self . libgccjit. display( ) )
72+ ) ;
73+ let target_dir = dst. join ( target) ;
74+ t ! (
75+ std:: fs:: create_dir_all( & target_dir) ,
76+ format!( "Cannot create target dir {} for libgccjit" , target_dir. display( ) )
77+ ) ;
78+ let dst = target_dir. join ( & target_filename) ;
79+ builder. copy_link ( & actual_libgccjit_path, & dst, FileType :: NativeLibrary ) ;
80+ }
81+ }
82+
5483 }
5584}
5685
0 commit comments