From 45d5f2256064306fdc3cc912ce5d6f569f6159b9 Mon Sep 17 00:00:00 2001 From: Baoshan Pang Date: Fri, 16 Aug 2019 13:56:03 -0700 Subject: [PATCH 1/5] run test for vxWorks in 'pure' static linking mode by default; if environment variables 'RUST_TEST_DYLINK' is set to 1, then run test in 'pure' dynamic linking mode --- src/tools/compiletest/src/runtest.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 3da6be74129f4..a712a27015d25 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1725,6 +1725,17 @@ impl<'test> TestCx<'test> { } } + fn use_dynamic_linking(&self) -> bool { + if self.config.target.contains("vxworks") { + match env::var("RUST_TEST_DYLINK") { + Ok(s) => s == "1", + _ => false + } + } else { + true + } + } + fn compose_and_run_compiler(&self, mut rustc: Command, input: Option) -> ProcRes { let aux_dir = self.aux_output_dir_name(); @@ -1768,6 +1779,7 @@ impl<'test> TestCx<'test> { && !self.config.host.contains("musl")) || self.config.target.contains("wasm32") || self.config.target.contains("nvptx") + || !self.use_dynamic_linking() { // We primarily compile all auxiliary libraries as dynamic libraries // to avoid code size bloat and large binaries as much as possible @@ -1999,10 +2011,14 @@ impl<'test> TestCx<'test> { } if !is_rustdoc { - if self.config.target == "wasm32-unknown-unknown" { + if self.config.target == "wasm32-unknown-unknown" + || !self.use_dynamic_linking() { // rustc.arg("-g"); // get any backtrace at all on errors } else if !self.props.no_prefer_dynamic { rustc.args(&["-C", "prefer-dynamic"]); + if self.config.target.contains("vxworks") { + rustc.args(&["-C", "target-feature=-crt-static"]); + } } } From f5b1b1cdf9d8c893530599924f1a9f4564e28d98 Mon Sep 17 00:00:00 2001 From: Salim Nasser Date: Thu, 22 Aug 2019 15:26:52 -0700 Subject: [PATCH 2/5] VxWorks ignores the SO_SNDTIMEO socket option (this is long-standing behavior), so skip the following tests: net::tcp::tests::timeouts net::udp::tests::timeouts --- src/libstd/net/tcp.rs | 3 ++- src/libstd/net/udp.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index cdffa390223a2..d8b6fb6da9395 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -1597,7 +1597,8 @@ mod tests { // FIXME: re-enabled openbsd tests once their socket timeout code // no longer has rounding errors. - #[cfg_attr(any(target_os = "netbsd", target_os = "openbsd"), ignore)] + // VxWorks ignores SO_SNDTIMEO. + #[cfg_attr(any(target_os = "netbsd", target_os = "openbsd", target_os = "vxworks"), ignore)] #[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31 #[test] fn timeouts() { diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index c430e103951f1..a5e7cd992f227 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -1026,7 +1026,8 @@ mod tests { // FIXME: re-enabled openbsd/netbsd tests once their socket timeout code // no longer has rounding errors. - #[cfg_attr(any(target_os = "netbsd", target_os = "openbsd"), ignore)] + // VxWorks ignores SO_SNDTIMEO. + #[cfg_attr(any(target_os = "netbsd", target_os = "openbsd", target_os = "vxworks"), ignore)] #[test] fn timeouts() { let addr = next_test_ip4(); From cae6d66d9989857e321e0963142b08b1517dc723 Mon Sep 17 00:00:00 2001 From: Baoshan Pang Date: Fri, 16 Aug 2019 13:56:03 -0700 Subject: [PATCH 3/5] run test for vxWorks in 'pure' static linking mode by default; if environment variables 'RUST_TEST_DYLINK' is set to 1, then run test in 'pure' dynamic linking mode --- src/tools/compiletest/src/runtest.rs | 29 ++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 3da6be74129f4..0bc77c6c502dc 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1725,6 +1725,28 @@ impl<'test> TestCx<'test> { } } + fn is_vxworks_pure_static(&self) -> bool { + if self.config.target.contains("vxworks") { + match env::var("RUST_TEST_DYLINK") { + Ok(s) => s != "1", + _ => true + } + } else { + false + } + } + + fn is_vxworks_pure_dynamic(&self) -> bool { + if self.config.target.contains("vxworks") { + match env::var("RUST_TEST_DYLINK") { + Ok(s) => s == "1", + _ => false + } + } else { + false + } + } + fn compose_and_run_compiler(&self, mut rustc: Command, input: Option) -> ProcRes { let aux_dir = self.aux_output_dir_name(); @@ -1768,6 +1790,7 @@ impl<'test> TestCx<'test> { && !self.config.host.contains("musl")) || self.config.target.contains("wasm32") || self.config.target.contains("nvptx") + || self.is_vxworks_pure_static() { // We primarily compile all auxiliary libraries as dynamic libraries // to avoid code size bloat and large binaries as much as possible @@ -1999,7 +2022,8 @@ impl<'test> TestCx<'test> { } if !is_rustdoc { - if self.config.target == "wasm32-unknown-unknown" { + if self.config.target == "wasm32-unknown-unknown" + || self.is_vxworks_pure_static() { // rustc.arg("-g"); // get any backtrace at all on errors } else if !self.props.no_prefer_dynamic { rustc.args(&["-C", "prefer-dynamic"]); @@ -2044,7 +2068,8 @@ impl<'test> TestCx<'test> { } // Use dynamic musl for tests because static doesn't allow creating dylibs - if self.config.host.contains("musl") { + if self.config.host.contains("musl") + || self.is_vxworks_pure_dynamic() { rustc.arg("-Ctarget-feature=-crt-static"); } From 20b9ea88c7360bfbcf76021db568463deb158bc1 Mon Sep 17 00:00:00 2001 From: Baoshan Pang Date: Tue, 3 Sep 2019 19:01:14 -0700 Subject: [PATCH 4/5] change RUST_TEST_DYLINK to RUST_VXWORKS_TEST_DYLINK --- src/tools/compiletest/src/runtest.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 0bc77c6c502dc..7b68896df7e66 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1727,7 +1727,7 @@ impl<'test> TestCx<'test> { fn is_vxworks_pure_static(&self) -> bool { if self.config.target.contains("vxworks") { - match env::var("RUST_TEST_DYLINK") { + match env::var("RUST_VXWORKS_TEST_DYLINK") { Ok(s) => s != "1", _ => true } @@ -1738,7 +1738,7 @@ impl<'test> TestCx<'test> { fn is_vxworks_pure_dynamic(&self) -> bool { if self.config.target.contains("vxworks") { - match env::var("RUST_TEST_DYLINK") { + match env::var("RUST_VXWORKS_TEST_DYLINK") { Ok(s) => s == "1", _ => false } From bdc6cfc96a181653d6747762027902097e43bd3f Mon Sep 17 00:00:00 2001 From: Baoshan Pang Date: Thu, 5 Sep 2019 11:26:29 -0700 Subject: [PATCH 5/5] simplify is_vxworks_pure_dynamic --- src/tools/compiletest/src/runtest.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 84123cf326535..26fdfe9d1ef1b 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1733,14 +1733,7 @@ impl<'test> TestCx<'test> { } fn is_vxworks_pure_dynamic(&self) -> bool { - if self.config.target.contains("vxworks") { - match env::var("RUST_VXWORKS_TEST_DYLINK") { - Ok(s) => s == "1", - _ => false - } - } else { - false - } + self.config.target.contains("vxworks") && !self.is_vxworks_pure_static() } fn compose_and_run_compiler(&self, mut rustc: Command, input: Option) -> ProcRes {