Skip to content

Commit

Permalink
Merge pull request #4039 from tgross35/backport-waxbeans
Browse files Browse the repository at this point in the history
[0.2] Backports
  • Loading branch information
tgross35 authored Nov 16, 2024
2 parents 4afdaf5 + 6c8488a commit bea7771
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 318 deletions.
6 changes: 3 additions & 3 deletions ci/emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set -ex

# FIXME: 3.1.21 removed a lot of header files (https://github.com/emscripten-core/emscripten/pull/17704).
# We have to tweak libc-test (and deprecate unsupported items, maybe) when updating emsdk.
EMSDK_VERSION=3.1.20
# Note: keep in sync with:
# https://github.com/rust-lang/rust/blob/master/src/ci/docker/scripts/emscripten.sh
EMSDK_VERSION=3.1.68

git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
cd /emsdk-portable
Expand Down
126 changes: 52 additions & 74 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,18 @@ fn test_android(target: &str) {
// Added in API level 28, but some tests use level 24.
"fread_unlocked" | "fwrite_unlocked" | "fgets_unlocked" | "fflush_unlocked" => true,

// Added in API level 28, but some tests use level 24.
"aligned_alloc" => true,

// Added in API level 26, but some tests use level 24.
"getgrent" => true,

// Added in API level 26, but some tests use level 24.
"setgrent" => true,

// Added in API level 26, but some tests use level 24.
"endgrent" => true,

// FIXME: bad function pointers:
"isalnum" | "isalpha" | "iscntrl" | "isdigit" | "isgraph" | "islower" | "isprint"
| "ispunct" | "isspace" | "isupper" | "isxdigit" | "isblank" | "tolower"
Expand Down Expand Up @@ -2782,7 +2794,6 @@ fn test_emscripten(target: &str) {
cfg.define("_GNU_SOURCE", None); // FIXME: ??

headers! { cfg:
"aio.h",
"ctype.h",
"dirent.h",
"dlfcn.h",
Expand Down Expand Up @@ -2823,32 +2834,21 @@ fn test_emscripten(target: &str) {
"stdio.h",
"stdlib.h",
"string.h",
"sys/epoll.h",
"sys/eventfd.h",
"sys/file.h",
"sys/ioctl.h",
"sys/ipc.h",
"sys/mman.h",
"sys/mount.h",
"sys/msg.h",
"sys/personality.h",
"sys/prctl.h",
"sys/ptrace.h",
"sys/quota.h",
"sys/reboot.h",
"sys/resource.h",
"sys/sem.h",
"sys/shm.h",
"sys/signalfd.h",
"sys/socket.h",
"sys/stat.h",
"sys/statvfs.h",
"sys/swap.h",
"sys/syscall.h",
"sys/sysctl.h",
"sys/sysinfo.h",
"sys/time.h",
"sys/timerfd.h",
"sys/times.h",
"sys/types.h",
"sys/uio.h",
Expand All @@ -2874,9 +2874,7 @@ fn test_emscripten(target: &str) {
// Just pass all these through, no need for a "struct" prefix
"FILE" | "fd_set" | "Dl_info" | "DIR" => ty.to_string(),

"os_unfair_lock" => "struct os_unfair_lock_s".to_string(),

// LFS64 types have been removed in Emscripten 3.1.44+
// LFS64 types have been removed in Emscripten 3.1.44
// https://github.com/emscripten-core/emscripten/pull/19812
"off64_t" => "off_t".to_string(),

Expand All @@ -2900,7 +2898,7 @@ fn test_emscripten(target: &str) {
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
s.replace("e_nsec", ".tv_nsec")
}
// FIXME: appears that `epoll_event.data` is an union
// Rust struct uses raw u64, rather than union
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
s => s.to_string(),
}
Expand All @@ -2912,10 +2910,11 @@ fn test_emscripten(target: &str) {
// FIXME: is this necessary?
"sighandler_t" => true,

// FIXME: The size has been changed due to musl's time64
"time_t" => true,
// No epoll support
// https://github.com/emscripten-core/emscripten/issues/5033
ty if ty.starts_with("epoll") => true,

// LFS64 types have been removed in Emscripten 3.1.44+
// LFS64 types have been removed in Emscripten 3.1.44
// https://github.com/emscripten-core/emscripten/pull/19812
t => t.ends_with("64") || t.ends_with("64_t"),
}
Expand All @@ -2924,29 +2923,19 @@ fn test_emscripten(target: &str) {
cfg.skip_struct(move |ty| {
match ty {
// This is actually a union, not a struct
// FIXME: is this necessary?
"sigval" => true,

// FIXME: It was removed in
// emscripten-core/emscripten@953e414
"pthread_mutexattr_t" => true,

// FIXME: Investigate why the test fails.
// Skip for now to unblock CI.
"pthread_condattr_t" => true,
"pthread_mutexattr_t" => true,

// FIXME: The size has been changed when upgraded to musl 1.2.2
"pthread_mutex_t" => true,

// 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
"utimbuf" | "timeval" | "timespec" | "rusage" | "itimerval" | "sched_param"
| "stat" | "stat64" | "shmid_ds" | "msqid_ds" => true,
// No epoll support
// https://github.com/emscripten-core/emscripten/issues/5033
ty if ty.starts_with("epoll") => true,
ty if ty.starts_with("signalfd") => true,

// LFS64 types have been removed in Emscripten 3.1.44+
// LFS64 types have been removed in Emscripten 3.1.44
// https://github.com/emscripten-core/emscripten/pull/19812
ty => ty.ends_with("64") || ty.ends_with("64_t"),
}
Expand All @@ -2955,12 +2944,9 @@ fn test_emscripten(target: &str) {
cfg.skip_fn(move |name| {
match name {
// 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
// https://github.com/emscripten-core/emscripten/blob/3.1.68/tools/system_libs.py#L1100
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true,

// FIXME: Remove after emscripten-core/emscripten#18492 is released (> 3.1.30).
"clearenv" => true,

_ => false,
}
});
Expand All @@ -2974,23 +2960,35 @@ fn test_emscripten(target: &str) {
// FIXME: emscripten uses different constants to constructs these
n if n.contains("__SIZEOF_PTHREAD") => true,

// FIXME: `SYS_gettid` was removed in
// emscripten-core/emscripten@6d6474e
// No epoll support
// https://github.com/emscripten-core/emscripten/issues/5033
n if n.starts_with("EPOLL") => true,

// No ptrace.h
// https://github.com/emscripten-core/emscripten/pull/17704
n if n.starts_with("PTRACE_") => true,

// No quota.h
// https://github.com/emscripten-core/emscripten/pull/17704
n if n.starts_with("QIF_") => true,
"USRQUOTA" | "GRPQUOTA" | "Q_GETFMT" | "Q_GETINFO" | "Q_SETINFO" | "Q_SYNC"
| "Q_QUOTAON" | "Q_QUOTAOFF" | "Q_GETQUOTA" | "Q_SETQUOTA" => true,

// `SYS_gettid` was removed in Emscripten v1.39.9
// https://github.com/emscripten-core/emscripten/pull/10439
"SYS_gettid" => true,

// FIXME: These values have been changed
| "POSIX_MADV_DONTNEED" // to 4
| "RLIMIT_NLIMITS" // to 16
| "RLIM_NLIMITS" // to 16
| "IPPROTO_MAX" // to 263
| "F_GETLK" // to 5
| "F_SETLK" // to 6
| "F_SETLKW" // to 7
| "O_TMPFILE" // to 65
| "SIG_IGN" // -1
=> true,
// No personality.h
// https://github.com/emscripten-core/emscripten/pull/17704
"ADDR_NO_RANDOMIZE" | "MMAP_PAGE_ZERO" | "ADDR_COMPAT_LAYOUT" | "READ_IMPLIES_EXEC"
| "ADDR_LIMIT_32BIT" | "SHORT_INODE" | "WHOLE_SECONDS" | "STICKY_TIMEOUTS"
| "ADDR_LIMIT_3GB" => true,

// LFS64 types have been removed in Emscripten 3.1.44+
// `SIG_IGN` has been changed to -2 since 1 is a valid function address
// https://github.com/emscripten-core/emscripten/pull/14883
"SIG_IGN" => true,

// LFS64 types have been removed in Emscripten 3.1.44
// https://github.com/emscripten-core/emscripten/pull/19812
n if n.starts_with("RLIM64") => true,

Expand All @@ -3000,38 +2998,19 @@ fn test_emscripten(target: &str) {

cfg.skip_field_type(move |struct_, field| {
// This is a weird union, don't check the type.
// FIXME: is this necessary?
(struct_ == "ifaddrs" && field == "ifa_ifu") ||
// sighandler_t type is super weird
// FIXME: is this necessary?
(struct_ == "sigaction" && field == "sa_sigaction") ||
// sigval is actually a union, but we pretend it's a struct
// FIXME: is this necessary?
(struct_ == "sigevent" && field == "sigev_value") ||
// aio_buf is "volatile void*" and Rust doesn't understand volatile
// FIXME: is this necessary?
(struct_ == "aiocb" && field == "aio_buf")
(struct_ == "sigevent" && field == "sigev_value")
});

cfg.skip_field(move |struct_, field| {
// this is actually a union on linux, so we can't represent it well and
// just insert some padding.
// FIXME: is this necessary?
(struct_ == "siginfo_t" && field == "_pad") ||
// musl names this __dummy1 but it's still there
// FIXME: is this necessary?
(struct_ == "glob_t" && field == "gl_flags") ||
// musl seems to define this as an *anonymous* bitfield
// FIXME: is this necessary?
(struct_ == "statvfs" && field == "__f_unused") ||
// sigev_notify_thread_id is actually part of a sigev_un union
(struct_ == "sigevent" && field == "sigev_notify_thread_id") ||
// signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet.
(struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" ||
field == "_pad2" ||
field == "ssi_syscall" ||
field == "ssi_call_addr" ||
field == "ssi_arch")) ||
// FIXME: After musl 1.1.24, it have only one field `sched_priority`,
// while other fields become reserved.
(struct_ == "sched_param" && [
Expand All @@ -3042,7 +3021,6 @@ fn test_emscripten(target: &str) {
].contains(&field))
});

// FIXME: test linux like
cfg.generate("../src/lib.rs", "main.rs");
}

Expand Down
3 changes: 3 additions & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3186,6 +3186,7 @@ dlsym
dup
dup2
duplocale
endgrent
endservent
epoll_create
epoll_create1
Expand Down Expand Up @@ -3290,6 +3291,7 @@ getegid
getenv
geteuid
getgid
getgrent
getgrgid
getgrgid_r
getgrnam
Expand Down Expand Up @@ -3684,6 +3686,7 @@ seteuid
setfsgid
setfsuid
setgid
setgrent
setgroups
sethostname
setlocale
Expand Down
49 changes: 49 additions & 0 deletions libc-test/semver/espidf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
AF_INET6
AF_UNIX
FIONBIO
MSG_CTRUNC
MSG_DONTROUTE
MSG_DONTWAIT
MSG_EOR
MSG_MORE
MSG_NOSIGNAL
MSG_OOB
MSG_PEEK
MSG_TRUNC
MSG_WAITALL
NSIG
POLLERR
POLLHUP
POLLIN
POLLOUT
POLLPRI
POLLRDBAND
POLLRDNORM
POLLWRBAND
POLLWRNORM
PTHREAD_STACK_MIN
SIGABRT
SIGFPE
SIGHUP
SIGILL
SIGINT
SIGQUIT
SIGSEGV
SIGTERM
SOL_SOCKET
cmsghdr
dirent
eventfd
gethostname
getrandom
msghdr
pthread_create
recvmsg
sendmsg
sigset_t
sockaddr
sockaddr_in
sockaddr_in6
sockaddr_storage
sockaddr_un
stat
3 changes: 3 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3675,6 +3675,9 @@ safe_f! {
}

extern "C" {
pub fn setgrent();
pub fn endgrent();
pub fn getgrent() -> *mut ::group;
pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int;
pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
Expand Down
4 changes: 2 additions & 2 deletions src/unix/linux_like/emscripten/align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ macro_rules! expand_align {
}

#[allow(missing_debug_implementations)]
#[repr(align(16))]
#[repr(align(8))]
pub struct max_align_t {
priv_: [f64; 4]
priv_: [f64; 3]
}

}
Expand Down
Loading

0 comments on commit bea7771

Please sign in to comment.