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

Feature gate FFI imports of LLVM intrinsics #20334

Merged
merged 1 commit into from
Jan 2, 2015
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
7 changes: 5 additions & 2 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2561,6 +2561,9 @@ The currently implemented features of the reference compiler are:
if the system linker is not used then specifying custom flags
doesn't have much meaning.

* `link_llvm_intrinsics` – Allows linking to LLVM intrinsics via
`#[link_name="llvm.*"]`.

* `linkage` - Allows use of the `linkage` attribute, which is not portable.

* `log_syntax` - Allows use of the `log_syntax` macro attribute, which is a
Expand Down Expand Up @@ -4149,11 +4152,11 @@ Unwinding the stack of a thread is done by the thread itself, on its own control
stack. If a value with a destructor is freed during unwinding, the code for the
destructor is run, also on the thread's control stack. Running the destructor
code causes a temporary transition to a *running* state, and allows the
destructor code to cause any subsequent state transitions. The original thread
destructor code to cause any subsequent state transitions. The original thread
of unwinding and panicking thereby may suspend temporarily, and may involve
(recursive) unwinding of the stack of a failed destructor. Nonetheless, the
outermost unwinding activity will continue until the stack is unwound and the
thread transitions to the *dead* state. There is no way to "recover" from thread
thread transitions to the *dead* state. There is no way to "recover" from thread
panics. Once a thread has temporarily suspended its unwinding in the *panicking*
state, a panic occurring from within this destructor results in *hard* panic.
A hard panic currently results in the process aborting.
Expand Down
11 changes: 11 additions & 0 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("simd", Active),
("default_type_params", Active),
("quote", Active),
("link_llvm_intrinsics", Active),
("linkage", Active),
("struct_inherit", Removed),

Expand Down Expand Up @@ -292,6 +293,16 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
"the `linkage` attribute is experimental \
and not portable across platforms")
}

let links_to_llvm = match attr::first_attr_value_str_by_name(i.attrs[], "link_name") {
Some(val) => val.get().starts_with("llvm."),
_ => false
};
if links_to_llvm {
self.gate_feature("link_llvm_intrinsics", i.span,
"linking to LLVM intrinsics is experimental");
}

visit::walk_foreign_item(self, i)
}

Expand Down
17 changes: 17 additions & 0 deletions src/test/compile-fail/issue-20313.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern {
#[link_name = "llvm.sqrt.f32"]
fn sqrt(x: f32) -> f32; //~ ERROR linking to LLVM intrinsics is experimental
}

fn main(){
}
18 changes: 18 additions & 0 deletions src/test/run-pass/issue-20313.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(link_llvm_intrinsics)]

extern {
#[link_name = "llvm.sqrt.f32"]
fn sqrt(x: f32) -> f32;
}

fn main(){
}