Skip to content

Commit f84cab4

Browse files
authored
Rollup merge of rust-lang#48725 - humenda:master, r=nikomatsakis
Update L4Re target specification Due to the dynamically generated linker arguments of the L4Re build system, it is not a good idea to hard-code them in Rust. This PR undoes this step. It also adds an empty implementation to retrieve the number of CPUs.
2 parents 7bd8f6e + 9fd941e commit f84cab4

File tree

3 files changed

+23
-56
lines changed

3 files changed

+23
-56
lines changed

src/librustc_back/target/l4re_base.rs

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

11-
use PanicStrategy;
1211
use LinkerFlavor;
12+
use PanicStrategy;
1313
use target::{LinkArgs, TargetOptions};
1414
use std::default::Default;
15-
use std::env;
16-
use std::process::Command;
15+
//use std::process::Command;
1716

1817
// Use GCC to locate code for crt* libraries from the host, not from L4Re. Note
1918
// that a few files also come from L4Re, for these, the function shouldn't be
2019
// used. This uses GCC for the location of the file, but GCC is required for L4Re anyway.
21-
fn get_path_or(filename: &str) -> String {
22-
let child = Command::new("gcc")
23-
.arg(format!("-print-file-name={}", filename)).output()
24-
.expect("Failed to execute GCC");
25-
String::from_utf8(child.stdout)
26-
.expect("Couldn't read path from GCC").trim().into()
27-
}
20+
//fn get_path_or(filename: &str) -> String {
21+
// let child = Command::new("gcc")
22+
// .arg(format!("-print-file-name={}", filename)).output()
23+
// .expect("Failed to execute GCC");
24+
// String::from_utf8(child.stdout)
25+
// .expect("Couldn't read path from GCC").trim().into()
26+
//}
2827

29-
pub fn opts() -> Result<TargetOptions, String> {
30-
let l4re_lib_path = env::var_os("L4RE_LIBDIR").ok_or("Unable to find L4Re \
31-
library directory: L4RE_LIBDIR not set.")?.into_string().unwrap();
32-
let mut pre_link_args = LinkArgs::new();
33-
pre_link_args.insert(LinkerFlavor::Ld, vec![
34-
format!("-T{}/main_stat.ld", l4re_lib_path),
35-
"--defsym=__executable_start=0x01000000".to_string(),
36-
"--defsym=__L4_KIP_ADDR__=0x6ffff000".to_string(),
37-
format!("{}/crt1.o", l4re_lib_path),
38-
format!("{}/crti.o", l4re_lib_path),
39-
get_path_or("crtbeginT.o"),
40-
]);
41-
let mut post_link_args = LinkArgs::new();
42-
post_link_args.insert(LinkerFlavor::Ld, vec![
43-
format!("{}/l4f/libpthread.a", l4re_lib_path),
44-
format!("{}/l4f/libc_be_sig.a", l4re_lib_path),
45-
format!("{}/l4f/libc_be_sig_noop.a", l4re_lib_path),
46-
format!("{}/l4f/libc_be_socket_noop.a", l4re_lib_path),
47-
format!("{}/l4f/libc_be_fs_noop.a", l4re_lib_path),
48-
format!("{}/l4f/libc_be_sem_noop.a", l4re_lib_path),
49-
format!("{}/l4f/libl4re-vfs.o.a", l4re_lib_path),
50-
format!("{}/l4f/lib4re.a", l4re_lib_path),
51-
format!("{}/l4f/lib4re-util.a", l4re_lib_path),
52-
format!("{}/l4f/libc_support_misc.a", l4re_lib_path),
53-
format!("{}/l4f/libsupc++.a", l4re_lib_path),
54-
format!("{}/l4f/lib4shmc.a", l4re_lib_path),
55-
format!("{}/l4f/lib4re-c.a", l4re_lib_path),
56-
format!("{}/l4f/lib4re-c-util.a", l4re_lib_path),
57-
get_path_or("libgcc_eh.a"),
58-
format!("{}/l4f/libdl.a", l4re_lib_path),
59-
"--start-group".to_string(),
60-
format!("{}/l4f/libl4util.a", l4re_lib_path),
61-
format!("{}/l4f/libc_be_l4re.a", l4re_lib_path),
62-
format!("{}/l4f/libuc_c.a", l4re_lib_path),
63-
format!("{}/l4f/libc_be_l4refile.a", l4re_lib_path),
64-
"--end-group".to_string(),
65-
format!("{}/l4f/libl4sys.a", l4re_lib_path),
66-
"-gc-sections".to_string(),
67-
get_path_or("crtend.o"),
68-
format!("{}/crtn.o", l4re_lib_path),
69-
]);
28+
pub fn opts() -> TargetOptions {
29+
let mut args = LinkArgs::new();
30+
args.insert(LinkerFlavor::Gcc, vec![]);
7031

71-
Ok(TargetOptions {
32+
TargetOptions {
7233
executables: true,
7334
has_elf_tls: false,
7435
exe_allocation_crate: None,
7536
panic_strategy: PanicStrategy::Abort,
76-
pre_link_args,
77-
post_link_args,
37+
linker: Some("ld".to_string()),
38+
pre_link_args: args,
7839
target_family: Some("unix".to_string()),
7940
.. Default::default()
80-
})
41+
}
8142
}

src/librustc_back/target/x86_64_unknown_l4re_uclibc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use LinkerFlavor;
1212
use target::{Target, TargetResult};
1313

1414
pub fn target() -> TargetResult {
15-
let mut base = super::l4re_base::opts()?;
15+
let mut base = super::l4re_base::opts();
1616
base.cpu = "x86-64".to_string();
1717
base.max_atomic_width = Some(64);
1818

src/libtest/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,12 @@ fn get_concurrency() -> usize {
12941294
// FIXME: implement
12951295
1
12961296
}
1297+
1298+
#[cfg(target_os = "l4re")]
1299+
fn num_cpus() -> usize {
1300+
// FIXME: implement
1301+
1
1302+
}
12971303
}
12981304

12991305
pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> {

0 commit comments

Comments
 (0)