| author | |
| committer | |
| log | 437311756d88984d9bf3057d9cd93986c15434fa |
| tree | 9845ed7d4ad76a191610b885061c26050bd7c349 |
| parent | 35f62bc7aeca5c84f4ddda5736ce902018d23964 |
This was present in stage1 but missing from self-hosted.4 files changed, 17 insertions(+), 1 deletions(-)
src/Compilation.zig+1-1| ... | ... | @@ -1231,7 +1231,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1231 | 1231 | break :blk lm; |
| 1232 | 1232 | } else default_link_mode; |
| 1233 | 1233 | |
| 1234 | const dll_export_fns = if (options.dll_export_fns) |explicit| explicit else is_dyn_lib or options.rdynamic; | |
| 1234 | const dll_export_fns = options.dll_export_fns orelse (is_dyn_lib or options.rdynamic); | |
| 1235 | 1235 | |
| 1236 | 1236 | const libc_dirs = try detectLibCIncludeDirs( |
| 1237 | 1237 | arena, |
src/Module.zig+4| ... | ... | @@ -6529,3 +6529,7 @@ pub fn addGlobalAssembly(mod: *Module, decl_index: Decl.Index, source: []const u |
| 6529 | 6529 | |
| 6530 | 6530 | mod.global_assembly.putAssumeCapacityNoClobber(decl_index, duped_source); |
| 6531 | 6531 | } |
| 6532 | ||
| 6533 | pub fn wantDllExports(mod: Module) bool { | |
| 6534 | return mod.comp.bin_file.options.dll_export_fns and mod.getTarget().os.tag == .windows; | |
| 6535 | } |
src/codegen/llvm.zig+3| ... | ... | @@ -1103,6 +1103,7 @@ pub const Object = struct { |
| 1103 | 1103 | } |
| 1104 | 1104 | llvm_global.setUnnamedAddr(.False); |
| 1105 | 1105 | llvm_global.setLinkage(.External); |
| 1106 | if (module.wantDllExports()) llvm_global.setDLLStorageClass(.Default); | |
| 1106 | 1107 | if (self.di_map.get(decl)) |di_node| { |
| 1107 | 1108 | if (try decl.isFunction()) { |
| 1108 | 1109 | const di_func = @ptrCast(*llvm.DISubprogram, di_node); |
| ... | ... | @@ -1128,6 +1129,7 @@ pub const Object = struct { |
| 1128 | 1129 | const exp_name = exports[0].options.name; |
| 1129 | 1130 | llvm_global.setValueName2(exp_name.ptr, exp_name.len); |
| 1130 | 1131 | llvm_global.setUnnamedAddr(.False); |
| 1132 | if (module.wantDllExports()) llvm_global.setDLLStorageClass(.DLLExport); | |
| 1131 | 1133 | if (self.di_map.get(decl)) |di_node| { |
| 1132 | 1134 | if (try decl.isFunction()) { |
| 1133 | 1135 | const di_func = @ptrCast(*llvm.DISubprogram, di_node); |
| ... | ... | @@ -1187,6 +1189,7 @@ pub const Object = struct { |
| 1187 | 1189 | defer module.gpa.free(fqn); |
| 1188 | 1190 | llvm_global.setValueName2(fqn.ptr, fqn.len); |
| 1189 | 1191 | llvm_global.setLinkage(.Internal); |
| 1192 | if (module.wantDllExports()) llvm_global.setDLLStorageClass(.Default); | |
| 1190 | 1193 | llvm_global.setUnnamedAddr(.True); |
| 1191 | 1194 | if (decl.val.castTag(.variable)) |variable| { |
| 1192 | 1195 | const single_threaded = module.comp.bin_file.options.single_threaded; |
src/codegen/llvm/bindings.zig+9| ... | ... | @@ -223,6 +223,9 @@ pub const Value = opaque { |
| 223 | 223 | pub const setInitializer = LLVMSetInitializer; |
| 224 | 224 | extern fn LLVMSetInitializer(GlobalVar: *const Value, ConstantVal: *const Value) void; |
| 225 | 225 | |
| 226 | pub const setDLLStorageClass = LLVMSetDLLStorageClass; | |
| 227 | extern fn LLVMSetDLLStorageClass(Global: *const Value, Class: DLLStorageClass) void; | |
| 228 | ||
| 226 | 229 | pub const addCase = LLVMAddCase; |
| 227 | 230 | extern fn LLVMAddCase(Switch: *const Value, OnVal: *const Value, Dest: *const BasicBlock) void; |
| 228 | 231 | |
| ... | ... | @@ -1482,6 +1485,12 @@ pub const CallAttr = enum(c_int) { |
| 1482 | 1485 | AlwaysInline, |
| 1483 | 1486 | }; |
| 1484 | 1487 | |
| 1488 | pub const DLLStorageClass = enum(c_uint) { | |
| 1489 | Default, | |
| 1490 | DLLImport, | |
| 1491 | DLLExport, | |
| 1492 | }; | |
| 1493 | ||
| 1485 | 1494 | pub const address_space = struct { |
| 1486 | 1495 | pub const default: c_uint = 0; |
| 1487 | 1496 |