Skip to content

Commit 639a4cc

Browse files
authored
Merge branch 'main' into avoid-xrun
2 parents 7c3de38 + 53fb72c commit 639a4cc

File tree

4 files changed

+104
-28
lines changed

4 files changed

+104
-28
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
10-
build: [stable, beta, nightly, linux32, macos, aarch64-ios, win32, win64, mingw32, mingw64, windows-2016]
10+
build: [stable, beta, nightly, linux32, macos, aarch64-ios, win32, win64, mingw32, mingw64, windows-2019]
1111
include:
1212
- build: stable
1313
os: ubuntu-latest
@@ -40,23 +40,27 @@ jobs:
4040
target: aarch64-pc-windows-msvc
4141
no_run: --no-run
4242
- build: win32
43-
os: windows-2016
43+
os: windows-2019
4444
rust: stable-i686-msvc
4545
target: i686-pc-windows-msvc
4646
- build: win64
4747
os: windows-latest
4848
rust: stable
4949
target: x86_64-pc-windows-msvc
5050
- build: mingw32
51-
os: windows-latest
51+
# windows-latest, a.k.a. windows-2022, runner is equipped with
52+
# a newer mingw toolchain, which appears to produce unexecutable
53+
# mixed-language binaries in debug builds. Fall back to
54+
# windows-2019 for now and revisit it later...
55+
os: windows-2019
5256
rust: stable-i686-gnu
5357
target: i686-pc-windows-gnu
5458
- build: mingw64
5559
os: windows-latest
5660
rust: stable-x86_64-gnu
5761
target: x86_64-pc-windows-gnu
58-
- build: windows-2016
59-
os: windows-2016
62+
- build: windows-2019
63+
os: windows-2019
6064
rust: stable-x86_64
6165
target: x86_64-pc-windows-msvc
6266
steps:
@@ -92,16 +96,16 @@ jobs:
9296
runs-on: ubuntu-20.04
9397
steps:
9498
- uses: actions/checkout@master
95-
- name: Install cuda-minimal-build-11-4
99+
- name: Install cuda-minimal-build-11-6
96100
shell: bash
97101
run: |
98102
# https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=deb_network
99103
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
100104
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
101-
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
105+
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
102106
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
103107
sudo apt-get update
104-
sudo apt-get -y install cuda-minimal-build-11-4
108+
sudo apt-get -y install cuda-minimal-build-11-6
105109
- name: Test 'cudart' feature
106110
shell: bash
107111
run: env PATH=/usr/local/cuda/bin:$PATH cargo test --manifest-path cc-test/Cargo.toml --features test_cuda

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "cc"
33
version = "1.0.73"
44
authors = ["Alex Crichton <[email protected]>"]
5-
license = "MIT/Apache-2.0"
5+
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/alexcrichton/cc-rs"
77
homepage = "https://github.com/alexcrichton/cc-rs"
88
documentation = "https://docs.rs/cc"
@@ -14,7 +14,7 @@ code.
1414
keywords = ["build-dependencies"]
1515
readme = "README.md"
1616
categories = ["development-tools::build-utils"]
17-
exclude = ["/.github", "/.travis.yml", "/appveyor.yml"]
17+
exclude = ["/.github"]
1818
edition = "2018"
1919

2020
[dependencies]

src/lib.rs

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
use std::collections::HashMap;
6060
use std::env;
6161
use std::ffi::{OsStr, OsString};
62-
use std::fmt::{self, Display};
62+
use std::fmt::{self, Display, Formatter};
6363
use std::fs;
6464
use std::io::{self, BufRead, BufReader, Read, Write};
6565
use std::path::{Component, Path, PathBuf};
@@ -168,7 +168,7 @@ impl From<io::Error> for Error {
168168
}
169169

