File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-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,29 @@ fn gnu_shared() {
354354 test. cmd ( 0 ) . must_have ( "-shared" ) . must_not_have ( "-static" ) ;
355355}
356356
357+ #[ test]
358+ fn gnu_link_shared ( ) {
359+ reset_env ( ) ;
360+ let test = Test :: gnu ( ) ;
361+
362+ let root_dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
363+ let src = format ! ( "{root_dir}/dev-tools/cc-test/src/foo.c" ) ;
364+ let target = "x86_64-unknown-linux-gnu" ;
365+
366+ cc:: Build :: new ( )
367+ . host ( target)
368+ . target ( target)
369+ . opt_level ( 2 )
370+ . out_dir ( test. td . path ( ) )
371+ . file ( & src)
372+ . shared_flag ( true )
373+ . static_flag ( false )
374+ . link_shared_flag ( true )
375+ . compile ( "foo" ) ;
376+
377+ assert ! ( test. td. path( ) . join( "libfoo.so" ) . exists( ) ) ;
378+ }
379+
357380#[ test]
358381fn gnu_flag_if_supported ( ) {
359382 reset_env ( ) ;
You can’t perform that action at this time.
0 commit comments