@@ -209,6 +209,14 @@ fn build(target_os: &str) -> io::Result<()> {
209
209
// The cc crate has the messy logic of guessing a working prefix,
210
210
// and this is a messy way of reusing that logic.
211
211
let cc = cc:: Build :: new ( ) ;
212
+
213
+ // Apple-clang needs this, -arch is not enough.
214
+ let target_flag = format ! ( "--target={}" , target) ;
215
+ if cc. is_flag_supported ( & target_flag) . unwrap_or ( false ) {
216
+ configure. arg ( format ! ( "--extra-cflags={}" , target_flag) ) ;
217
+ configure. arg ( format ! ( "--extra-ldflags={}" , target_flag) ) ;
218
+ }
219
+
212
220
let compiler = cc. get_compiler ( ) ;
213
221
let compiler = compiler. path ( ) . file_stem ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
214
222
if let Some ( suffix_pos) = compiler. rfind ( '-' ) {
@@ -340,6 +348,8 @@ fn build(target_os: &str) -> io::Result<()> {
340
348
// configure misc build options
341
349
enable ! ( configure, "BUILD_PIC" , "pic" ) ;
342
350
351
+ println ! ( "configure cmd: {:?}" , configure) ;
352
+
343
353
// run ./configure
344
354
let output = configure
345
355
. output ( )
@@ -654,11 +664,11 @@ fn main() {
654
664
"cargo:rustc-link-search=native={}" ,
655
665
search( ) . join( "lib" ) . to_string_lossy( )
656
666
) ;
657
- link_to_libraries ( statik, & target_os) ;
667
+ link_to_libraries ( statik, target_os) ;
658
668
if fs:: metadata ( & search ( ) . join ( "lib" ) . join ( "libavutil.a" ) ) . is_err ( ) {
659
669
fs:: create_dir_all ( & output ( ) ) . expect ( "failed to create build directory" ) ;
660
670
fetch ( ) . unwrap ( ) ;
661
- build ( & target_os) . unwrap ( ) ;
671
+ build ( target_os) . unwrap ( ) ;
662
672
}
663
673
664
674
// Check additional required libraries.
@@ -691,7 +701,7 @@ fn main() {
691
701
"cargo:rustc-link-search=native={}" ,
692
702
ffmpeg_dir. join( "lib" ) . to_string_lossy( )
693
703
) ;
694
- link_to_libraries ( statik, & target_os) ;
704
+ link_to_libraries ( statik, target_os) ;
695
705
vec ! [ ffmpeg_dir. join( "include" ) ]
696
706
} else if let Some ( paths) = try_vcpkg ( statik) {
697
707
// vcpkg doesn't detect the "system" dependencies
0 commit comments