170170
impl Display for Error {
171-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
171+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
172172
write!(f, "{:?}: {}", self.kind, self.message)
173173
}
174174
}
@@ -1311,6 +1311,13 @@ impl Build {
13111311
if self.cuda && self.files.len() > 1 {
13121312
cmd.arg("--device-c");
13131313
}
1314+
if compiler.family == (ToolFamily::Msvc { clang_cl: true }) {
1315+
// #513: For `clang-cl`, separate flags/options from the input file.
1316+
// When cross-compiling macOS -> Windows, this avoids interpreting
1317+
// common `/Users/...` paths as the `/U` flag and triggering
1318+
// `-Wslash-u-filename` warning.
1319+
cmd.arg("--");
1320+
}
13141321
cmd.arg(&obj.src);
13151322
if cfg!(target_os = "macos") {
13161323
self.fix_env_for_apple_os(&mut cmd)?;
@@ -1522,7 +1529,7 @@ impl Build {
15221529
cmd.push_opt_unless_duplicate("-DANDROID".into());
15231530
}
15241531

1525-
if !target.contains("apple-ios") {
1532+
if !target.contains("apple-ios") && !target.contains("apple-watchos") {
15261533
cmd.push_cc_arg("-ffunction-sections".into());
15271534
cmd.push_cc_arg("-fdata-sections".into());
15281535
}
@@ -1590,6 +1597,20 @@ impl Build {
15901597
.into(),
15911598
);
15921599
}
1600+
} else if target.contains("watchos-sim") {
1601+
if let Some(arch) =
1602+
map_darwin_target_from_rust_to_compiler_architecture(target)
1603+
{
1604+
let deployment_target = env::var("WATCHOS_DEPLOYMENT_TARGET")
1605+
.unwrap_or_else(|_| "5.0".into());
1606+
cmd.args.push(
1607+
format!(
1608+
"--target={}-apple-watchos{}-simulator",
1609+
arch, deployment_target
1610+
)
1611+
.into(),
1612+
);
1613+
}
15931614
} else if target.starts_with("riscv64gc-") {
15941615
cmd.args.push(
15951616
format!("--target={}", target.replace("riscv64gc", "riscv64")).into(),
@@ -1849,8 +1870,8 @@ impl Build {
18491870
}
18501871
}
18511872

1852-
if target.contains("apple-ios") {
1853-
self.ios_flags(cmd)?;
1873+
if target.contains("apple-ios") || target.contains("apple-watchos") {
1874+
self.ios_watchos_flags(cmd)?;
18541875
}
18551876

18561877
if self.static_flag.unwrap_or(false) {
@@ -2043,18 +2064,37 @@ impl Build {
20432064
Ok(())
20442065
}
20452066

2046-
fn ios_flags(&self, cmd: &mut Tool) -> Result<(), Error> {
2067+
fn ios_watchos_flags(&self, cmd: &mut Tool) -> Result<(), Error> {
20472068
enum ArchSpec {
20482069
Device(&'static str),
20492070
Simulator(&'static str),
20502071
Catalyst(&'static str),
20512072
}
20522073

2074+
enum Os {
2075+
Ios,
2076+
WatchOs,
2077+
}
2078+
impl Display for Os {
2079+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
2080+
match self {
2081+
Os::Ios => f.write_str("iOS"),
2082+
Os::WatchOs => f.write_str("WatchOS"),
2083+
}
2084+
}
2085+
}
2086+
20532087
let target = self.get_target()?;
2088+
let os = if target.contains("-watchos") {
2089+
Os::WatchOs
2090+
} else {
2091+
Os::Ios
2092+
};
2093+
20542094
let arch = target.split('-').nth(0).ok_or_else(|| {
20552095
Error::new(
20562096
ErrorKind::ArchitectureInvalid,
2057-
"Unknown architecture for iOS target.",
2097+
format!("Unknown architecture for {} target.", os).as_str(),
20582098
)
20592099
})?;
20602100

@@ -2083,6 +2123,7 @@ impl Build {
20832123
} else if is_sim {
20842124
match arch {
20852125
"arm64" | "aarch64" => ArchSpec::Simulator("-arch arm64"),
2126+
"x86_64" => ArchSpec::Simulator("-m64"),
20862127
_ => {
20872128
return Err(Error::new(
20882129
ErrorKind::ArchitectureInvalid,
@@ -2093,46 +2134,59 @@ impl Build {
20932134
} else {
20942135
match arch {
20952136
"arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"),
2137+
"armv7k" => ArchSpec::Device("armv7k"),
20962138
"armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"),
20972139
"arm64e" => ArchSpec::Device("arm64e"),
20982140
"arm64" | "aarch64" => ArchSpec::Device("arm64"),
2141+
"arm64_32" => ArchSpec::Device("arm64_32"),
20992142
"i386" | "i686" => ArchSpec::Simulator("-m32"),
21002143
"x86_64" => ArchSpec::Simulator("-m64"),
21012144
_ => {
21022145
return Err(Error::new(
21032146
ErrorKind::ArchitectureInvalid,
2104-
"Unknown architecture for iOS target.",
2147+
format!("Unknown architecture for {} target.", os).as_str(),
21052148
));
21062149
}
21072150
}
21082151
};
21092152

2110-
let min_version =
2111-
std::env::var("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or_else(|_| "7.0".into());
2153+
let (sdk_prefix, sim_prefix, min_version) = match os {
2154+
Os::Ios => (
2155+
"iphone",
2156+
"ios-",
2157+
std::env::var("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or_else(|_| "7.0".into()),
2158+
),
2159+
Os::WatchOs => (
2160+
"watch",
2161+
"watch",
2162+
std::env::var("WATCHOS_DEPLOYMENT_TARGET").unwrap_or_else(|_| "2.0".into()),
2163+
),
2164+
};
21122165

21132166
let sdk = match arch {
21142167
ArchSpec::Device(arch) => {
21152168
cmd.args.push("-arch".into());
21162169
cmd.args.push(arch.into());
21172170
cmd.args
2118-
.push(format!("-miphoneos-version-min={}", min_version).into());
2119-
"iphoneos"
2171+
.push(format!("-m{}os-version-min={}", sdk_prefix, min_version).into());
2172+
format!("{}os", sdk_prefix)
21202173
}
21212174
ArchSpec::Simulator(arch) => {
21222175
cmd.args.push(arch.into());
21232176
cmd.args
2124-
.push(format!("-mios-simulator-version-min={}", min_version).into());
2125-
"iphonesimulator"
2177+
.push(format!("-m{}simulator-version-min={}", sim_prefix, min_version).into());
2178+
format!("{}simulator", sdk_prefix)
21262179
}
2127-
ArchSpec::Catalyst(_) => "macosx",
2180+
ArchSpec::Catalyst(_) => "macosx".to_owned(),
21282181
};
21292182

2130-
self.print(&format!("Detecting iOS SDK path for {}", sdk));
2183+
self.print(&format!("Detecting {} SDK path for {}", os, sdk));
21312184
let sdk_path = if let Some(sdkroot) = env::var_os("SDKROOT") {
21322185
sdkroot
21332186
} else {
2134-
self.apple_sdk_root(sdk)?
2187+
self.apple_sdk_root(sdk.as_str())?
21352188
};
2189+
21362190
cmd.args.push("-isysroot".into());
21372191
cmd.args.push(sdk_path);
21382192
cmd.args.push("-fembed-bitcode".into());
@@ -2234,6 +2288,8 @@ impl Build {
22342288
}
22352289
} else if target.contains("apple-ios") {
22362290
clang.to_string()
2291+
} else if target.contains("apple-watchos") {
2292+
clang.to_string()
22372293
} else if target.contains("android") {
22382294
autodetect_android_compiler(&target, &host, gnu, clang)
22392295
} else if target.contains("cloudabi") {
@@ -2810,7 +2866,7 @@ impl Build {
28102866
Err(_) => {
28112867
return Err(Error::new(
28122868
ErrorKind::IOError,
2813-
"Unable to determine iOS SDK path.",
2869+
"Unable to determine Apple SDK path.",
28142870
));
28152871
}
28162872
};

tests/test.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,14 @@ fn gnu_static() {
343343
test.cmd(0).must_have("-static").must_not_have("-shared");
344344
}
345345

346+
#[test]
347+
fn gnu_no_dash_dash() {
348+
let test = Test::gnu();
349+
test.gcc().file("foo.c").compile("foo");
350+
351+
test.cmd(0).must_not_have("--");
352+
}
353+
346354
#[test]
347355
fn msvc_smoke() {
348356
reset_env();
@@ -411,3 +419,11 @@ fn msvc_no_static_crt() {
411419

412420
test.cmd(0).must_have("-MD");
413421
}
422+
423+
#[test]
424+
fn msvc_no_dash_dash() {
425+
let test = Test::msvc();
426+
test.gcc().file("foo.c").compile("foo");
427+
428+
test.cmd(0).must_not_have("--");
429+
}

0 commit comments

Comments
 (0)