Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Implement RFC2574 for FFI declarations #59238

Closed
wants to merge 9 commits into from

Conversation

gnzlbg
Copy link
Contributor

@gnzlbg gnzlbg commented Mar 16, 2019

This PR implements RFC2574 (rust-lang/rfcs#2574) for FFI declarations only. This is done by checking whether target features explicitly enabled for FFI declarations allow using the vector types that appear on the function signature.


WIP: I'm a bit stuck here. I'm getting the following error:

+	error[E0391]: cycle detected when processing `qux`
+	  --> $DIR/simd-ffi.rs:14:5
+	   |
+	LL |     fn qux(x: v128);
+	   |     ^^^^^^^^^^^^^^^^
+	   |
+	   = note: ...which again requires processing `qux`, completing the cycle
+	note: cycle used when collecting item types in top-level module

but I have no idea what this means. How can there be a cycle here? AFAICT the new functionality is not recursive. Is there a way to dump something more about the cycle ?

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 16, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:11241aac:start=1552755717686316435,finish=1552755718601757887,duration=915441452
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---

[00:04:13] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:14] tidy error: /checkout/src/test/ui/simd-ffi.rs:9: line longer than 100 chars
[00:04:14] tidy error: /checkout/src/test/ui/simd-ffi.rs:10: line longer than 100 chars
[00:04:14] tidy error: /checkout/src/test/ui/simd-ffi.rs:12: line longer than 100 chars
[00:04:14] tidy error: /checkout/src/test/ui/simd-ffi.rs:26: line longer than 100 chars
[00:04:14] tidy error: /checkout/src/test/ui/simd-ffi.rs:28: line longer than 100 chars
[00:04:14] tidy error: /checkout/src/test/ui/simd-ffi.rs:36: line longer than 100 chars
[00:04:14] tidy error: /checkout/src/test/ui/simd-ffi.rs:38: line longer than 100 chars
[00:04:14] tidy error: /checkout/src/test/ui/simd-ffi.rs:40: line longer than 100 chars
[00:04:15] some tidy checks failed
[00:04:15] 
[00:04:15] 
[00:04:15] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:15] 
[00:04:15] 
[00:04:15] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:15] Build completed unsuccessfully in 0:00:46
[00:04:15] Build completed unsuccessfully in 0:00:46
[00:04:15] make: *** [tidy] Error 1
[00:04:15] Makefile:67: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:09a6d17d
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sat Mar 16 17:06:25 UTC 2019
---
travis_time:end:0a1335ec:start=1552755986327428855,finish=1552755986332253928,duration=4825073
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:24b5210e
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0175fca6
travis_time:start:0175fca6
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:01283298
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@petrochenkov
Copy link
Contributor

r? @alexcrichton

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good to me!

One thing I'm curious about, you've got a bit of checking here for something like how any number of 3 different features could enable 128-bit SIMD, but in reality I think anything above SSE enables 128-bit SIMD, right? (or something like that). Do we want to eventually support all this? Support where a feature enables all its hierarchichal features as well, and only check for the bare minimum?

I was thinking it may be best to start conservatively and just say that if you use 128-bit vectors you must say "feature x is enabled" where "x" is defined per architecture.

Additionally I'm not sure if we actually respect target_feature on FFI definitions, but can you verify? We'd want to verify that we emit the right LLVM target feature and then LLVM actually does pass the argument in a vector register.

src/librustc_typeck/collect.rs Outdated Show resolved Hide resolved
@gnzlbg
Copy link
Contributor Author

gnzlbg commented Mar 18, 2019

One thing I'm curious about, you've got a bit of checking here for something like how any number of 3 different features could enable 128-bit SIMD, but in reality I think anything above SSE enables 128-bit SIMD, right? (or something like that). Do we want to eventually support all this? Support where a feature enables all its hierarchichal features as well, and only check for the bare minimum?

I was thinking it may be best to start conservatively and just say that if you use 128-bit vectors you must say "feature x is enabled" where "x" is defined per architecture.

So the RFC only requires this last thing. For example, if one want to use __m128 on a SSE4.2 FFI declaration, the RFC requires explicitly enabling the sse feature, only enablingsse4.2 is not enough.

There was general consensus that we should try to do better here, but I didn't wanted to mix a discussion about x86 feature hierarchies in the RFC, yet this was my private branch and I wanted to figure out how hard could this be. As you have discovered, there are still some bugs open, e.g., enabling avx doesn't allow using __m128 yet. There should be tests for these cases in this PR, but due to the cyclic query haven't been able to run them and fix them yet.

If these things are easy to solve, which appears to be the case, my intent is to make them part of the PR. If the logic ends up being to complicated, I think that you are right and we might want to do that in a subsequent PR.

