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