Skip to content

Commit 30117a1

Browse files
committed
Auto merge of rust-lang#103179 - ferrocene:pa-run-in-run-make, r=jyn514
Fix `src/test/run-make/issue-36710` on cross-compiled targets This PR fixes the `src/test/run-make/issue-36710` test not working on cross-compiled targets by telling the make infra how to run tests remotely with `remote-test-server`. This PR includes a revert of rust-lang#102723 (cc `@pcc),` which disabled that test on all cross-compiled targets.
2 parents 83356b7 + 00ec679 commit 30117a1

File tree

6 files changed

+54
-29
lines changed

6 files changed

+54
-29
lines changed

src/bootstrap/cc_detect.rs

+22-18
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,7 @@ fn set_compiler(
168168
// compiler already takes into account the triple in question.
169169
t if t.contains("android") => {
170170
if let Some(ndk) = config.and_then(|c| c.ndk.as_ref()) {
171-
let mut triple_iter = target.triple.split("-");
172-
let triple_translated = if let Some(arch) = triple_iter.next() {
173-
let arch_new = match arch {
174-
"arm" | "armv7" | "armv7neon" | "thumbv7" | "thumbv7neon" => "armv7a",
175-
other => other,
176-
};
177-
std::iter::once(arch_new).chain(triple_iter).collect::<Vec<&str>>().join("-")
178-
} else {
179-
target.triple.to_string()
180-
};
181-
182-
// API 19 is the earliest API level supported by NDK r25b but AArch64 and x86_64 support
183-
// begins at API level 21.
184-
let api_level =
185-
if t.contains("aarch64") || t.contains("x86_64") { "21" } else { "19" };
186-
let compiler = format!("{}{}-{}", triple_translated, api_level, compiler.clang());
187-
cfg.compiler(ndk.join("bin").join(compiler));
171+
cfg.compiler(ndk_compiler(compiler, &*target.triple, ndk));
188172
}
189173
}
190174

@@ -236,8 +220,28 @@ fn set_compiler(
236220
}
237221
}
238222

