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

Add pthread_[s,g]etschedparam to emscripten. #2764

Closed
2 changes: 1 addition & 1 deletion ci/emscripten-entry.sh
Expand Up @@ -7,6 +7,6 @@ source /emsdk-portable/emsdk_env.sh &> /dev/null

# emsdk-portable provides a node binary, but we need version 8 to run wasm
# NOTE: Do not forget to sync Node.js version with `emscripten.sh`!
export PATH="/node-v14.17.0-linux-x64/bin:$PATH"
export PATH="/node-v18.0.0-linux-x64/bin:$PATH"

exec "$@"
4 changes: 2 additions & 2 deletions ci/emscripten.sh
Expand Up @@ -2,7 +2,7 @@

set -ex

EMSDK_VERSION=1.39.20
EMSDK_VERSION=3.1.9

hide_output() {
set +x
Expand Down Expand Up @@ -39,5 +39,5 @@ chmod a+rxw -R /emsdk-portable
# node 8 is required to run wasm
# NOTE: Do not forget to sync Node.js version with `emscripten-entry.sh`!
cd /
curl --retry 5 -L https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz | \
curl --retry 5 -L https://nodejs.org/dist/v18.0.0/node-v18.0.0-linux-x64.tar.xz | \
tar -xJ
7 changes: 7 additions & 0 deletions ci/run.sh
Expand Up @@ -109,6 +109,13 @@ if [ "$TARGET" = "s390x-unknown-linux-gnu" ]; then
sleep 1
done
else
if [ "$TARGET" = "asmjs-unknown-emscripten" ]; then
# Rust uses -g4 by default what causes link issues.
# This should disable the -g4 option.
export RUSTFLAGS="-Cdebuginfo=0"
export EMCC_FLAGS="-s USE_PTHREADS=1 -s SHARED_MEMORY"
export EMCC_CFLAGS="-s USE_PTHREADS=1 -s SHARED_MEMORY"
fi
cargo test --no-default-features --manifest-path libc-test/Cargo.toml \
--target "${TARGET}" ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}

Expand Down
1 change: 0 additions & 1 deletion libc-test/build.rs
Expand Up @@ -2511,7 +2511,6 @@ fn test_emscripten(target: &str) {
"sys/reboot.h",
"sys/resource.h",
"sys/sem.h",
"sys/sendfile.h",
"sys/shm.h",
"sys/signalfd.h",
"sys/socket.h",
Expand Down
10 changes: 10 additions & 0 deletions src/unix/linux_like/emscripten/mod.rs
Expand Up @@ -1879,6 +1879,16 @@ extern "C" {
f: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
value: *mut ::c_void,
) -> ::c_int;
pub fn pthread_setschedparam(
native: ::pthread_t,
policy: ::c_int,
param: *const ::sched_param,
) -> ::c_int;
pub fn pthread_getschedparam(
native: ::pthread_t,
policy: *mut ::c_int,
param: *mut ::sched_param,
) -> ::c_int;
}

cfg_if! {
Expand Down
8 changes: 4 additions & 4 deletions src/unix/linux_like/mod.rs
Expand Up @@ -108,13 +108,13 @@ s! {

pub struct sched_param {
pub sched_priority: ::c_int,
#[cfg(any(target_env = "musl", target_os = "emscripten"))]
#[cfg(target_env = "musl")]
pub sched_ss_low_priority: ::c_int,
#[cfg(any(target_env = "musl", target_os = "emscripten"))]
#[cfg(target_env = "musl")]
pub sched_ss_repl_period: ::timespec,
#[cfg(any(target_env = "musl", target_os = "emscripten"))]
#[cfg(target_env = "musl")]
pub sched_ss_init_budget: ::timespec,
#[cfg(any(target_env = "musl", target_os = "emscripten"))]
#[cfg(target_env = "musl")]
pub sched_ss_max_repl: ::c_int,
}

Expand Down