Skip to content

Commit d997a62

Browse files
committed
Call emcc with ERROR_ON_UNDEFINED_SYMBOLS
1 parent 834bbab commit d997a62

File tree

6 files changed

+28
-8
lines changed

6 files changed

+28
-8
lines changed

src/libcoretest/num/flt2dec/estimator.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// FIXME https://github.com/kripken/emscripten/issues/4563
12+
// NB we have to actually not compile this test to avoid
13+
// an undefined symbol error
14+
#![cfg(not(target_os = "emscripten"))]
15+
1116
use core::num::flt2dec::estimator::*;
1217

1318
#[test]
14-
// FIXME https://github.com/kripken/emscripten/issues/4563
15-
#[cfg_attr(target_os = "emscripten", ignore)]
1619
fn test_estimate_scaling_factor() {
1720
macro_rules! assert_almost_eq {
1821
($actual:expr, $expected:expr) => ({

src/librustc_back/target/asmjs_unknown_emscripten.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn target() -> Result<Target, String> {
2222
allow_asm: false,
2323
obj_is_bitcode: true,
2424
max_atomic_width: 32,
25+
post_link_args: vec!["-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()],
2526
.. Default::default()
2627
};
2728
Ok(Target {

src/librustc_back/target/wasm32_unknown_emscripten.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ pub fn target() -> Result<Target, String> {
2424
allow_asm: false,
2525
obj_is_bitcode: true,
2626
max_atomic_width: 32,
27-
post_link_args: vec!["-s".to_string(), "BINARYEN=1".to_string()],
27+
post_link_args: vec!["-s".to_string(), "BINARYEN=1".to_string(),
28+
"-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()],
2829
.. Default::default()
2930
};
3031
Ok(Target {

src/libstd/sys/unix/process.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl Command {
369369
}
370370

371371
// NaCl has no signal support.
372-
if cfg!(not(target_os = "nacl")) {
372+
if cfg!(not(any(target_os = "nacl", target_os = "emscripten"))) {
373373
// Reset signal handling so the child process starts in a
374374
// standardized state. libstd ignores SIGPIPE, and signal-handling
375375
// libraries often set a mask. Child processes inherit ignored
@@ -589,7 +589,7 @@ impl Process {
589589
}
590590
}
591591

592-
#[cfg(test)]
592+
#[cfg(all(test, not(target_os = "emscripten")))]
593593
mod tests {
594594
use super::*;
595595

@@ -630,7 +630,6 @@ mod tests {
630630
#[test]
631631
#[cfg_attr(target_os = "macos", ignore)]
632632
#[cfg_attr(target_os = "nacl", ignore)] // no signals on NaCl.
633-
#[cfg_attr(target_os = "emscripten", ignore)]
634633
fn test_process_mask() {
635634
unsafe {
636635
// Test to make sure that a signal mask does not get inherited.

src/libstd/sys/unix/thread.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ pub struct Thread {
2929
unsafe impl Send for Thread {}
3030
unsafe impl Sync for Thread {}
3131

32+
// The pthread_attr_setstacksize symbol doesn't exist in the emscripten libc,
33+
// so we have to not link to it to satisfy emcc's ERROR_ON_UNDEFINED_SYMBOLS.
34+
#[cfg(not(target_os = "emscripten"))]
35+
unsafe fn pthread_attr_setstacksize(attr: *mut libc::pthread_attr_t,
36+
stack_size: libc::size_t) -> libc::c_int {
37+
libc::pthread_attr_setstacksize(attr, stack_size)
38+
}
39+
40+
#[cfg(target_os = "emscripten")]
41+
unsafe fn pthread_attr_setstacksize(_attr: *mut libc::pthread_attr_t,
42+
_stack_size: libc::size_t) -> libc::c_int {
43+
panic!()
44+
}
45+
3246
impl Thread {
3347
pub unsafe fn new<'a>(stack: usize, p: Box<FnBox() + 'a>)
3448
-> io::Result<Thread> {
@@ -38,8 +52,8 @@ impl Thread {
3852
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
3953

4054
let stack_size = cmp::max(stack, min_stack_size(&attr));
41-
match libc::pthread_attr_setstacksize(&mut attr,
42-
stack_size as libc::size_t) {
55+
match pthread_attr_setstacksize(&mut attr,
56+
stack_size as libc::size_t) {
4357
0 => {}
4458
n => {
4559
assert_eq!(n, libc::EINVAL);

src/test/run-pass/format-no-std.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-emscripten missing rust_begin_unwind
12+
1113
#![feature(lang_items, start, collections)]
1214
#![no_std]
1315

0 commit comments

Comments
 (0)