Skip to content

Conversation

12101111
Copy link
Contributor

@12101111 12101111 commented Mar 16, 2025

Description

Fix #4331

RISC-V 32 don't define __ARCH_WANT_NEW_STAT and __ARCH_WANT_TIME32_SYSCALLS, and it only has time64 syscall.

Sources

https://github.com/torvalds/linux/blob/88d324e69ea9f3ae1c1905ea75d717c08bdb8e15/include/uapi/asm-generic/unistd.h
https://github.com/bminor/musl/blob/c47ad25ea3b484e10326f933e927c0bc8cded3da/include/dlfcn.h
https://github.com/bminor/musl/blob/c47ad25ea3b484e10326f933e927c0bc8cded3da/arch/generic/bits/fcntl.h
https://github.com/bminor/musl/blob/c47ad25ea3b484e10326f933e927c0bc8cded3da/arch/riscv32/bits/signal.h#L77

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI
The test is broken
warning: [email protected]: src/cmsg.c:14:9: warning: comparison of integers of different signs: 'unsigned long' and 'int' [-Wsign-compare]
warning: [email protected]:    14 |         return CMSG_NXTHDR(msgh, cmsg);
warning: [email protected]:       |                ^~~~~~~~~~~~~~~~~~~~~~~
warning: [email protected]: /usr/riscv32-ilp32f-linux-musl/usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR'
warning: [email protected]:   358 |         __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
warning: [email protected]:       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: [email protected]: 1 warning generated.
error: failed to run custom build command for `libc-test v0.1.0 (/home/han/Project/libc/libc-test)`

