Skip to content

Commit db5c9b5

Browse files
committed
a hopeless attempt
1 parent 85aa7af commit db5c9b5

File tree

6 files changed

+71
-46
lines changed

6 files changed

+71
-46
lines changed

ci/docker/aarch64_be-unknown-linux-gnu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN mkdir /toolchains && mv "./${TOOLCHAIN}" /toolchains
2424
ENV AARCH64_BE_TOOLCHAIN="/toolchains/${TOOLCHAIN}"
2525
ENV AARCH64_BE_LIBC="${AARCH64_BE_TOOLCHAIN}/aarch64_be-none-linux-gnu/libc"
2626

27-
ENV CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER="${AARCH64_BE_TOOLCHAIN}/bin/aarch64_be-none-linux-gnu-gcc"
27+
ENV CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER="${AARCH64_BE_TOOLCHAIN}/bin/aarch64_be-none-linux-gnu-g++"
2828
ENV CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64_be -cpu max -L ${AARCH64_BE_LIBC}"
2929
ENV OBJDUMP="${AARCH64_BE_TOOLCHAIN}/bin/aarch64_be-none-linux-gnu-objdump"
3030
ENV STDARCH_TEST_SKIP_FEATURE=tme

ci/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ STD_DETECT="--manifest-path=crates/std_detect/Cargo.toml"
8282
STDARCH_EXAMPLES="--manifest-path=examples/Cargo.toml"
8383
INTRINSIC_TEST="--manifest-path=crates/intrinsic-test/Cargo.toml"
8484

85-
cargo_test "${CORE_ARCH} ${PROFILE}"
85+
# cargo_test "${CORE_ARCH} ${PROFILE}"
8686

8787
if [ "$NOSTD" != "1" ]; then
8888
cargo_test "${STD_DETECT} ${PROFILE}"

crates/intrinsic-test/src/arm/compile.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::common::compile_c::CompilationCommandBuilder;
1+
use crate::common::compile_c::{CompilationCommand, CompilationCommandBuilder};
22

33
pub fn compile_c_arm(
44
compiler: &str,
@@ -67,12 +67,14 @@ pub fn compile_c_arm(
6767
command.command_mut().arg("-c");
6868
}
6969
command.command_mut().args(["-o", output]);
70+
71+
if let CompilationCommand::CustomLinker { linker, .. } = &mut command {
72+
linker.arg(format!("c_programs/{output}"));
73+
}
7074
} else {
7175
trace!("running {compiler}");
7276
}
7377

74-
trace!("running {compiler}\n{:?}", &command);
75-
7678
if log::log_enabled!(log::Level::Trace) {
7779
command.command_mut().stdout(std::process::Stdio::inherit());
7880
command.command_mut().stderr(std::process::Stdio::inherit());

crates/intrinsic-test/src/arm/mod.rs

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,51 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
9696
)
9797
.unwrap();
9898

99-
let mut inputs = vec![format!("main.cpp")];
100-
for i in 0..Ord::min(available_parallelism, self.intrinsics.len()) {
101-
inputs.push(format!("mod_{i}.o"));
99+
if let Some(linker) = &self.cli_options.linker {
100+
compile_c_arm(
101+
compiler,
102+
target,
103+
cxx_toolchain_dir,
104+
&["main.cpp".to_string()],
105+
Some("intrinsic-test-programs.o"),
106+
);
107+
108+
let mut cmd = std::process::Command::new(linker);
109+
cmd.current_dir("c_programs");
110+
111+
let mut inputs = vec![];
112+
for i in 0..Ord::min(available_parallelism, self.intrinsics.len()) {
113+
inputs.push(format!("mod_{i}.o"));
114+
}
115+
cmd.args(inputs);
116+
117+
cmd.arg("intrinsic-test-programs.o");
118+
119+
cmd.arg("-o");
120+
cmd.arg("intrinsic-test-programs");
121+
122+
if log::log_enabled!(log::Level::Trace) {
123+
cmd.stdout(std::process::Stdio::inherit());
124+
cmd.stderr(std::process::Stdio::inherit());
125+
}
126+
127+
assert!(cmd.output().unwrap().status.success());
128+
} else {
129+
let mut inputs = vec![format!("main.cpp")];
130+
for i in 0..Ord::min(available_parallelism, self.intrinsics.len()) {
131+
inputs.push(format!("mod_{i}.o"));
132+
}
133+
134+
compile_c_arm(
135+
compiler,
136+
target,
137+
cxx_toolchain_dir,
138+
&inputs,
139+
Some("intrinsic-test-programs"),
140+
);
102141
}
103142

104-
compile_c_arm(
105-
compiler,
106-
target,
107-
cxx_toolchain_dir,
108-
&inputs,
109-
Some("intrinsic-test-programs"),
110-
)
143+
true
111144
}
112145

