From a4b3e695af47a93788b265b0fc4a55d4dded1ef3 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 9 Oct 2019 17:08:07 +0200 Subject: Shuffle around some stack-probing functions --- lib/std/special/compiler_rt.zig | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/std') diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index 902f2da2ff..ec703afc9f 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -234,14 +234,16 @@ comptime { @export("__aeabi_dcmpun", @import("compiler_rt/comparedf2.zig").__unorddf2, linkage); } if (builtin.os == .windows) { - if (!builtin.link_libc) { + // Default stack-probe functions emitted by LLVM + if (is_mingw) { + @export("_alloca", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage); + @export("___chkstk_ms", @import("compiler_rt/stack_probe.zig").___chkstk_ms, strong_linkage); + } else { @export("_chkstk", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage); @export("__chkstk", @import("compiler_rt/stack_probe.zig").__chkstk, strong_linkage); - @export("___chkstk", @import("compiler_rt/stack_probe.zig").___chkstk, strong_linkage); - @export("__chkstk_ms", @import("compiler_rt/stack_probe.zig").__chkstk_ms, strong_linkage); - @export("___chkstk_ms", @import("compiler_rt/stack_probe.zig").___chkstk_ms, strong_linkage); - } else if (is_mingw) { - @export("___chkstk_ms", @import("compiler_rt/stack_probe.zig").___chkstk_ms, strong_linkage); + } + + if (is_mingw) { @export("__stack_chk_fail", __stack_chk_fail, strong_linkage); @export("__stack_chk_guard", __stack_chk_guard, strong_linkage); } -- cgit v1.2.3 From 9ae293ae3bda918280a9ee254685ec9468e7d141 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 9 Oct 2019 22:07:05 +0200 Subject: Remove x86/Windows name mangling hack Let's fix this properly by generating the correct lib files from the mingw sources. --- lib/std/special/compiler_rt.zig | 10 ++++++---- src/codegen.cpp | 8 -------- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'lib/std') diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index ec703afc9f..88e3078d6a 100644 --- a/lib/std/special/compiler_rt.zig +++ b/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); diff --git a/src/codegen.cpp b/src/codegen.cpp index fdc67b4dd6..055a66792e 100644 --- a/src/codegen.cpp +++ b/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); -- cgit v1.2.3 From 4de3f9d8537fb32017265a2228f9799481db11a0 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Thu, 10 Oct 2019 09:25:39 +0200 Subject: Fix stack-probe symbol redefinition --- lib/std/special/compiler_rt.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/std') diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index 88e3078d6a..0a09f616e9 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -238,7 +238,8 @@ comptime { if (is_mingw) { @export("_alloca", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage); @export("___chkstk_ms", @import("compiler_rt/stack_probe.zig").___chkstk_ms, strong_linkage); - } else { + } else if (!builtin.link_libc) { + // This symbols are otherwise exported by MSVCRT.lib @export("_chkstk", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage); @export("__chkstk", @import("compiler_rt/stack_probe.zig").__chkstk, strong_linkage); } -- cgit v1.2.3