Skip to content

Commit 5afe9bc

Browse files
authored
Attempt to fix tests on master (#662)
* Attempt to fix tests on master * Make all doctests use items from the real `std` rather than this crate, it's just easier * Handle debuginfo weirdness by flagging functions as `no_mangle` that we're looking for instructions within. * Handle double undescores in symbol names
1 parent 77a38ba commit 5afe9bc

File tree

10 files changed

+15
-82
lines changed

10 files changed

+15
-82
lines changed

ci/run.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ case ${TARGET} in
104104
# proposal, but hopefully that's coming soon! For now just test that we
105105
# can codegen with no LLVM faults, and we'll remove `--no-run` at a
106106
# later date.
107-
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+simd128"
108-
export RUSTFLAGS="${RUSTFLAGS} -Cllvm-args=-wasm-enable-unimplemented-simd"
107+
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+simd128,+unimplemented-simd128"
109108
cargo_test "--release --no-run"
110109
;;
111110
*)

crates/assert-instr-macro/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn assert_instr(
4949
.replace(':', "_")
5050
.replace(|c: char| c.is_whitespace(), "");
5151
let assert_name = syn::Ident::new(&format!("assert_{}_{}", name, instr_str), name.span());
52-
let shim_name = syn::Ident::new(&format!("{}_shim", name), name.span());
52+
let shim_name = syn::Ident::new(&format!("{}_shim_{}", name, instr_str), name.span());
5353
let mut inputs = Vec::new();
5454
let mut input_vals = Vec::new();
5555
let ret = &func.decl.output;
@@ -99,6 +99,7 @@ pub fn assert_instr(
9999
let shim_name_str = format!("{}{}", shim_name, assert_name);
100100
let to_test = quote! {
101101
#attrs
102+
#[no_mangle]
102103
unsafe extern #abi fn #shim_name(#(#inputs),*) #ret {
103104
// The compiler in optimized mode by default runs a pass called
104105
// "mergefunc" where it'll merge functions that look identical.

crates/core_arch/src/core_arch_docs.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,6 @@ Next up let's take a look at an example of manually using intrinsics. Here
251251
we'll be using SSE4.1 features to implement hex encoding.
252252

253253
```
254-
# #![cfg_attr(not(dox),feature(stdsimd))]
255-
# #![cfg_attr(not(dox), no_std)]
256-
# #[cfg(not(dox))]
257-
# extern crate std as real_std;
258-
# #[cfg(not(dox))]
259-
# extern crate core_arch as std;
260-
# #[cfg(not(dox))]
261-
# #[macro_use(is_x86_feature_detected)]
262-
# extern crate std_detect;
263-
264254
fn main() {
265255
let mut dst = [0; 32];
266256
hex_encode(b"\x01\x02\x03", &mut dst);

crates/core_arch/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![doc(include = "core_arch_docs.md")]
2-
32
#![cfg_attr(stdsimd_strict, deny(warnings))]
43
#![allow(dead_code)]
54
#![allow(unused_features)]

crates/core_arch/src/wasm32/simd128.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub fn i8x16_splat(a: i8) -> v128 {
237237
#[rustc_args_required_const(1)]
238238
pub unsafe fn i8x16_extract_lane(a: v128, imm: usize) -> i8 {
239239
#[cfg(test)]
240-
#[assert_instr(i16x8.extract_lane_s)]
240+
#[assert_instr(i8x16.extract_lane_s)]
241241
fn extract_lane_s(a: v128) -> i32 {
242242
unsafe { i8x16_extract_lane(a, 0) as i32 }
243243
}

crates/core_arch/src/x86/bmi2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use stdsimd_test::assert_instr;
2222
#[inline]
2323
// LLVM BUG (should be mulxl): https://bugs.llvm.org/show_bug.cgi?id=34232
2424
#[cfg_attr(all(test, target_arch = "x86_64"), assert_instr(imul))]
25-
#[cfg_attr(all(test, target_arch = "x86"), assert_instr(mulx))]
25+
#[cfg_attr(all(test, target_arch = "x86"), assert_instr(mul))]
2626
#[target_feature(enable = "bmi2")]
2727
#[stable(feature = "simd_x86", since = "1.27.0")]
2828
pub unsafe fn _mulx_u32(a: u32, b: u32, hi: &mut u32) -> u32 {

crates/core_arch/src/x86/mod.rs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ types! {
3434
///
3535
/// ```
3636
/// # #![feature(stdsimd, mmx_target_feature)]
37-
/// # #![cfg_attr(not(dox), no_std)]
38-
/// # #[cfg(not(dox))]
39-
/// # extern crate std as real_std;
40-
/// # #[cfg(not(dox))]
41-
/// # extern crate core_arch as std;
42-
/// # #[cfg(not(dox))]
43-
/// # #[macro_use(is_x86_feature_detected)]
44-
/// # extern crate std_detect;
4537
/// #[cfg(target_arch = "x86")]
4638
/// use std::arch::x86::*;
4739
/// #[cfg(target_arch = "x86_64")]
@@ -85,15 +77,6 @@ types! {
8577
/// # Examples
8678
///
8779
/// ```
88-
/// # #![cfg_attr(not(dox), feature(stdsimd))]
89-
/// # #![cfg_attr(not(dox), no_std)]
90-
/// # #[cfg(not(dox))]
91-
/// # extern crate std as real_std;
92-
/// # #[cfg(not(dox))]
93-
/// # extern crate core_arch as std;
94-
/// # #[cfg(not(dox))]
95-
/// # #[macro_use(is_x86_feature_detected)]
96-
/// # extern crate std_detect;
9780
/// #[cfg(target_arch = "x86")]
9881
/// use std::arch::x86::*;
9982
/// #[cfg(target_arch = "x86_64")]
@@ -131,15 +114,6 @@ types! {
131114
/// # Examples
132115
///
133116
/// ```
134-
/// # #![cfg_attr(not(dox), feature(stdsimd))]
135-
/// # #![cfg_attr(not(dox), no_std)]
136-
/// # #[cfg(not(dox))]
137-
/// # extern crate std as real_std;
138-
/// # #[cfg(not(dox))]
139-
/// # extern crate core_arch as std;
140-
/// # #[cfg(not(dox))]
141-
/// # #[macro_use(is_x86_feature_detected)]
142-
/// # extern crate std_detect;
143117
/// #[cfg(target_arch = "x86")]
144118
/// use std::arch::x86::*;
145119
/// #[cfg(target_arch = "x86_64")]
@@ -177,15 +151,6 @@ types! {
177151
/// # Examples
178152
///
179153
/// ```
180-
/// # #![cfg_attr(not(dox), feature(stdsimd))]
181-
/// # #![cfg_attr(not(dox), no_std)]
182-
/// # #[cfg(not(dox))]
183-
/// # extern crate std as real_std;
184-
/// # #[cfg(not(dox))]
185-
/// # extern crate core_arch as std;
186-
/// # #[cfg(not(dox))]
187-
/// # #[macro_use(is_x86_feature_detected)]
188-
/// # extern crate std_detect;
189154
/// #[cfg(target_arch = "x86")]
190155
/// use std::arch::x86::*;
191156
/// #[cfg(target_arch = "x86_64")]
@@ -227,15 +192,6 @@ types! {
227192
/// # Examples
228193
///
229194
/// ```
230-
/// # #![cfg_attr(not(dox), feature(stdsimd))]
231-
/// # #![cfg_attr(not(dox), no_std)]
232-
/// # #[cfg(not(dox))]
233-
/// # extern crate std as real_std;
234-
/// # #[cfg(not(dox))]
235-
/// # extern crate core_arch as std;
236-
/// # #[cfg(not(dox))]
237-
/// # #[macro_use(is_x86_feature_detected)]
238-
/// # extern crate std_detect;
239195
/// #[cfg(target_arch = "x86")]
240196
/// use std::arch::x86::*;
241197
/// #[cfg(target_arch = "x86_64")]
@@ -273,15 +229,6 @@ types! {
273229
/// # Examples
274230
///
275231
/// ```
276-
/// # #![cfg_attr(not(dox), feature(stdsimd))]
277-
/// # #![cfg_attr(not(dox), no_std)]
278-
/// # #[cfg(not(dox))]
279-
/// # extern crate std as real_std;
280-
/// # #[cfg(not(dox))]
281-
/// # extern crate core_arch as std;
282-
/// # #[cfg(not(dox))]
283-
/// # #[macro_use(is_x86_feature_detected)]
284-
/// # extern crate std_detect;
285232
/// #[cfg(target_arch = "x86")]
286233
/// use std::arch::x86::*;
287234
/// #[cfg(target_arch = "x86_64")]
@@ -319,15 +266,6 @@ types! {
319266
/// # Examples
320267
///
321268
/// ```
322-
/// # #![cfg_attr(not(dox), feature(stdsimd))]
323-
/// # #![cfg_attr(not(dox), no_std)]
324-
/// # #[cfg(not(dox))]
325-
/// # extern crate std as real_std;
326-
/// # #[cfg(not(dox))]
327-
/// # extern crate core_arch as std;
328-
/// # #[cfg(not(dox))]
329-
/// # #[macro_use(is_x86_feature_detected)]
330-
/// # extern crate std_detect;
331269
/// #[cfg(target_arch = "x86")]
332270
/// use std::arch::x86::*;
333271
/// #[cfg(target_arch = "x86_64")]

crates/core_arch/src/x86_64/bmi2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use stdsimd_test::assert_instr;
2020
///
2121
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mulx_u64)
2222
#[inline]
23-
#[cfg_attr(test, assert_instr(mulx))]
23+
#[cfg_attr(test, assert_instr(mul))]
2424
#[target_feature(enable = "bmi2")]
2525
#[cfg(not(target_arch = "x86"))] // calls an intrinsic
2626
#[stable(feature = "simd_x86", since = "1.27.0")]

crates/stdsimd-test/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ struct Instruction {
5959

6060
fn normalize(symbol: &str) -> String {
6161
let symbol = rustc_demangle::demangle(symbol).to_string();
62-
match symbol.rfind("::h") {
62+
let mut ret = match symbol.rfind("::h") {
6363
Some(i) => symbol[..i].to_string(),
6464
None => symbol.to_string(),
65+
};
66+
// Normalize to no leading underscore to handle platforms that may
67+
// inject extra ones in symbol names
68+
while ret.starts_with("_") {
69+
ret.remove(0);
6570
}
71+
return ret;
6672
}
6773

6874
/// Main entry point for this crate, called by the `#[assert_instr]` macro.

crates/stdsimd-test/src/wasm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ pub(crate) fn disassemble_myself() -> HashMap<String, Vec<Function>> {
4848
let mut parts = line.split_whitespace().skip(3);
4949
let offset = parts.next()
5050
.unwrap()
51-
.trim_right_matches(")")
51+
.trim_end_matches(")")
5252
.parse::<usize>()
5353
.unwrap();
5454
for (i, name) in parts.enumerate() {
55-
let name = name.trim_right_matches(")");
55+
let name = name.trim_end_matches(")");
5656
for f in ret.get_mut(name).expect("ret.get_mut(name) failed") {
5757
f.addr = Some(i + offset);
5858
}

0 commit comments

Comments
 (0)