Skip to content

Commit 85f8f33

Browse files
committed
remote-test-server: make it build for Motor OS
Had to tweak linking options in target spec to make it work (see moturus/motor-os#46).
1 parent c910098 commit 85f8f33

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

compiler/rustc_target/src/spec/base/motor.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ use crate::spec::{
44

55
pub(crate) fn opts() -> TargetOptions {
66
let pre_link_args = TargetOptions::link_args(
7-
LinkerFlavor::Gnu(Cc::No, Lld::No),
7+
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
88
&[
99
"-e",
1010
"motor_start",
11-
"--no-undefined",
12-
"--error-unresolved-symbols",
13-
"--no-undefined-version",
14-
"-u",
11+
"-u",
1512
"__rust_abort",
1613
],
1714
);
@@ -23,7 +20,7 @@ pub(crate) fn opts() -> TargetOptions {
2320
// We use "OS level" TLS (see thread/local.rs in stdlib).
2421
has_thread_local: false,
2522
frame_pointer: FramePointer::NonLeaf,
26-
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::No),
23+
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
2724
main_needs_argc_argv: true,
2825
panic_strategy: PanicStrategy::Abort,
2926
pre_link_args,

compiler/rustc_target/src/spec/targets/x86_64_unknown_motor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::spec::{
2-
Arch, CodeModel, LinkSelfContainedDefault, LldFlavor, RelocModel, RelroLevel, Target, base,
2+
Arch, CodeModel, LinkSelfContainedDefault, RelocModel, RelroLevel, Target, base,
33
};
44

55
pub(crate) fn target() -> Target {
@@ -15,7 +15,6 @@ pub(crate) fn target() -> Target {
1515
base.relro_level = RelroLevel::Full;
1616
base.static_position_independent_executables = true;
1717
base.relocation_model = RelocModel::Pic;
18-
base.lld_flavor_json = LldFlavor::Ld;
1918
base.link_self_contained = LinkSelfContainedDefault::True;
2019
base.dynamic_linking = false;
2120
base.crt_static_default = true;

src/tools/remote-test-server/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
//! themselves having support libraries. All data over the TCP sockets is in a
1111
//! basically custom format suiting our needs.
1212
13-
#[cfg(not(windows))]
13+
#[cfg(all(not(windows), not(target_os = "motor")))]
1414
use std::fs::Permissions;
1515
use std::fs::{self, File};
1616
use std::io::prelude::*;
1717
use std::io::{self, BufReader};
1818
use std::net::{SocketAddr, TcpListener, TcpStream};
19-
#[cfg(not(windows))]
19+
#[cfg(all(not(windows), not(target_os = "motor")))]
2020
use std::os::unix::prelude::*;
2121
use std::path::{Path, PathBuf};
2222
use std::process::{Command, ExitStatus, Stdio};
@@ -325,15 +325,15 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf
325325
]));
326326
}
327327

328-
#[cfg(not(windows))]
328+
#[cfg(all(not(windows), not(target_os = "motor")))]
329329
fn get_status_code(status: &ExitStatus) -> (u8, i32) {
330330
match status.code() {
331331
Some(n) => (0, n),
332332
None => (1, status.signal().unwrap()),
333333
}
334334
}
335335

336-
#[cfg(windows)]
336+
#[cfg(any(windows, target_os = "motor"))]
337337
fn get_status_code(status: &ExitStatus) -> (u8, i32) {
338338
(0, status.code().unwrap())
339339
}
@@ -359,11 +359,11 @@ fn recv<B: BufRead>(dir: &Path, io: &mut B) -> PathBuf {
359359
dst
360360
}
361361

362-
#[cfg(not(windows))]
362+
#[cfg(all(not(windows), not(target_os = "motor")))]
363363
fn set_permissions(path: &Path) {
364364
t!(fs::set_permissions(&path, Permissions::from_mode(0o755)));
365365
}
366-
#[cfg(windows)]
366+
#[cfg(any(windows, target_os = "motor"))]
367367
fn set_permissions(_path: &Path) {}
368368

369369
fn my_copy(src: &mut dyn Read, which: u8, dst: &Mutex<dyn Write>) {

0 commit comments

Comments
 (0)