mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
LLVM: add DLL export attribute
This was present in stage1 but missing from self-hosted.
This commit is contained in:
parent
35f62bc7ae
commit
437311756d
@ -1231,7 +1231,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
|
||||
break :blk lm;
|
||||
} else default_link_mode;
|
||||
|
||||
const dll_export_fns = if (options.dll_export_fns) |explicit| explicit else is_dyn_lib or options.rdynamic;
|
||||
const dll_export_fns = options.dll_export_fns orelse (is_dyn_lib or options.rdynamic);
|
||||
|
||||
const libc_dirs = try detectLibCIncludeDirs(
|
||||
arena,
|
||||
|
@ -6529,3 +6529,7 @@ pub fn addGlobalAssembly(mod: *Module, decl_index: Decl.Index, source: []const u
|
||||
|
||||
mod.global_assembly.putAssumeCapacityNoClobber(decl_index, duped_source);
|
||||
}
|
||||
|
||||
pub fn wantDllExports(mod: Module) bool {
|
||||
return mod.comp.bin_file.options.dll_export_fns and mod.getTarget().os.tag == .windows;
|
||||
}
|
||||
|
@ -1103,6 +1103,7 @@ pub const Object = struct {
|
||||
}
|
||||
llvm_global.setUnnamedAddr(.False);
|
||||
llvm_global.setLinkage(.External);
|
||||
if (module.wantDllExports()) llvm_global.setDLLStorageClass(.Default);
|
||||
if (self.di_map.get(decl)) |di_node| {
|
||||
if (try decl.isFunction()) {
|
||||
const di_func = @ptrCast(*llvm.DISubprogram, di_node);
|
||||
@ -1128,6 +1129,7 @@ pub const Object = struct {
|
||||
const exp_name = exports[0].options.name;
|
||||
llvm_global.setValueName2(exp_name.ptr, exp_name.len);
|
||||
llvm_global.setUnnamedAddr(.False);
|
||||
if (module.wantDllExports()) llvm_global.setDLLStorageClass(.DLLExport);
|
||||
if (self.di_map.get(decl)) |di_node| {
|
||||
if (try decl.isFunction()) {
|
||||
const di_func = @ptrCast(*llvm.DISubprogram, di_node);
|
||||
@ -1187,6 +1189,7 @@ pub const Object = struct {
|
||||
defer module.gpa.free(fqn);
|
||||
llvm_global.setValueName2(fqn.ptr, fqn.len);
|
||||
llvm_global.setLinkage(.Internal);
|
||||
if (module.wantDllExports()) llvm_global.setDLLStorageClass(.Default);
|
||||
llvm_global.setUnnamedAddr(.True);
|
||||
if (decl.val.castTag(.variable)) |variable| {
|
||||
const single_threaded = module.comp.bin_file.options.single_threaded;
|
||||
|
@ -223,6 +223,9 @@ pub const Value = opaque {
|
||||
pub const setInitializer = LLVMSetInitializer;
|
||||
extern fn LLVMSetInitializer(GlobalVar: *const Value, ConstantVal: *const Value) void;
|
||||
|
||||
pub const setDLLStorageClass = LLVMSetDLLStorageClass;
|
||||
extern fn LLVMSetDLLStorageClass(Global: *const Value, Class: DLLStorageClass) void;
|
||||
|
||||
pub const addCase = LLVMAddCase;
|
||||
extern fn LLVMAddCase(Switch: *const Value, OnVal: *const Value, Dest: *const BasicBlock) void;
|
||||
|
||||
@ -1482,6 +1485,12 @@ pub const CallAttr = enum(c_int) {
|
||||
AlwaysInline,
|
||||
};
|
||||
|
||||
pub const DLLStorageClass = enum(c_uint) {
|
||||
Default,
|
||||
DLLImport,
|
||||
DLLExport,
|
||||
};
|
||||
|
||||
pub const address_space = struct {
|
||||
pub const default: c_uint = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user