Skip to content

Commit 5c7adfe

Browse files
committed
Merge branch 'main' into parse-targets
2 parents 5ade71f + 218365e commit 5c7adfe

File tree

7 files changed

+156
-12
lines changed

7 files changed

+156
-12
lines changed

.github/workflows/main.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,49 @@ jobs:
192192
- run: cargo test --no-run --target ${{ matrix.target }} --release
193193
- run: cargo test --no-run --target ${{ matrix.target }} --features parallel
194194

195+
test-wasm32-wasip1-thread:
196+
name: Test wasm32-wasip1-thread
197+
runs-on: ubuntu-latest
198+
env:
199+
TARGET: wasm32-wasip1-threads
200+
steps:
201+
- uses: actions/checkout@v4
202+
- name: Install Rust (rustup)
203+
run: |
204+
rustup toolchain install nightly --no-self-update --profile minimal --target $TARGET
205+
206+
- name: Get latest version of wasi-sdk
207+
env:
208+
REPO: WebAssembly/wasi-sdk
209+
GH_TOKEN: ${{ github.token }}
210+
run: |
211+
set -euxo pipefail
212+
VERSION="$(gh release list --repo $REPO -L 1 --json tagName --jq '.[]|.tagName')"
213+
echo "WASI_TOOLCHAIN_VERSION=$VERSION" >> "$GITHUB_ENV"
214+
215+
- name: Install wasi-sdk
216+
working-directory: /tmp
217+
env:
218+
REPO: WebAssembly/wasi-sdk
219+
run: |
220+
set -euxo pipefail
221+
VERSION="$WASI_TOOLCHAIN_VERSION"
222+
FILE="${VERSION}.0-x86_64-linux.deb"
223+
wget "https://github.com/$REPO/releases/download/${VERSION}/${FILE}"
224+
sudo dpkg -i "${FILE}"
225+
WASI_SDK_PATH="/opt/wasi-sdk"
226+
CC="${WASI_SDK_PATH}/bin/clang"
227+
echo "WASI_SDK_PATH=$WASI_SDK_PATH" >> "$GITHUB_ENV"
228+
echo "CC=$CC" >> "$GITHUB_ENV"
229+
230+
- uses: Swatinem/rust-cache@v2
231+
with:
232+
env-vars: "WASI_TOOLCHAIN_VERSION"
233+
cache-all-crates: "true"
234+
235+
- name: Run tests
236+
run: cargo +nightly build -p $TARGET-test --target $TARGET
237+
195238
cuda:
196239
name: Test CUDA support
197240
runs-on: ubuntu-20.04

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [1.1.28](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.27...cc-v1.1.28) - 2024-10-06
10+
11+
### Other
12+
13+
- Environment variables: For one accepting boolean, treat "0", "false" and empty env as false ([#1238](https://github.com/rust-lang/cc-rs/pull/1238))
14+
15+
## [1.1.27](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.26...cc-v1.1.27) - 2024-10-06
16+
17+
### Other
18+
19+
- Revert "Use debug version of MSVC runtime library on debug ([#1231](https://github.com/rust-lang/cc-rs/pull/1231))" ([#1237](https://github.com/rust-lang/cc-rs/pull/1237))
20+
- Disable `CC_ENABLE_DEBUG_OUTPUT` if it is set to "0" ([#1234](https://github.com/rust-lang/cc-rs/pull/1234))
21+
22+
## [1.1.26](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.25...cc-v1.1.26) - 2024-10-06
23+
24+
### Other
25+
26+
- Use debug version of MSVC runtime library on debug ([#1231](https://github.com/rust-lang/cc-rs/pull/1231))
27+
28+
## [1.1.25](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.24...cc-v1.1.25) - 2024-10-05
29+
30+
### Other
31+
32+
- Remove incorrect "lib" prefixes in CXXSTDLIB doc comments ([#1228](https://github.com/rust-lang/cc-rs/pull/1228))
33+
34+
## [1.1.24](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.23...cc-v1.1.24) - 2024-10-01
35+
36+
### Other
37+
38+
- Fix wasm32-wasip1-threads: shared-memory disallowed due to not compiled with 'atomics' or 'bulk-memory' features ([#1221](https://github.com/rust-lang/cc-rs/pull/1221))
39+
- Reduce the need for the host target triple ([#1224](https://github.com/rust-lang/cc-rs/pull/1224))
40+
- Add auto cancellation for CI jobs ([#1222](https://github.com/rust-lang/cc-rs/pull/1222))
41+
942
## [1.1.23](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.22...cc-v1.1.23) - 2024-09-30
1043

1144
### Other

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cc"
3-
version = "1.1.23"
3+
version = "1.1.28"
44
authors = ["Alex Crichton <[email protected]>"]
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/rust-lang/cc-rs"
@@ -42,4 +42,8 @@ members = [
4242
"dev-tools/cc-test",
4343
"dev-tools/gen-target-info",
4444
"dev-tools/gen-windows-sys-binding",
45+
"dev-tools/wasm32-wasip1-threads-test",
4546
]
47+
48+
[patch.crates-io]
49+
cc = { path = "." }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "wasm32-wasip1-threads-test"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[dependencies]
8+
rusqlite = { version = "0.32.0", features = ["bundled"] }
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
use rusqlite::{Connection, Result};
2+
3+
#[derive(Debug)]
4+
struct Person {
5+
pub id: i32,
6+
pub name: String,
7+
pub data: Option<Vec<u8>>,
8+
}
9+
10+
fn main() -> Result<()> {
11+
let conn = Connection::open_in_memory()?;
12+
13+
conn.execute(
14+
"CREATE TABLE person (
15+
id INTEGER PRIMARY KEY,
16+
name TEXT NOT NULL,
17+
data BLOB
18+
)",
19+
(), // empty list of parameters.
20+
)?;
21+
let me = Person {
22+
id: 0,
23+
name: "Steven".to_string(),
24+
data: None,
25+
};
26+
conn.execute(
27+
"INSERT INTO person (name, data) VALUES (?1, ?2)",
28+
(&me.name, &me.data),
29+
)?;
30+
31+
let mut stmt = conn.prepare("SELECT id, name, data FROM person")?;
32+
let person_iter = stmt.query_map([], |row| {
33+
Ok(Person {
34+
id: row.get(0)?,
35+
name: row.get(1)?,
36+
data: row.get(2)?,
37+
})
38+
})?;
39+
40+
for person in person_iter {
41+
println!("Found person {:?}", person.unwrap());
42+
}
43+
Ok(())
44+
}

src/command_helpers.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ impl CargoOutput {
4444
metadata: true,
4545
warnings: true,
4646
output: OutputKind::Forward,
47-
debug: std::env::var_os("CC_ENABLE_DEBUG_OUTPUT").is_some(),
47+
debug: match std::env::var_os("CC_ENABLE_DEBUG_OUTPUT") {
48+
Some(v) => v != "0" && v != "false" && v != "",
49+
None => false,
50+
},
4851
checked_dbg_var: Arc::new(AtomicBool::new(false)),
4952
}
5053
}

src/lib.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,8 @@ impl Build {
847847
/// The name of the C++ standard library to link is decided by:
848848
/// 1. If [`cpp_link_stdlib`](Build::cpp_link_stdlib) is set, use its value.
849849
/// 2. Else if the `CXXSTDLIB` environment variable is set, use its value.
850-
/// 3. Else the default is `libc++` for OS X and BSDs, `libc++_shared` for Android,
851-
/// `None` for MSVC and `libstdc++` for anything else.
850+
/// 3. Else the default is `c++` for OS X and BSDs, `c++_shared` for Android,
851+
/// `None` for MSVC and `stdc++` for anything else.
852852
pub fn cpp(&mut self, cpp: bool) -> &mut Build {
853853
self.cpp = cpp;
854854
self
@@ -1859,7 +1859,7 @@ impl Build {
18591859
let mut cmd = self.get_base_compiler()?;
18601860

18611861
// Disable default flag generation via `no_default_flags` or environment variable
1862-
let no_defaults = self.no_default_flags || self.getenv("CRATE_CC_NO_DEFAULTS").is_some();
1862+
let no_defaults = self.no_default_flags || self.getenv_boolean("CRATE_CC_NO_DEFAULTS");
18631863

18641864
if !no_defaults {
18651865
self.add_default_flags(&mut cmd, &target, &opt_level)?;
@@ -2022,6 +2022,10 @@ impl Build {
20222022
format!("--sysroot={}", Path::new(&wasi_sysroot).display()).into(),
20232023
);
20242024
}
2025+
2026+
if target.contains("threads") {
2027+
cmd.push_cc_arg("-pthread".into());
2028+
}
20252029
}
20262030
}
20272031
}
@@ -3123,8 +3127,8 @@ impl Build {
31233127
/// Returns the C++ standard library:
31243128
/// 1. If [`cpp_link_stdlib`](cc::Build::cpp_link_stdlib) is set, uses its value.
31253129
/// 2. Else if the `CXXSTDLIB` environment variable is set, uses its value.
3126-
/// 3. Else the default is `libc++` for OS X and BSDs, `libc++_shared` for Android,
3127-
/// `None` for MSVC and `libstdc++` for anything else.
3130+
/// 3. Else the default is `c++` for OS X and BSDs, `c++_shared` for Android,
3131+
/// `None` for MSVC and `stdc++` for anything else.
31283132
fn get_cpp_link_stdlib(&self) -> Result<Option<Cow<'_, Path>>, Error> {
31293133
match &self.cpp_link_stdlib {
31303134
Some(s) => Ok(s.as_deref().map(Path::new).map(Cow::Borrowed)),
@@ -3602,15 +3606,12 @@ impl Build {
36023606
}
36033607

36043608
fn get_debug(&self) -> bool {
3605-
self.debug.unwrap_or_else(|| match self.getenv("DEBUG") {
3606-
Some(s) => &*s != "false",
3607-
None => false,
3608-
})
3609+
self.debug.unwrap_or_else(|| self.getenv_boolean("DEBUG"))
36093610
}
36103611

36113612
fn get_shell_escaped_flags(&self) -> bool {
36123613
self.shell_escaped_flags
3613-
.unwrap_or_else(|| self.getenv("CC_SHELL_ESCAPED_FLAGS").is_some())
3614+
.unwrap_or_else(|| self.getenv_boolean("CC_SHELL_ESCAPED_FLAGS"))
36143615
}
36153616

36163617
fn get_dwarf_version(&self) -> Option<u32> {
@@ -3684,6 +3685,14 @@ impl Build {
36843685
r
36853686
}
36863687

3688+
/// get boolean flag that is either true or false
3689+
fn getenv_boolean(&self, v: &str) -> bool {
3690+
match self.getenv(v) {
3691+
Some(s) => &*s != "0" && &*s != "false" && !s.is_empty(),
3692+
None => false,
3693+
}
3694+
}
3695+
36873696
fn getenv_unwrap(&self, v: &str) -> Result<Arc<OsStr>, Error> {
36883697
match self.getenv(v) {
36893698
Some(s) => Ok(s),

0 commit comments

Comments
 (0)