Skip to content

Commit 60842c1

Browse files
committed
Rollup merge of rust-lang#38451 - semarie:openbsd-rustbuild, r=alexcrichton
adaptation to rustbuild for openbsd Since the switch to rustbuild, the build for openbsd is broken: - [X] `ar` inference based on compiler name is wrong (OpenBSD usually use `egcc`, but `ear` doesn't exist) - [X] `make` isn't GNU-make under OpenBSD (and others BSD platforms) - [x] `stdc++` isn't the right stdc++ library to link with (it should be `estdc++`) - [x] corrects tests that don't pass anymore (problems related to rustbuild) r? @alexcrichton
2 parents a8e7f95 + 2c39ee1 commit 60842c1

File tree

9 files changed

+32
-6
lines changed

9 files changed

+32
-6
lines changed

src/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/check.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
//! This file implements the various regression test suites that we execute on
1414
//! our CI.
1515
16+
extern crate build_helper;
17+
1618
use std::collections::HashSet;
1719
use std::env;
1820
use std::fmt;
@@ -543,7 +545,7 @@ pub fn distcheck(build: &Build) {
543545
build.run(&mut cmd);
544546
build.run(Command::new("./configure")
545547
.current_dir(&dir));
546-
build.run(Command::new("make")
548+
build.run(Command::new(build_helper::make(&build.config.build))
547549
.arg("check")
548550
.current_dir(&dir));
549551
}

src/build_helper/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ pub fn cc2ar(cc: &Path, target: &str) -> Option<PathBuf> {
4747
None
4848
} else if target.contains("musl") {
4949
Some(PathBuf::from("ar"))
50+
} else if target.contains("openbsd") {
51+
Some(PathBuf::from("ar"))
5052
} else {
5153
let parent = cc.parent().unwrap();
5254
let file = cc.file_name().unwrap().to_str().unwrap();
@@ -61,6 +63,16 @@ pub fn cc2ar(cc: &Path, target: &str) -> Option<PathBuf> {
6163
}
6264
}
6365

66+
pub fn make(host: &str) -> PathBuf {
67+
if host.contains("bitrig") || host.contains("dragonfly") ||
68+
host.contains("freebsd") || host.contains("netbsd") ||
69+
host.contains("openbsd") {
70+
PathBuf::from("gmake")
71+
} else {
72+
PathBuf::from("make")
73+
}
74+
}
75+
6476
pub fn output(cmd: &mut Command) -> String {
6577
let output = match cmd.stderr(Stdio::inherit()).output() {
6678
Ok(status) => status,

src/liballoc_jemalloc/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn main() {
151151
cmd.arg(format!("--build={}", build_helper::gnu_target(&host)));
152152

153153
run(&mut cmd);
154-
let mut make = Command::new("make");
154+
let mut make = Command::new(build_helper::make(&host));
155155
make.current_dir(&build_dir)
156156
.arg("build_lib_static");
157157

src/librustc_llvm/build.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,25 @@ fn main() {
230230
}
231231
}
232232

233+
// OpenBSD has a particular C++ runtime library name
234+
let stdcppname = if target.contains("openbsd") {
235+
"estdc++"
236+
} else {
237+
"stdc++"
238+
};
239+
233240
// C++ runtime library
234241
if !target.contains("msvc") {
235242
if let Some(s) = env::var_os("LLVM_STATIC_STDCPP") {
236243
assert!(!cxxflags.contains("stdlib=libc++"));
237244
let path = PathBuf::from(s);
238245
println!("cargo:rustc-link-search=native={}",
239246
path.parent().unwrap().display());
240-
println!("cargo:rustc-link-lib=static=stdc++");
247+
println!("cargo:rustc-link-lib=static={}", stdcppname);
241248
} else if cxxflags.contains("stdlib=libc++") {
242249
println!("cargo:rustc-link-lib=c++");
243250
} else {
244-
println!("cargo:rustc-link-lib=stdc++");
251+
println!("cargo:rustc-link-lib={}", stdcppname);
245252
}
246253
}
247254
}

src/libstd/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn build_libbacktrace(host: &str, target: &str) {
104104
.env("AR", &ar)
105105
.env("RANLIB", format!("{} s", ar.display()))
106106
.env("CFLAGS", cflags));
107-
run(Command::new("make")
107+
run(Command::new(build_helper::make(host))
108108
.current_dir(&build_dir)
109109
.arg(format!("INCDIR={}", src_dir.display()))
110110
.arg("-j").arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));

src/test/run-pass/backtrace.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-android FIXME #17520
1212
// ignore-emscripten spawning processes is not supported
13+
// ignore-openbsd no support for libbacktrace without filename
1314
// compile-flags:-g
1415

1516
use std::env;

src/tools/compiletest/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ build = "build.rs"
88
log = "0.3"
99
env_logger = { version = "0.3.5", default-features = false }
1010
serialize = { path = "../../libserialize" }
11+
build_helper = { path = "../../build_helper" }

src/tools/compiletest/src/runtest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
extern crate build_helper;
12+
1113
use common::Config;
1214
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
1315
use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc, CodegenUnits};
@@ -2108,7 +2110,7 @@ actual:\n\
21082110
}
21092111
self.create_dir_racy(&tmpdir);
21102112

2111-
let mut cmd = Command::new("make");
2113+
let mut cmd = Command::new(build_helper::make(&self.config.host));
21122114
cmd.current_dir(&self.testpaths.file)
21132115
.env("TARGET", &self.config.target)
21142116
.env("PYTHON", &self.config.docck_python)

0 commit comments

Comments
 (0)