Skip to content

Use libc::strerror_r instead of our own definition#85

Merged
sunfishcode merged 1 commit intolambda-fairy:mainfrom
taiki-e:libc
Nov 1, 2023
Merged

Use libc::strerror_r instead of our own definition#85
sunfishcode merged 1 commit intolambda-fairy:mainfrom
taiki-e:libc

Conversation

@taiki-e
Copy link
Contributor

@taiki-e taiki-e commented Nov 1, 2023

We already depend on libc to use strlen, and libc provides strerror_r for all unix/wasi platforms we support.

(As for errno_location, it seems that libc does not provide a corresponding one for some platforms yet.)

@taiki-e
Copy link
Contributor Author

taiki-e commented Nov 1, 2023

for all unix/wasi platforms we support.

FYI, the following is a script I used to check this.

#!/bin/bash

targets=(
    # src/windows.rs
    x86_64-pc-windows-msvc
    x86_64-pc-windows-gnu
    # src/wasi.rs
    wasm32-wasi
    # src/unix.rs
    aarch64-apple-ios
    i686-unknown-hurd-gnu
    powerpc64-ibm-aix
    riscv32imc-esp-espidf
    x86_64-apple-darwin
    x86_64-linux-android
    x86_64-pc-nto-qnx710
    x86_64-pc-solaris
    x86_64-unknown-dragonfly
    x86_64-unknown-freebsd
    x86_64-unknown-haiku
    x86_64-unknown-hermit
    x86_64-unknown-illumos
    x86_64-unknown-linux-gnu
    x86_64-unknown-linux-musl
    x86_64-unknown-netbsd
    x86_64-unknown-openbsd
    x86_64-unknown-redox
)

# Use -Z build-std for tier 3 targets.
rustup component add rust-src

for target in "${targets[@]}"; do
    if rustup target add "${target}" &>/dev/null; then
        cargo build --no-default-features --target "${target}"
    else
        cargo build --no-default-features -Z build-std=core --target "${target}"
    fi
done

@sunfishcode
Copy link
Collaborator

It does appear that the libc crate version has the needed __xpg_strerror_r attribute, so this looks good.

@sunfishcode sunfishcode merged commit 235907b into lambda-fairy:main Nov 1, 2023
@taiki-e taiki-e deleted the libc branch November 1, 2023 15:44
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

Successfully merging this pull request may close these issues.

2 participants