Skip to content

Commit 899d23b

Browse files
committed
Auto merge of #1373 - gnzlbg:cleanup_emscripten, r=gnzlbg
Re-enable emscripten on CI and cleanup its libc-test
2 parents 48193e8 + f8ea9b7 commit 899d23b

File tree

14 files changed

+130
-218
lines changed

14 files changed

+130
-218
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ matrix:
235235
allow_failures:
236236
# FIXME: https://github.com/rust-lang/libc/issues/1226
237237
- env: TARGET=asmjs-unknown-emscripten
238-
- env: TARGET=wasm32-unknown-emscripten
239238
- name: "Semver Linux"
240239
- name: "Semver MacOSX"
241240

ci/docker/wasm32-unknown-emscripten/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ FROM ubuntu:19.04
33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends \
55
ca-certificates \
6+
g++ \
7+
make \
8+
file \
69
curl \
710
gcc \
811
git \
912
libc6-dev \
1013
python \
14+
cmake \
15+
sudo \
16+
gdb \
1117
xz-utils
1218

1319
COPY emscripten.sh /

ci/emscripten-entry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ set -ex
1515
source /emsdk-portable/emsdk_env.sh &> /dev/null
1616

1717
# emsdk-portable provides a node binary, but we need version 8 to run wasm
18-
export PATH="/node-v8.0.0-linux-x64/bin:$PATH"
18+
export PATH="/node-v12.3.1-linux-x64/bin:$PATH"
1919

2020
exec "$@"

ci/emscripten.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ curl --retry 5 -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/ems
3434

3535
cd /emsdk-portable
3636
./emsdk update
37-
hide_output ./emsdk install sdk-1.37.20-64bit
38-
./emsdk activate sdk-1.37.20-64bit
37+
hide_output ./emsdk install sdk-1.38.15-64bit
38+
./emsdk activate sdk-1.38.15-64bit
3939

4040
# Compile and cache libc
4141
# shellcheck disable=SC1091
@@ -51,6 +51,6 @@ chmod a+rxw -R /emsdk-portable
5151

5252
# node 8 is required to run wasm
5353
cd /
54-
curl --retry 5 -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \
54+
curl --retry 5 -L https://nodejs.org/dist/v12.3.1/node-v12.3.1-linux-x64.tar.xz | \
5555
tar -xJ
5656

libc-test/build.rs

Lines changed: 29 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,8 +1370,8 @@ fn test_android(target: &str) {
13701370

13711371
// FIXME: still necessary?
13721372
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness
1373-
// FIXME: still necessary?
1374-
"SIGUNUSED" => true, // removed in glibc 2.26
1373+
// FIXME: deprecated - removed in glibc 2.26
1374+
"SIGUNUSED" => true,
13751375

13761376
_ => false,
13771377
}
@@ -1428,7 +1428,7 @@ fn test_android(target: &str) {
14281428

14291429
cfg.generate("../src/lib.rs", "main.rs");
14301430

1431-
test_linux_incompatible_apis(target);
1431+
test_linux_like_apis(target);
14321432
}
14331433

