Merge pull request #203 from alexcrichton/wasm
Prepare this crate for more wasm32 compatibility
This commit is contained in:
commit
1be2858df7
12
build.rs
12
build.rs
|
@ -12,6 +12,12 @@ fn main() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forcibly enable memory intrinsics on wasm32 as we don't have a libc to
|
||||||
|
// provide them.
|
||||||
|
if target.contains("wasm32") {
|
||||||
|
println!("cargo:rustc-cfg=feature=\"mem\"");
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE we are going to assume that llvm-target, what determines our codegen option, matches the
|
// NOTE we are going to assume that llvm-target, what determines our codegen option, matches the
|
||||||
// target triple. This is usually correct for our built-in targets but can break in presence of
|
// target triple. This is usually correct for our built-in targets but can break in presence of
|
||||||
// custom targets, which can have arbitrary names.
|
// custom targets, which can have arbitrary names.
|
||||||
|
@ -25,9 +31,13 @@ fn main() {
|
||||||
// mangling names though we assume that we're also in test mode so we don't
|
// mangling names though we assume that we're also in test mode so we don't
|
||||||
// build anything and we rely on the upstream implementation of compiler-rt
|
// build anything and we rely on the upstream implementation of compiler-rt
|
||||||
// functions
|
// functions
|
||||||
if !cfg!(feature = "mangled-names") {
|
if !cfg!(feature = "mangled-names") && cfg!(feature = "c") {
|
||||||
|
// no C compiler for wasm
|
||||||
|
if !target.contains("wasm32") {
|
||||||
#[cfg(feature = "c")]
|
#[cfg(feature = "c")]
|
||||||
c::compile(&llvm_target);
|
c::compile(&llvm_target);
|
||||||
|
println!("cargo:rustc-cfg=use_c");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// To compile intrinsics.rs for thumb targets, where there is no libc
|
// To compile intrinsics.rs for thumb targets, where there is no libc
|
||||||
|
|
|
@ -65,6 +65,7 @@ case "$TRAVIS_OS_NAME" in
|
||||||
# NOTE OSx's nm doesn't accept the `--defined-only` or provide an equivalent.
|
# NOTE OSx's nm doesn't accept the `--defined-only` or provide an equivalent.
|
||||||
# Use GNU nm instead
|
# Use GNU nm instead
|
||||||
NM=gnm
|
NM=gnm
|
||||||
|
brew update
|
||||||
brew install binutils
|
brew install binutils
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
/// A quick overview of attributes supported right now are:
|
/// A quick overview of attributes supported right now are:
|
||||||
///
|
///
|
||||||
/// * `use_c_shim_if` - takes a #[cfg] directive and falls back to the
|
/// * `use_c_shim_if` - takes a #[cfg] directive and falls back to the
|
||||||
/// C-compiled version if `feature = "c"` is specified.
|
/// C-compiled version if `use_c` is specified.
|
||||||
/// * `aapcs_on_arm` - forces the ABI of the function to be `"aapcs"` on ARM and
|
/// * `aapcs_on_arm` - forces the ABI of the function to be `"aapcs"` on ARM and
|
||||||
/// the specified ABI everywhere else.
|
/// the specified ABI everywhere else.
|
||||||
/// * `unadjusted_on_win64` - like `aapcs_on_arm` this switches to the
|
/// * `unadjusted_on_win64` - like `aapcs_on_arm` this switches to the
|
||||||
|
@ -68,7 +68,7 @@ macro_rules! intrinsics {
|
||||||
$($rest:tt)*
|
$($rest:tt)*
|
||||||
) => (
|
) => (
|
||||||
|
|
||||||
#[cfg(all(feature = "c", $($cfg_clause)*))]
|
#[cfg(all(use_c, $($cfg_clause)*))]
|
||||||
pub extern $abi fn $name( $($argname: $ty),* ) -> $ret {
|
pub extern $abi fn $name( $($argname: $ty),* ) -> $ret {
|
||||||
extern $abi {
|
extern $abi {
|
||||||
fn $name($($argname: $ty),*) -> $ret;
|
fn $name($($argname: $ty),*) -> $ret;
|
||||||
|
@ -78,7 +78,7 @@ macro_rules! intrinsics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(all(feature = "c", $($cfg_clause)*)))]
|
#[cfg(not(all(use_c, $($cfg_clause)*)))]
|
||||||
intrinsics! {
|
intrinsics! {
|
||||||
$(#[$($attr)*])*
|
$(#[$($attr)*])*
|
||||||
pub extern $abi fn $name( $($argname: $ty),* ) -> $ret {
|
pub extern $abi fn $name( $($argname: $ty),* ) -> $ret {
|
||||||
|
|
Loading…
Reference in New Issue