113146
fn build_rust_file(&self) -> bool {
@@ -153,8 +186,6 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
153186
.map(|(i, chunk)| {
154187
use std::io::Write;
155188

156-
dbg!(chunk_size, chunk.len());
157-
158189
let rust_filename = format!("rust_programs/src/mod_{i}.rs");
159190
trace!("generating `{rust_filename}`");
160191
let mut file = File::create(rust_filename).unwrap();

crates/intrinsic-test/src/common/compile_c.rs

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::path::PathBuf;
2-
31
#[derive(Clone)]
42
pub struct CompilationCommandBuilder {
53
compiler: String,
@@ -9,7 +7,6 @@ pub struct CompilationCommandBuilder {
97
optimization: String,
108
include_paths: Vec<String>,
119
project_root: Option<String>,
12-
output: String,
1310
linker: Option<String>,
1411
extra_flags: Vec<String>,
1512
}
@@ -24,7 +21,6 @@ impl CompilationCommandBuilder {
2421
optimization: "2".to_string(),
2522
include_paths: Vec::new(),
2623
project_root: None,
27-
output: String::new(),
2824
linker: None,
2925
extra_flags: Vec::new(),
3026
}
@@ -91,10 +87,10 @@ impl CompilationCommandBuilder {
9187
#[allow(clippy::large_enum_variant)]
9288
pub enum CompilationCommand {
9389
Simple(std::process::Command),
90+
#[allow(unused)]
9491
CustomLinker {
9592
cmd: std::process::Command,
9693
linker: std::process::Command,
97-
cleanup: PathBuf,
9894
},
9995
}
10096

@@ -112,12 +108,9 @@ impl CompilationCommand {
112108
CompilationCommand::CustomLinker {
113109
mut cmd,
114110
mut linker,
115-
cleanup,
116111
} => {
117112
let output = cmd.output()?;
118113

119-
linker.current_dir("c_programs");
120-
121114
if log::log_enabled!(log::Level::Trace) {
122115
linker.stdout(std::process::Stdio::inherit());
123116
linker.stderr(std::process::Stdio::inherit());
@@ -129,9 +122,9 @@ impl CompilationCommand {
129122
linker.get_program(),
130123
);
131124
}
132-
if cleanup.exists() {
133-
std::fs::remove_file(cleanup)?;
134-
}
125+
// if cleanup.exists() {
126+
// std::fs::remove_file(cleanup)?;
127+
// }
135128

136129
Ok(output)
137130
}
@@ -141,8 +134,8 @@ impl CompilationCommand {
141134

142135
impl CompilationCommandBuilder {
143136
pub fn into_command(self) -> CompilationCommand {
144-
let project_root = self.project_root.unwrap_or_default();
145-
let project_root_str = project_root.as_str();
137+
// let project_root = self.project_root.unwrap_or_default();
138+
// let project_root_str = project_root.as_str();
146139

147140
let mut cmd = std::process::Command::new(self.compiler);
148141

@@ -159,28 +152,27 @@ impl CompilationCommandBuilder {
159152
cmd.arg(format!("--target={target}"));
160153
}
161154

162-
if let (Some(linker), Some(cxx_toolchain_dir)) = (&self.linker, &self.cxx_toolchain_dir) {
155+
if let (Some(_linker), Some(cxx_toolchain_dir)) = (&self.linker, &self.cxx_toolchain_dir) {
163156
cmd.arg("-c");
164157
cmd.args(
165158
self.include_paths
166159
.iter()
167160
.map(|path| "--include-directory=".to_string() + cxx_toolchain_dir + path),
168161
);
169162

170-
let output = "dummy_value";
171-
let mut linker_cmd = std::process::Command::new(linker);
172-
linker_cmd.arg(format!("{project_root_str}/{output}"));
163+
// let linker_cmd = std::process::Command::new(linker);
164+
// linker_cmd.arg(format!("{project_root_str}/{output}"));
173165

174-
linker_cmd.arg("-o");
175-
linker_cmd.arg(format!("{project_root_str}/{}", self.output));
166+
// let remove_path = PathBuf::new();
167+
// PathBuf::from(format!("{project_root_str}/{output}"));
176168

177-
let remove_path = PathBuf::from(format!("{project_root_str}/{output}"));
169+
// CompilationCommand::CustomLinker {
170+
// cmd,
171+
// linker: linker_cmd,
172+
// // cleanup: remove_path,
173+
// }
178174

179-
CompilationCommand::CustomLinker {
180-
cmd,
181-
linker: linker_cmd,
182-
cleanup: remove_path,
183-
}
175+
CompilationCommand::Simple(cmd)
184176
} else {
185177
CompilationCommand::Simple(cmd)
186178
}

crates/intrinsic-test/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ fn main() {
3636

3737
let test_environment = test_environment_result.unwrap();
3838

39-
warn!("building Rust binaries");
40-
if !test_environment.build_rust_file() {
41-
std::process::exit(3);
42-
}
4339
warn!("building C binaries");
4440
if !test_environment.build_c_file() {
4541
std::process::exit(2);
4642
}
43+
warn!("building Rust binaries");
44+
if !test_environment.build_rust_file() {
45+
std::process::exit(3);
46+
}
4747
warn!("comparing outputs");
4848
if !test_environment.compare_outputs() {
4949
std::process::exit(1);

0 commit comments

Comments
 (0)