Skip to content
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

rust-lld: error: undefined symbol: memchr when compiling with nightly-aarch64-unknown-linux-musl #91

Open
yogh333 opened this issue Aug 23, 2024 · 1 comment

Comments

@yogh333
Copy link

yogh333 commented Aug 23, 2024

Hello,

I have an undefined symbol error when trying to compile qrcodegen.c with toolchain nightly-aarch64-unknown-linux-musl:

 rust-lld: error: undefined symbol: memchr
          >>> referenced by qrcodegen.c:964 (/apps/ledger-device-rust-sdk/target/stax/debug/build/ledger_secure_sdk_sys-d4f9f369bf0ebeb9/out/ledger-secure-sdk/qrcode/src/qrcodegen.c:964)
          >>>               8ea603dc3489e912-qrcodegen.o:(qrcodegen_isAlphanumeric) in archive /apps/ledger-device-rust-sdk/target/stax/debug/deps/libledger_secure_sdk_sys-4bf5710c68e34674.rlib
          >>> referenced by qrcodegen.c:1093 (/apps/ledger-device-rust-sdk/target/stax/debug/build/ledger_secure_sdk_sys-d4f9f369bf0ebeb9/out/ledger-secure-sdk/qrcode/src/qrcodegen.c:1093)
          >>>               8ea603dc3489e912-qrcodegen.o:(qrcodegen_makeAlphanumeric) in archive /apps/ledger-device-rust-sdk/target/stax/debug/deps/libledger_secure_sdk_sys-4bf5710c68e34674.rlib

part of qrcodegen source code raising the error is below:

// Public function - see documentation comment in header file.
bool qrcodegen_isAlphanumeric(const char *text)
{
    assert(text != NULL);
    for (; *text != '\0'; text++) {
        if (strchr(ALPHANUMERIC_CHARSET, *text) == NULL) {
            return false;
        }
    }
    return true;
}

For your information, I am using the following unstable feature in my .cargo/config.toml:

[unstable]
build-std = ["core", "alloc"]
build-std-features = ["compiler-builtins-mem"]

I do not know if I provide enough information to get help, please tell me.
Thanks for your support 🙏

@adamgemmell
Copy link

Most likely you don't have an aarch64 musl libc available if the linker reports an undefined symbol that is meant to come from libc.

Possibly similar to #76 where adding -Lpath/to/self-contained fixes things. Your example originates in C code but if you have a concise reproduction of the issue that'd be very helpful.

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