Skip to content

Commit 1df1e22

Browse files
committed
Auto merge of #3087 - kleisauke:getentropy-emscripten, r=JohnTitor
Add getentropy for Emscripten Required by rust-lang/rust#107221. ~~Marked as draft because I could not find `libc-test/semver/emscripten.txt`, so it doesn't meet the checklist.~~ Fixed with commit 6a7bd43.
2 parents f7b4c2e + 6a7bd43 commit 1df1e22

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

libc-test/build.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -2566,7 +2566,8 @@ fn test_emscripten(target: &str) {
25662566
// FIXME: The size has been changed when upgraded to musl 1.2.2
25672567
"pthread_mutex_t" => true,
25682568

2569-
// FIXME: The size has been changed
2569+
// FIXME: Lowered from 16 to 8 bytes in
2570+
// llvm/llvm-project@d1a96e9
25702571
"max_align_t" => true,
25712572

25722573
// FIXME: The size has been changed due to time64
@@ -2579,20 +2580,13 @@ fn test_emscripten(target: &str) {
25792580

25802581
cfg.skip_fn(move |name| {
25812582
match name {
2582-
// FIXME: https://github.com/rust-lang/libc/issues/1272
2583-
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,
2583+
// Emscripten does not support fork/exec/wait or any kind of multi-process support
2584+
// https://github.com/emscripten-core/emscripten/blob/3.1.30/tools/system_libs.py#L973
2585+
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true,
25842586

2585-
// FIXME: Investigate why CI is missing it.
2587+
// FIXME: Remove after emscripten-core/emscripten#18492 is released (> 3.1.30).
25862588
"clearenv" => true,
25872589

2588-
// FIXME: Somehow the ctest cannot find it on emscripten:
2589-
// = note: error: undefined symbol: wait4 (referenced by top-level compiled C/C++ code)
2590-
// warning: Link with `-sLLD_REPORT_UNDEFINED` to get more information on undefined symbols
2591-
// warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
2592-
// warning: _wait4 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
2593-
// Error: Aborting compilation due to previous errors
2594-
"wait4" => true,
2595-
25962590
_ => false,
25972591
}
25982592
});

libc-test/semver/TODO-unix.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# These symbols are missing for the targets:
1+
# These symbols are no-op or missing on these targets:
22
# * asmjs-unknown-emscripten
3+
# * wasm32-unknown-emscripten
34
getpwuid_r
45
pthread_atfork
56
pthread_sigmask

libc-test/semver/emscripten.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
getentropy

src/unix/linux_like/emscripten/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ f! {
17241724
pub fn major(dev: ::dev_t) -> ::c_uint {
17251725
// see
17261726
// https://github.com/emscripten-core/emscripten/blob/
1727-
// master/system/include/libc/sys/sysmacros.h
1727+
// main/system/lib/libc/musl/include/sys/sysmacros.h
17281728
let mut major = 0;
17291729
major |= (dev & 0x00000fff) >> 8;
17301730
major |= (dev & 0xfffff000) >> 31 >> 1;
@@ -1734,7 +1734,7 @@ f! {
17341734
pub fn minor(dev: ::dev_t) -> ::c_uint {
17351735
// see
17361736
// https://github.com/emscripten-core/emscripten/blob/
1737-
// master/system/include/libc/sys/sysmacros.h
1737+
// main/system/lib/libc/musl/include/sys/sysmacros.h
17381738
let mut minor = 0;
17391739
minor |= (dev & 0x000000ff) >> 0;
17401740
minor |= (dev & 0xffffff00) >> 12;
@@ -1814,7 +1814,6 @@ extern "C" {
18141814
) -> ::c_int;
18151815
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
18161816

1817-
// Not available now on Android
18181817
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int;
18191818
pub fn if_nameindex() -> *mut if_nameindex;
18201819
pub fn if_freenameindex(ptr: *mut if_nameindex);
@@ -1882,6 +1881,8 @@ extern "C" {
18821881
f: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
18831882
value: *mut ::c_void,
18841883
) -> ::c_int;
1884+
1885+
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
18851886
}
18861887

18871888
cfg_if! {

0 commit comments

Comments
 (0)