aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Eric Kidd <git@randomhacks.net> 2015-11-12 08:50:53 -0500
committerGravatar Eric Kidd <git@randomhacks.net> 2015-11-12 08:50:53 -0500
commite583a89a561a84dbde8e0ab92252eddd06a1b5ea (patch)
tree110ec98da4c5458d588ba9af729eff90df81596e
parentc96f029202155560796851fecf8ce8d1c33e9bd5 (diff)
downloadrust-x86-e583a89a561a84dbde8e0ab92252eddd06a1b5ea.tar.gz
rust-x86-e583a89a561a84dbde8e0ab92252eddd06a1b5ea.tar.zst
rust-x86-e583a89a561a84dbde8e0ab92252eddd06a1b5ea.zip
Add a test to reproduce link errors reported in gz/rust-x86#1
This will cause `cargo test` to fail if any lang_items are being pulled in by supporting crates. This code is designed to simulate a typical OS kernel written in Rust, using `#[no_std]` and custom `lang_items`. Tested against rustc 1.6.0-nightly (cc3094872 2015-11-11). Fixing this will make it much easier for beginner Rust OS developers to use libx86 in more configurations. But I haven't figured out what's causing the error yet, only how to reproduce it. Thank you for working on such a promising library!
-rw-r--r--tests/no_std_build.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/no_std_build.rs b/tests/no_std_build.rs
new file mode 100644
index 0000000..8a68214
--- /dev/null
+++ b/tests/no_std_build.rs
@@ -0,0 +1,24 @@
+// Verify that we can be linked against an appliction which only uses
+// libcore, which is common in kernel space.
+
+#![feature(no_std, lang_items)]
+#![no_std]
+
+extern crate x86;
+
+fn main() {
+}
+
+// We want to supply these definitions ourselves, and not have them
+// accidentally pulled in via the x86 crate.
+#[lang = "eh_personality"]
+extern "C" fn eh_personality() {
+}
+
+#[lang = "panic_fmt"]
+extern "C" fn panic_fmt(
+ args: ::core::fmt::Arguments, file: &str, line: usize)
+ -> !
+{
+ loop {}
+}