14341434
fn test_freebsd(target: &str) {
@@ -1635,11 +1635,7 @@ fn test_emscripten(target: &str) {
16351635
assert!(target.contains("emscripten"));
16361636

16371637
let mut cfg = ctest::TestGenerator::new();
1638-
// FIXME: still necessary?
1639-
cfg.define("_GNU_SOURCE", None);
1640-
1641-
// FIXME: still necessary?
1642-
cfg.flag("-Wno-deprecated-declarations");
1638+
cfg.define("_GNU_SOURCE", None); // FIXME: ??
16431639

16441640
headers! { cfg:
16451641
"aio.h",
@@ -1732,11 +1728,7 @@ fn test_emscripten(target: &str) {
17321728
cfg.type_name(move |ty, is_struct, is_union| {
17331729
match ty {
17341730
// Just pass all these through, no need for a "struct" prefix
1735-
// FIXME: is this necessary?
1736-
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr"
1737-
| "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym"
1738-
| "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr"
1739-
| "Elf64_Chdr" => ty.to_string(),
1731+
"FILE" | "fd_set" | "Dl_info" | "DIR" => ty.to_string(),
17401732

17411733
t if is_union => format!("union {}", t),
17421734

@@ -1756,7 +1748,7 @@ fn test_emscripten(target: &str) {
17561748
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
17571749
s.replace("e_nsec", ".tv_nsec")
17581750
}
1759-
// FIXME: is this necessary?
1751+
// FIXME: appears that `epoll_event.data` is an union
17601752
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
17611753
s => s.to_string(),
17621754
}
@@ -1774,157 +1766,31 @@ fn test_emscripten(target: &str) {
17741766

17751767
cfg.skip_struct(move |ty| {
17761768
match ty {
1777-
// FIXME: is this necessary?
1778-
"sockaddr_nl" => true,
1779-
17801769
// This is actually a union, not a struct
17811770
// FIXME: is this necessary?
17821771
"sigval" => true,
17831772

1784-
// Linux kernel headers used on musl are too old to have this
1785-
// definition. Because it's tested on other Linux targets, skip it.
1786-
// FIXME: is this necessary?
1787-
"input_mask" => true,
1788-
1789-
// These are tested as part of the linux_fcntl tests since there are
1790-
// header conflicts when including them with all the other structs.
1791-
// FIXME: is this necessary?
1792-
"termios2" => true,
1793-
17941773
_ => false,
17951774
}
17961775
});
17971776

1798-
cfg.skip_signededness(move |c| match c {
1799-
// FIXME: is this necessary?
1800-
"LARGE_INTEGER" | "float" | "double" => true,
1801-
// FIXME: is this necessary?
1802-
n if n.starts_with("pthread") => true,
1803-
_ => false,
1804-
});
1805-
1806-
cfg.skip_const(move |name| {
1777+
cfg.skip_fn(move |name| {
18071778
match name {
1808-
// FIXME: is this necessary?
1809-
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness
1810-
// FIXME: is this necessary?
1811-
"SIGUNUSED" => true, // removed in glibc 2.26
1812-
1813-
// types on musl are defined a little differently
1814-
// FIXME: is this necessary?
1815-
n if n.contains("__SIZEOF_PTHREAD") => true,
1816-
1817-
// Skip constants not defined in MUSL but just passed down to the
1818-
// kernel regardless
1819-
// FIXME: is this necessary?
1820-
"RLIMIT_NLIMITS"
1821-
| "TCP_COOKIE_TRANSACTIONS"
1822-
| "RLIMIT_RTTIME"
1823-
| "MSG_COPY"
1824-
=>
1825-
{
1826-
true
1827-
}
1828-
1829-
// weird signed extension or something like that?
1830-
// FIXME: is this necessary?
1831-
"MS_NOUSER" => true,
1832-
// FIXME: is this necessary?
1833-
"MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13
1834-
1835-
// Musl uses old, patched kernel headers
1836-
// FIXME: is this necessary?
1837-
"FALLOC_FL_COLLAPSE_RANGE"
1838-
| "FALLOC_FL_ZERO_RANGE"
1839-
| "FALLOC_FL_INSERT_RANGE"
1840-
| "FALLOC_FL_UNSHARE_RANGE"
1841-
| "RENAME_NOREPLACE"
1842-
| "RENAME_EXCHANGE"
1843-
| "RENAME_WHITEOUT"
1844-
// ALG_SET_AEAD_* constants are available starting from kernel 3.19
1845-
| "ALG_SET_AEAD_ASSOCLEN"
1846-
| "ALG_SET_AEAD_AUTHSIZE"
1847-
=>
1848-
{
1849-
true
1850-
}
1851-
1852-
// musl uses old kernel headers
1853-
// These are constants used in getrandom syscall
1854-
// FIXME: is this necessary?
1855-
"GRND_NONBLOCK" | "GRND_RANDOM" => true,
1856-
1857-
1858-
// These constants are tested in a separate test program generated below because there
1859-
// are header conflicts if we try to include the headers that define them here.
1860-
// FIXME: is this necessary?
1861-
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true,
1862-
// FIXME: is this necessary?
1863-
"F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW"
1864-
| "F_SEAL_WRITE" => true,
1865-
// FIXME: is this necessary?
1866-
"BOTHER" => true,
1867-
1868-
// FIXME: is this necessary?
1869-
"MFD_CLOEXEC" | "MFD_ALLOW_SEALING" => true,
1870-
// MFD_HUGETLB is not available in some older libc versions on the CI builders. On the
1871-
// x86_64 and i686 builders it seems to be available for all targets, so at least test
1872-
// it there.
1873-
// FIXME: is this necessary?
1874-
"MFD_HUGETLB" =>
1875-
{
1876-
true
1877-
}
1878-
1879-
// These are defined for Solaris 11, but the crate is tested on
1880-
// illumos, where they are currently not defined
1881-
// FIXME: is this necessary?
1882-
"EADI"
1883-
| "PORT_SOURCE_POSTWAIT"
1884-
| "PORT_SOURCE_SIGNAL"
1885-
| "PTHREAD_STACK_MIN" => true,
1886-
1887-
// These change all the time from release to release of linux
1888-
// distros, let's just not bother trying to verify them. They
1889-
// shouldn't be used in code anyway...
1890-
// FIXME: is this necessary?
1891-
"AF_MAX" | "PF_MAX" => true,
1779+
// FIXME: https://github.com/rust-lang/libc/issues/1272
1780+
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,
18921781

18931782
_ => false,
18941783
}
18951784
});
18961785

1897-
cfg.skip_fn(move |name| {
1898-
// skip those that are manually verified
1786+
cfg.skip_const(move |name| {
18991787
match name {
1900-
// FIXME: is this necessary?
1901-
"execv" | // crazy stuff with const/mut
1902-
"execve" |
1903-
"execvp" |
1904-
"execvpe" |
1905-
"fexecve" => true,
1906-
1907-
"getrlimit" | "getrlimit64" | // non-int in 1st arg
1908-
"setrlimit" | "setrlimit64" | // non-int in 1st arg
1909-
"prlimit" | "prlimit64" | // non-int in 2nd arg
1910-
1911-
// int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that
1912-
// they match the interface defined by Linux verbatim, but they conflict with other
1913-
// send*/recv* syscalls
1914-
// FIXME: is this necessary?
1915-
"sendmmsg" | "recvmmsg" => true,
1916-
1917-
// FIXME: is this necessary?
1918-
"dladdr" => true, // const-ness only added recently
1919-
1920-
// FIXME: is this necessary?
1921-
"lio_listio" => true,
1788+
// FIXME: deprecated - SIGNUNUSED was removed in glibc 2.26
1789+
// users should use SIGSYS instead
1790+
"SIGUNUSED" => true,
19221791

1923-
// Definition of those functions as changed since unified headers from NDK r14b
1924-
// These changes imply some API breaking changes but are still ABI compatible.
1925-
// We can wait for the next major release to be compliant with the new API.
1926-
// FIXME: unskip these for next major release
1927-
"strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" |
1792+
// FIXME: emscripten uses different constants to constructs these
1793+
n if n.contains("__SIZEOF_PTHREAD") => true,
19281794

19291795
_ => false,
19301796
}
@@ -1966,9 +1832,7 @@ fn test_emscripten(target: &str) {
19661832
field == "ssi_arch"))
19671833
});
19681834

1969-
// FIXME: remove
1970-
cfg.fn_cname(move |name, _cname| name.to_string());
1971-
1835+
// FIXME: test linux like
19721836
cfg.generate("../src/lib.rs", "main.rs");
19731837
}
19741838

@@ -2377,17 +2241,19 @@ fn test_linux(target: &str) {
23772241

23782242
cfg.generate("../src/lib.rs", "main.rs");
23792243

2380-
test_linux_incompatible_apis(target);
2244+
test_linux_like_apis(target);
23812245
}
23822246

23832247
// This function tests APIs that are incompatible to test when other APIs
23842248
// are included (e.g. because including both sets of headers clashes)
2385-
fn test_linux_incompatible_apis(target: &str) {
2386-
assert!(target.contains("linux") || target.contains("android"));
2249+
fn test_linux_like_apis(target: &str) {
23872250
let musl = target.contains("musl");
23882251
let linux = target.contains("linux");
2252+
let emscripten = target.contains("emscripten");
2253+
let android = target.contains("android");
2254+
assert!(linux || android || emscripten);
23892255

2390-
{
2256+
if linux || android || emscripten {
23912257
// test strerror_r from the `string.h` header
23922258
let mut cfg = ctest::TestGenerator::new();
23932259
cfg.skip_type(|_| true).skip_static(|_| true);
@@ -2401,7 +2267,8 @@ fn test_linux_incompatible_apis(target: &str) {
24012267
.skip_struct(|_| true);
24022268
cfg.generate("../src/lib.rs", "linux_strerror_r.rs");
24032269
}
2404-
{
2270+
2271+
if linux || android || emscripten {
24052272
// test fcntl - see:
24062273
// http://man7.org/linux/man-pages/man2/fcntl.2.html
24072274
let mut cfg = ctest::TestGenerator::new();
@@ -2431,7 +2298,8 @@ fn test_linux_incompatible_apis(target: &str) {
24312298

24322299
cfg.generate("../src/lib.rs", "linux_fcntl.rs");
24332300
}
2434-
{
2301+
2302+
if linux || android {
24352303
// test termios
24362304
let mut cfg = ctest::TestGenerator::new();
24372305
cfg.header("asm/termbits.h");
@@ -2448,12 +2316,7 @@ fn test_linux_incompatible_apis(target: &str) {
24482316
cfg.generate("../src/lib.rs", "linux_termios.rs");
24492317
}
24502318

2451-
if !linux {
2452-
return;
2453-
}
2454-
// linux-only tests (no android):
2455-
2456-
{
2319+
if linux || android {
24572320
// test IPV6_ constants:
24582321
let mut cfg = ctest::TestGenerator::new();
24592322
headers! {
@@ -2480,7 +2343,8 @@ fn test_linux_incompatible_apis(target: &str) {
24802343
});
24812344
cfg.generate("../src/lib.rs", "linux_ipv6.rs");
24822345
}
2483-
{
2346+
2347+
if linux || android {
24842348
// Test Elf64_Phdr and Elf32_Phdr
24852349
// These types have a field called `p_type`, but including
24862350
// "resolve.h" defines a `p_type` macro that expands to `__p_type`

libc-test/test/linux_elf.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_elf.rs"));
88

99
#[cfg(not(target_os = "linux"))]
10-
fn main() { println!("PASSED 0 tests"); }
10+
fn main() {
11+
println!("PASSED 0 tests");
12+
}

libc-test/test/linux_fcntl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_fcntl.rs"));
88

99
#[cfg(not(any(target_os = "linux", target_os = "android")))]
10-
fn main() { println!("PASSED 0 tests"); }
10+
fn main() {
11+
println!("PASSED 0 tests");
12+
}

libc-test/test/linux_ipv6.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_ipv6.rs"));
88

99
#[cfg(not(target_os = "linux"))]
10-
fn main() { println!("PASSED 0 tests"); }
10+
fn main() {
11+
println!("PASSED 0 tests");
12+
}

libc-test/test/linux_strerror_r.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_strerror_r.rs"));
88

99
#[cfg(not(any(target_os = "linux", target_os = "android")))]
10-
fn main() { println!("PASSED 0 tests"); }
10+
fn main() {
11+
println!("PASSED 0 tests");
12+
}

libc-test/test/linux_termios.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ use libc::*;
77
include!(concat!(env!("OUT_DIR"), "/linux_termios.rs"));
88

99
#[cfg(not(any(target_os = "linux", target_os = "android")))]
10-
fn main() { println!("PASSED 0 tests"); }
10+
fn main() {
11+
println!("PASSED 0 tests");
12+
}

0 commit comments

Comments
 (0)