Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ fn main() {
// which, outside of `std`, are only available on nightly.
use_feature_or_nothing("rustc_attrs");

// Work around
// https://github.com/rust-lang/rust/issues/103306.
use_feature_or_nothing("wasi_ext");

// Rust 1.56 and earlier don't support panic in const fn.
if has_panic_in_const_fn() {
use_feature("panic_in_const_fn")
Expand All @@ -35,10 +39,13 @@ fn use_feature(feature: &str) {
fn has_feature(feature: &str) -> bool {
let out_dir = var("OUT_DIR").unwrap();
let rustc = var("RUSTC").unwrap();
let target = var("TARGET").unwrap();

let mut child = std::process::Command::new(rustc)
.arg("--crate-type=rlib") // Don't require `main`.
.arg("--emit=metadata") // Do as little as possible but still parse.
.arg("--target")
.arg(target)
.arg("--out-dir")
.arg(out_dir) // Put the output somewhere inconsequential.
.arg("-") // Read from stdin.
Expand All @@ -55,10 +62,13 @@ fn has_feature(feature: &str) -> bool {
fn has_panic_in_const_fn() -> bool {
let out_dir = var("OUT_DIR").unwrap();
let rustc = var("RUSTC").unwrap();
let target = var("TARGET").unwrap();

let mut child = std::process::Command::new(rustc)
.arg("--crate-type=rlib") // Don't require `main`.
.arg("--emit=metadata") // Do as little as possible but still parse.
.arg("--target")
.arg(target)
.arg("--out-dir")
.arg(out_dir) // Put the output somewhere inconsequential.
.arg("-") // Read from stdin.
Expand All @@ -75,10 +85,13 @@ fn has_panic_in_const_fn() -> bool {
fn has_io_safety() -> bool {
let out_dir = var("OUT_DIR").unwrap();
let rustc = var("RUSTC").unwrap();
let target = var("TARGET").unwrap();

let mut child = std::process::Command::new(rustc)
.arg("--crate-type=rlib") // Don't require `main`.
.arg("--emit=metadata") // Do as little as possible but still parse.
.arg("--target")
.arg(target)
.arg("--out-dir")
.arg(out_dir) // Put the output somewhere inconsequential.
.arg("-") // Read from stdin.
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#![deny(missing_docs)]
#![cfg_attr(rustc_attrs, feature(rustc_attrs))]
// Work around https://github.com/rust-lang/rust/issues/103306.
#![cfg_attr(all(wasi_ext, target_os = "wasi"), feature(wasi_ext))]

mod portability;
mod traits;
Expand Down