Skip to content

Commit a9f0681

Browse files
committedJul 19, 2018
prevent non-export symbols from clobbering builtins
closes #1263
·
0.15.10.3.0
1 parent fd3a41d commit a9f0681

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
 

‎src/codegen.cpp‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,33 @@ PackageTableEntry *new_anonymous_package(void) {
6060
return new_package("", "");
6161
}
6262

63+
static const char *symbols_that_llvm_depends_on[] = {
64+
"memcpy",
65+
"memset",
66+
"sqrt",
67+
"powi",
68+
"sin",
69+
"cos",
70+
"pow",
71+
"exp",
72+
"exp2",
73+
"log",
74+
"log10",
75+
"log2",
76+
"fma",
77+
"fabs",
78+
"minnum",
79+
"maxnum",
80+
"copysign",
81+
"floor",
82+
"ceil",
83+
"trunc",
84+
"rint",
85+
"nearbyint",
86+
"round",
87+
// TODO probably all of compiler-rt needs to go here
88+
};
89+
6390
CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out_type, BuildMode build_mode,
6491
Buf *zig_lib_dir)
6592
{
@@ -94,6 +121,10 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
94121
g->want_h_file = (out_type == OutTypeObj || out_type == OutTypeLib);
95122
buf_resize(&g->global_asm, 0);
96123

124+
for (size_t i = 0; i < array_length(symbols_that_llvm_depends_on); i += 1) {
125+
g->external_prototypes.put(buf_create_from_str(symbols_that_llvm_depends_on[i]), nullptr);
126+
}
127+
97128
if (root_src_path) {
98129
Buf *src_basename = buf_alloc();
99130
Buf *src_dir = buf_alloc();

0 commit comments

Comments
 (0)
Please sign in to comment.