@@ -493,14 +493,11 @@ mod c {
493493 // sets of flags to the same source file.
494494 let src_dir = root. join ( "lib/builtins" ) ;
495495 if target_arch == "aarch64" {
496- let atomics_libs = build_aarch64_out_of_line_atomics_libraries ( & src_dir, cfg) ;
497- if !atomics_libs. is_empty ( ) {
498- for library in atomics_libs {
499- cfg. object ( library) ;
500- }
501- // Some run-time CPU feature detection is necessary, as well.
502- sources. extend ( & [ ( "__aarch64_have_lse_atomics" , "cpu_model.c" ) ] ) ;
503- }
496+ // See below for why we're building these as separate libraries.
497+ build_aarch64_out_of_line_atomics_libraries ( & src_dir, cfg) ;
498+
499+ // Some run-time CPU feature detection is necessary, as well.
500+ sources. extend ( & [ ( "__aarch64_have_lse_atomics" , "cpu_model.c" ) ] ) ;
504501 }
505502
506503 for ( sym, src) in sources. map . iter ( ) {
@@ -513,10 +510,7 @@ mod c {
513510 cfg. compile ( "libcompiler-rt.a" ) ;
514511 }
515512
516- fn build_aarch64_out_of_line_atomics_libraries (
517- builtins_dir : & Path ,
518- cfg : & cc:: Build ,
519- ) -> Vec < PathBuf > {
513+ fn build_aarch64_out_of_line_atomics_libraries ( builtins_dir : & Path , cfg : & cc:: Build ) {
520514 // NOTE: because we're recompiling the same source file in N different ways, building
521515 // serially is necessary. If we want to lift this restriction, we can either:
522516 // - create symlinks to lse.S and build those_(though we'd still need to pass special
@@ -528,11 +522,8 @@ mod c {
528522 let outlined_atomics_file = builtins_dir. join ( "aarch64/lse.S" ) ;
529523 println ! ( "cargo:rerun-if-changed={}" , outlined_atomics_file. display( ) ) ;
530524
531- let out_dir: PathBuf = env:: var ( "OUT_DIR" ) . unwrap ( ) . into ( ) ;
532-
533525 // Ideally, this would be a Vec of object files, but cc doesn't make it *entirely*
534526 // trivial to build an individual object.
535- let mut atomics_libraries = Vec :: new ( ) ;
536527 for instruction_type in & [ "cas" , "swp" , "ldadd" , "ldclr" , "ldeor" , "ldset" ] {
537528 for size in & [ 1 , 2 , 4 , 8 , 16 ] {
538529 if * size == 16 && * instruction_type != "cas" {
@@ -556,11 +547,9 @@ mod c {
556547 . file ( & outlined_atomics_file) ;
557548 cfg. compile ( & library_name) ;
558549
559- atomics_libraries. push ( out_dir. join ( library_name) ) ;
560550 println ! ( "cargo:rustc-cfg={}=\" optimized-c\" " , sym) ;
561551 }
562552 }
563553 }
564- atomics_libraries
565554 }
566555}
0 commit comments