@@ -3648,15 +3648,20 @@ fn test_linux(target: &str) {
36483648 let x32 = target. contains ( "x32" ) ;
36493649 let x86_32 = target. contains ( "i686" ) ;
36503650 let x86_64 = target. contains ( "x86_64" ) ;
3651- let aarch64_musl = aarch64 && musl;
36523651 let gnueabihf = target. contains ( "gnueabihf" ) ;
36533652 let x86_64_gnux32 = target. contains ( "gnux32" ) && x86_64;
36543653 let riscv64 = target. contains ( "riscv64" ) ;
36553654 let loongarch64 = target. contains ( "loongarch64" ) ;
36563655 let wasm32 = target. contains ( "wasm32" ) ;
36573656 let uclibc = target. contains ( "uclibc" ) ;
36583657
3658+ let musl_v1_2_3 = env:: var ( "RUST_LIBC_UNSTABLE_MUSL_V1_2_3" ) . is_ok ( ) ;
3659+ let old_musl = musl && !musl_v1_2_3;
3660+
36593661 let mut cfg = ctest_cfg ( ) ;
3662+ if musl_v1_2_3 {
3663+ cfg. cfg ( "musl_v1_2_3" , None ) ;
3664+ }
36603665 cfg. define ( "_GNU_SOURCE" , None ) ;
36613666 // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are
36623667 // deprecated since glibc >= 2.29. This allows Rust binaries to link against
@@ -4125,6 +4130,9 @@ fn test_linux(target: &str) {
41254130 // FIXME(linux): Requires >= 6.4 kernel headers.
41264131 "ptrace_sud_config" => true ,
41274132
4133+ // Struct has changed for new musl versions
4134+ "tcp_info" if old_musl => true ,
4135+
41284136 _ => false ,
41294137 }
41304138 } ) ;
@@ -4226,9 +4234,9 @@ fn test_linux(target: &str) {
42264234 if name == "PR_GET_MDWE" || name == "PR_MDWE_NO_INHERIT" || name == "PR_MDWE_REFUSE_EXEC_GAIN" || name == "PR_SET_MDWE" {
42274235 return true ;
42284236 }
4229- // FIXME(musl): Requires musl >= 1.2
4230- if name == "SO_PREFER_BUSY_POLL"
4231- || name == "SO_BUSY_POLL_BUDGET"
4237+ // Requires musl >= 1.2
4238+ if old_musl && ( name == "SO_PREFER_BUSY_POLL"
4239+ || name == "SO_BUSY_POLL_BUDGET" )
42324240 {
42334241 return true ;
42344242 }
@@ -4252,6 +4260,14 @@ fn test_linux(target: &str) {
42524260 {
42534261 return true ;
42544262 }
4263+ // Values changed in newer musl versions on these arches
4264+ if old_musl && ( riscv64 || x86_64) && name == "O_LARGEFILE" {
4265+ return true ;
4266+ }
4267+ // Values changed in newer musl versions
4268+ if old_musl && name == "RLIM_NLIMITS" {
4269+ return true ;
4270+ }
42554271 }
42564272 match name {
42574273 // These constants are not available if gnu headers have been included
@@ -4657,18 +4673,18 @@ fn test_linux(target: &str) {
46574673 "getnameinfo" if uclibc => true ,
46584674
46594675 // FIXME(musl): This needs musl 1.2.2 or later.
4660- "gettid" if musl => true ,
4676+ "gettid" if old_musl => true ,
46614677
46624678 // Needs glibc 2.33 or later.
46634679 "mallinfo2" => true ,
46644680
4665- "reallocarray" if musl => true ,
4681+ "reallocarray" if old_musl => true ,
46664682
46674683 // Not defined in uclibc as of 1.0.34
46684684 "gettid" if uclibc => true ,
46694685
46704686 // Needs musl 1.2.3 or later.
4671- "pthread_getname_np" if musl => true ,
4687+ "pthread_getname_np" if old_musl => true ,
46724688
46734689 // pthread_sigqueue uses sigval, which was initially declared
46744690 // as a struct but should be defined as a union. However due
@@ -4762,8 +4778,8 @@ fn test_linux(target: &str) {
47624778 "sched_ss_init_budget" ,
47634779 "sched_ss_max_repl" ,
47644780 ] . contains ( & field) && musl) ||
4765- // FIXME(musl): After musl 1.1.24, the type becomes `int` instead of `unsigned short`.
4766- ( struct_ == "ipc_perm" && field == "__seq" && aarch64_musl ) ||
4781+ // After musl 1.1.24, the type becomes `int` instead of `unsigned short`.
4782+ ( struct_ == "ipc_perm" && field == "__seq" && old_musl && aarch64 ) ||
47674783 // glibc uses unnamed fields here and Rust doesn't support that yet
47684784 ( struct_ == "timex" && field. starts_with ( "__unused" ) ) ||
47694785 // FIXME(linux): It now takes mode_t since glibc 2.31 on some targets.
@@ -4812,8 +4828,8 @@ fn test_linux(target: &str) {
48124828 ( struct_ == "statvfs64" && field == "__f_spare" ) ||
48134829 // the `xsk_tx_metadata_union` field is an anonymous union
48144830 ( struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union" ) ||
4815- // FIXME(musl): After musl 1.2.0, the type becomes `int` instead of `long`.
4816- ( struct_ == "utmpx" && field == "ut_session" )
4831+ // After musl 1.2.0, the type becomes `int` instead of `long`.
4832+ ( old_musl && struct_ == "utmpx" && field == "ut_session" )
48174833 } ) ;
48184834
48194835 cfg. skip_roundtrip ( move |s| match s {
0 commit comments