File tree 2 files changed +33
-2
lines changed
2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -1434,10 +1434,10 @@ impl Build {
1434
1434
. arg ( dst. join ( dynlib_name) )
1435
1435
. args ( & objects) ;
1436
1436
run ( cmd, & self . cargo_output ) ?;
1437
+ } else {
1438
+ self . assemble ( lib_name, & dst. join ( static_name) , & objects) ?;
1437
1439
}
1438
1440
1439
- self . assemble ( lib_name, & dst. join ( static_name) , & objects) ?;
1440
-
1441
1441
let target = self . get_target ( ) ?;
1442
1442
if target. env == "msvc" {
1443
1443
let compiler = self . get_base_compiler ( ) ?;
Original file line number Diff line number Diff line change @@ -354,6 +354,37 @@ fn gnu_shared() {
354
354
test. cmd ( 0 ) . must_have ( "-shared" ) . must_not_have ( "-static" ) ;
355
355
}
356
356
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
+
357
388
#[ test]
358
389
fn gnu_flag_if_supported ( ) {
359
390
reset_env ( ) ;
You can’t perform that action at this time.
0 commit comments