improvements for windows and libc integration

* standard library knows if it is linking against libc and will
   sometimes call libc functions in that case instead of providing
   redundant definitions
 * fix infinite loop bug when resolving use declarations
 * allow calling the same C function from different C imports.
   closes #277
 * push more logic from compiler to std/bootstrap.zig
 * standard library provides way to access errno
   closes #274
 * fix compile error in standard library for windows
 * add implementation of getRandomBytes for windows
This commit is contained in:
Andrew Kelley
2017-03-23 02:59:58 -04:00
parent 01b2bf4a44
commit d6856859d3
13 changed files with 119 additions and 17 deletions

View File

@@ -272,7 +272,17 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
}
TypeTableEntry *fn_type = fn_table_entry->type_entry;
fn_table_entry->llvm_value = LLVMAddFunction(g->module, buf_ptr(symbol_name), fn_type->data.fn.raw_type_ref);
LLVMTypeRef fn_llvm_type = fn_type->data.fn.raw_type_ref;
if (!fn_table_entry->internal_linkage && fn_table_entry->body_node == nullptr) {
LLVMValueRef existing_llvm_fn = LLVMGetNamedFunction(g->module, buf_ptr(symbol_name));
if (existing_llvm_fn) {
fn_table_entry->llvm_value = LLVMConstBitCast(existing_llvm_fn, LLVMPointerType(fn_llvm_type, 0));
} else {
fn_table_entry->llvm_value = LLVMAddFunction(g->module, buf_ptr(symbol_name), fn_llvm_type);
}
} else {
fn_table_entry->llvm_value = LLVMAddFunction(g->module, buf_ptr(symbol_name), fn_llvm_type);
}
switch (fn_table_entry->fn_inline) {
case FnInlineAlways: