summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-12-16 22:59:16 +0800
committerJohn Hodge <tpg@mutabah.net>2016-12-16 22:59:16 +0800
commit83f37af7a3d962753d8c6b7693d194d80b44b43c (patch)
tree708581c1195e383edc59f84ada84da7f36399b69
parentaa17374e03e4bcd5060576dfb8b63a46694d3852 (diff)
downloadmrust-83f37af7a3d962753d8c6b7693d194d80b44b43c.tar.gz
Add panic_abort and allocator_system to executables
-rw-r--r--Makefile2
-rw-r--r--src/main.cpp8
2 files changed, 9 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 46a34f86..18570b83 100644
--- a/Makefile
+++ b/Makefile
@@ -206,7 +206,7 @@ rust_tests-run-pass: $(call DEF_RUST_TESTS,run-pass)
rust_tests-run-fail: $(call DEF_RUST_TESTS,run-fail)
#rust_tests-compile-fail: $(call DEF_RUST_TESTS,compile-fail)
-output/rust/test_run-pass_hello: $(RUST_TESTS_DIR)run-pass/hello.rs output/libstd.hir $(BIN)
+output/rust/test_run-pass_hello: $(RUST_TESTS_DIR)run-pass/hello.rs output/libstd.hir $(BIN) output/liballoc_system.hir output/libpanic_abort.hir
$(DBG) $(BIN) $< -o $@.c $(PIPECMD)
TEST_ARGS_run-pass/cfgs-on-items := --cfg fooA --cfg fooB
diff --git a/src/main.cpp b/src/main.cpp
index b8219c48..4d8c0b0a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -271,6 +271,14 @@ int main(int argc, char *argv[])
return 0;
}
+ // Allocator and panic strategies
+ if( crate.m_crate_type == ::AST::Crate::Type::Executable )
+ {
+ // TODO: Detect if an allocator crate is already present.
+ crate.load_extern_crate(Span(), "alloc_system");
+ crate.load_extern_crate(Span(), "panic_abort");
+ }
+
// Resolve names to be absolute names (include references to the relevant struct/global/function)
// - This does name checking on types and free functions.
// - Resolves all identifiers/paths to references