223+
pub(crate) fn ndk_compiler(compiler: Language, triple: &str, ndk: &Path) -> PathBuf {
224+
let mut triple_iter = triple.split("-");
225+
let triple_translated = if let Some(arch) = triple_iter.next() {
226+
let arch_new = match arch {
227+
"arm" | "armv7" | "armv7neon" | "thumbv7" | "thumbv7neon" => "armv7a",
228+
other => other,
229+
};
230+
std::iter::once(arch_new).chain(triple_iter).collect::<Vec<&str>>().join("-")
231+
} else {
232+
triple.to_string()
233+
};
234+
235+
// API 19 is the earliest API level supported by NDK r25b but AArch64 and x86_64 support
236+
// begins at API level 21.
237+
let api_level =
238+
if triple.contains("aarch64") || triple.contains("x86_64") { "21" } else { "19" };
239+
let compiler = format!("{}{}-{}", triple_translated, api_level, compiler.clang());
240+
ndk.join("bin").join(compiler)
241+
}
242+
239243
/// The target programming language for a native compiler.
240-
enum Language {
244+
pub(crate) enum Language {
241245
/// The compiler is targeting C.
242246
C,
243247
/// The compiler is targeting C++.

src/bootstrap/config.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::str::FromStr;
1515

1616
use crate::builder::TaskPath;
1717
use crate::cache::{Interned, INTERNER};
18+
use crate::cc_detect::{ndk_compiler, Language};
1819
use crate::channel::{self, GitInfo};
1920
pub use crate::flags::Subcommand;
2021
use crate::flags::{Color, Flags};
@@ -1237,8 +1238,12 @@ impl Config {
12371238
if let Some(s) = cfg.no_std {
12381239
target.no_std = s;
12391240
}
1240-
target.cc = cfg.cc.map(PathBuf::from);
1241-
target.cxx = cfg.cxx.map(PathBuf::from);
1241+
target.cc = cfg.cc.map(PathBuf::from).or_else(|| {
1242+
target.ndk.as_ref().map(|ndk| ndk_compiler(Language::C, &triple, ndk))
1243+
});
1244+
target.cxx = cfg.cxx.map(PathBuf::from).or_else(|| {
1245+
target.ndk.as_ref().map(|ndk| ndk_compiler(Language::CPlusPlus, &triple, ndk))
1246+
});
12421247
target.ar = cfg.ar.map(PathBuf::from);
12431248
target.ranlib = cfg.ranlib.map(PathBuf::from);
12441249
target.linker = cfg.linker.map(PathBuf::from);

src/ci/docker/host-x86_64/armhf-gnu/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-
99
curl \
1010
file \
1111
g++ \
12-
gcc-arm-linux-gnueabihf \
12+
g++-arm-linux-gnueabihf \
1313
git \
1414
libc6-dev \
1515
libc6-dev-armhf-cross \

src/test/run-make-fulldeps/tools.mk

+17-6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ endif
4040
# e.g. for `$(CC) -o $(RUN_BINFILE)`.
4141
RUN_BINFILE = $(TMPDIR)/$(1)
4242

43+
# Invoke the generated binary on the remote machine if compiletest was
44+
# configured to use a remote test device, otherwise run it on the current host.
45+
ifdef REMOTE_TEST_CLIENT
46+
# FIXME: if a test requires additional files, this will need to be changed to
47+
# also push them (by changing the 0 to the number of additional files, and
48+
# providing the path of the additional files as the last arguments).
49+
EXECUTE = $(REMOTE_TEST_CLIENT) run 0 $(RUN_BINFILE)
50+
else
51+
EXECUTE = $(RUN_BINFILE)
52+
endif
53+
4354
# RUN and FAIL are basic way we will invoke the generated binary. On
4455
# non-windows platforms, they set the LD_LIBRARY_PATH environment
4556
# variable before running the binary.
@@ -50,16 +61,16 @@ BIN = $(1)
5061
UNAME = $(shell uname)
5162

5263
ifeq ($(UNAME),Darwin)
53-
RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
54-
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
64+
RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
65+
FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
5566
DYLIB_GLOB = lib$(1)*.dylib
5667
DYLIB = $(TMPDIR)/lib$(1).dylib
5768
STATICLIB = $(TMPDIR)/lib$(1).a
5869
STATICLIB_GLOB = lib$(1)*.a
5970
else
6071
ifdef IS_WINDOWS
61-
RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
62-
FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
72+
RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE)
73+
FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE) && exit 1 || exit 0
6374
DYLIB_GLOB = $(1)*.dll
6475
DYLIB = $(TMPDIR)/$(1).dll
6576
ifdef IS_MSVC
@@ -73,8 +84,8 @@ endif
7384
BIN = $(1).exe
7485
LLVM_FILECHECK := $(shell cygpath -u "$(LLVM_FILECHECK)")
7586
else
76-
RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
77-
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
87+
RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
88+
FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
7889
DYLIB_GLOB = lib$(1)*.so
7990
DYLIB = $(TMPDIR)/lib$(1).so
8091
STATICLIB = $(TMPDIR)/lib$(1).a

src/test/run-make/issue-36710/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# ignore-cross-compile $(call RUN,foo) expects to run the target executable natively
2-
# so it won't work with remote-test-server
31
# ignore-none no-std is not supported
2+
# ignore-wasm32 FIXME: don't attempt to compile C++ to WASM
3+
# ignore-wasm64 FIXME: don't attempt to compile C++ to WASM
4+
# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for `std`
45
# ignore-musl FIXME: this makefile needs teaching how to use a musl toolchain
56
# (see dist-i586-gnu-i586-i686-musl Dockerfile)
67

src/tools/compiletest/src/runtest.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,10 @@ impl<'test> TestCx<'test> {
29872987
cmd.env("LLVM_BIN_DIR", llvm_bin_dir);
29882988
}
29892989

2990+
if let Some(ref remote_test_client) = self.config.remote_test_client {
2991+
cmd.env("REMOTE_TEST_CLIENT", remote_test_client);
2992+
}
2993+
29902994
// We don't want RUSTFLAGS set from the outside to interfere with
29912995
// compiler flags set in the test cases:
29922996
cmd.env_remove("RUSTFLAGS");

0 commit comments

Comments
 (0)