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