Commit 9ae293ae3b

LemonBoy <thatlemon@gmail.com>
2019-10-09 22:07:05
Remove x86/Windows name mangling hack
Let's fix this properly by generating the correct lib files from the mingw sources.
1 parent f83bb3d
Changed files (2)
lib
std
src
lib/std/special/compiler_rt.zig
@@ -250,10 +250,12 @@ comptime {
 
         switch (builtin.arch) {
             .i386 => {
-                @export("_alldiv", @import("compiler_rt/aulldiv.zig")._alldiv, strong_linkage);
-                @export("_aulldiv", @import("compiler_rt/aulldiv.zig")._aulldiv, strong_linkage);
-                @export("_allrem", @import("compiler_rt/aullrem.zig")._allrem, strong_linkage);
-                @export("_aullrem", @import("compiler_rt/aullrem.zig")._aullrem, strong_linkage);
+                // Don't let LLVM apply the stdcall name mangling on those MSVC
+                // builtin functions
+                @export("\x01__alldiv", @import("compiler_rt/aulldiv.zig")._alldiv, strong_linkage);
+                @export("\x01__aulldiv", @import("compiler_rt/aulldiv.zig")._aulldiv, strong_linkage);
+                @export("\x01__allrem", @import("compiler_rt/aullrem.zig")._allrem, strong_linkage);
+                @export("\x01__aullrem", @import("compiler_rt/aullrem.zig")._aullrem, strong_linkage);
 
                 @export("__divti3", @import("compiler_rt/divti3.zig").__divti3, linkage);
                 @export("__modti3", @import("compiler_rt/modti3.zig").__modti3, linkage);
src/codegen.cpp
@@ -415,16 +415,8 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
 
     bool external_linkage = linkage != GlobalLinkageIdInternal;
     CallingConvention cc = fn->type_entry->data.fn.fn_type_id.cc;
-    if (cc == CallingConventionStdcall && external_linkage &&
-        g->zig_target->arch == ZigLLVM_x86)
-    {
-        // prevent llvm name mangling
-        symbol_name = buf_ptr(buf_sprintf("\x01_%s", symbol_name));
-    }
-
     bool is_async = fn_is_async(fn);
 
-
     ZigType *fn_type = fn->type_entry;
     // Make the raw_type_ref populated
     resolve_llvm_types_fn(g, fn);