Caused by:
  process didn't exit successfully: `/var/tmp/rust/debug/build/libc-test-861cdb585a4197af/build-script-build` (signal: 6, SIGABRT: process abort signal)
  --- stdout
  cargo:rerun-if-changed=build.rs
  OUT_DIR = Some(/var/tmp/rust/riscv32imafc-unknown-linux-musl/debug/build/libc-test-51a88f9b6708270e/out)
  OPT_LEVEL = Some(0)
  TARGET = Some(riscv32imafc-unknown-linux-musl)
  HOST = Some(x86_64-unknown-linux-musl)
  cargo:rerun-if-env-changed=CC_riscv32imafc-unknown-linux-musl
  CC_riscv32imafc-unknown-linux-musl = Some(riscv32-ilp32f-linux-musl-cc)
  cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
  CC_KNOWN_WRAPPER_CUSTOM = None
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(true)
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32imafc_unknown_linux_musl
  CFLAGS_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32imafc-unknown-linux-musl
  CFLAGS_riscv32imafc-unknown-linux-musl = None
  CARGO_ENCODED_RUSTFLAGS = Some(-Ctarget-feature=-crt-static-L/usr/riscv32-ilp32f-linux-musl/usr/lib)
  cargo:warning=src/cmsg.c:14:9: warning: comparison of integers of different signs: 'unsigned long' and 'int' [-Wsign-compare]
  cargo:warning=   14 |         return CMSG_NXTHDR(msgh, cmsg);
  cargo:warning=      |                ^~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=/usr/riscv32-ilp32f-linux-musl/usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR'
  cargo:warning=  358 |         __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
  cargo:warning=      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=1 warning generated.
  cargo:rerun-if-env-changed=AR_riscv32imafc-unknown-linux-musl
  AR_riscv32imafc-unknown-linux-musl = None
  cargo:rerun-if-env-changed=AR_riscv32imafc_unknown_linux_musl
  AR_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  RUSTC_LINKER = Some(riscv32-ilp32f-linux-musl-cc)
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv32imafc_unknown_linux_musl
  ARFLAGS_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv32imafc-unknown-linux-musl
  ARFLAGS_riscv32imafc-unknown-linux-musl = None
  cargo:rustc-link-lib=static=cmsg
  cargo:rustc-link-search=native=/var/tmp/rust/riscv32imafc-unknown-linux-musl/debug/build/libc-test-51a88f9b6708270e/out
  OUT_DIR = Some(/var/tmp/rust/riscv32imafc-unknown-linux-musl/debug/build/libc-test-51a88f9b6708270e/out)
  OPT_LEVEL = Some(0)
  TARGET = Some(riscv32imafc-unknown-linux-musl)
  HOST = Some(x86_64-unknown-linux-musl)
  cargo:rerun-if-env-changed=CC_riscv32imafc-unknown-linux-musl
  CC_riscv32imafc-unknown-linux-musl = Some(riscv32-ilp32f-linux-musl-cc)
  cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
  CC_KNOWN_WRAPPER_CUSTOM = None
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(true)
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32imafc_unknown_linux_musl
  CFLAGS_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32imafc-unknown-linux-musl
  CFLAGS_riscv32imafc-unknown-linux-musl = None
  CARGO_ENCODED_RUSTFLAGS = Some(-Ctarget-feature=-crt-static-L/usr/riscv32-ilp32f-linux-musl/usr/lib)
  cargo:rerun-if-env-changed=AR_riscv32imafc-unknown-linux-musl
  AR_riscv32imafc-unknown-linux-musl = None
  cargo:rerun-if-env-changed=AR_riscv32imafc_unknown_linux_musl
  AR_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  RUSTC_LINKER = Some(riscv32-ilp32f-linux-musl-cc)
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv32imafc_unknown_linux_musl
  ARFLAGS_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv32imafc-unknown-linux-musl
  ARFLAGS_riscv32imafc-unknown-linux-musl = None
  cargo:rustc-link-lib=static=makedev
  cargo:rustc-link-search=native=/var/tmp/rust/riscv32imafc-unknown-linux-musl/debug/build/libc-test-51a88f9b6708270e/out
  OUT_DIR = Some(/var/tmp/rust/riscv32imafc-unknown-linux-musl/debug/build/libc-test-51a88f9b6708270e/out)
  OPT_LEVEL = Some(0)
  TARGET = Some(riscv32imafc-unknown-linux-musl)
  HOST = Some(x86_64-unknown-linux-musl)
  cargo:rerun-if-env-changed=CC_riscv32imafc-unknown-linux-musl
  CC_riscv32imafc-unknown-linux-musl = Some(riscv32-ilp32f-linux-musl-cc)
  cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
  CC_KNOWN_WRAPPER_CUSTOM = None
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(true)
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32imafc_unknown_linux_musl
  CFLAGS_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32imafc-unknown-linux-musl
  CFLAGS_riscv32imafc-unknown-linux-musl = None
  CARGO_ENCODED_RUSTFLAGS = Some(-Ctarget-feature=-crt-static-L/usr/riscv32-ilp32f-linux-musl/usr/lib)
  cargo:rerun-if-env-changed=AR_riscv32imafc-unknown-linux-musl
  AR_riscv32imafc-unknown-linux-musl = None
  cargo:rerun-if-env-changed=AR_riscv32imafc_unknown_linux_musl
  AR_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  RUSTC_LINKER = Some(riscv32-ilp32f-linux-musl-cc)
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv32imafc_unknown_linux_musl
  ARFLAGS_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv32imafc-unknown-linux-musl
  ARFLAGS_riscv32imafc-unknown-linux-musl = None
  cargo:rustc-link-lib=static=errqueue
  cargo:rustc-link-search=native=/var/tmp/rust/riscv32imafc-unknown-linux-musl/debug/build/libc-test-51a88f9b6708270e/out
  OUT_DIR = Some(/var/tmp/rust/riscv32imafc-unknown-linux-musl/debug/build/libc-test-51a88f9b6708270e/out)
  OPT_LEVEL = Some(0)
  TARGET = Some(riscv32imafc-unknown-linux-musl)
  HOST = Some(x86_64-unknown-linux-musl)
  cargo:rerun-if-env-changed=CC_riscv32imafc-unknown-linux-musl
  CC_riscv32imafc-unknown-linux-musl = Some(riscv32-ilp32f-linux-musl-cc)
  cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
  CC_KNOWN_WRAPPER_CUSTOM = None
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(true)
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32imafc_unknown_linux_musl
  CFLAGS_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32imafc-unknown-linux-musl
  CFLAGS_riscv32imafc-unknown-linux-musl = None
  CARGO_ENCODED_RUSTFLAGS = Some(-Ctarget-feature=-crt-static-L/usr/riscv32-ilp32f-linux-musl/usr/lib)
  cargo:rerun-if-env-changed=AR_riscv32imafc-unknown-linux-musl
  AR_riscv32imafc-unknown-linux-musl = None
  cargo:rerun-if-env-changed=AR_riscv32imafc_unknown_linux_musl
  AR_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  RUSTC_LINKER = Some(riscv32-ilp32f-linux-musl-cc)
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv32imafc_unknown_linux_musl
  ARFLAGS_riscv32imafc_unknown_linux_musl = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv32imafc-unknown-linux-musl
  ARFLAGS_riscv32imafc-unknown-linux-musl = None
  cargo:rustc-link-lib=static=sigrt
  cargo:rustc-link-search=native=/var/tmp/rust/riscv32imafc-unknown-linux-musl/debug/build/libc-test-51a88f9b6708270e/out

  --- stderr

  thread 'main' panicked at library/core/src/panicking.rs:218:5:
  unsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice

  This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/f4a216d28ee635afce685b4206e713579f66e130/library/std/src/panicking.rs:695:5
     1: core::panicking::panic_nounwind_fmt::runtime
               at /rustc/f4a216d28ee635afce685b4206e713579f66e130/library/core/src/panicking.rs:117:22
     2: core::panicking::panic_nounwind_fmt
               at /rustc/f4a216d28ee635afce685b4206e713579f66e130/library/core/src/intrinsics/mod.rs:3089:9
     3: core::panicking::panic_nounwind
               at /rustc/f4a216d28ee635afce685b4206e713579f66e130/library/core/src/panicking.rs:218:5
     4: <usize as core::slice::index::SliceIndex<[T]>>::get_unchecked::precondition_check
               at /home/han/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/src/rust/library/core/src/ub_checks.rs:68:21
     5: <usize as core::slice::index::SliceIndex<[T]>>::get_unchecked
               at /home/han/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/src/rust/library/core/src/ub_checks.rs:75:17
     6: core::slice::<impl [T]>::get_unchecked
               at /home/han/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/src/rust/library/core/src/slice/mod.rs:663:20
     7: <alloc::vec::Vec<T> as garando_syntax::util::move_map::MoveMap<T>>::move_flat_map
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/garando_syntax-0.1.0/src/util/move_map.rs:32:35
     8: garando_syntax::fold::fold_attrs
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/garando_syntax-0.1.0/src/fold.rs:329:5
     9: garando_syntax::fold::noop_fold_item_simple
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/garando_syntax-0.1.0/src/fold.rs:1111:16
    10: garando_syntax::fold::Folder::fold_item_simple
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/garando_syntax-0.1.0/src/fold.rs:62:9
    11: garando_syntax::fold::noop_fold_item::{{closure}}
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/garando_syntax-0.1.0/src/fold.rs:1092:32
    12: garando_syntax::ptr::P<T>::map
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/garando_syntax-0.1.0/src/ptr.rs:80:27
    13: garando_syntax::fold::noop_fold_item
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/garando_syntax-0.1.0/src/fold.rs:1092:22
    14: <ctest2::StripUnchecked as garando_syntax::fold::Folder>::fold_item
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ctest2-0.4.10/src/lib.rs:2513:43
    15: garando_syntax::fold::noop_fold_crate
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/garando_syntax-0.1.0/src/fold.rs:1045:21
    16: garando_syntax::fold::Folder::fold_crate
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/garando_syntax-0.1.0/src/fold.rs:34:9
    17: ctest2::TestGenerator::_generate_files
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ctest2-0.4.10/src/lib.rs:903:21
    18: ctest2::TestGenerator::generate_files
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ctest2-0.4.10/src/lib.rs:871:9
    19: ctest2::TestGenerator::_generate
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ctest2-0.4.10/src/lib.rs:807:19
    20: ctest2::TestGenerator::generate
               at /home/han/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ctest2-0.4.10/src/lib.rs:803:9
    21: build_script_build::test_linux
               at ./build.rs:4763:5
    22: build_script_build::do_ctest
               at ./build.rs:61:44
    23: build_script_build::main
               at ./build.rs:166:5
    24: core::ops::function::FnOnce::call_once
               at /home/han/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
  thread caused non-unwinding panic. aborting.

Wait #4283 for fix of test

@rustbot
Copy link
Collaborator

rustbot commented Mar 16, 2025

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@tgross35
Copy link
Contributor

Has it always been this way, or did this change with musl 1.2's change to 64-bit time_t? Unfortunately we haven't yet updated to 1.2, see #3791 and related PRs/issues

@12101111
Copy link
Contributor Author

musl land the support of riscv32 in 1.2.5
bminor/musl@01d9fe4

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thanks for the fixes!

@rustbot label +stable-nominated

@rustbot rustbot added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Mar 22, 2025
@tgross35 tgross35 added this pull request to the merge queue Mar 22, 2025
Merged via the queue into rust-lang:main with commit f5105c6 Mar 22, 2025
43 checks passed
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Apr 3, 2025
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Apr 3, 2025
(backport <rust-lang#4335>)
(cherry picked from commit 9f7b63f)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Apr 3, 2025
(backport <rust-lang#4335>)
(cherry picked from commit 5c778ef)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Apr 3, 2025
@tgross35 tgross35 mentioned this pull request Apr 3, 2025
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-linux O-musl O-riscv O-unix S-waiting-on-review stable-applied This PR has been cherry-picked to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RISC-V 32 Linux Don't have SYS_futex
3 participants