diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-02-16 17:06:19 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-02-16 17:06:19 -0700 |
| commit | 0e92b440431bb9dd181ff4c0dc4da3b599a6a66c (patch) | |
| tree | 6255a17f4ff2842f39ee60ea77829b270376de4f /src/analyze.cpp | |
| parent | 77ffb5075bd550893b9f6ac99f151b1d55a8040e (diff) | |
| download | zig-0e92b440431bb9dd181ff4c0dc4da3b599a6a66c.tar.gz zig-0e92b440431bb9dd181ff4c0dc4da3b599a6a66c.zip | |
prepend underscore to non exported functions
to prevent symbol collisions
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index f075740c44..e73902f118 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -945,9 +945,14 @@ static void resolve_function_proto(CodeGen *g, AstNode *node, FnTableEntry *fn_t return; } - - fn_table_entry->fn_value = LLVMAddFunction(g->module, buf_ptr(&fn_table_entry->symbol_name), - fn_type->data.fn.raw_type_ref); + Buf *symbol_name; + if (is_c_compat) { + symbol_name = &fn_table_entry->symbol_name; + } else { + symbol_name = buf_sprintf("_%s", buf_ptr(&fn_table_entry->symbol_name)); + } + fn_table_entry->fn_value = LLVMAddFunction(g->module, buf_ptr(symbol_name), + fn_type->data.fn.raw_type_ref); if (fn_table_entry->is_inline) { LLVMAddFunctionAttr(fn_table_entry->fn_value, LLVMAlwaysInlineAttribute); |
