summaryrefslogtreecommitdiff
path: root/src/trans/codegen_c.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-10-12 17:45:40 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-10-12 17:45:40 +0800
commit97b12bcf017c43a544d44ddcded5596f9ffdf3c4 (patch)
tree42711ac8133208c2495f1b05b2ca44a370b63a69 /src/trans/codegen_c.cpp
parent69750e1264bdaf13aff133b0e1820c707f391b6f (diff)
downloadmrust-97b12bcf017c43a544d44ddcded5596f9ffdf3c4.tar.gz
Codegen C - Don't link proc macros into final executable
Diffstat (limited to 'src/trans/codegen_c.cpp')
-rw-r--r--src/trans/codegen_c.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index 81a1a68c..1ee74fee 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -824,15 +824,18 @@ namespace {
case CodegenOutput::Executable:
for( const auto& crate : m_crate.m_ext_crates )
{
- // TODO: If this crate is included in a dylib crate, ignore it
+ auto is_dylib = [](const ::HIR::ExternCrate& c) {
+ bool rv = false;
+ // TODO: Better rule than this
+ rv |= (c.m_path.compare(c.m_path.size() - 3, 3, ".so") == 0);
+ rv |= (c.m_path.compare(c.m_path.size() - 4, 4, ".dll") == 0);
+ return rv;
+ };
+ // If this crate is included in a dylib crate, ignore it
bool is_in_dylib = false;
for( const auto& crate2 : m_crate.m_ext_crates )
{
- // TODO: Better rule than this
- bool is_dylib = false;
- is_dylib |= (crate2.second.m_path.compare(crate2.second.m_path.size() - 3, 3, ".so") == 0);
- is_dylib |= (crate2.second.m_path.compare(crate2.second.m_path.size() - 4, 4, ".dll") == 0);
- if( is_dylib )
+ if( is_dylib(crate2.second) )
{
for(const auto& subcrate : crate2.second.m_data->m_ext_crates)
{
@@ -850,9 +853,12 @@ namespace {
else if( crate.second.m_path.compare(crate.second.m_path.size() - 5, 5, ".rlib") == 0 ) {
args.push_back(crate.second.m_path + ".o");
}
- else {
+ else if( is_dylib(crate.second) ) {
args.push_back(crate.second.m_path);
}
+ else {
+ // Proc macro.
+ }
}
for(const auto& path : link_dirs )
{