Skip to content

loongarch64: error[E0425]: cannot find value MADV_SOFT_OFFLINE in module c #1461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
strophy opened this issue May 6, 2025 · 2 comments
Open

Comments

@strophy
Copy link

strophy commented May 6, 2025

I'm attempting to add loongarch64 support to the https://github.com/bytecodealliance/wasmtime package under Alpine Linux 3.21. rustix is a dependency of this package, and causes the following build error:

error[E0425]: cannot find value `MADV_SOFT_OFFLINE` in module `c`
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-1.0.3/src/backend/libc/mm/types.rs:408:36
    |
408 |     LinuxSoftOffline = bitcast!(c::MADV_SOFT_OFFLINE),
    |                                    ^^^^^^^^^^^^^^^^^ not found in `c`
    |
help: consider importing this constant
    |
1   + use linux_raw_sys::general::MADV_SOFT_OFFLINE;
    |
help: if you import `MADV_SOFT_OFFLINE`, refer to it directly
    |
408 -     LinuxSoftOffline = bitcast!(c::MADV_SOFT_OFFLINE),
408 +     LinuxSoftOffline = bitcast!(MADV_SOFT_OFFLINE),
    |

I have tried updating to 1.0.7 without success, so I forked the rustix repo and tried depending on a branch with the following naive patch:

diff --git a/src/backend/libc/mm/types.rs b/src/backend/libc/mm/types.rs
index 0b99e3c48..75ba79bd3 100644
--- a/src/backend/libc/mm/types.rs
+++ b/src/backend/libc/mm/types.rs
@@ -402,7 +402,8 @@ pub enum Advice {
             target_arch = "mips",
             target_arch = "mips32r6",
             target_arch = "mips64",
-            target_arch = "mips64r6"
+            target_arch = "mips64r6",
+            target_arch = "loongarch64"
         ))
     ))]
     LinuxSoftOffline = bitcast!(c::MADV_SOFT_OFFLINE),

This resolves the issue for me, and I have no other errors building wasmtime. Is this an appropriate patch to merge here, should I open a PR? Or is the lack of MADV_SOFT_OFFLINE exclusive to musl libc and not GNU libc? Is this related to the stalled loongarch64 enabling work at #1086?

Ping @zhaixiaojuan and @sunfishcode

@heiher
Copy link
Contributor

heiher commented May 7, 2025

It seems that some symbols are missing in rust-lang/libc for LoongArch with musl. I'll fix them later. In the meantime, could you switch to using the linux-raw backend instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants