Skip to content

Conversation

@taiki-e
Copy link
Owner

@taiki-e taiki-e commented Nov 4, 2024

Of the CPU architectures supported by Rust, this is the last architectures not supported by this crate.

The build passed, but has not yet been tested. The qemu binary mentioned on the platform support docs does not work with even a minimal program due to the following error: UPDATE: See #32 (comment)

qemu: 0x00009ab4: unhandled CPU                 exception 0x4 - aborting
qemu:handle_cpu_signal received signal outside vCPU context @ pc=0x7f16efded943

TODO: ldex/stex is ck860* only? #32 (comment) UPDATE: See #32 (comment)

@Dirreke
Copy link

Dirreke commented Sep 27, 2025

Ideally, I'd like to run a full test suite by ./tools/test.sh, but for now, it's not working due to the following build error.

I've been a bit busy recently, so I may not have looked into it very thoroughly. However, my initial investigation suggests the compilation error originates from the quickcheck crate, and I see a similar failure when running ./tools/test.sh with +crt-static enabled for ARMv7.

@taiki-e taiki-e force-pushed the csky branch 9 times, most recently from d3fb6a3 to 205bc81 Compare October 4, 2025 11:42
@taiki-e
Copy link
Owner Author

taiki-e commented Oct 4, 2025

However, my initial investigation suggests the compilation error originates from the quickcheck crate, and I see a similar failure when running ./tools/test.sh with +crt-static enabled for ARMv7.

Thanks for the investigation! I'm not sure why, but quickcheck indeed to be related, disabling quickcheck-related tests allowed the full test suite to build.

In multi-threaded tests, hangs or the following assertion failures in glibc or pthread occur (can be reproduced without this crate's atomics). Considering the discussion in rust-lang/rust#117306 that libatomic is broken and likely causing data races, this is an understandable result.

pthread_mutex_lock.c:79: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed.
arena.c:960: __malloc_arena_thread_freeres: Assertion `a->attached_threads > 0' failed.

As for the issue that QEMU cannot run tests using ldex/stex when non-ck860 CPU is specified (#32 (comment)), looking at the Linux kernel code, only ck860 set CPU_HAS_LDSTEX, so it seems QEMU is correct here.

https://github.com/torvalds/linux/blob/cbf33b8e0b360f667b17106c15d9e2aac77a76a1/arch/csky/Kconfig#L200-L215

config CPU_CK810
	bool "CSKY CPU ck810"
	select CPU_HAS_HILO
	select CPU_NEED_TLBSYNC

config CPU_CK807
	bool "CSKY CPU ck807"
	select CPU_HAS_HILO

config CPU_CK860
	bool "CSKY CPU ck860"
	select CPU_HAS_TLBI
	select CPU_HAS_CACHEV2
	select CPU_HAS_LDSTEX
	select CPU_HAS_FPUV2

Updated PR to check the -C target-cpu and target's default cpu, and enabling CAS/RMW which requires ldex/stex only on ck860*. (It would be better if LLVM and rustc had a target feature for this purpose.)

@taiki-e taiki-e force-pushed the csky branch 4 times, most recently from be1fabe to 3b18848 Compare October 4, 2025 13:16
@taiki-e
Copy link
Owner Author

taiki-e commented Oct 4, 2025

As for "multiple definition of `__lll_lock_wait_private'" error, it maybe related to https://sourceware.org/bugzilla/show_bug.cgi?id=15648 that was fixed in glibc 2.34.

@taiki-e taiki-e force-pushed the csky branch 5 times, most recently from 79592ad to 1f75c5f Compare October 4, 2025 16:57
@taiki-e
Copy link
Owner Author

taiki-e commented Oct 4, 2025

Ideally, I'd like to run a full test suite by ./tools/test.sh, but for now, it's not working due to the following build error.

However, my initial investigation suggests the compilation error originates from the quickcheck crate, and I see a similar failure when running ./tools/test.sh with +crt-static enabled for ARMv7.

Thanks for the investigation! I'm not sure why, but quickcheck indeed to be related, disabling quickcheck-related tests allowed the full test suite to build.

This has been resolved by applying a patch to quickcheck that uses fastrand instead of rand.

@taiki-e taiki-e merged commit a1b4a22 into main Oct 5, 2025
113 checks passed
@taiki-e taiki-e deleted the csky branch October 5, 2025 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-csky Target: C-SKY processors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants