Skip to content

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

@strophy

Description

@strophy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions