File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -1434,10 +1434,10 @@ impl Build {
14341434 . arg ( dst. join ( dynlib_name) )
14351435 . args ( & objects) ;
14361436 run ( cmd, & self . cargo_output ) ?;
1437+ } else {
1438+ self . assemble ( lib_name, & dst. join ( static_name) , & objects) ?;
14371439 }
14381440
1439- self . assemble ( lib_name, & dst. join ( static_name) , & objects) ?;
1440-
14411441 let target = self . get_target ( ) ?;
14421442 if target. env == "msvc" {
14431443 let compiler = self . get_base_compiler ( ) ?;
Original file line number Diff line number Diff line change @@ -354,6 +354,37 @@ fn gnu_shared() {
354354 test. cmd ( 0 ) . must_have ( "-shared" ) . must_not_have ( "-static" ) ;
355355}
356356
357+ #[ test]
358+ #[ cfg( target_os = "linux" ) ]
359+ fn gnu_link_shared ( ) {
360+ use std:: process:: Command ;
361+
362+ let output = Command :: new ( "rustc" ) . arg ( "-vV" ) . output ( ) . unwrap ( ) ;
363+ let stdout_buf = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
364+ let target = stdout_buf
365+ . lines ( )
366+ . find_map ( |l| l. strip_prefix ( "host: " ) )
367+ . unwrap ( ) ;
368+
369+ reset_env ( ) ;
370+ let test = Test :: gnu ( ) ;
371+ let root_dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
372+ let src = format ! ( "{root_dir}/dev-tools/cc-test/src/foo.c" ) ;
373+
374+ cc:: Build :: new ( )
375+ . host ( target)
376+ . target ( target)
377+ . opt_level ( 2 )
378+ . out_dir ( test. td . path ( ) )
379+ . file ( & src)
380+ . shared_flag ( true )
381+ . static_flag ( false )
382+ . link_shared_flag ( true )
383+ . compile ( "foo" ) ;
384+
385+ assert ! ( test. td. path( ) . join( "libfoo.so" ) . exists( ) ) ;
386+ }
387+
357388#[ test]
358389fn gnu_flag_if_supported ( ) {
359390 reset_env ( ) ;
You can’t perform that action at this time.
0 commit comments