authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-09 10:36:51+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-09 13:43:06-05:00
log5ab5de89c03bf9b3f08dfaa78d3b0fe41a72cdea
treec93dcfb6b6dad6d52d8d03e1d1a4601da5f04a3c
parent4613e4d15f85406d23f91134a9ec5854da33965f

New @export() handling

Use a struct as second parameter to be future proof (and also allows to specify default values for the parameters) Closes #2679 as it was just a matter of a few lines of code.

13 files changed, 335 insertions(+), 298 deletions(-)

doc/langref.html.in+3-3
...@@ -7327,21 +7327,21 @@ test "main" {...@@ -7327,21 +7327,21 @@ test "main" {
7327 {#header_close#}7327 {#header_close#}
73287328
7329 {#header_open|@export#}7329 {#header_open|@export#}
7330 <pre>{#syntax#}@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) void{#endsyntax#}</pre>7330 <pre>{#syntax#}@export(target: var, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre>
7331 <p>7331 <p>
7332 Creates a symbol in the output object file.7332 Creates a symbol in the output object file.
7333 </p>7333 </p>
7334 <p>7334 <p>
7335 This function can be called from a {#link|comptime#} block to conditionally export symbols.7335 This function can be called from a {#link|comptime#} block to conditionally export symbols.
7336 When {#syntax#}target{#endsyntax#} is a function with the C calling convention and7336 When {#syntax#}target{#endsyntax#} is a function with the C calling convention and
7337 {#syntax#}linkage{#endsyntax#} is {#syntax#}Strong{#endsyntax#}, this is equivalent to7337 {#syntax#}options.linkage{#endsyntax#} is {#syntax#}Strong{#endsyntax#}, this is equivalent to
7338 the {#syntax#}export{#endsyntax#} keyword used on a function:7338 the {#syntax#}export{#endsyntax#} keyword used on a function:
7339 </p>7339 </p>
7340 {#code_begin|obj#}7340 {#code_begin|obj#}
7341const builtin = @import("builtin");7341const builtin = @import("builtin");
73427342
7343comptime {7343comptime {
7344 @export("foo", internalName, builtin.GlobalLinkage.Strong);7344 @export(internalName, .{ .name = "foo", .linkage = .Strong });
7345}7345}
73467346
7347extern fn internalName() void {}7347extern fn internalName() void {}
lib/std/builtin.zig+8
...@@ -419,6 +419,14 @@ pub const CallOptions = struct {...@@ -419,6 +419,14 @@ pub const CallOptions = struct {
419 };419 };
420};420};
421421
422/// This data structure is used by the Zig language code generation and
423/// therefore must be kept in sync with the compiler implementation.
424pub const ExportOptions = struct {
425 name: []const u8,
426 linkage: GlobalLinkage = .Strong,
427 section: ?[]const u8 = null,
428};
429
422/// This function type is used by the Zig language code generation and430/// This function type is used by the Zig language code generation and
423/// therefore must be kept in sync with the compiler implementation.431/// therefore must be kept in sync with the compiler implementation.
424pub const TestFn = struct {432pub const TestFn = struct {
lib/std/c/darwin.zig+1-1
...@@ -37,7 +37,7 @@ const mach_hdr = if (@sizeOf(usize) == 8) mach_header_64 else mach_header;...@@ -37,7 +37,7 @@ const mach_hdr = if (@sizeOf(usize) == 8) mach_header_64 else mach_header;
37pub extern "c" var _mh_execute_header: mach_hdr = undefined;37pub extern "c" var _mh_execute_header: mach_hdr = undefined;
38comptime {38comptime {
39 if (std.Target.current.isDarwin()) {39 if (std.Target.current.isDarwin()) {
40 @export("_mh_execute_header", _mh_execute_header, .Weak);40 @export(_mh_execute_header, .{ .name = "_mh_execute_header", .linkage = .Weak });
41 }41 }
42}42}
4343
lib/std/special/c.zig+9-9
...@@ -23,17 +23,17 @@ const is_freestanding = switch (builtin.os) {...@@ -23,17 +23,17 @@ const is_freestanding = switch (builtin.os) {
23};23};
24comptime {24comptime {
25 if (is_freestanding and is_wasm and builtin.link_libc) {25 if (is_freestanding and is_wasm and builtin.link_libc) {
26 @export("_start", wasm_start, .Strong);26 @export(wasm_start, .{ .name = "_start", .linkage = .Strong });
27 }27 }
28 if (builtin.link_libc) {28 if (builtin.link_libc) {
29 @export("strcmp", strcmp, .Strong);29 @export(strcmp, .{ .name = "strcmp", .linkage = .Strong });
30 @export("strncmp", strncmp, .Strong);30 @export(strncmp, .{ .name = "strncmp", .linkage = .Strong });
31 @export("strerror", strerror, .Strong);31 @export(strerror, .{ .name = "strerror", .linkage = .Strong });
32 @export("strlen", strlen, .Strong);32 @export(strlen, .{ .name = "strlen", .linkage = .Strong });
33 } else if (is_msvc) {33 } else if (is_msvc) {
34 @export("_fltused", _fltused, .Strong);34 @export(_fltused, .{ .name = "_fltused", .linkage = .Strong });
35 } else if (builtin.arch == builtin.Arch.arm and builtin.os == .linux) {35 } else if (builtin.arch == builtin.Arch.arm and builtin.os == .linux) {
36 @export("__aeabi_read_tp", std.os.linux.getThreadPointer, .Strong);36 @export(std.os.linux.getThreadPointer, .{ .name = "__aeabi_read_tp", .linkage = .Strong });
37 }37 }
38}38}
3939
...@@ -182,10 +182,10 @@ comptime {...@@ -182,10 +182,10 @@ comptime {
182 builtin.mode != builtin.Mode.ReleaseSmall and182 builtin.mode != builtin.Mode.ReleaseSmall and
183 builtin.os != builtin.Os.windows)183 builtin.os != builtin.Os.windows)
184 {184 {
185 @export("__stack_chk_fail", __stack_chk_fail, builtin.GlobalLinkage.Strong);185 @export(__stack_chk_fail, .{ .name = "__stack_chk_fail" });
186 }186 }
187 if (builtin.os == builtin.Os.linux) {187 if (builtin.os == builtin.Os.linux) {
188 @export("clone", clone, builtin.GlobalLinkage.Strong);188 @export(clone, .{ .name = "clone" });
189 }189 }
190}190}
191fn __stack_chk_fail() callconv(.C) noreturn {191fn __stack_chk_fail() callconv(.C) noreturn {
lib/std/special/compiler_rt.zig+219-219
...@@ -12,289 +12,289 @@ comptime {...@@ -12,289 +12,289 @@ comptime {
12 const strong_linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Strong;12 const strong_linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Strong;
1313
14 switch (builtin.arch) {14 switch (builtin.arch) {
15 .i386, .x86_64 => @export("__zig_probe_stack", @import("compiler_rt/stack_probe.zig").zig_probe_stack, linkage),15 .i386, .x86_64 => @export(@import("compiler_rt/stack_probe.zig").zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage }),
16 else => {},16 else => {},
17 }17 }
1818
19 @export("__lesf2", @import("compiler_rt/comparesf2.zig").__lesf2, linkage);19 @export(@import("compiler_rt/comparesf2.zig").__lesf2, .{ .name = "__lesf2", .linkage = linkage });
20 @export("__ledf2", @import("compiler_rt/comparedf2.zig").__ledf2, linkage);20 @export(@import("compiler_rt/comparedf2.zig").__ledf2, .{ .name = "__ledf2", .linkage = linkage });
21 @export("__letf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);21 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__letf2", .linkage = linkage });
2222
23 @export("__gesf2", @import("compiler_rt/comparesf2.zig").__gesf2, linkage);23 @export(@import("compiler_rt/comparesf2.zig").__gesf2, .{ .name = "__gesf2", .linkage = linkage });
24 @export("__gedf2", @import("compiler_rt/comparedf2.zig").__gedf2, linkage);24 @export(@import("compiler_rt/comparedf2.zig").__gedf2, .{ .name = "__gedf2", .linkage = linkage });
25 @export("__getf2", @import("compiler_rt/comparetf2.zig").__getf2, linkage);25 @export(@import("compiler_rt/comparetf2.zig").__getf2, .{ .name = "__getf2", .linkage = linkage });
2626
27 if (!is_test) {27 if (!is_test) {
28 @export("__cmpsf2", @import("compiler_rt/comparesf2.zig").__lesf2, linkage);28 @export(@import("compiler_rt/comparesf2.zig").__lesf2, .{ .name = "__cmpsf2", .linkage = linkage });
29 @export("__cmpdf2", @import("compiler_rt/comparedf2.zig").__ledf2, linkage);29 @export(@import("compiler_rt/comparedf2.zig").__ledf2, .{ .name = "__cmpdf2", .linkage = linkage });
30 @export("__cmptf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);30 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__cmptf2", .linkage = linkage });
3131
32 @export("__eqsf2", @import("compiler_rt/comparesf2.zig").__eqsf2, linkage);32 @export(@import("compiler_rt/comparesf2.zig").__eqsf2, .{ .name = "__eqsf2", .linkage = linkage });
33 @export("__eqdf2", @import("compiler_rt/comparedf2.zig").__eqdf2, linkage);33 @export(@import("compiler_rt/comparedf2.zig").__eqdf2, .{ .name = "__eqdf2", .linkage = linkage });
34 @export("__eqtf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);34 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__eqtf2", .linkage = linkage });
3535
36 @export("__ltsf2", @import("compiler_rt/comparesf2.zig").__ltsf2, linkage);36 @export(@import("compiler_rt/comparesf2.zig").__ltsf2, .{ .name = "__ltsf2", .linkage = linkage });
37 @export("__ltdf2", @import("compiler_rt/comparedf2.zig").__ltdf2, linkage);37 @export(@import("compiler_rt/comparedf2.zig").__ltdf2, .{ .name = "__ltdf2", .linkage = linkage });
38 @export("__lttf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);38 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__lttf2", .linkage = linkage });
3939
40 @export("__nesf2", @import("compiler_rt/comparesf2.zig").__nesf2, linkage);40 @export(@import("compiler_rt/comparesf2.zig").__nesf2, .{ .name = "__nesf2", .linkage = linkage });
41 @export("__nedf2", @import("compiler_rt/comparedf2.zig").__nedf2, linkage);41 @export(@import("compiler_rt/comparedf2.zig").__nedf2, .{ .name = "__nedf2", .linkage = linkage });
42 @export("__netf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);42 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__netf2", .linkage = linkage });
4343
44 @export("__gtsf2", @import("compiler_rt/comparesf2.zig").__gtsf2, linkage);44 @export(@import("compiler_rt/comparesf2.zig").__gtsf2, .{ .name = "__gtsf2", .linkage = linkage });
45 @export("__gtdf2", @import("compiler_rt/comparedf2.zig").__gtdf2, linkage);45 @export(@import("compiler_rt/comparedf2.zig").__gtdf2, .{ .name = "__gtdf2", .linkage = linkage });
46 @export("__gttf2", @import("compiler_rt/comparetf2.zig").__getf2, linkage);46 @export(@import("compiler_rt/comparetf2.zig").__getf2, .{ .name = "__gttf2", .linkage = linkage });
4747
48 @export("__gnu_h2f_ieee", @import("compiler_rt/extendXfYf2.zig").__extendhfsf2, linkage);48 @export(@import("compiler_rt/extendXfYf2.zig").__extendhfsf2, .{ .name = "__gnu_h2f_ieee", .linkage = linkage });
49 @export("__gnu_f2h_ieee", @import("compiler_rt/truncXfYf2.zig").__truncsfhf2, linkage);49 @export(@import("compiler_rt/truncXfYf2.zig").__truncsfhf2, .{ .name = "__gnu_f2h_ieee", .linkage = linkage });
50 }50 }
5151
52 @export("__unordsf2", @import("compiler_rt/comparesf2.zig").__unordsf2, linkage);52 @export(@import("compiler_rt/comparesf2.zig").__unordsf2, .{ .name = "__unordsf2", .linkage = linkage });
53 @export("__unorddf2", @import("compiler_rt/comparedf2.zig").__unorddf2, linkage);53 @export(@import("compiler_rt/comparedf2.zig").__unorddf2, .{ .name = "__unorddf2", .linkage = linkage });
54 @export("__unordtf2", @import("compiler_rt/comparetf2.zig").__unordtf2, linkage);54 @export(@import("compiler_rt/comparetf2.zig").__unordtf2, .{ .name = "__unordtf2", .linkage = linkage });
5555
56 @export("__addsf3", @import("compiler_rt/addXf3.zig").__addsf3, linkage);56 @export(@import("compiler_rt/addXf3.zig").__addsf3, .{ .name = "__addsf3", .linkage = linkage });
57 @export("__adddf3", @import("compiler_rt/addXf3.zig").__adddf3, linkage);57 @export(@import("compiler_rt/addXf3.zig").__adddf3, .{ .name = "__adddf3", .linkage = linkage });
58 @export("__addtf3", @import("compiler_rt/addXf3.zig").__addtf3, linkage);58 @export(@import("compiler_rt/addXf3.zig").__addtf3, .{ .name = "__addtf3", .linkage = linkage });
59 @export("__subsf3", @import("compiler_rt/addXf3.zig").__subsf3, linkage);59 @export(@import("compiler_rt/addXf3.zig").__subsf3, .{ .name = "__subsf3", .linkage = linkage });
60 @export("__subdf3", @import("compiler_rt/addXf3.zig").__subdf3, linkage);60 @export(@import("compiler_rt/addXf3.zig").__subdf3, .{ .name = "__subdf3", .linkage = linkage });
61 @export("__subtf3", @import("compiler_rt/addXf3.zig").__subtf3, linkage);61 @export(@import("compiler_rt/addXf3.zig").__subtf3, .{ .name = "__subtf3", .linkage = linkage });
6262
63 @export("__mulsf3", @import("compiler_rt/mulXf3.zig").__mulsf3, linkage);63 @export(@import("compiler_rt/mulXf3.zig").__mulsf3, .{ .name = "__mulsf3", .linkage = linkage });
64 @export("__muldf3", @import("compiler_rt/mulXf3.zig").__muldf3, linkage);64 @export(@import("compiler_rt/mulXf3.zig").__muldf3, .{ .name = "__muldf3", .linkage = linkage });
65 @export("__multf3", @import("compiler_rt/mulXf3.zig").__multf3, linkage);65 @export(@import("compiler_rt/mulXf3.zig").__multf3, .{ .name = "__multf3", .linkage = linkage });
6666
67 @export("__divsf3", @import("compiler_rt/divsf3.zig").__divsf3, linkage);67 @export(@import("compiler_rt/divsf3.zig").__divsf3, .{ .name = "__divsf3", .linkage = linkage });
68 @export("__divdf3", @import("compiler_rt/divdf3.zig").__divdf3, linkage);68 @export(@import("compiler_rt/divdf3.zig").__divdf3, .{ .name = "__divdf3", .linkage = linkage });
6969
70 @export("__ashlti3", @import("compiler_rt/ashlti3.zig").__ashlti3, linkage);70 @export(@import("compiler_rt/ashlti3.zig").__ashlti3, .{ .name = "__ashlti3", .linkage = linkage });
71 @export("__lshrti3", @import("compiler_rt/lshrti3.zig").__lshrti3, linkage);71 @export(@import("compiler_rt/lshrti3.zig").__lshrti3, .{ .name = "__lshrti3", .linkage = linkage });
72 @export("__ashrti3", @import("compiler_rt/ashrti3.zig").__ashrti3, linkage);72 @export(@import("compiler_rt/ashrti3.zig").__ashrti3, .{ .name = "__ashrti3", .linkage = linkage });
7373
74 @export("__floatsidf", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage);74 @export(@import("compiler_rt/floatsiXf.zig").__floatsidf, .{ .name = "__floatsidf", .linkage = linkage });
75 @export("__floatsisf", @import("compiler_rt/floatsiXf.zig").__floatsisf, linkage);75 @export(@import("compiler_rt/floatsiXf.zig").__floatsisf, .{ .name = "__floatsisf", .linkage = linkage });
76 @export("__floatdidf", @import("compiler_rt/floatdidf.zig").__floatdidf, linkage);76 @export(@import("compiler_rt/floatdidf.zig").__floatdidf, .{ .name = "__floatdidf", .linkage = linkage });
77 @export("__floatsitf", @import("compiler_rt/floatsiXf.zig").__floatsitf, linkage);77 @export(@import("compiler_rt/floatsiXf.zig").__floatsitf, .{ .name = "__floatsitf", .linkage = linkage });
7878
79 @export("__floatunsisf", @import("compiler_rt/floatunsisf.zig").__floatunsisf, linkage);79 @export(@import("compiler_rt/floatunsisf.zig").__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage });
80 @export("__floatundisf", @import("compiler_rt/floatundisf.zig").__floatundisf, linkage);80 @export(@import("compiler_rt/floatundisf.zig").__floatundisf, .{ .name = "__floatundisf", .linkage = linkage });
81 @export("__floatunsidf", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage);81 @export(@import("compiler_rt/floatunsidf.zig").__floatunsidf, .{ .name = "__floatunsidf", .linkage = linkage });
82 @export("__floatundidf", @import("compiler_rt/floatundidf.zig").__floatundidf, linkage);82 @export(@import("compiler_rt/floatundidf.zig").__floatundidf, .{ .name = "__floatundidf", .linkage = linkage });
8383
84 @export("__floattitf", @import("compiler_rt/floattitf.zig").__floattitf, linkage);84 @export(@import("compiler_rt/floattitf.zig").__floattitf, .{ .name = "__floattitf", .linkage = linkage });
85 @export("__floattidf", @import("compiler_rt/floattidf.zig").__floattidf, linkage);85 @export(@import("compiler_rt/floattidf.zig").__floattidf, .{ .name = "__floattidf", .linkage = linkage });
86 @export("__floattisf", @import("compiler_rt/floattisf.zig").__floattisf, linkage);86 @export(@import("compiler_rt/floattisf.zig").__floattisf, .{ .name = "__floattisf", .linkage = linkage });
8787
88 @export("__floatunditf", @import("compiler_rt/floatunditf.zig").__floatunditf, linkage);88 @export(@import("compiler_rt/floatunditf.zig").__floatunditf, .{ .name = "__floatunditf", .linkage = linkage });
89 @export("__floatunsitf", @import("compiler_rt/floatunsitf.zig").__floatunsitf, linkage);89 @export(@import("compiler_rt/floatunsitf.zig").__floatunsitf, .{ .name = "__floatunsitf", .linkage = linkage });
9090
91 @export("__floatuntitf", @import("compiler_rt/floatuntitf.zig").__floatuntitf, linkage);91 @export(@import("compiler_rt/floatuntitf.zig").__floatuntitf, .{ .name = "__floatuntitf", .linkage = linkage });
92 @export("__floatuntidf", @import("compiler_rt/floatuntidf.zig").__floatuntidf, linkage);92 @export(@import("compiler_rt/floatuntidf.zig").__floatuntidf, .{ .name = "__floatuntidf", .linkage = linkage });
93 @export("__floatuntisf", @import("compiler_rt/floatuntisf.zig").__floatuntisf, linkage);93 @export(@import("compiler_rt/floatuntisf.zig").__floatuntisf, .{ .name = "__floatuntisf", .linkage = linkage });
9494
95 @export("__extenddftf2", @import("compiler_rt/extendXfYf2.zig").__extenddftf2, linkage);95 @export(@import("compiler_rt/extendXfYf2.zig").__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage });
96 @export("__extendsftf2", @import("compiler_rt/extendXfYf2.zig").__extendsftf2, linkage);96 @export(@import("compiler_rt/extendXfYf2.zig").__extendsftf2, .{ .name = "__extendsftf2", .linkage = linkage });
97 @export("__extendhfsf2", @import("compiler_rt/extendXfYf2.zig").__extendhfsf2, linkage);97 @export(@import("compiler_rt/extendXfYf2.zig").__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = linkage });
9898
99 @export("__truncsfhf2", @import("compiler_rt/truncXfYf2.zig").__truncsfhf2, linkage);99 @export(@import("compiler_rt/truncXfYf2.zig").__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = linkage });
100 @export("__truncdfhf2", @import("compiler_rt/truncXfYf2.zig").__truncdfhf2, linkage);100 @export(@import("compiler_rt/truncXfYf2.zig").__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = linkage });
101 @export("__trunctfdf2", @import("compiler_rt/truncXfYf2.zig").__trunctfdf2, linkage);101 @export(@import("compiler_rt/truncXfYf2.zig").__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = linkage });
102 @export("__trunctfsf2", @import("compiler_rt/truncXfYf2.zig").__trunctfsf2, linkage);102 @export(@import("compiler_rt/truncXfYf2.zig").__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = linkage });
103103
104 @export("__truncdfsf2", @import("compiler_rt/truncXfYf2.zig").__truncdfsf2, linkage);104 @export(@import("compiler_rt/truncXfYf2.zig").__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = linkage });
105105
106 @export("__extendsfdf2", @import("compiler_rt/extendXfYf2.zig").__extendsfdf2, linkage);106 @export(@import("compiler_rt/extendXfYf2.zig").__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = linkage });
107107
108 @export("__fixunssfsi", @import("compiler_rt/fixunssfsi.zig").__fixunssfsi, linkage);108 @export(@import("compiler_rt/fixunssfsi.zig").__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = linkage });
109 @export("__fixunssfdi", @import("compiler_rt/fixunssfdi.zig").__fixunssfdi, linkage);109 @export(@import("compiler_rt/fixunssfdi.zig").__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = linkage });
110 @export("__fixunssfti", @import("compiler_rt/fixunssfti.zig").__fixunssfti, linkage);110 @export(@import("compiler_rt/fixunssfti.zig").__fixunssfti, .{ .name = "__fixunssfti", .linkage = linkage });
111111
112 @export("__fixunsdfsi", @import("compiler_rt/fixunsdfsi.zig").__fixunsdfsi, linkage);112 @export(@import("compiler_rt/fixunsdfsi.zig").__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = linkage });
113 @export("__fixunsdfdi", @import("compiler_rt/fixunsdfdi.zig").__fixunsdfdi, linkage);113 @export(@import("compiler_rt/fixunsdfdi.zig").__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = linkage });
114 @export("__fixunsdfti", @import("compiler_rt/fixunsdfti.zig").__fixunsdfti, linkage);114 @export(@import("compiler_rt/fixunsdfti.zig").__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = linkage });
115115
116 @export("__fixunstfsi", @import("compiler_rt/fixunstfsi.zig").__fixunstfsi, linkage);116 @export(@import("compiler_rt/fixunstfsi.zig").__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = linkage });
117 @export("__fixunstfdi", @import("compiler_rt/fixunstfdi.zig").__fixunstfdi, linkage);117 @export(@import("compiler_rt/fixunstfdi.zig").__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = linkage });
118 @export("__fixunstfti", @import("compiler_rt/fixunstfti.zig").__fixunstfti, linkage);118 @export(@import("compiler_rt/fixunstfti.zig").__fixunstfti, .{ .name = "__fixunstfti", .linkage = linkage });
119119
120 @export("__fixdfdi", @import("compiler_rt/fixdfdi.zig").__fixdfdi, linkage);120 @export(@import("compiler_rt/fixdfdi.zig").__fixdfdi, .{ .name = "__fixdfdi", .linkage = linkage });
121 @export("__fixdfsi", @import("compiler_rt/fixdfsi.zig").__fixdfsi, linkage);121 @export(@import("compiler_rt/fixdfsi.zig").__fixdfsi, .{ .name = "__fixdfsi", .linkage = linkage });
122 @export("__fixdfti", @import("compiler_rt/fixdfti.zig").__fixdfti, linkage);122 @export(@import("compiler_rt/fixdfti.zig").__fixdfti, .{ .name = "__fixdfti", .linkage = linkage });
123 @export("__fixsfdi", @import("compiler_rt/fixsfdi.zig").__fixsfdi, linkage);123 @export(@import("compiler_rt/fixsfdi.zig").__fixsfdi, .{ .name = "__fixsfdi", .linkage = linkage });
124 @export("__fixsfsi", @import("compiler_rt/fixsfsi.zig").__fixsfsi, linkage);124 @export(@import("compiler_rt/fixsfsi.zig").__fixsfsi, .{ .name = "__fixsfsi", .linkage = linkage });
125 @export("__fixsfti", @import("compiler_rt/fixsfti.zig").__fixsfti, linkage);125 @export(@import("compiler_rt/fixsfti.zig").__fixsfti, .{ .name = "__fixsfti", .linkage = linkage });
126 @export("__fixtfdi", @import("compiler_rt/fixtfdi.zig").__fixtfdi, linkage);126 @export(@import("compiler_rt/fixtfdi.zig").__fixtfdi, .{ .name = "__fixtfdi", .linkage = linkage });
127 @export("__fixtfsi", @import("compiler_rt/fixtfsi.zig").__fixtfsi, linkage);127 @export(@import("compiler_rt/fixtfsi.zig").__fixtfsi, .{ .name = "__fixtfsi", .linkage = linkage });
128 @export("__fixtfti", @import("compiler_rt/fixtfti.zig").__fixtfti, linkage);128 @export(@import("compiler_rt/fixtfti.zig").__fixtfti, .{ .name = "__fixtfti", .linkage = linkage });
129129
130 @export("__udivmoddi4", @import("compiler_rt/udivmoddi4.zig").__udivmoddi4, linkage);130 @export(@import("compiler_rt/udivmoddi4.zig").__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = linkage });
131 @export("__popcountdi2", @import("compiler_rt/popcountdi2.zig").__popcountdi2, linkage);131 @export(@import("compiler_rt/popcountdi2.zig").__popcountdi2, .{ .name = "__popcountdi2", .linkage = linkage });
132132
133 @export("__muldi3", @import("compiler_rt/muldi3.zig").__muldi3, linkage);133 @export(@import("compiler_rt/muldi3.zig").__muldi3, .{ .name = "__muldi3", .linkage = linkage });
134 @export("__divmoddi4", __divmoddi4, linkage);134 @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = linkage });
135 @export("__divsi3", __divsi3, linkage);135 @export(__divsi3, .{ .name = "__divsi3", .linkage = linkage });
136 @export("__divdi3", __divdi3, linkage);136 @export(__divdi3, .{ .name = "__divdi3", .linkage = linkage });
137 @export("__udivsi3", __udivsi3, linkage);137 @export(__udivsi3, .{ .name = "__udivsi3", .linkage = linkage });
138 @export("__udivdi3", __udivdi3, linkage);138 @export(__udivdi3, .{ .name = "__udivdi3", .linkage = linkage });
139 @export("__modsi3", __modsi3, linkage);139 @export(__modsi3, .{ .name = "__modsi3", .linkage = linkage });
140 @export("__moddi3", __moddi3, linkage);140 @export(__moddi3, .{ .name = "__moddi3", .linkage = linkage });
141 @export("__umodsi3", __umodsi3, linkage);141 @export(__umodsi3, .{ .name = "__umodsi3", .linkage = linkage });
142 @export("__umoddi3", __umoddi3, linkage);142 @export(__umoddi3, .{ .name = "__umoddi3", .linkage = linkage });
143 @export("__divmodsi4", __divmodsi4, linkage);143 @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = linkage });
144 @export("__udivmodsi4", __udivmodsi4, linkage);144 @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = linkage });
145145
146 @export("__negsf2", @import("compiler_rt/negXf2.zig").__negsf2, linkage);146 @export(@import("compiler_rt/negXf2.zig").__negsf2, .{ .name = "__negsf2", .linkage = linkage });
147 @export("__negdf2", @import("compiler_rt/negXf2.zig").__negdf2, linkage);147 @export(@import("compiler_rt/negXf2.zig").__negdf2, .{ .name = "__negdf2", .linkage = linkage });
148148
149 if (is_arm_arch and !is_arm_64 and !is_test) {149 if (is_arm_arch and !is_arm_64 and !is_test) {
150 @export("__aeabi_unwind_cpp_pr0", __aeabi_unwind_cpp_pr0, strong_linkage);150 @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = strong_linkage });
151 @export("__aeabi_unwind_cpp_pr1", __aeabi_unwind_cpp_pr1, linkage);151 @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage });
152 @export("__aeabi_unwind_cpp_pr2", __aeabi_unwind_cpp_pr2, linkage);152 @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage });
153153
154 @export("__aeabi_lmul", @import("compiler_rt/muldi3.zig").__muldi3, linkage);154 @export(@import("compiler_rt/muldi3.zig").__muldi3, .{ .name = "__aeabi_lmul", .linkage = linkage });
155155
156 @export("__aeabi_ldivmod", __aeabi_ldivmod, linkage);156 @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = linkage });
157 @export("__aeabi_uldivmod", __aeabi_uldivmod, linkage);157 @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = linkage });
158158
159 @export("__aeabi_idiv", __divsi3, linkage);159 @export(__divsi3, .{ .name = "__aeabi_idiv", .linkage = linkage });
160 @export("__aeabi_idivmod", __aeabi_idivmod, linkage);160 @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = linkage });
161 @export("__aeabi_uidiv", __udivsi3, linkage);161 @export(__udivsi3, .{ .name = "__aeabi_uidiv", .linkage = linkage });
162 @export("__aeabi_uidivmod", __aeabi_uidivmod, linkage);162 @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = linkage });
163163
164 @export("__aeabi_memcpy", __aeabi_memcpy, linkage);164 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = linkage });
165 @export("__aeabi_memcpy4", __aeabi_memcpy, linkage);165 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy4", .linkage = linkage });
166 @export("__aeabi_memcpy8", __aeabi_memcpy, linkage);166 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy8", .linkage = linkage });
167167
168 @export("__aeabi_memmove", __aeabi_memmove, linkage);168 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = linkage });
169 @export("__aeabi_memmove4", __aeabi_memmove, linkage);169 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove4", .linkage = linkage });
170 @export("__aeabi_memmove8", __aeabi_memmove, linkage);170 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove8", .linkage = linkage });
171171
172 @export("__aeabi_memset", __aeabi_memset, linkage);172 @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = linkage });
173 @export("__aeabi_memset4", __aeabi_memset, linkage);173 @export(__aeabi_memset, .{ .name = "__aeabi_memset4", .linkage = linkage });
174 @export("__aeabi_memset8", __aeabi_memset, linkage);174 @export(__aeabi_memset, .{ .name = "__aeabi_memset8", .linkage = linkage });
175175
176 @export("__aeabi_memclr", __aeabi_memclr, linkage);176 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = linkage });
177 @export("__aeabi_memclr4", __aeabi_memclr, linkage);177 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage });
178 @export("__aeabi_memclr8", __aeabi_memclr, linkage);178 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage });
179179
180 @export("__aeabi_memcmp", __aeabi_memcmp, linkage);180 @export(__aeabi_memcmp, .{ .name = "__aeabi_memcmp", .linkage = linkage });
181 @export("__aeabi_memcmp4", __aeabi_memcmp, linkage);181 @export(__aeabi_memcmp, .{ .name = "__aeabi_memcmp4", .linkage = linkage });
182 @export("__aeabi_memcmp8", __aeabi_memcmp, linkage);182 @export(__aeabi_memcmp, .{ .name = "__aeabi_memcmp8", .linkage = linkage });
183183
184 @export("__aeabi_f2d", @import("compiler_rt/extendXfYf2.zig").__aeabi_f2d, linkage);184 @export(@import("compiler_rt/extendXfYf2.zig").__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });
185 @export("__aeabi_i2d", @import("compiler_rt/floatsiXf.zig").__aeabi_i2d, linkage);185 @export(@import("compiler_rt/floatsiXf.zig").__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });
186 @export("__aeabi_l2d", @import("compiler_rt/floatdidf.zig").__aeabi_l2d, linkage);186 @export(@import("compiler_rt/floatdidf.zig").__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });
187 @export("__aeabi_ui2d", @import("compiler_rt/floatunsidf.zig").__aeabi_ui2d, linkage);187 @export(@import("compiler_rt/floatunsidf.zig").__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = linkage });
188 @export("__aeabi_ul2d", @import("compiler_rt/floatundidf.zig").__aeabi_ul2d, linkage);188 @export(@import("compiler_rt/floatundidf.zig").__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = linkage });
189 @export("__aeabi_ui2f", @import("compiler_rt/floatunsisf.zig").__aeabi_ui2f, linkage);189 @export(@import("compiler_rt/floatunsisf.zig").__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = linkage });
190 @export("__aeabi_ul2f", @import("compiler_rt/floatundisf.zig").__aeabi_ul2f, linkage);190 @export(@import("compiler_rt/floatundisf.zig").__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = linkage });
191191
192 @export("__aeabi_fneg", @import("compiler_rt/negXf2.zig").__aeabi_fneg, linkage);192 @export(@import("compiler_rt/negXf2.zig").__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = linkage });
193 @export("__aeabi_dneg", @import("compiler_rt/negXf2.zig").__aeabi_dneg, linkage);193 @export(@import("compiler_rt/negXf2.zig").__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = linkage });
194194
195 @export("__aeabi_fmul", @import("compiler_rt/mulXf3.zig").__aeabi_fmul, linkage);195 @export(@import("compiler_rt/mulXf3.zig").__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = linkage });
196 @export("__aeabi_dmul", @import("compiler_rt/mulXf3.zig").__aeabi_dmul, linkage);196 @export(@import("compiler_rt/mulXf3.zig").__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = linkage });
197197
198 @export("__aeabi_d2h", @import("compiler_rt/truncXfYf2.zig").__aeabi_d2h, linkage);198 @export(@import("compiler_rt/truncXfYf2.zig").__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = linkage });
199199
200 @export("__aeabi_f2ulz", @import("compiler_rt/fixunssfdi.zig").__aeabi_f2ulz, linkage);200 @export(@import("compiler_rt/fixunssfdi.zig").__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = linkage });
201 @export("__aeabi_d2ulz", @import("compiler_rt/fixunsdfdi.zig").__aeabi_d2ulz, linkage);201 @export(@import("compiler_rt/fixunsdfdi.zig").__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = linkage });
202202
203 @export("__aeabi_f2lz", @import("compiler_rt/fixsfdi.zig").__aeabi_f2lz, linkage);203 @export(@import("compiler_rt/fixsfdi.zig").__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = linkage });
204 @export("__aeabi_d2lz", @import("compiler_rt/fixdfdi.zig").__aeabi_d2lz, linkage);204 @export(@import("compiler_rt/fixdfdi.zig").__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = linkage });
205205
206 @export("__aeabi_d2uiz", @import("compiler_rt/fixunsdfsi.zig").__aeabi_d2uiz, linkage);206 @export(@import("compiler_rt/fixunsdfsi.zig").__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = linkage });
207207
208 @export("__aeabi_h2f", @import("compiler_rt/extendXfYf2.zig").__aeabi_h2f, linkage);208 @export(@import("compiler_rt/extendXfYf2.zig").__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = linkage });
209 @export("__aeabi_f2h", @import("compiler_rt/truncXfYf2.zig").__aeabi_f2h, linkage);209 @export(@import("compiler_rt/truncXfYf2.zig").__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = linkage });
210210
211 @export("__aeabi_i2f", @import("compiler_rt/floatsiXf.zig").__aeabi_i2f, linkage);211 @export(@import("compiler_rt/floatsiXf.zig").__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = linkage });
212 @export("__aeabi_d2f", @import("compiler_rt/truncXfYf2.zig").__aeabi_d2f, linkage);212 @export(@import("compiler_rt/truncXfYf2.zig").__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = linkage });
213213
214 @export("__aeabi_fadd", @import("compiler_rt/addXf3.zig").__aeabi_fadd, linkage);214 @export(@import("compiler_rt/addXf3.zig").__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = linkage });
215 @export("__aeabi_dadd", @import("compiler_rt/addXf3.zig").__aeabi_dadd, linkage);215 @export(@import("compiler_rt/addXf3.zig").__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = linkage });
216 @export("__aeabi_fsub", @import("compiler_rt/addXf3.zig").__aeabi_fsub, linkage);216 @export(@import("compiler_rt/addXf3.zig").__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = linkage });
217 @export("__aeabi_dsub", @import("compiler_rt/addXf3.zig").__aeabi_dsub, linkage);217 @export(@import("compiler_rt/addXf3.zig").__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = linkage });
218218
219 @export("__aeabi_f2uiz", @import("compiler_rt/fixunssfsi.zig").__aeabi_f2uiz, linkage);219 @export(@import("compiler_rt/fixunssfsi.zig").__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = linkage });
220220
221 @export("__aeabi_f2iz", @import("compiler_rt/fixsfsi.zig").__aeabi_f2iz, linkage);221 @export(@import("compiler_rt/fixsfsi.zig").__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = linkage });
222 @export("__aeabi_d2iz", @import("compiler_rt/fixdfsi.zig").__aeabi_d2iz, linkage);222 @export(@import("compiler_rt/fixdfsi.zig").__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = linkage });
223223
224 @export("__aeabi_fdiv", @import("compiler_rt/divsf3.zig").__aeabi_fdiv, linkage);224 @export(@import("compiler_rt/divsf3.zig").__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = linkage });
225 @export("__aeabi_ddiv", @import("compiler_rt/divdf3.zig").__aeabi_ddiv, linkage);225 @export(@import("compiler_rt/divdf3.zig").__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = linkage });
226226
227 @export("__aeabi_fcmpeq", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpeq, linkage);227 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = linkage });
228 @export("__aeabi_fcmplt", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmplt, linkage);228 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = linkage });
229 @export("__aeabi_fcmple", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmple, linkage);229 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = linkage });
230 @export("__aeabi_fcmpge", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpge, linkage);230 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = linkage });
231 @export("__aeabi_fcmpgt", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpgt, linkage);231 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = linkage });
232 @export("__aeabi_fcmpun", @import("compiler_rt/comparesf2.zig").__aeabi_fcmpun, linkage);232 @export(@import("compiler_rt/comparesf2.zig").__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = linkage });
233233
234 @export("__aeabi_dcmpeq", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpeq, linkage);234 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = linkage });
235 @export("__aeabi_dcmplt", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmplt, linkage);235 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = linkage });
236 @export("__aeabi_dcmple", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmple, linkage);236 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = linkage });
237 @export("__aeabi_dcmpge", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpge, linkage);237 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = linkage });
238 @export("__aeabi_dcmpgt", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpgt, linkage);238 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = linkage });
239 @export("__aeabi_dcmpun", @import("compiler_rt/comparedf2.zig").__aeabi_dcmpun, linkage);239 @export(@import("compiler_rt/comparedf2.zig").__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage });
240 }240 }
241 if (builtin.os == .windows) {241 if (builtin.os == .windows) {
242 // Default stack-probe functions emitted by LLVM242 // Default stack-probe functions emitted by LLVM
243 if (is_mingw) {243 if (is_mingw) {
244 @export("_alloca", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage);244 @export(@import("compiler_rt/stack_probe.zig")._chkstk, .{ .name = "_alloca", .linkage = strong_linkage });
245 @export("___chkstk_ms", @import("compiler_rt/stack_probe.zig").___chkstk_ms, strong_linkage);245 @export(@import("compiler_rt/stack_probe.zig").___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = strong_linkage });
246 } else if (!builtin.link_libc) {246 } else if (!builtin.link_libc) {
247 // This symbols are otherwise exported by MSVCRT.lib247 // This symbols are otherwise exported by MSVCRT.lib
248 @export("_chkstk", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage);248 @export(@import("compiler_rt/stack_probe.zig")._chkstk, .{ .name = "_chkstk", .linkage = strong_linkage });
249 @export("__chkstk", @import("compiler_rt/stack_probe.zig").__chkstk, strong_linkage);249 @export(@import("compiler_rt/stack_probe.zig").__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage });
250 }250 }
251251
252 if (is_mingw) {252 if (is_mingw) {
253 @export("__stack_chk_fail", __stack_chk_fail, strong_linkage);253 @export(__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = strong_linkage });
254 @export("__stack_chk_guard", __stack_chk_guard, strong_linkage);254 @export(__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = strong_linkage });
255 }255 }
256256
257 switch (builtin.arch) {257 switch (builtin.arch) {
258 .i386 => {258 .i386 => {
259 // Don't let LLVM apply the stdcall name mangling on those MSVC259 // Don't let LLVM apply the stdcall name mangling on those MSVC
260 // builtin functions260 // builtin functions
261 @export("\x01__alldiv", @import("compiler_rt/aulldiv.zig")._alldiv, strong_linkage);261 @export(@import("compiler_rt/aulldiv.zig")._alldiv, .{ .name = "\x01__alldiv", .linkage = strong_linkage });
262 @export("\x01__aulldiv", @import("compiler_rt/aulldiv.zig")._aulldiv, strong_linkage);262 @export(@import("compiler_rt/aulldiv.zig")._aulldiv, .{ .name = "\x01__aulldiv", .linkage = strong_linkage });
263 @export("\x01__allrem", @import("compiler_rt/aullrem.zig")._allrem, strong_linkage);263 @export(@import("compiler_rt/aullrem.zig")._allrem, .{ .name = "\x01__allrem", .linkage = strong_linkage });
264 @export("\x01__aullrem", @import("compiler_rt/aullrem.zig")._aullrem, strong_linkage);264 @export(@import("compiler_rt/aullrem.zig")._aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage });
265265
266 @export("__divti3", @import("compiler_rt/divti3.zig").__divti3, linkage);266 @export(@import("compiler_rt/divti3.zig").__divti3, .{ .name = "__divti3", .linkage = linkage });
267 @export("__modti3", @import("compiler_rt/modti3.zig").__modti3, linkage);267 @export(@import("compiler_rt/modti3.zig").__modti3, .{ .name = "__modti3", .linkage = linkage });
268 @export("__multi3", @import("compiler_rt/multi3.zig").__multi3, linkage);268 @export(@import("compiler_rt/multi3.zig").__multi3, .{ .name = "__multi3", .linkage = linkage });
269 @export("__udivti3", @import("compiler_rt/udivti3.zig").__udivti3, linkage);269 @export(@import("compiler_rt/udivti3.zig").__udivti3, .{ .name = "__udivti3", .linkage = linkage });
270 @export("__udivmodti4", @import("compiler_rt/udivmodti4.zig").__udivmodti4, linkage);270 @export(@import("compiler_rt/udivmodti4.zig").__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage });
271 @export("__umodti3", @import("compiler_rt/umodti3.zig").__umodti3, linkage);271 @export(@import("compiler_rt/umodti3.zig").__umodti3, .{ .name = "__umodti3", .linkage = linkage });
272 },272 },
273 .x86_64 => {273 .x86_64 => {
274 // The "ti" functions must use @Vector(2, u64) parameter types to adhere to the ABI274 // The "ti" functions must use @Vector(2, u64) parameter types to adhere to the ABI
275 // that LLVM expects compiler-rt to have.275 // that LLVM expects compiler-rt to have.
276 @export("__divti3", @import("compiler_rt/divti3.zig").__divti3_windows_x86_64, linkage);276 @export(@import("compiler_rt/divti3.zig").__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = linkage });
277 @export("__modti3", @import("compiler_rt/modti3.zig").__modti3_windows_x86_64, linkage);277 @export(@import("compiler_rt/modti3.zig").__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = linkage });
278 @export("__multi3", @import("compiler_rt/multi3.zig").__multi3_windows_x86_64, linkage);278 @export(@import("compiler_rt/multi3.zig").__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = linkage });
279 @export("__udivti3", @import("compiler_rt/udivti3.zig").__udivti3_windows_x86_64, linkage);279 @export(@import("compiler_rt/udivti3.zig").__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = linkage });
280 @export("__udivmodti4", @import("compiler_rt/udivmodti4.zig").__udivmodti4_windows_x86_64, linkage);280 @export(@import("compiler_rt/udivmodti4.zig").__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = linkage });
281 @export("__umodti3", @import("compiler_rt/umodti3.zig").__umodti3_windows_x86_64, linkage);281 @export(@import("compiler_rt/umodti3.zig").__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = linkage });
282 },282 },
283 else => {},283 else => {},
284 }284 }
285 } else {285 } else {
286 if (builtin.glibc_version != null) {286 if (builtin.glibc_version != null) {
287 @export("__stack_chk_guard", __stack_chk_guard, linkage);287 @export(__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = linkage });
288 }288 }
289 @export("__divti3", @import("compiler_rt/divti3.zig").__divti3, linkage);289 @export(@import("compiler_rt/divti3.zig").__divti3, .{ .name = "__divti3", .linkage = linkage });
290 @export("__modti3", @import("compiler_rt/modti3.zig").__modti3, linkage);290 @export(@import("compiler_rt/modti3.zig").__modti3, .{ .name = "__modti3", .linkage = linkage });
291 @export("__multi3", @import("compiler_rt/multi3.zig").__multi3, linkage);291 @export(@import("compiler_rt/multi3.zig").__multi3, .{ .name = "__multi3", .linkage = linkage });
292 @export("__udivti3", @import("compiler_rt/udivti3.zig").__udivti3, linkage);292 @export(@import("compiler_rt/udivti3.zig").__udivti3, .{ .name = "__udivti3", .linkage = linkage });
293 @export("__udivmodti4", @import("compiler_rt/udivmodti4.zig").__udivmodti4, linkage);293 @export(@import("compiler_rt/udivmodti4.zig").__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage });
294 @export("__umodti3", @import("compiler_rt/umodti3.zig").__umodti3, linkage);294 @export(@import("compiler_rt/umodti3.zig").__umodti3, .{ .name = "__umodti3", .linkage = linkage });
295 }295 }
296 @export("__muloti4", @import("compiler_rt/muloti4.zig").__muloti4, linkage);296 @export(@import("compiler_rt/muloti4.zig").__muloti4, .{ .name = "__muloti4", .linkage = linkage });
297 @export("__mulodi4", @import("compiler_rt/mulodi4.zig").__mulodi4, linkage);297 @export(@import("compiler_rt/mulodi4.zig").__mulodi4, .{ .name = "__mulodi4", .linkage = linkage });
298}298}
299299
300const std = @import("std");300const std = @import("std");
lib/std/start.zig+6-6
...@@ -22,23 +22,23 @@ const start_sym_name = if (is_mips) "__start" else "_start";...@@ -22,23 +22,23 @@ const start_sym_name = if (is_mips) "__start" else "_start";
22comptime {22comptime {
23 if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) {23 if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) {
24 if (builtin.os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {24 if (builtin.os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {
25 @export("_DllMainCRTStartup", _DllMainCRTStartup, .Strong);25 @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });
26 }26 }
27 } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {27 } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
28 if (builtin.link_libc and @hasDecl(root, "main")) {28 if (builtin.link_libc and @hasDecl(root, "main")) {
29 if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {29 if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
30 @export("main", main, .Weak);30 @export(main, .{ .name = "main", .linkage = .Weak });
31 }31 }
32 } else if (builtin.os == .windows) {32 } else if (builtin.os == .windows) {
33 if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup")) {33 if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup")) {
34 @export("WinMainCRTStartup", WinMainCRTStartup, .Strong);34 @export(WinMainCRTStartup, .{ .name = "WinMainCRTStartup" });
35 }35 }
36 } else if (builtin.os == .uefi) {36 } else if (builtin.os == .uefi) {
37 if (!@hasDecl(root, "EfiMain")) @export("EfiMain", EfiMain, .Strong);37 if (!@hasDecl(root, "EfiMain")) @export(EfiMain, .{ .name = "EfiMain" });
38 } else if (is_wasm and builtin.os == .freestanding) {38 } else if (is_wasm and builtin.os == .freestanding) {
39 if (!@hasDecl(root, start_sym_name)) @export(start_sym_name, wasm_freestanding_start, .Strong);39 if (!@hasDecl(root, start_sym_name)) @export(wasm_freestanding_start, .{ .name = start_sym_name });
40 } else if (builtin.os != .other and builtin.os != .freestanding) {40 } else if (builtin.os != .other and builtin.os != .freestanding) {
41 if (!@hasDecl(root, start_sym_name)) @export(start_sym_name, _start, .Strong);41 if (!@hasDecl(root, start_sym_name)) @export(_start, .{ .name = start_sym_name });
42 }42 }
43 }43 }
44}44}
src/all_types.hpp+3-3
...@@ -526,7 +526,6 @@ struct TldVar {...@@ -526,7 +526,6 @@ struct TldVar {
526526
527 ZigVar *var;527 ZigVar *var;
528 Buf *extern_lib_name;528 Buf *extern_lib_name;
529 Buf *section_name;
530 bool analyzing_type; // flag to detect dependency loops529 bool analyzing_type; // flag to detect dependency loops
531};530};
532531
...@@ -2231,6 +2230,8 @@ struct ZigVar {...@@ -2231,6 +2230,8 @@ struct ZigVar {
2231 size_t mem_slot_index;2230 size_t mem_slot_index;
2232 IrExecutable *owner_exec;2231 IrExecutable *owner_exec;
22332232
2233 Buf *section_name;
2234
2234 // In an inline loop, multiple variables may be created,2235 // In an inline loop, multiple variables may be created,
2235 // In this case, a reference to a variable should follow2236 // In this case, a reference to a variable should follow
2236 // this pointer to the redefined variable.2237 // this pointer to the redefined variable.
...@@ -3785,9 +3786,8 @@ struct IrInstructionArgType {...@@ -3785,9 +3786,8 @@ struct IrInstructionArgType {
3785struct IrInstructionExport {3786struct IrInstructionExport {
3786 IrInstruction base;3787 IrInstruction base;
37873788
3788 IrInstruction *name;
3789 IrInstruction *linkage;
3790 IrInstruction *target;3789 IrInstruction *target;
3790 IrInstruction *options;
3791};3791};
37923792
3793struct IrInstructionErrorReturnTrace {3793struct IrInstructionErrorReturnTrace {
src/analyze.cpp+2-2
...@@ -3955,8 +3955,8 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {...@@ -3955,8 +3955,8 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
3955 }3955 }
39563956
3957 if (var_decl->section_expr != nullptr) {3957 if (var_decl->section_expr != nullptr) {
3958 if (!analyze_const_string(g, tld_var->base.parent_scope, var_decl->section_expr, &tld_var->section_name)) {3958 if (!analyze_const_string(g, tld_var->base.parent_scope, var_decl->section_expr, &tld_var->var->section_name)) {
3959 tld_var->section_name = nullptr;3959 tld_var->var->section_name = nullptr;
3960 }3960 }
3961 }3961 }
39623962
src/codegen.cpp+3-3
...@@ -7538,8 +7538,8 @@ static void do_code_gen(CodeGen *g) {...@@ -7538,8 +7538,8 @@ static void do_code_gen(CodeGen *g) {
7538 LLVMSetLinkage(global_value, to_llvm_linkage(linkage));7538 LLVMSetLinkage(global_value, to_llvm_linkage(linkage));
7539 maybe_export_dll(g, global_value, GlobalLinkageIdStrong);7539 maybe_export_dll(g, global_value, GlobalLinkageIdStrong);
7540 }7540 }
7541 if (tld_var->section_name) {7541 if (var->section_name) {
7542 LLVMSetSection(global_value, buf_ptr(tld_var->section_name));7542 LLVMSetSection(global_value, buf_ptr(var->section_name));
7543 }7543 }
7544 LLVMSetAlignment(global_value, var->align_bytes);7544 LLVMSetAlignment(global_value, var->align_bytes);
75457545
...@@ -8264,7 +8264,7 @@ static void define_builtin_fns(CodeGen *g) {...@@ -8264,7 +8264,7 @@ static void define_builtin_fns(CodeGen *g) {
8264 create_builtin_fn(g, BuiltinFnIdOpaqueType, "OpaqueType", 0);8264 create_builtin_fn(g, BuiltinFnIdOpaqueType, "OpaqueType", 0);
8265 create_builtin_fn(g, BuiltinFnIdSetAlignStack, "setAlignStack", 1);8265 create_builtin_fn(g, BuiltinFnIdSetAlignStack, "setAlignStack", 1);
8266 create_builtin_fn(g, BuiltinFnIdArgType, "ArgType", 2);8266 create_builtin_fn(g, BuiltinFnIdArgType, "ArgType", 2);
8267 create_builtin_fn(g, BuiltinFnIdExport, "export", 3);8267 create_builtin_fn(g, BuiltinFnIdExport, "export", 2);
8268 create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0);8268 create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0);
8269 create_builtin_fn(g, BuiltinFnIdAtomicRmw, "atomicRmw", 5);8269 create_builtin_fn(g, BuiltinFnIdAtomicRmw, "atomicRmw", 5);
8270 create_builtin_fn(g, BuiltinFnIdAtomicLoad, "atomicLoad", 3);8270 create_builtin_fn(g, BuiltinFnIdAtomicLoad, "atomicLoad", 3);
src/ir.cpp+73-34
...@@ -2227,19 +2227,17 @@ static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *sourc...@@ -2227,19 +2227,17 @@ static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *sourc
2227}2227}
22282228
2229static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *source_node,2229static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *source_node,
2230 IrInstruction *name, IrInstruction *target, IrInstruction *linkage)2230 IrInstruction *target, IrInstruction *options)
2231{2231{
2232 IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>(2232 IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>(
2233 irb, scope, source_node);2233 irb, scope, source_node);
2234 export_instruction->base.value->special = ConstValSpecialStatic;2234 export_instruction->base.value->special = ConstValSpecialStatic;
2235 export_instruction->base.value->type = irb->codegen->builtin_types.entry_void;2235 export_instruction->base.value->type = irb->codegen->builtin_types.entry_void;
2236 export_instruction->name = name;
2237 export_instruction->target = target;2236 export_instruction->target = target;
2238 export_instruction->linkage = linkage;2237 export_instruction->options = options;
22392238
2240 ir_ref_instruction(name, irb->current_basic_block);
2241 ir_ref_instruction(target, irb->current_basic_block);2239 ir_ref_instruction(target, irb->current_basic_block);
2242 if (linkage) ir_ref_instruction(linkage, irb->current_basic_block);2240 ir_ref_instruction(options, irb->current_basic_block);
22432241
2244 return &export_instruction->base;2242 return &export_instruction->base;
2245}2243}
...@@ -6272,22 +6270,26 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo...@@ -6272,22 +6270,26 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
6272 }6270 }
6273 case BuiltinFnIdExport:6271 case BuiltinFnIdExport:
6274 {6272 {
6275 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);6273 // Cast the options parameter to the options type
6276 IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope);6274 ZigType *options_type = get_builtin_type(irb->codegen, "ExportOptions");
6277 if (arg0_value == irb->codegen->invalid_instruction)6275 IrInstruction *options_type_inst = ir_build_const_type(irb, scope, node, options_type);
6278 return arg0_value;6276 ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc());
62796277
6280 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);6278 AstNode *target_node = node->data.fn_call_expr.params.at(0);
6281 IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope);6279 IrInstruction *target_value = ir_gen_node(irb, target_node, scope);
6282 if (arg1_value == irb->codegen->invalid_instruction)6280 if (target_value == irb->codegen->invalid_instruction)
6283 return arg1_value;6281 return target_value;
62846282
6285 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);6283 AstNode *options_node = node->data.fn_call_expr.params.at(1);
6286 IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope);6284 IrInstruction *options_value = ir_gen_node_extra(irb, options_node,
6287 if (arg2_value == irb->codegen->invalid_instruction)6285 scope, LValNone, &result_loc_cast->base);
6288 return arg2_value;6286 if (options_value == irb->codegen->invalid_instruction)
62896287 return options_value;
6290 IrInstruction *ir_export = ir_build_export(irb, scope, node, arg0_value, arg1_value, arg2_value);6288
6289 IrInstruction *casted_options_value = ir_build_implicit_cast(
6290 irb, scope, options_node, options_value, result_loc_cast);
6291
6292 IrInstruction *ir_export = ir_build_export(irb, scope, node, target_value, casted_options_value);
6291 return ir_lval_wrap(irb, scope, ir_export, lval, result_loc);6293 return ir_lval_wrap(irb, scope, ir_export, lval, result_loc);
6292 }6294 }
6293 case BuiltinFnIdErrorReturnTrace:6295 case BuiltinFnIdErrorReturnTrace:
...@@ -16683,27 +16685,61 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,...@@ -16683,27 +16685,61 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
16683}16685}
1668416686
16685static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExport *instruction) {16687static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExport *instruction) {
16686 Error err;16688 IrInstruction *target = instruction->target->child;
16689 if (type_is_invalid(target->value->type))
16690 return ira->codegen->invalid_instruction;
1668716691
16688 IrInstruction *name = instruction->name->child;16692 IrInstruction *options = instruction->options->child;
16689 Buf *symbol_name = ir_resolve_str(ira, name);16693 if (type_is_invalid(options->value->type))
16690 if (symbol_name == nullptr) {
16691 return ira->codegen->invalid_instruction;16694 return ira->codegen->invalid_instruction;
16692 }
1669316695
16694 IrInstruction *target = instruction->target->child;16696 ZigType *options_type = options->value->type;
16695 if (type_is_invalid(target->value->type)) {16697 assert(options_type->id == ZigTypeIdStruct);
16698
16699 TypeStructField *name_field = find_struct_type_field(options_type, buf_create_from_str("name"));
16700 ir_assert(name_field != nullptr, &instruction->base);
16701 IrInstruction *name_inst = ir_analyze_struct_value_field_value(ira, &instruction->base, options, name_field);
16702 if (type_is_invalid(name_inst->value->type))
16703 return ira->codegen->invalid_instruction;
16704
16705 TypeStructField *linkage_field = find_struct_type_field(options_type, buf_create_from_str("linkage"));
16706 ir_assert(linkage_field != nullptr, &instruction->base);
16707 IrInstruction *linkage_inst = ir_analyze_struct_value_field_value(ira, &instruction->base, options, linkage_field);
16708 if (type_is_invalid(linkage_inst->value->type))
16709 return ira->codegen->invalid_instruction;
16710
16711 TypeStructField *section_field = find_struct_type_field(options_type, buf_create_from_str("section"));
16712 ir_assert(section_field != nullptr, &instruction->base);
16713 IrInstruction *section_inst = ir_analyze_struct_value_field_value(ira, &instruction->base, options, section_field);
16714 if (type_is_invalid(section_inst->value->type))
16696 return ira->codegen->invalid_instruction;16715 return ira->codegen->invalid_instruction;
16697 }
1669816716
16699 GlobalLinkageId global_linkage_id = GlobalLinkageIdStrong;16717 // The `section` field is optional, we have to unwrap it first
16700 if (instruction->linkage != nullptr) {16718 IrInstruction *non_null_check = ir_analyze_test_non_null(ira, &instruction->base, section_inst);
16701 IrInstruction *linkage_value = instruction->linkage->child;16719 bool is_non_null;
16702 if (!ir_resolve_global_linkage(ira, linkage_value, &global_linkage_id)) {16720 if (!ir_resolve_bool(ira, non_null_check, &is_non_null))
16721 return ira->codegen->invalid_instruction;
16722
16723 IrInstruction *section_str_inst = nullptr;
16724 if (is_non_null) {
16725 section_str_inst = ir_analyze_optional_value_payload_value(ira, &instruction->base, section_inst, false);
16726 if (type_is_invalid(section_str_inst->value->type))
16703 return ira->codegen->invalid_instruction;16727 return ira->codegen->invalid_instruction;
16704 }
16705 }16728 }
1670616729
16730 // Resolve all the comptime values
16731 Buf *symbol_name = ir_resolve_str(ira, name_inst);
16732 if (!symbol_name)
16733 return ira->codegen->invalid_instruction;
16734
16735 GlobalLinkageId global_linkage_id;
16736 if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id))
16737 return ira->codegen->invalid_instruction;
16738
16739 Buf *section_name = nullptr;
16740 if (section_str_inst != nullptr && !(section_name = ir_resolve_str(ira, section_str_inst)))
16741 return ira->codegen->invalid_instruction;
16742
16707 // TODO: This function needs to be audited.16743 // TODO: This function needs to be audited.
16708 // It's not clear how all the different types are supposed to be handled.16744 // It's not clear how all the different types are supposed to be handled.
16709 // Need comprehensive tests for exporting one thing in one file and declaring an extern var16745 // Need comprehensive tests for exporting one thing in one file and declaring an extern var
...@@ -16721,6 +16757,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio...@@ -16721,6 +16757,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
16721 return ira->codegen->invalid_instruction;16757 return ira->codegen->invalid_instruction;
16722 }16758 }
1672316759
16760 Error err;
16724 bool want_var_export = false;16761 bool want_var_export = false;
16725 switch (target->value->type->id) {16762 switch (target->value->type->id) {
16726 case ZigTypeIdInvalid:16763 case ZigTypeIdInvalid:
...@@ -16755,6 +16792,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio...@@ -16755,6 +16792,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
16755 case CallingConventionAAPCS:16792 case CallingConventionAAPCS:
16756 case CallingConventionAAPCSVFP:16793 case CallingConventionAAPCSVFP:
16757 add_fn_export(ira->codegen, fn_entry, buf_ptr(symbol_name), global_linkage_id, cc);16794 add_fn_export(ira->codegen, fn_entry, buf_ptr(symbol_name), global_linkage_id, cc);
16795 fn_entry->section_name = section_name;
16758 break;16796 break;
16759 }16797 }
16760 } break;16798 } break;
...@@ -16896,6 +16934,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio...@@ -16896,6 +16934,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
16896 IrInstructionVarPtr *var_ptr = reinterpret_cast<IrInstructionVarPtr *>(load_ptr->ptr);16934 IrInstructionVarPtr *var_ptr = reinterpret_cast<IrInstructionVarPtr *>(load_ptr->ptr);
16897 ZigVar *var = var_ptr->var;16935 ZigVar *var = var_ptr->var;
16898 add_var_export(ira->codegen, var, buf_ptr(symbol_name), global_linkage_id);16936 add_var_export(ira->codegen, var, buf_ptr(symbol_name), global_linkage_id);
16937 var->section_name = section_name;
16899 }16938 }
16900 }16939 }
1690116940
src/ir_print.cpp+5-15
...@@ -1893,21 +1893,11 @@ static void ir_print_enum_tag_type(IrPrint *irp, IrInstructionTagType *instructi...@@ -1893,21 +1893,11 @@ static void ir_print_enum_tag_type(IrPrint *irp, IrInstructionTagType *instructi
1893}1893}
18941894
1895static void ir_print_export(IrPrint *irp, IrInstructionExport *instruction) {1895static void ir_print_export(IrPrint *irp, IrInstructionExport *instruction) {
1896 if (instruction->linkage == nullptr) {1896 fprintf(irp->f, "@export(");
1897 fprintf(irp->f, "@export(");1897 ir_print_other_instruction(irp, instruction->target);
1898 ir_print_other_instruction(irp, instruction->name);1898 fprintf(irp->f, ",");
1899 fprintf(irp->f, ",");1899 ir_print_other_instruction(irp, instruction->options);
1900 ir_print_other_instruction(irp, instruction->target);1900 fprintf(irp->f, ")");
1901 fprintf(irp->f, ")");
1902 } else {
1903 fprintf(irp->f, "@exportWithLinkage(");
1904 ir_print_other_instruction(irp, instruction->name);
1905 fprintf(irp->f, ",");
1906 ir_print_other_instruction(irp, instruction->target);
1907 fprintf(irp->f, ",");
1908 ir_print_other_instruction(irp, instruction->linkage);
1909 fprintf(irp->f, ")");
1910 }
1911}1901}
19121902
1913static void ir_print_error_return_trace(IrPrint *irp, IrInstructionErrorReturnTrace *instruction) {1903static void ir_print_error_return_trace(IrPrint *irp, IrInstructionErrorReturnTrace *instruction) {
test/compile_errors.zig+2-2
...@@ -5650,10 +5650,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -5650,10 +5650,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
5650 cases.add("wrong types given to @export",5650 cases.add("wrong types given to @export",
5651 \\fn entry() callconv(.C) void { }5651 \\fn entry() callconv(.C) void { }
5652 \\comptime {5652 \\comptime {
5653 \\ @export("entry", entry, @as(u32, 1234));5653 \\ @export(entry, .{.name = "entry", .linkage = @as(u32, 1234) });
5654 \\}5654 \\}
5655 , &[_][]const u8{5655 , &[_][]const u8{
5656 "tmp.zig:3:29: error: expected type 'std.builtin.GlobalLinkage', found 'u32'",5656 "tmp.zig:3:50: error: expected type 'std.builtin.GlobalLinkage', found 'u32'",
5657 });5657 });
56585658
5659 cases.add("struct with invalid field",5659 cases.add("struct with invalid field",
test/stage1/behavior/misc.zig+1-1
...@@ -16,7 +16,7 @@ test "empty function with comments" {...@@ -16,7 +16,7 @@ test "empty function with comments" {
16}16}
1717
18comptime {18comptime {
19 @export("disabledExternFn", disabledExternFn, builtin.GlobalLinkage.Internal);19 @export(disabledExternFn, .{ .name = "disabledExternFn", .linkage = .Internal });
20}20}
2121
22fn disabledExternFn() callconv(.C) void {}22fn disabledExternFn() callconv(.C) void {}