From 079baafdf1fc90805373ff2ef7d57eea3a7f15ce Mon Sep 17 00:00:00 2001 From: "Pang, Baoshan" Date: Fri, 7 Aug 2020 16:55:15 -0700 Subject: [PATCH] For VxWorks: fix building errors use wr-c++ as linker --- library/std/src/sys/vxworks/fd.rs | 2 +- .../std/src/sys/vxworks/process/process_common.rs | 15 +++------------ library/std/src/sys/vxworks/thread_local_dtor.rs | 2 +- src/bootstrap/cc_detect.rs | 3 ++- src/bootstrap/lib.rs | 4 ++++ 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/library/std/src/sys/vxworks/fd.rs b/library/std/src/sys/vxworks/fd.rs index ea186846929be..d58468ad539ff 100644 --- a/library/std/src/sys/vxworks/fd.rs +++ b/library/std/src/sys/vxworks/fd.rs @@ -53,7 +53,7 @@ impl FileDesc { } #[inline] - fn is_read_vectored(&self) -> bool { + pub fn is_read_vectored(&self) -> bool { true } diff --git a/library/std/src/sys/vxworks/process/process_common.rs b/library/std/src/sys/vxworks/process/process_common.rs index bbbd5eda77314..6473a0c3cec41 100644 --- a/library/std/src/sys/vxworks/process/process_common.rs +++ b/library/std/src/sys/vxworks/process/process_common.rs @@ -351,8 +351,7 @@ impl ExitStatus { } fn exited(&self) -> bool { - /*unsafe*/ - { libc::WIFEXITED(self.0) } + libc::WIFEXITED(self.0) } pub fn success(&self) -> bool { @@ -360,19 +359,11 @@ impl ExitStatus { } pub fn code(&self) -> Option { - if self.exited() { - Some(/*unsafe*/ { libc::WEXITSTATUS(self.0) }) - } else { - None - } + if self.exited() { Some(libc::WEXITSTATUS(self.0)) } else { None } } pub fn signal(&self) -> Option { - if !self.exited() { - Some(/*unsafe*/ { libc::WTERMSIG(self.0) }) - } else { - None - } + if !self.exited() { Some(libc::WTERMSIG(self.0)) } else { None } } } diff --git a/library/std/src/sys/vxworks/thread_local_dtor.rs b/library/std/src/sys/vxworks/thread_local_dtor.rs index 3f73f6c490326..5391ed83ebc36 100644 --- a/library/std/src/sys/vxworks/thread_local_dtor.rs +++ b/library/std/src/sys/vxworks/thread_local_dtor.rs @@ -2,6 +2,6 @@ #![unstable(feature = "thread_local_internals", issue = "none")] pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - use crate::sys_common::thread_local::register_dtor_fallback; + use crate::sys_common::thread_local_dtor::register_dtor_fallback; register_dtor_fallback(t, dtor); } diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs index 7ff00d85dd2f2..d50e4cf52697a 100644 --- a/src/bootstrap/cc_detect.rs +++ b/src/bootstrap/cc_detect.rs @@ -132,7 +132,8 @@ pub fn find(build: &mut Build) { false }; - if cxx_configured { + // for VxWorks, record CXX compiler which will be used in lib.rs:linker() + if cxx_configured || target.contains("vxworks") { let compiler = cfg.get_compiler(); build.cxx.insert(target, compiler); } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 77820ef87e3b4..c93df8d514912 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -857,6 +857,10 @@ impl Build { if let Some(linker) = self.config.target_config.get(&target).and_then(|c| c.linker.as_ref()) { Some(linker) + } else if target.contains("vxworks") { + // need to use CXX compiler as linker to resolve the exception functions + // that are only existed in CXX libraries + Some(self.cxx[&target].path()) } else if target != self.config.build && util::use_host_linker(target) && !target.contains("msvc")