| author | |
| committer | |
| log | 9924897c065af526f43c82d4b8328b5e72d100bd |
| tree | 57014d8d0c5834f0ef98c285b45218b44630ab9f |
| parent | 5d019abe4ec70373db7a75c2a8a3e2d76939817c |
| parent | 837e56431232e5257e988227dff45be6f4dececf |
| signature |
ubsan-rt: export symbols with hidden visibility2 files changed, 11 insertions(+), 4 deletions(-)
lib/ubsan_rt.zig+3-3| ... | ... | @@ -627,7 +627,7 @@ fn exportHandler( |
| 627 | 627 | // Work around x86_64 backend limitation. |
| 628 | 628 | const linkage = if (builtin.zig_backend == .stage2_x86_64 and builtin.os.tag == .windows) .internal else .weak; |
| 629 | 629 | const N = "__ubsan_handle_" ++ sym_name; |
| 630 | @export(handler, .{ .name = N, .linkage = linkage }); | |
| 630 | @export(handler, .{ .name = N, .linkage = linkage, .visibility = if (linkage == .internal) .default else .hidden }); | |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | fn exportHandlerWithAbort( |
| ... | ... | @@ -639,11 +639,11 @@ fn exportHandlerWithAbort( |
| 639 | 639 | const linkage = if (builtin.zig_backend == .stage2_x86_64 and builtin.os.tag == .windows) .internal else .weak; |
| 640 | 640 | { |
| 641 | 641 | const N = "__ubsan_handle_" ++ sym_name; |
| 642 | @export(handler, .{ .name = N, .linkage = linkage }); | |
| 642 | @export(handler, .{ .name = N, .linkage = linkage, .visibility = if (linkage == .internal) .default else .hidden }); | |
| 643 | 643 | } |
| 644 | 644 | { |
| 645 | 645 | const N = "__ubsan_handle_" ++ sym_name ++ "_abort"; |
| 646 | @export(abort_handler, .{ .name = N, .linkage = linkage }); | |
| 646 | @export(abort_handler, .{ .name = N, .linkage = linkage, .visibility = if (linkage == .internal) .default else .hidden }); | |
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 |
src/Compilation.zig+8-1| ... | ... | @@ -2048,7 +2048,14 @@ pub fn create(gpa: Allocator, arena: Allocator, diag: *CreateDiagnostic, options |
| 2048 | 2048 | break :s .none; // only LLD can handle ubsan-rt for this target |
| 2049 | 2049 | } else true, |
| 2050 | 2050 | }; |
| 2051 | if (have_zcu and (!need_llvm or use_llvm)) break :s .zcu; | |
| 2051 | if (have_zcu and (!need_llvm or use_llvm)) { | |
| 2052 | // ubsan-rt's exports use hidden visibility. If we're building a Windows DLL and | |
| 2053 | // exported functions are going to be dllexported, LLVM will complain that | |
| 2054 | // dllexported functions must use default or protected visibility. So we can't use | |
| 2055 | // the ZCU strategy in this case. | |
| 2056 | if (options.config.dll_export_fns) break :s .lib; | |
| 2057 | break :s .zcu; | |
| 2058 | } | |
| 2052 | 2059 | if (need_llvm and !build_options.have_llvm) break :s .none; // impossible to build without llvm |
| 2053 | 2060 | if (is_exe_or_dyn_lib) break :s .lib; |
| 2054 | 2061 | break :s .obj; |