summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-25 16:13:14 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-25 16:13:14 +0800
commita2fc0567c434af1d5888db4f5c82df7f1e6b970f (patch)
treed72548d0b8a3aba415f7a09e3b19743781e19ccf
parent50b01c18df98c8502f823a4b9a9e347514870858 (diff)
downloadmrust-a2fc0567c434af1d5888db4f5c82df7f1e6b970f.tar.gz
Start on liblibc - Add cfg_attr support to LoadCrates
-rw-r--r--Makefile11
-rw-r--r--src/ast/crate.cpp11
-rw-r--r--src/main.cpp4
3 files changed, 24 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index c62e5352..cf2d03e0 100644
--- a/Makefile
+++ b/Makefile
@@ -94,14 +94,21 @@ output/lib%.hir: $(RUSTCSRC)src/lib%/lib.rs $(BIN)
@echo "--- [MRUSTC] $@"
@mkdir -p output/
$(DBG) $(BIN) $< -o $@ $(PIPECMD)
- # HACK: Work around gdb returning success even if the program crashed
+# # HACK: Work around gdb returning success even if the program crashed
+ @test -e $@
+output/lib%.hir: $(RUSTCSRC)src/lib%/src/lib.rs $(BIN)
+ @echo "--- [MRUSTC] $@"
+ @mkdir -p output/
+ $(DBG) $(BIN) $< -o $@ $(PIPECMD)
+# # HACK: Work around gdb returning success even if the program crashed
@test -e $@
output/liballoc.hir: output/libcore.hir
output/librustc_unicode.hir: output/libcore.hir
output/libcollections.hir: output/libcore.hir output/liballoc.hir output/librustc_unicode.hir
output/librand.hir: output/libcore.hir
-output/libstd.hir: output/libcore.hir output/libcollections.hir output/librand.hir
+output/liblibc.hir: output/libcore.hir
+output/libstd.hir: output/libcore.hir output/libcollections.hir output/librand.hir output/liblibc.hir
.PHONY: UPDATE
UPDATE:
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp
index fc93a809..5f27e02f 100644
--- a/src/ast/crate.cpp
+++ b/src/ast/crate.cpp
@@ -59,6 +59,7 @@ void Crate::load_externs()
// Check for no_std or no_core, and load libstd/libcore
// - Duplicates some of the logic in "Expand", but also helps keep crate loading separate to most of expand
+ // NOTE: Not all crates are loaded here, any crates loaded by macro invocations will be done during expand.
bool no_std = false;
bool no_core = false;
@@ -68,6 +69,16 @@ void Crate::load_externs()
no_std = true;
if( a.name() == "no_core" )
no_core = true;
+ if( a.name() == "cfg_attr" && a.items().size() == 2 ) {
+ if( check_cfg(this->m_attrs.m_span, a.items().at(0)) )
+ {
+ const auto& a2 = a.items().at(1);
+ if( a2.name() == "no_std" )
+ no_std = true;
+ if( a2.name() == "no_core" )
+ no_core = true;
+ }
+ }
}
if( no_core ) {
diff --git a/src/main.cpp b/src/main.cpp
index b3425e0d..439ccbaf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -147,6 +147,7 @@ int main(int argc, char *argv[])
Cfg_SetValue("target_pointer_width", "64");
Cfg_SetValue("target_endian", "little");
Cfg_SetValue("target_arch", "x86-noasm"); // TODO: asm! macro
+ Cfg_SetValue("target_os", "foobar");
Cfg_SetValueCb("target_has_atomic", [](const ::std::string& s) {
if(s == "8") return true; // Has an atomic byte
if(s == "ptr") return true; // Has an atomic pointer-sized value
@@ -155,6 +156,9 @@ int main(int argc, char *argv[])
Cfg_SetValueCb("target_feature", [](const ::std::string& s) {
return false;
});
+ Cfg_SetValueCb("feature", [](const ::std::string& s) {
+ return false;
+ });
try