From 2fb7a4ab33f4d5a909a778fb223c6ded18d4a3b6 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 18 Jan 2023 11:27:14 +0100 Subject: [PATCH 1/4] Add getentropy for Emscripten Required by https://github.com/rust-lang/rust/pull/107221. --- src/unix/linux_like/emscripten/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index f2024900cbca9..d6abdcdb67408 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1814,7 +1814,6 @@ extern "C" { ) -> ::c_int; pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; - // Not available now on Android pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); @@ -1882,6 +1881,8 @@ extern "C" { f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, value: *mut ::c_void, ) -> ::c_int; + + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; } cfg_if! { From d6c991e32c3f058131d8c8c2fa2f2133987df684 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 23 Jan 2023 16:53:03 +0100 Subject: [PATCH 2/4] Fix broken URLs --- src/unix/linux_like/emscripten/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index d6abdcdb67408..9e5ea6c2696c8 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1724,7 +1724,7 @@ f! { pub fn major(dev: ::dev_t) -> ::c_uint { // see // https://github.com/emscripten-core/emscripten/blob/ - // master/system/include/libc/sys/sysmacros.h + // main/system/lib/libc/musl/include/sys/sysmacros.h let mut major = 0; major |= (dev & 0x00000fff) >> 8; major |= (dev & 0xfffff000) >> 31 >> 1; @@ -1734,7 +1734,7 @@ f! { pub fn minor(dev: ::dev_t) -> ::c_uint { // see // https://github.com/emscripten-core/emscripten/blob/ - // master/system/include/libc/sys/sysmacros.h + // main/system/lib/libc/musl/include/sys/sysmacros.h let mut minor = 0; minor |= (dev & 0x000000ff) >> 0; minor |= (dev & 0xffffff00) >> 12; From 03b410a6b2ab951a63b86091b54557d2e637f7bd Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 23 Jan 2023 17:32:29 +0100 Subject: [PATCH 3/4] Update a couple of comments --- libc-test/build.rs | 18 ++++++------------ libc-test/semver/TODO-unix.txt | 3 ++- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index f98dbbfe84d96..c1a42784c0a1e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2566,7 +2566,8 @@ fn test_emscripten(target: &str) { // FIXME: The size has been changed when upgraded to musl 1.2.2 "pthread_mutex_t" => true, - // FIXME: The size has been changed + // FIXME: Lowered from 16 to 8 bytes in + // llvm/llvm-project@d1a96e9 "max_align_t" => true, // FIXME: The size has been changed due to time64 @@ -2579,20 +2580,13 @@ fn test_emscripten(target: &str) { cfg.skip_fn(move |name| { match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, + // Emscripten does not support fork/exec/wait or any kind of multi-process support + // https://github.com/emscripten-core/emscripten/blob/3.1.30/tools/system_libs.py#L973 + "execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true, - // FIXME: Investigate why CI is missing it. + // FIXME: Remove after emscripten-core/emscripten#18492 is released (> 3.1.30). "clearenv" => true, - // FIXME: Somehow the ctest cannot find it on emscripten: - // = note: error: undefined symbol: wait4 (referenced by top-level compiled C/C++ code) - // warning: Link with `-sLLD_REPORT_UNDEFINED` to get more information on undefined symbols - // warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0` - // warning: _wait4 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library - // Error: Aborting compilation due to previous errors - "wait4" => true, - _ => false, } }); diff --git a/libc-test/semver/TODO-unix.txt b/libc-test/semver/TODO-unix.txt index 4d6874d90c874..3d4866076ebd1 100644 --- a/libc-test/semver/TODO-unix.txt +++ b/libc-test/semver/TODO-unix.txt @@ -1,5 +1,6 @@ -# These symbols are missing for the targets: +# These symbols are no-op or missing on these targets: # * asmjs-unknown-emscripten +# * wasm32-unknown-emscripten getpwuid_r pthread_atfork pthread_sigmask From 6a7bd4380cd33ce9ac2e494c34b518273689d26c Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 23 Jan 2023 17:33:55 +0100 Subject: [PATCH 4/4] Add libc-test/semver/emscripten.txt --- libc-test/semver/emscripten.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 libc-test/semver/emscripten.txt diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt new file mode 100644 index 0000000000000..48882791e7c8d --- /dev/null +++ b/libc-test/semver/emscripten.txt @@ -0,0 +1 @@ +getentropy