Additionally I'm not sure if we actually respect target_feature on FFI definitions, but can you verify?

Oh, nice catch! I don't know either. I'll just add a codegen test for this here and if it fails I'll just fix it as part of this PR if that's ok.

@alexcrichton
Copy link
Member

Ok cool that makes sense to me. If you have access to &dyn CodegenBackend then you can call the target_features method to get the full expanded list of target features enabled (and for something like that'd probably need API tweaks and whatnot). I'm not sure if that's available during typechecking though, so the compiler may not be architected currently to provide access to "if I enable feature X what is the total set of features enabled?"

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0b90254d:start=1552990673344889172,finish=1552990766072404099,duration=92727514927
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---

[00:03:10] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:10] tidy error: /checkout/src/test/ui/simd-ffi.rs:9: line longer than 100 chars
[00:03:10] tidy error: /checkout/src/test/ui/simd-ffi.rs:10: line longer than 100 chars
[00:03:10] tidy error: /checkout/src/test/ui/simd-ffi.rs:12: line longer than 100 chars
[00:03:10] tidy error: /checkout/src/test/ui/simd-ffi.rs:26: line longer than 100 chars
[00:03:10] tidy error: /checkout/src/test/ui/simd-ffi.rs:28: line longer than 100 chars
[00:03:10] tidy error: /checkout/src/test/ui/simd-ffi.rs:36: line longer than 100 chars
[00:03:10] tidy error: /checkout/src/test/ui/simd-ffi.rs:38: line longer than 100 chars
[00:03:10] tidy error: /checkout/src/test/ui/simd-ffi.rs:40: line longer than 100 chars
[00:03:11] some tidy checks failed
[00:03:11] 
[00:03:11] 
[00:03:11] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:11] 
[00:03:11] 
[00:03:11] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:11] Build completed unsuccessfully in 0:00:44
[00:03:11] Build completed unsuccessfully in 0:00:44
[00:03:11] Makefile:67: recipe for target 'tidy' failed
[00:03:11] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:20040f54
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Mar 19 10:22:46 UTC 2019
---
travis_time:end:0fdc4ba0:start=1552990967256207985,finish=1552990967261170962,duration=4962977
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:266b0cb7
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:2ac5a240
travis_time:start:2ac5a240
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:03a7c658
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think LLVM may have picked up a stray update here as well?

// ignore-mips
// ignore-mips64
// ignore-aarch64
// ignore-arm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think nowadays we have // only-x86

