Skip to content

Commit

Permalink
prevent non-export symbols from clobbering builtins
Browse files Browse the repository at this point in the history
closes #1263
  • Loading branch information
andrewrk committed Jul 19, 2018
1 parent fd3a41d commit a9f0681
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/codegen.cpp
Expand Up @@ -60,6 +60,33 @@ PackageTableEntry *new_anonymous_package(void) {
return new_package("", "");
}

static const char *symbols_that_llvm_depends_on[] = {
"memcpy",
"memset",
"sqrt",
"powi",
"sin",
"cos",
"pow",
"exp",
"exp2",
"log",
"log10",
"log2",
"fma",
"fabs",
"minnum",
"maxnum",
"copysign",
"floor",
"ceil",
"trunc",
"rint",
"nearbyint",
"round",
// TODO probably all of compiler-rt needs to go here
};

CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out_type, BuildMode build_mode,
Buf *zig_lib_dir)
{
Expand Down Expand Up @@ -94,6 +121,10 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
g->want_h_file = (out_type == OutTypeObj || out_type == OutTypeLib);
buf_resize(&g->global_asm, 0);

for (size_t i = 0; i < array_length(symbols_that_llvm_depends_on); i += 1) {
g->external_prototypes.put(buf_create_from_str(symbols_that_llvm_depends_on[i]), nullptr);
}

if (root_src_path) {
Buf *src_basename = buf_alloc();
Buf *src_dir = buf_alloc();
Expand Down

0 comments on commit a9f0681

Please sign in to comment.