Skip to content

Commit 3d1d66d

Browse files
author
bors-servo
authored
Auto merge of #146 - servo:build, r=jdm
Pass -stdlib=libc++ on Apple systems ``` /Users/nox/src/mozjs/target/debug/build/mozjs_sys-0b48e14e1603d6a2/out/dist/include/mozilla/Span.h:32:10: fatal error: 'array' file not found ``` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/mozjs/146) <!-- Reviewable:end -->
2 parents 9b44b1e + dd270bf commit 3d1d66d

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env:
2626

2727
before_script:
2828
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CC=gcc-6; export CXX=g++-6; fi
29-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install [email protected] ccache yasm; fi
29+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install [email protected] ccache llvm yasm; fi
3030

3131
script:
3232
- ccache -z

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository = "https://github.com/servo/mozjs/"
5-
version = "0.60.0"
5+
version = "0.60.1"
66
authors = ["Mozilla"]
77
links = "mozjs"
88
build = "build.rs"

build.rs

+21-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use std::ffi::{OsStr, OsString};
1111
use std::process::{Command, Stdio};
1212

1313
fn main() {
14-
if cfg!(feature = "debugmozjs") && cfg!(windows) {
14+
let target = env::var("TARGET").unwrap();
15+
if env::var_os("CARGO_FEATURE_DEBUGMOZJS").is_some() && target.contains("windows") {
1516
// https://github.com/rust-lang/rust/issues/39016
1617
panic!("Rustc doesn't support MSVC debug runtime.");
1718
}
@@ -38,22 +39,23 @@ fn cc_flags() -> Vec<&'static str> {
3839
"-DSTATIC_JS_API",
3940
];
4041

41-
if cfg!(feature = "debugmozjs") {
42+
if env::var_os("CARGO_FEATURE_DEBUGMOZJS").is_some() {
4243
result.extend(&[
4344
"-DJS_GC_ZEAL",
4445
"-DDEBUG",
4546
"-DJS_DEBUG",
4647
]);
4748
}
4849

49-
if cfg!(windows) {
50+
let target = env::var("TARGET").unwrap();
51+
if target.contains("windows") {
5052
result.extend(&[
5153
"-std=c++14",
5254
"-DWIN32",
53-
// Don't use reinterpret_cast() in offsetof(),
54-
// since it's not a constant expression, so can't
55-
// be used in static_assert().
56-
"-D_CRT_USE_BUILTIN_OFFSETOF",
55+
// Don't use reinterpret_cast() in offsetof(),
56+
// since it's not a constant expression, so can't
57+
// be used in static_assert().
58+
"-D_CRT_USE_BUILTIN_OFFSETOF",
5759
]);
5860
} else {
5961
result.extend(&[
@@ -64,6 +66,13 @@ fn cc_flags() -> Vec<&'static str> {
6466
]);
6567
}
6668

69+
let is_apple = target.contains("apple");
70+
let is_freebsd = target.contains("freebsd");
71+
72+
if is_apple || is_freebsd {
73+
result.push("-stdlib=libc++");
74+
}
75+
6776
result
6877
}
6978

@@ -86,7 +95,7 @@ fn build_jsapi() {
8695

8796
// We're using the MSYS make which doesn't work with the mingw32-make-style
8897
// MAKEFLAGS, so remove that from the env if present.
89-
if cfg!(windows) {
98+
if target.contains("windows") {
9099
cmd.env_remove("MAKEFLAGS").env_remove("MFLAGS");
91100
} else if let Some(makeflags) = env::var_os("CARGO_MAKEFLAGS") {
92101
cmd.env("MAKEFLAGS", makeflags);
@@ -133,8 +142,9 @@ fn build_jsglue() {
133142
build.flag_if_supported(flag);
134143
}
135144

145+
let target = env::var("TARGET").unwrap();
136146
let config = format!("{}/js/src/js-confdefs.h", out.display());
137-
if cfg!(windows) {
147+
if target.contains("windows") {
138148
build.flag("-FI");
139149
} else {
140150
build.flag("-include");
@@ -180,7 +190,8 @@ fn build_jsapi_bindings() {
180190
.clang_arg("-I").clang_arg(out.join("js/src").to_str().expect("UTF-8"))
181191
.clang_arg("-x").clang_arg("c++");
182192

183-
if cfg!(windows) {
193+
let target = env::var("TARGET").unwrap();
194+
if target.contains("windows") {
184195
builder = builder.clang_arg("-fms-compatibility");
185196
}
186197

0 commit comments

Comments
 (0)