Skip to content

Commit 01f159e

Browse files
committed
DEFAULT_TARGET -> HOST_TARGET
1 parent 8a3ed3c commit 01f159e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/docbuilder/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl Metadata {
130130
metadata
131131
}
132132
pub(super) fn select_extra_targets<'a: 'ret, 'b: 'ret, 'ret>(&'a self) -> (&'ret str, Vec<&'ret str>) {
133-
use super::rustwide_builder::{DEFAULT_TARGET, TARGETS};
133+
use super::rustwide_builder::{HOST_TARGET, TARGETS};
134134
// Let people opt-in to only having specific targets
135135
// Ideally this would use Iterator instead of Vec so I could collect to a `HashSet`,
136136
// but I had trouble with `chain()` ¯\_(ツ)_/¯
@@ -142,7 +142,7 @@ impl Metadata {
142142

143143
// default_target unset and extra_targets set to `[]`
144144
let landing_page = if all_targets.is_empty() {
145-
DEFAULT_TARGET
145+
HOST_TARGET
146146
} else {
147147
// This `swap_remove` has to come before the `sort()` to keep the ordering
148148
// `swap_remove` is ok because ordering doesn't matter except for first element

src/docbuilder/rustwide_builder.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ use super::Metadata;
2121
const USER_AGENT: &str = "docs.rs builder (https://github.com/rust-lang/docs.rs)";
2222
const DEFAULT_RUSTWIDE_WORKSPACE: &str = ".rustwide";
2323

24-
pub(super) const DEFAULT_TARGET: &str = "x86_64-unknown-linux-gnu";
24+
// It is crucial that this be the same as the host that `docs.rs` is being run on.
25+
// Other values may cause strange and hard-to-debug errors.
26+
// TODO: use `TARGET` instead? I think `TARGET` is only set for build scripts, though.
27+
pub(super) const HOST_TARGET: &str = "x86_64-unknown-linux-gnu";
2528
pub(super) const TARGETS: &[&str] = &[
2629
"i686-pc-windows-msvc",
2730
"i686-unknown-linux-gnu",
@@ -191,7 +194,7 @@ impl RustwideBuilder {
191194
.run(|build| {
192195
let metadata = Metadata::from_source_dir(&build.host_source_dir())?;
193196

194-
let res = self.execute_build(DEFAULT_TARGET, true, build, &limits, &metadata)?;
197+
let res = self.execute_build(HOST_TARGET, true, build, &limits, &metadata)?;
195198
if !res.result.successful {
196199
bail!("failed to build dummy crate for {}", self.rustc_version);
197200
}
@@ -447,7 +450,7 @@ impl RustwideBuilder {
447450
rustdoc_flags.append(&mut package_rustdoc_args.iter().map(|s| s.to_owned()).collect());
448451
}
449452
let mut cargo_args = vec!["doc".to_owned(), "--lib".to_owned(), "--no-deps".to_owned()];
450-
if target != DEFAULT_TARGET {
453+
if target != HOST_TARGET {
451454
cargo_args.push("--target".to_owned());
452455
cargo_args.push(target.to_owned());
453456
};
@@ -487,7 +490,7 @@ impl RustwideBuilder {
487490
// cargo will put the output in `target/<target>/doc`.
488491
// However, if this is the default build, we don't want it there,
489492
// we want it in `target/doc`.
490-
if target != DEFAULT_TARGET && is_default_target {
493+
if target != HOST_TARGET && is_default_target {
491494
// mv target/target/doc target/doc
492495
let target_dir = build.host_target_dir();
493496
let old_dir = target_dir.join(target).join("doc");

0 commit comments

Comments
 (0)