fn simd_ffi_check<'a, 'tcx, 'b: 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, ast_ty: &hir::Ty, ty: Ty<'b>,
) {
if !ty.is_simd() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that this won't handle I think is:

#[repr(transparent)]
struct MyType(__m128i);

but is that perhaps best left for a future implementation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not even sure if this is something we properly gate today

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, and no, we don't gate this today:

use std::arch::x86_64::__m128;

#[allow(improper_ctypes)]
extern "C" {
    //fn e(x: __m128); // ERROR
    pub fn a(x: A);
    pub fn b(x: B);
}

#[repr(transparent)] pub struct A(__m128);
#[repr(C)] pub struct B(__m128);

both of these are allowed on stable Rust, and both should be rejected.

Copy link
Contributor Author

@gnzlbg gnzlbg Mar 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also should gate foreign function definitions:

use std::arch::x86_64::__m128;

pub extern "C" fn foo(x: __m128) -> __m128 { x }

These also work on stable Rust.

I'll try to fix all of these issues as part of this PR. We can do a crater run afterwards, and see if we need to change any of these to warn instead of error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me!

}).unwrap().details.size.bytes() as usize;
let simd_elem_width = simd_len / ty.simd_size(tcx);
let target: &str = &tcx.sess.target.target.arch;
if !features.iter().any(|f| simd_ffi_feature_check(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this condition get inverted to return early to de-indent the error generation code?

// * on mips: 16 => msa,
// * wasm: 16 => simd128
match target {
t if t.contains("x86") => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to deduplicate this block up here with the block down below?

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:07edcfe0:start=1553007326531921066,finish=1553007420499162807,duration=93967241741
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---
[01:12:41] ..................i................................................................................. 4700/5479
[01:12:46] ...............................................................ii................................... 4800/5479
[01:12:50] .................................................................................................... 4900/5479
[01:12:53] .................................................................................................... 5000/5479
[01:12:57] .........................F.......................................................................... 5100/5479
[01:13:04] .................................................................................................... 5300/5479
[01:13:06] .................................................................................................... 5400/5479
[01:13:09] .................i.............................................................
[01:13:09] failures:
[01:13:09] failures:
[01:13:09] 
[01:13:09] ---- [ui] ui/target-feature-wrong.rs stdout ----
[01:13:09] diff of stderr:
[01:13:09] 
[01:13:09] 22 LL | #[target_feature(disable = "baz")]
[01:13:09] 24 
[01:13:09] 24 
[01:13:09] - error: #[target_feature(..)] can only be applied to `unsafe` function
[01:13:09] -    |
[01:13:09] -    |
[01:13:09] - LL | #[target_feature(enable = "sse2")]
[01:13:09] - 
[01:13:09] 31 error: attribute should be applied to a function
[01:13:09] 32   --> $DIR/target-feature-wrong.rs:30:1
[01:13:09] 33    |
[01:13:09] 33    |
[01:13:09] 
[01:13:09] 42    |
[01:13:09] 43 LL | #[inline(always)]
[01:13:09] 44    | ^^^^^^^^^^^^^^^^^
[01:13:09] + 
[01:13:09] + error: #[target_feature(..)] can only be applied to `unsafe` function
[01:13:09] +    |
[01:13:09] + LL | fn bar() {}
[01:13:09] +    | ^^^^^^^^^^^
[01:13:09] 45 
[01:13:09] 45 
[01:13:09] 46 error: aborting due to 7 previous errors
[01:13:09] 47 
[01:13:09] 
[01:13:09] 
[01:13:09] The actual stderr differed from the expected stderr.
[01:13:09] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/target-feature-wrong/target-feature-wrong.stderr
[01:13:09] To update references, rerun the tests and pass the `--bless` flag
[01:13:09] To only update this specific test, also pass `--test-args target-feature-wrong.rs`
[01:13:09] error: 1 errors occurred comparing output.
[01:13:09] status: exit code: 1
[01:13:09] status: exit code: 1
[01:13:09] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/target-feature-wrong.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/target-feature-wrong/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/target-feature-wrong/auxiliary" "-A" "unused"
[01:13:09] ------------------------------------------
[01:13:09] 
[01:13:09] ------------------------------------------
[01:13:09] stderr:
[01:13:09] stderr:
[01:13:09] ------------------------------------------
[01:13:09] {"message":"attribute must be of the form `#[target_feature(enable = \"name\")]`","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/target-feature-wrong.rs","byte_start":240,"byte_end":267,"line_start":16,"line_end":16,"column_start":1,"column_end":28,"is_primary":true,"text":[{"text":"#[target_feature = \"+sse2\"]","highlight_start":1,"highlight_end":28}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: attribute must be of the form `#[target_feature(enable = \"name\")]`\n  --> /checkout/src/test/ui/target-feature-wrong.rs:16:1\n   |\nLL | #[target_feature = \"+sse2\"]\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"}
[01:13:09] {"message":"the feature named `foo` is not valid for this target","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/target-feature-wrong.rs","byte_start":317,"byte_end":331,"line_start":18,"line_end":18,"column_start":18,"column_end":32,"is_primary":true,"text":[{"text":"#[target_feature(enable = \"foo\")]","highlight_start":18,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: the feature named `foo` is not valid for this target\n  --> /checkout/src/test/ui/target-feature-wrong.rs:18:18\n   |\nLL | #[target_feature(enable = \"foo\")]\n   |                  ^^^^^^^^^^^^^^\n\n"}
[01:13:09] {"message":"#[target_feature(..)] only accepts sub-keys of `enable` currently","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/target-feature-wrong.rs","byte_start":389,"byte_end":392,"line_start":20,"line_end":20,"column_start":18,"column_end":21,"is_primary":true,"text":[{"text":"#[target_feature(bar)]","highlight_start":18,"highlight_end":21}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: #[target_feature(..)] only accepts sub-keys of `enable` currently\n  --> /checkout/src/test/ui/target-feature-wrong.rs:20:18\n   |\nLL | #[target_feature(bar)]\n   |                  ^^^\n\n"}
[01:13:09] {"message":"#[target_feature(..)] only accepts sub-keys of `enable` currently","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/target-feature-wrong.rs","byte_start":446,"byte_end":461,"line_start":22,"line_end":22,"column_start":18,"column_end":33,"is_primary":true,"text":[{"text":"#[target_feature(disable = \"baz\")]","highlight_start":18,"highlight_end":33}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: #[target_feature(..)] only accepts sub-keys of `enable` currently\n  --> /checkout/src/test/ui/target-feature-wrong.rs:22:18\n   |\nLL | #[target_feature(disable = \"baz\")]\n   |                  ^^^^^^^^^^^^^^^\n\n"}
[01:13:09] {"message":"attribute should be applied to a function","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/target-feature-wrong.rs","byte_start":698,"byte_end":712,"line_start":32,"line_end":32,"column_start":1,"column_end":15,"is_primary":false,"text":[{"text":"mod another {}","highlight_start":1,"highlight_end":15}],"label":"not a function","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/target-feature-wrong.rs","byte_start":619,"byte_end":653,"line_start":30,"line_end":30,"column_start":1,"column_end":35,"is_primary":true,"text":[{"text":"#[target_feature(enable = \"sse2\")]","highlight_start":1,"highlight_end":35}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: attribute should be applied to a function\n  --> /checkout/src/test/ui/target-feature-wrong.rs:30:1\n   |\nLL | #[target_feature(enable = \"sse2\")]\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nLL | //~^ ERROR: should be applied to a function\nLL | mod another {}\n   | -------------- not a function\n\n"}
[01:13:09] {"message":"cannot use #[inline(always)] with #[target_feature]","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/target-feature-wrong.rs","byte_start":714,"byte_end":731,"line_start":34,"line_end":34,"column_start":1,"column_end":18,"is_primary":true,"text":[{"text":"#[inline(always)]","highlight_start":1,"highlight_end":18}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: cannot use #[inline(always)] with #[target_feature]\n  --> /checkout/src/test/ui/target-feature-wrong.rs:34:1\n   |\nLL | #[inline(always)]\n   | ^^^^^^^^^^^^^^^^^\n\n"}
[01:13:09] {"message":"#[target_feature(..)] can only be applied to `unsafe` function","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/target-feature-wrong.rs","byte_start":606,"byte_end":617,"line_start":28,"line_end":28,"column_start":1,"column_end":12,"is_primary":true,"text":[{"text":"fn bar() {}","highlight_start":1,"highlight_end":12}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: #[target_feature(..)] can only be applied to `unsafe` function\n  --> /checkout/src/test/ui/target-feature-wrong.rs:28:1\n   |\nLL | fn bar() {}\n   | ^^^^^^^^^^^\n\n"}
[01:13:09] 
[01:13:09] ------------------------------------------
[01:13:09] 
[01:13:09] thread '[ui] ui/target-feature-wrong.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3325:9
---
[01:13:09] 
[01:13:09] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:496:22
[01:13:09] 
[01:13:09] 
[01:13:09] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:13:09] 
[01:13:09] 
[01:13:09] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:13:09] Build completed unsuccessfully in 0:04:18
[01:13:09] Build completed unsuccessfully in 0:04:18
[01:13:09] Makefile:48: recipe for target 'check' failed
[01:13:09] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1e4057c0
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Mar 19 16:10:19 UTC 2019
---
travis_time:end:03ccd4cc:start=1553011820329179345,finish=1553011820334180620,duration=5001275
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0841b123
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:00559376
travis_time:start:00559376
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0c04b9cb
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Mar 20, 2019

☔ The latest upstream changes (presumably #59298) made this pull request unmergeable. Please resolve the merge conflicts.

@hanna-kruppe
Copy link
Contributor

Haven't had the chance to look at the implementation, but scanning over the tests I am concerned by the lack of codegen tests (more specifically, assembly tests as LLVM IR doesn't really tell you which registers are actually used) for whether the now-allowed FFI calls really generate the right code. For example, AFAIK we still don't generate the shim that's necessary to allow passing __m256 in ymm registers if the caller doesn't have AVX enabled themselves. Would be good to have an xfail test for that and a test that ensure everything works if the caller has AVX enabled.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Mar 27, 2019

(more specifically, assembly tests as LLVM IR doesn't really tell you which registers are actually used)

An assembly test suite has been recently introduced, so this sounds like a good idea to me.

For example, AFAIK we still don't generate the shim that's necessary to allow passing __m256 in ymm registers if the caller doesn't have AVX enabled themselves.

Yeah, this PR needs to fix that: https://rust.godbolt.org/z/rYraGF

@Dylan-DPC-zz
Copy link

ping from triage @gnzlbg @alexcrichton any updates on this?

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 15, 2019
@@ -0,0 +1,57 @@
// ignore-tidy-linelength
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move all tests that relate to simd_ffi into: ui/rfc-2574-simd-ffi/$file.

@jonas-schievink
Copy link
Contributor

Ping from triage @gnzlbg, this has merge conflicts and review comments to be resolved

@JohnCSimon
Copy link
Member

Pinging from triage again @gnzlbg
this has merge conflicts
and review comments to be resolved

@JohnCSimon
Copy link
Member

@gnzlbg Hello from triage. Unfortunately this hasn't seen any movement in a month. Closing due to inactivity.

@JohnCSimon JohnCSimon closed this Jul 27, 2019
@JohnTitor JohnTitor added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.