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" {
73277327 {#header_close#}
73287328
73297329 {#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>
73317331 <p>
73327332 Creates a symbol in the output object file.
73337333 </p>
73347334 <p>
73357335 This function can be called from a {#link|comptime#} block to conditionally export symbols.
73367336 When {#syntax#}target{#endsyntax#} is a function with the C calling convention and
7337 {#syntax#}linkage{#endsyntax#} is {#syntax#}Strong{#endsyntax#}, this is equivalent to
7337 {#syntax#}options.linkage{#endsyntax#} is {#syntax#}Strong{#endsyntax#}, this is equivalent to
73387338 the {#syntax#}export{#endsyntax#} keyword used on a function:
73397339 </p>
73407340 {#code_begin|obj#}
73417341const builtin = @import("builtin");
73427342
73437343comptime {
7344 @export("foo", internalName, builtin.GlobalLinkage.Strong);
7344 @export(internalName, .{ .name = "foo", .linkage = .Strong });
73457345}
73467346
73477347extern fn internalName() void {}
lib/std/builtin.zig+8
......@@ -419,6 +419,14 @@ pub const CallOptions = struct {
419419 };
420420};
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
422430/// This function type is used by the Zig language code generation and
423431/// therefore must be kept in sync with the compiler implementation.
424432pub 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;
3737pub extern "c" var _mh_execute_header: mach_hdr = undefined;
3838comptime {
3939 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 });
4141 }
4242}
4343
lib/std/special/c.zig+9-9
......@@ -23,17 +23,17 @@ const is_freestanding = switch (builtin.os) {
2323};
2424comptime {
2525 if (is_freestanding and is_wasm and builtin.link_libc) {
26 @export("_start", wasm_start, .Strong);
26 @export(wasm_start, .{ .name = "_start", .linkage = .Strong });
2727 }
2828 if (builtin.link_libc) {
29 @export("strcmp", strcmp, .Strong);
30 @export("strncmp", strncmp, .Strong);
31 @export("strerror", strerror, .Strong);
32 @export("strlen", strlen, .Strong);
29 @export(strcmp, .{ .name = "strcmp", .linkage = .Strong });
30 @export(strncmp, .{ .name = "strncmp", .linkage = .Strong });
31 @export(strerror, .{ .name = "strerror", .linkage = .Strong });
32 @export(strlen, .{ .name = "strlen", .linkage = .Strong });
3333 } else if (is_msvc) {
34 @export("_fltused", _fltused, .Strong);
34 @export(_fltused, .{ .name = "_fltused", .linkage = .Strong });
3535 } 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 });
3737 }
3838}
3939
......@@ -182,10 +182,10 @@ comptime {
182182 builtin.mode != builtin.Mode.ReleaseSmall and
183183 builtin.os != builtin.Os.windows)
184184 {
185 @export("__stack_chk_fail", __stack_chk_fail, builtin.GlobalLinkage.Strong);
185 @export(__stack_chk_fail, .{ .name = "__stack_chk_fail" });
186186 }
187187 if (builtin.os == builtin.Os.linux) {
188 @export("clone", clone, builtin.GlobalLinkage.Strong);
188 @export(clone, .{ .name = "clone" });
189189 }
190190}
191191fn __stack_chk_fail() callconv(.C) noreturn {
lib/std/special/compiler_rt.zig+219-219
......@@ -12,289 +12,289 @@ comptime {
1212 const strong_linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Strong;
1313
1414 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 }),
1616 else => {},
1717 }
1818
19 @export("__lesf2", @import("compiler_rt/comparesf2.zig").__lesf2, linkage);
20 @export("__ledf2", @import("compiler_rt/comparedf2.zig").__ledf2, linkage);
21 @export("__letf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);
19 @export(@import("compiler_rt/comparesf2.zig").__lesf2, .{ .name = "__lesf2", .linkage = linkage });
20 @export(@import("compiler_rt/comparedf2.zig").__ledf2, .{ .name = "__ledf2", .linkage = linkage });
21 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__letf2", .linkage = linkage });
2222
23 @export("__gesf2", @import("compiler_rt/comparesf2.zig").__gesf2, linkage);
24 @export("__gedf2", @import("compiler_rt/comparedf2.zig").__gedf2, linkage);
25 @export("__getf2", @import("compiler_rt/comparetf2.zig").__getf2, linkage);
23 @export(@import("compiler_rt/comparesf2.zig").__gesf2, .{ .name = "__gesf2", .linkage = linkage });
24 @export(@import("compiler_rt/comparedf2.zig").__gedf2, .{ .name = "__gedf2", .linkage = linkage });
25 @export(@import("compiler_rt/comparetf2.zig").__getf2, .{ .name = "__getf2", .linkage = linkage });
2626
2727 if (!is_test) {
28 @export("__cmpsf2", @import("compiler_rt/comparesf2.zig").__lesf2, linkage);
29 @export("__cmpdf2", @import("compiler_rt/comparedf2.zig").__ledf2, linkage);
30 @export("__cmptf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);
28 @export(@import("compiler_rt/comparesf2.zig").__lesf2, .{ .name = "__cmpsf2", .linkage = linkage });
29 @export(@import("compiler_rt/comparedf2.zig").__ledf2, .{ .name = "__cmpdf2", .linkage = linkage });
30 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__cmptf2", .linkage = linkage });
3131
32 @export("__eqsf2", @import("compiler_rt/comparesf2.zig").__eqsf2, linkage);
33 @export("__eqdf2", @import("compiler_rt/comparedf2.zig").__eqdf2, linkage);
34 @export("__eqtf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);
32 @export(@import("compiler_rt/comparesf2.zig").__eqsf2, .{ .name = "__eqsf2", .linkage = linkage });
33 @export(@import("compiler_rt/comparedf2.zig").__eqdf2, .{ .name = "__eqdf2", .linkage = linkage });
34 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__eqtf2", .linkage = linkage });
3535
36 @export("__ltsf2", @import("compiler_rt/comparesf2.zig").__ltsf2, linkage);
37 @export("__ltdf2", @import("compiler_rt/comparedf2.zig").__ltdf2, linkage);
38 @export("__lttf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);
36 @export(@import("compiler_rt/comparesf2.zig").__ltsf2, .{ .name = "__ltsf2", .linkage = linkage });
37 @export(@import("compiler_rt/comparedf2.zig").__ltdf2, .{ .name = "__ltdf2", .linkage = linkage });
38 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__lttf2", .linkage = linkage });
3939
40 @export("__nesf2", @import("compiler_rt/comparesf2.zig").__nesf2, linkage);
41 @export("__nedf2", @import("compiler_rt/comparedf2.zig").__nedf2, linkage);
42 @export("__netf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);
40 @export(@import("compiler_rt/comparesf2.zig").__nesf2, .{ .name = "__nesf2", .linkage = linkage });
41 @export(@import("compiler_rt/comparedf2.zig").__nedf2, .{ .name = "__nedf2", .linkage = linkage });
42 @export(@import("compiler_rt/comparetf2.zig").__letf2, .{ .name = "__netf2", .linkage = linkage });
4343
44 @export("__gtsf2", @import("compiler_rt/comparesf2.zig").__gtsf2, linkage);
45 @export("__gtdf2", @import("compiler_rt/comparedf2.zig").__gtdf2, linkage);
46 @export("__gttf2", @import("compiler_rt/comparetf2.zig").__getf2, linkage);
44 @export(@import("compiler_rt/comparesf2.zig").__gtsf2, .{ .name = "__gtsf2", .linkage = linkage });
45 @export(@import("compiler_rt/comparedf2.zig").__gtdf2, .{ .name = "__gtdf2", .linkage = 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);
49 @export("__gnu_f2h_ieee", @import("compiler_rt/truncXfYf2.zig").__truncsfhf2, linkage);
48 @export(@import("compiler_rt/extendXfYf2.zig").__extendhfsf2, .{ .name = "__gnu_h2f_ieee", .linkage = linkage });
49 @export(@import("compiler_rt/truncXfYf2.zig").__truncsfhf2, .{ .name = "__gnu_f2h_ieee", .linkage = linkage });
5050 }
5151
52 @export("__unordsf2", @import("compiler_rt/comparesf2.zig").__unordsf2, linkage);
53 @export("__unorddf2", @import("compiler_rt/comparedf2.zig").__unorddf2, linkage);
54 @export("__unordtf2", @import("compiler_rt/comparetf2.zig").__unordtf2, linkage);
55
56 @export("__addsf3", @import("compiler_rt/addXf3.zig").__addsf3, linkage);
57 @export("__adddf3", @import("compiler_rt/addXf3.zig").__adddf3, linkage);
58 @export("__addtf3", @import("compiler_rt/addXf3.zig").__addtf3, linkage);
59 @export("__subsf3", @import("compiler_rt/addXf3.zig").__subsf3, linkage);
60 @export("__subdf3", @import("compiler_rt/addXf3.zig").__subdf3, linkage);
61 @export("__subtf3", @import("compiler_rt/addXf3.zig").__subtf3, linkage);
62
63 @export("__mulsf3", @import("compiler_rt/mulXf3.zig").__mulsf3, linkage);
64 @export("__muldf3", @import("compiler_rt/mulXf3.zig").__muldf3, linkage);
65 @export("__multf3", @import("compiler_rt/mulXf3.zig").__multf3, linkage);
66
67 @export("__divsf3", @import("compiler_rt/divsf3.zig").__divsf3, linkage);
68 @export("__divdf3", @import("compiler_rt/divdf3.zig").__divdf3, linkage);
69
70 @export("__ashlti3", @import("compiler_rt/ashlti3.zig").__ashlti3, linkage);
71 @export("__lshrti3", @import("compiler_rt/lshrti3.zig").__lshrti3, linkage);
72 @export("__ashrti3", @import("compiler_rt/ashrti3.zig").__ashrti3, linkage);
73
74 @export("__floatsidf", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage);
75 @export("__floatsisf", @import("compiler_rt/floatsiXf.zig").__floatsisf, linkage);
76 @export("__floatdidf", @import("compiler_rt/floatdidf.zig").__floatdidf, linkage);
77 @export("__floatsitf", @import("compiler_rt/floatsiXf.zig").__floatsitf, linkage);
78
79 @export("__floatunsisf", @import("compiler_rt/floatunsisf.zig").__floatunsisf, linkage);
80 @export("__floatundisf", @import("compiler_rt/floatundisf.zig").__floatundisf, linkage);
81 @export("__floatunsidf", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage);
82 @export("__floatundidf", @import("compiler_rt/floatundidf.zig").__floatundidf, linkage);
83
84 @export("__floattitf", @import("compiler_rt/floattitf.zig").__floattitf, linkage);
85 @export("__floattidf", @import("compiler_rt/floattidf.zig").__floattidf, linkage);
86 @export("__floattisf", @import("compiler_rt/floattisf.zig").__floattisf, linkage);
87
88 @export("__floatunditf", @import("compiler_rt/floatunditf.zig").__floatunditf, linkage);
89 @export("__floatunsitf", @import("compiler_rt/floatunsitf.zig").__floatunsitf, linkage);
90
91 @export("__floatuntitf", @import("compiler_rt/floatuntitf.zig").__floatuntitf, linkage);
92 @export("__floatuntidf", @import("compiler_rt/floatuntidf.zig").__floatuntidf, linkage);
93 @export("__floatuntisf", @import("compiler_rt/floatuntisf.zig").__floatuntisf, linkage);
94
95 @export("__extenddftf2", @import("compiler_rt/extendXfYf2.zig").__extenddftf2, linkage);
96 @export("__extendsftf2", @import("compiler_rt/extendXfYf2.zig").__extendsftf2, linkage);
97 @export("__extendhfsf2", @import("compiler_rt/extendXfYf2.zig").__extendhfsf2, linkage);
98
99 @export("__truncsfhf2", @import("compiler_rt/truncXfYf2.zig").__truncsfhf2, linkage);
100 @export("__truncdfhf2", @import("compiler_rt/truncXfYf2.zig").__truncdfhf2, linkage);
101 @export("__trunctfdf2", @import("compiler_rt/truncXfYf2.zig").__trunctfdf2, linkage);
102 @export("__trunctfsf2", @import("compiler_rt/truncXfYf2.zig").__trunctfsf2, linkage);
103
104 @export("__truncdfsf2", @import("compiler_rt/truncXfYf2.zig").__truncdfsf2, linkage);
105
106 @export("__extendsfdf2", @import("compiler_rt/extendXfYf2.zig").__extendsfdf2, linkage);
107
108 @export("__fixunssfsi", @import("compiler_rt/fixunssfsi.zig").__fixunssfsi, linkage);
109 @export("__fixunssfdi", @import("compiler_rt/fixunssfdi.zig").__fixunssfdi, linkage);
110 @export("__fixunssfti", @import("compiler_rt/fixunssfti.zig").__fixunssfti, linkage);
111
112 @export("__fixunsdfsi", @import("compiler_rt/fixunsdfsi.zig").__fixunsdfsi, linkage);
113 @export("__fixunsdfdi", @import("compiler_rt/fixunsdfdi.zig").__fixunsdfdi, linkage);
114 @export("__fixunsdfti", @import("compiler_rt/fixunsdfti.zig").__fixunsdfti, linkage);
115
116 @export("__fixunstfsi", @import("compiler_rt/fixunstfsi.zig").__fixunstfsi, linkage);
117 @export("__fixunstfdi", @import("compiler_rt/fixunstfdi.zig").__fixunstfdi, linkage);
118 @export("__fixunstfti", @import("compiler_rt/fixunstfti.zig").__fixunstfti, linkage);
119
120 @export("__fixdfdi", @import("compiler_rt/fixdfdi.zig").__fixdfdi, linkage);
121 @export("__fixdfsi", @import("compiler_rt/fixdfsi.zig").__fixdfsi, linkage);
122 @export("__fixdfti", @import("compiler_rt/fixdfti.zig").__fixdfti, linkage);
123 @export("__fixsfdi", @import("compiler_rt/fixsfdi.zig").__fixsfdi, linkage);
124 @export("__fixsfsi", @import("compiler_rt/fixsfsi.zig").__fixsfsi, linkage);
125 @export("__fixsfti", @import("compiler_rt/fixsfti.zig").__fixsfti, linkage);
126 @export("__fixtfdi", @import("compiler_rt/fixtfdi.zig").__fixtfdi, linkage);
127 @export("__fixtfsi", @import("compiler_rt/fixtfsi.zig").__fixtfsi, linkage);
128 @export("__fixtfti", @import("compiler_rt/fixtfti.zig").__fixtfti, linkage);
129
130 @export("__udivmoddi4", @import("compiler_rt/udivmoddi4.zig").__udivmoddi4, linkage);
131 @export("__popcountdi2", @import("compiler_rt/popcountdi2.zig").__popcountdi2, linkage);
132
133 @export("__muldi3", @import("compiler_rt/muldi3.zig").__muldi3, linkage);
134 @export("__divmoddi4", __divmoddi4, linkage);
135 @export("__divsi3", __divsi3, linkage);
136 @export("__divdi3", __divdi3, linkage);
137 @export("__udivsi3", __udivsi3, linkage);
138 @export("__udivdi3", __udivdi3, linkage);
139 @export("__modsi3", __modsi3, linkage);
140 @export("__moddi3", __moddi3, linkage);
141 @export("__umodsi3", __umodsi3, linkage);
142 @export("__umoddi3", __umoddi3, linkage);
143 @export("__divmodsi4", __divmodsi4, linkage);
144 @export("__udivmodsi4", __udivmodsi4, linkage);
145
146 @export("__negsf2", @import("compiler_rt/negXf2.zig").__negsf2, linkage);
147 @export("__negdf2", @import("compiler_rt/negXf2.zig").__negdf2, linkage);
52 @export(@import("compiler_rt/comparesf2.zig").__unordsf2, .{ .name = "__unordsf2", .linkage = linkage });
53 @export(@import("compiler_rt/comparedf2.zig").__unorddf2, .{ .name = "__unorddf2", .linkage = linkage });
54 @export(@import("compiler_rt/comparetf2.zig").__unordtf2, .{ .name = "__unordtf2", .linkage = linkage });
55
56 @export(@import("compiler_rt/addXf3.zig").__addsf3, .{ .name = "__addsf3", .linkage = linkage });
57 @export(@import("compiler_rt/addXf3.zig").__adddf3, .{ .name = "__adddf3", .linkage = linkage });
58 @export(@import("compiler_rt/addXf3.zig").__addtf3, .{ .name = "__addtf3", .linkage = linkage });
59 @export(@import("compiler_rt/addXf3.zig").__subsf3, .{ .name = "__subsf3", .linkage = linkage });
60 @export(@import("compiler_rt/addXf3.zig").__subdf3, .{ .name = "__subdf3", .linkage = linkage });
61 @export(@import("compiler_rt/addXf3.zig").__subtf3, .{ .name = "__subtf3", .linkage = linkage });
62
63 @export(@import("compiler_rt/mulXf3.zig").__mulsf3, .{ .name = "__mulsf3", .linkage = linkage });
64 @export(@import("compiler_rt/mulXf3.zig").__muldf3, .{ .name = "__muldf3", .linkage = linkage });
65 @export(@import("compiler_rt/mulXf3.zig").__multf3, .{ .name = "__multf3", .linkage = linkage });
66
67 @export(@import("compiler_rt/divsf3.zig").__divsf3, .{ .name = "__divsf3", .linkage = linkage });
68 @export(@import("compiler_rt/divdf3.zig").__divdf3, .{ .name = "__divdf3", .linkage = linkage });
69
70 @export(@import("compiler_rt/ashlti3.zig").__ashlti3, .{ .name = "__ashlti3", .linkage = linkage });
71 @export(@import("compiler_rt/lshrti3.zig").__lshrti3, .{ .name = "__lshrti3", .linkage = linkage });
72 @export(@import("compiler_rt/ashrti3.zig").__ashrti3, .{ .name = "__ashrti3", .linkage = linkage });
73
74 @export(@import("compiler_rt/floatsiXf.zig").__floatsidf, .{ .name = "__floatsidf", .linkage = linkage });
75 @export(@import("compiler_rt/floatsiXf.zig").__floatsisf, .{ .name = "__floatsisf", .linkage = linkage });
76 @export(@import("compiler_rt/floatdidf.zig").__floatdidf, .{ .name = "__floatdidf", .linkage = linkage });
77 @export(@import("compiler_rt/floatsiXf.zig").__floatsitf, .{ .name = "__floatsitf", .linkage = linkage });
78
79 @export(@import("compiler_rt/floatunsisf.zig").__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage });
80 @export(@import("compiler_rt/floatundisf.zig").__floatundisf, .{ .name = "__floatundisf", .linkage = linkage });
81 @export(@import("compiler_rt/floatunsidf.zig").__floatunsidf, .{ .name = "__floatunsidf", .linkage = linkage });
82 @export(@import("compiler_rt/floatundidf.zig").__floatundidf, .{ .name = "__floatundidf", .linkage = linkage });
83
84 @export(@import("compiler_rt/floattitf.zig").__floattitf, .{ .name = "__floattitf", .linkage = linkage });
85 @export(@import("compiler_rt/floattidf.zig").__floattidf, .{ .name = "__floattidf", .linkage = linkage });
86 @export(@import("compiler_rt/floattisf.zig").__floattisf, .{ .name = "__floattisf", .linkage = linkage });
87
88 @export(@import("compiler_rt/floatunditf.zig").__floatunditf, .{ .name = "__floatunditf", .linkage = linkage });
89 @export(@import("compiler_rt/floatunsitf.zig").__floatunsitf, .{ .name = "__floatunsitf", .linkage = linkage });
90
91 @export(@import("compiler_rt/floatuntitf.zig").__floatuntitf, .{ .name = "__floatuntitf", .linkage = linkage });
92 @export(@import("compiler_rt/floatuntidf.zig").__floatuntidf, .{ .name = "__floatuntidf", .linkage = linkage });
93 @export(@import("compiler_rt/floatuntisf.zig").__floatuntisf, .{ .name = "__floatuntisf", .linkage = linkage });
94
95 @export(@import("compiler_rt/extendXfYf2.zig").__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage });
96 @export(@import("compiler_rt/extendXfYf2.zig").__extendsftf2, .{ .name = "__extendsftf2", .linkage = linkage });
97 @export(@import("compiler_rt/extendXfYf2.zig").__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = linkage });
98
99 @export(@import("compiler_rt/truncXfYf2.zig").__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = linkage });
100 @export(@import("compiler_rt/truncXfYf2.zig").__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = linkage });
101 @export(@import("compiler_rt/truncXfYf2.zig").__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = linkage });
102 @export(@import("compiler_rt/truncXfYf2.zig").__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = linkage });
103
104 @export(@import("compiler_rt/truncXfYf2.zig").__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = linkage });
105
106 @export(@import("compiler_rt/extendXfYf2.zig").__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = linkage });
107
108 @export(@import("compiler_rt/fixunssfsi.zig").__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = linkage });
109 @export(@import("compiler_rt/fixunssfdi.zig").__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = linkage });
110 @export(@import("compiler_rt/fixunssfti.zig").__fixunssfti, .{ .name = "__fixunssfti", .linkage = linkage });
111
112 @export(@import("compiler_rt/fixunsdfsi.zig").__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = linkage });
113 @export(@import("compiler_rt/fixunsdfdi.zig").__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = linkage });
114 @export(@import("compiler_rt/fixunsdfti.zig").__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = linkage });
115
116 @export(@import("compiler_rt/fixunstfsi.zig").__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = linkage });
117 @export(@import("compiler_rt/fixunstfdi.zig").__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = linkage });
118 @export(@import("compiler_rt/fixunstfti.zig").__fixunstfti, .{ .name = "__fixunstfti", .linkage = linkage });
119
120 @export(@import("compiler_rt/fixdfdi.zig").__fixdfdi, .{ .name = "__fixdfdi", .linkage = linkage });
121 @export(@import("compiler_rt/fixdfsi.zig").__fixdfsi, .{ .name = "__fixdfsi", .linkage = linkage });
122 @export(@import("compiler_rt/fixdfti.zig").__fixdfti, .{ .name = "__fixdfti", .linkage = linkage });
123 @export(@import("compiler_rt/fixsfdi.zig").__fixsfdi, .{ .name = "__fixsfdi", .linkage = linkage });
124 @export(@import("compiler_rt/fixsfsi.zig").__fixsfsi, .{ .name = "__fixsfsi", .linkage = linkage });
125 @export(@import("compiler_rt/fixsfti.zig").__fixsfti, .{ .name = "__fixsfti", .linkage = linkage });
126 @export(@import("compiler_rt/fixtfdi.zig").__fixtfdi, .{ .name = "__fixtfdi", .linkage = linkage });
127 @export(@import("compiler_rt/fixtfsi.zig").__fixtfsi, .{ .name = "__fixtfsi", .linkage = linkage });
128 @export(@import("compiler_rt/fixtfti.zig").__fixtfti, .{ .name = "__fixtfti", .linkage = linkage });
129
130 @export(@import("compiler_rt/udivmoddi4.zig").__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = linkage });
131 @export(@import("compiler_rt/popcountdi2.zig").__popcountdi2, .{ .name = "__popcountdi2", .linkage = linkage });
132
133 @export(@import("compiler_rt/muldi3.zig").__muldi3, .{ .name = "__muldi3", .linkage = linkage });
134 @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = linkage });
135 @export(__divsi3, .{ .name = "__divsi3", .linkage = linkage });
136 @export(__divdi3, .{ .name = "__divdi3", .linkage = linkage });
137 @export(__udivsi3, .{ .name = "__udivsi3", .linkage = linkage });
138 @export(__udivdi3, .{ .name = "__udivdi3", .linkage = linkage });
139 @export(__modsi3, .{ .name = "__modsi3", .linkage = linkage });
140 @export(__moddi3, .{ .name = "__moddi3", .linkage = linkage });
141 @export(__umodsi3, .{ .name = "__umodsi3", .linkage = linkage });
142 @export(__umoddi3, .{ .name = "__umoddi3", .linkage = linkage });
143 @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = linkage });
144 @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = linkage });
145
146 @export(@import("compiler_rt/negXf2.zig").__negsf2, .{ .name = "__negsf2", .linkage = linkage });
147 @export(@import("compiler_rt/negXf2.zig").__negdf2, .{ .name = "__negdf2", .linkage = linkage });
148148
149149 if (is_arm_arch and !is_arm_64 and !is_test) {
150 @export("__aeabi_unwind_cpp_pr0", __aeabi_unwind_cpp_pr0, strong_linkage);
151 @export("__aeabi_unwind_cpp_pr1", __aeabi_unwind_cpp_pr1, linkage);
152 @export("__aeabi_unwind_cpp_pr2", __aeabi_unwind_cpp_pr2, linkage);
150 @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = strong_linkage });
151 @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = 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);
157 @export("__aeabi_uldivmod", __aeabi_uldivmod, linkage);
156 @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = linkage });
157 @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = linkage });
158158
159 @export("__aeabi_idiv", __divsi3, linkage);
160 @export("__aeabi_idivmod", __aeabi_idivmod, linkage);
161 @export("__aeabi_uidiv", __udivsi3, linkage);
162 @export("__aeabi_uidivmod", __aeabi_uidivmod, linkage);
159 @export(__divsi3, .{ .name = "__aeabi_idiv", .linkage = linkage });
160 @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = linkage });
161 @export(__udivsi3, .{ .name = "__aeabi_uidiv", .linkage = linkage });
162 @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = linkage });
163163
164 @export("__aeabi_memcpy", __aeabi_memcpy, linkage);
165 @export("__aeabi_memcpy4", __aeabi_memcpy, linkage);
166 @export("__aeabi_memcpy8", __aeabi_memcpy, linkage);
164 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = linkage });
165 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy4", .linkage = linkage });
166 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy8", .linkage = linkage });
167167
168 @export("__aeabi_memmove", __aeabi_memmove, linkage);
169 @export("__aeabi_memmove4", __aeabi_memmove, linkage);
170 @export("__aeabi_memmove8", __aeabi_memmove, linkage);
168 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = linkage });
169 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove4", .linkage = linkage });
170 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove8", .linkage = linkage });
171171
172 @export("__aeabi_memset", __aeabi_memset, linkage);
173 @export("__aeabi_memset4", __aeabi_memset, linkage);
174 @export("__aeabi_memset8", __aeabi_memset, linkage);
172 @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = linkage });
173 @export(__aeabi_memset, .{ .name = "__aeabi_memset4", .linkage = linkage });
174 @export(__aeabi_memset, .{ .name = "__aeabi_memset8", .linkage = linkage });
175175
176 @export("__aeabi_memclr", __aeabi_memclr, linkage);
177 @export("__aeabi_memclr4", __aeabi_memclr, linkage);
178 @export("__aeabi_memclr8", __aeabi_memclr, linkage);
176 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = linkage });
177 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage });
178 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage });
179179
180 @export("__aeabi_memcmp", __aeabi_memcmp, linkage);
181 @export("__aeabi_memcmp4", __aeabi_memcmp, linkage);
182 @export("__aeabi_memcmp8", __aeabi_memcmp, linkage);
180 @export(__aeabi_memcmp, .{ .name = "__aeabi_memcmp", .linkage = linkage });
181 @export(__aeabi_memcmp, .{ .name = "__aeabi_memcmp4", .linkage = linkage });
182 @export(__aeabi_memcmp, .{ .name = "__aeabi_memcmp8", .linkage = linkage });
183183
184 @export("__aeabi_f2d", @import("compiler_rt/extendXfYf2.zig").__aeabi_f2d, linkage);
185 @export("__aeabi_i2d", @import("compiler_rt/floatsiXf.zig").__aeabi_i2d, linkage);
186 @export("__aeabi_l2d", @import("compiler_rt/floatdidf.zig").__aeabi_l2d, linkage);
187 @export("__aeabi_ui2d", @import("compiler_rt/floatunsidf.zig").__aeabi_ui2d, linkage);
188 @export("__aeabi_ul2d", @import("compiler_rt/floatundidf.zig").__aeabi_ul2d, linkage);
189 @export("__aeabi_ui2f", @import("compiler_rt/floatunsisf.zig").__aeabi_ui2f, linkage);
190 @export("__aeabi_ul2f", @import("compiler_rt/floatundisf.zig").__aeabi_ul2f, linkage);
184 @export(@import("compiler_rt/extendXfYf2.zig").__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });
185 @export(@import("compiler_rt/floatsiXf.zig").__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });
186 @export(@import("compiler_rt/floatdidf.zig").__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });
187 @export(@import("compiler_rt/floatunsidf.zig").__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = linkage });
188 @export(@import("compiler_rt/floatundidf.zig").__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = linkage });
189 @export(@import("compiler_rt/floatunsisf.zig").__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = 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);
193 @export("__aeabi_dneg", @import("compiler_rt/negXf2.zig").__aeabi_dneg, linkage);
192 @export(@import("compiler_rt/negXf2.zig").__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = 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);
196 @export("__aeabi_dmul", @import("compiler_rt/mulXf3.zig").__aeabi_dmul, linkage);
195 @export(@import("compiler_rt/mulXf3.zig").__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = 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);
201 @export("__aeabi_d2ulz", @import("compiler_rt/fixunsdfdi.zig").__aeabi_d2ulz, linkage);
200 @export(@import("compiler_rt/fixunssfdi.zig").__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = 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);
204 @export("__aeabi_d2lz", @import("compiler_rt/fixdfdi.zig").__aeabi_d2lz, linkage);
203 @export(@import("compiler_rt/fixsfdi.zig").__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = 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);
209 @export("__aeabi_f2h", @import("compiler_rt/truncXfYf2.zig").__aeabi_f2h, linkage);
208 @export(@import("compiler_rt/extendXfYf2.zig").__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = 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);
212 @export("__aeabi_d2f", @import("compiler_rt/truncXfYf2.zig").__aeabi_d2f, linkage);
211 @export(@import("compiler_rt/floatsiXf.zig").__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = 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);
215 @export("__aeabi_dadd", @import("compiler_rt/addXf3.zig").__aeabi_dadd, linkage);
216 @export("__aeabi_fsub", @import("compiler_rt/addXf3.zig").__aeabi_fsub, linkage);
217 @export("__aeabi_dsub", @import("compiler_rt/addXf3.zig").__aeabi_dsub, linkage);
214 @export(@import("compiler_rt/addXf3.zig").__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = linkage });
215 @export(@import("compiler_rt/addXf3.zig").__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = linkage });
216 @export(@import("compiler_rt/addXf3.zig").__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = 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);
222 @export("__aeabi_d2iz", @import("compiler_rt/fixdfsi.zig").__aeabi_d2iz, linkage);
221 @export(@import("compiler_rt/fixsfsi.zig").__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = 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);
225 @export("__aeabi_ddiv", @import("compiler_rt/divdf3.zig").__aeabi_ddiv, linkage);
224 @export(@import("compiler_rt/divsf3.zig").__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = 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);
228 @export("__aeabi_fcmplt", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmplt, linkage);
229 @export("__aeabi_fcmple", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmple, linkage);
230 @export("__aeabi_fcmpge", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpge, linkage);
231 @export("__aeabi_fcmpgt", @import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpgt, linkage);
232 @export("__aeabi_fcmpun", @import("compiler_rt/comparesf2.zig").__aeabi_fcmpun, linkage);
227 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = linkage });
228 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = linkage });
229 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = linkage });
230 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = linkage });
231 @export(@import("compiler_rt/arm/aeabi_fcmp.zig").__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = 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);
235 @export("__aeabi_dcmplt", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmplt, linkage);
236 @export("__aeabi_dcmple", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmple, linkage);
237 @export("__aeabi_dcmpge", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpge, linkage);
238 @export("__aeabi_dcmpgt", @import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpgt, linkage);
239 @export("__aeabi_dcmpun", @import("compiler_rt/comparedf2.zig").__aeabi_dcmpun, linkage);
234 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = linkage });
235 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = linkage });
236 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = linkage });
237 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = linkage });
238 @export(@import("compiler_rt/arm/aeabi_dcmp.zig").__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = linkage });
239 @export(@import("compiler_rt/comparedf2.zig").__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage });
240240 }
241241 if (builtin.os == .windows) {
242242 // Default stack-probe functions emitted by LLVM
243243 if (is_mingw) {
244 @export("_alloca", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage);
245 @export("___chkstk_ms", @import("compiler_rt/stack_probe.zig").___chkstk_ms, strong_linkage);
244 @export(@import("compiler_rt/stack_probe.zig")._chkstk, .{ .name = "_alloca", .linkage = strong_linkage });
245 @export(@import("compiler_rt/stack_probe.zig").___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = strong_linkage });
246246 } else if (!builtin.link_libc) {
247247 // This symbols are otherwise exported by MSVCRT.lib
248 @export("_chkstk", @import("compiler_rt/stack_probe.zig")._chkstk, strong_linkage);
249 @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(@import("compiler_rt/stack_probe.zig").__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage });
250250 }
251251
252252 if (is_mingw) {
253 @export("__stack_chk_fail", __stack_chk_fail, strong_linkage);
254 @export("__stack_chk_guard", __stack_chk_guard, strong_linkage);
253 @export(__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = strong_linkage });
254 @export(__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = strong_linkage });
255255 }
256256
257257 switch (builtin.arch) {
258258 .i386 => {
259259 // Don't let LLVM apply the stdcall name mangling on those MSVC
260260 // builtin functions
261 @export("\x01__alldiv", @import("compiler_rt/aulldiv.zig")._alldiv, strong_linkage);
262 @export("\x01__aulldiv", @import("compiler_rt/aulldiv.zig")._aulldiv, strong_linkage);
263 @export("\x01__allrem", @import("compiler_rt/aullrem.zig")._allrem, strong_linkage);
264 @export("\x01__aullrem", @import("compiler_rt/aullrem.zig")._aullrem, strong_linkage);
265
266 @export("__divti3", @import("compiler_rt/divti3.zig").__divti3, linkage);
267 @export("__modti3", @import("compiler_rt/modti3.zig").__modti3, linkage);
268 @export("__multi3", @import("compiler_rt/multi3.zig").__multi3, linkage);
269 @export("__udivti3", @import("compiler_rt/udivti3.zig").__udivti3, linkage);
270 @export("__udivmodti4", @import("compiler_rt/udivmodti4.zig").__udivmodti4, linkage);
271 @export("__umodti3", @import("compiler_rt/umodti3.zig").__umodti3, linkage);
261 @export(@import("compiler_rt/aulldiv.zig")._alldiv, .{ .name = "\x01__alldiv", .linkage = strong_linkage });
262 @export(@import("compiler_rt/aulldiv.zig")._aulldiv, .{ .name = "\x01__aulldiv", .linkage = strong_linkage });
263 @export(@import("compiler_rt/aullrem.zig")._allrem, .{ .name = "\x01__allrem", .linkage = strong_linkage });
264 @export(@import("compiler_rt/aullrem.zig")._aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage });
265
266 @export(@import("compiler_rt/divti3.zig").__divti3, .{ .name = "__divti3", .linkage = linkage });
267 @export(@import("compiler_rt/modti3.zig").__modti3, .{ .name = "__modti3", .linkage = linkage });
268 @export(@import("compiler_rt/multi3.zig").__multi3, .{ .name = "__multi3", .linkage = linkage });
269 @export(@import("compiler_rt/udivti3.zig").__udivti3, .{ .name = "__udivti3", .linkage = linkage });
270 @export(@import("compiler_rt/udivmodti4.zig").__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage });
271 @export(@import("compiler_rt/umodti3.zig").__umodti3, .{ .name = "__umodti3", .linkage = linkage });
272272 },
273273 .x86_64 => {
274274 // The "ti" functions must use @Vector(2, u64) parameter types to adhere to the ABI
275275 // that LLVM expects compiler-rt to have.
276 @export("__divti3", @import("compiler_rt/divti3.zig").__divti3_windows_x86_64, linkage);
277 @export("__modti3", @import("compiler_rt/modti3.zig").__modti3_windows_x86_64, linkage);
278 @export("__multi3", @import("compiler_rt/multi3.zig").__multi3_windows_x86_64, linkage);
279 @export("__udivti3", @import("compiler_rt/udivti3.zig").__udivti3_windows_x86_64, linkage);
280 @export("__udivmodti4", @import("compiler_rt/udivmodti4.zig").__udivmodti4_windows_x86_64, linkage);
281 @export("__umodti3", @import("compiler_rt/umodti3.zig").__umodti3_windows_x86_64, linkage);
276 @export(@import("compiler_rt/divti3.zig").__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = linkage });
277 @export(@import("compiler_rt/modti3.zig").__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = linkage });
278 @export(@import("compiler_rt/multi3.zig").__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = linkage });
279 @export(@import("compiler_rt/udivti3.zig").__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = linkage });
280 @export(@import("compiler_rt/udivmodti4.zig").__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = linkage });
281 @export(@import("compiler_rt/umodti3.zig").__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = linkage });
282282 },
283283 else => {},
284284 }
285285 } else {
286286 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 });
288288 }
289 @export("__divti3", @import("compiler_rt/divti3.zig").__divti3, linkage);
290 @export("__modti3", @import("compiler_rt/modti3.zig").__modti3, linkage);
291 @export("__multi3", @import("compiler_rt/multi3.zig").__multi3, linkage);
292 @export("__udivti3", @import("compiler_rt/udivti3.zig").__udivti3, linkage);
293 @export("__udivmodti4", @import("compiler_rt/udivmodti4.zig").__udivmodti4, linkage);
294 @export("__umodti3", @import("compiler_rt/umodti3.zig").__umodti3, linkage);
289 @export(@import("compiler_rt/divti3.zig").__divti3, .{ .name = "__divti3", .linkage = linkage });
290 @export(@import("compiler_rt/modti3.zig").__modti3, .{ .name = "__modti3", .linkage = linkage });
291 @export(@import("compiler_rt/multi3.zig").__multi3, .{ .name = "__multi3", .linkage = linkage });
292 @export(@import("compiler_rt/udivti3.zig").__udivti3, .{ .name = "__udivti3", .linkage = linkage });
293 @export(@import("compiler_rt/udivmodti4.zig").__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage });
294 @export(@import("compiler_rt/umodti3.zig").__umodti3, .{ .name = "__umodti3", .linkage = linkage });
295295 }
296 @export("__muloti4", @import("compiler_rt/muloti4.zig").__muloti4, linkage);
297 @export("__mulodi4", @import("compiler_rt/mulodi4.zig").__mulodi4, linkage);
296 @export(@import("compiler_rt/muloti4.zig").__muloti4, .{ .name = "__muloti4", .linkage = linkage });
297 @export(@import("compiler_rt/mulodi4.zig").__mulodi4, .{ .name = "__mulodi4", .linkage = linkage });
298298}
299299
300300const std = @import("std");
lib/std/start.zig+6-6
......@@ -22,23 +22,23 @@ const start_sym_name = if (is_mips) "__start" else "_start";
2222comptime {
2323 if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) {
2424 if (builtin.os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {
25 @export("_DllMainCRTStartup", _DllMainCRTStartup, .Strong);
25 @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });
2626 }
2727 } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
2828 if (builtin.link_libc and @hasDecl(root, "main")) {
2929 if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
30 @export("main", main, .Weak);
30 @export(main, .{ .name = "main", .linkage = .Weak });
3131 }
3232 } else if (builtin.os == .windows) {
3333 if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup")) {
34 @export("WinMainCRTStartup", WinMainCRTStartup, .Strong);
34 @export(WinMainCRTStartup, .{ .name = "WinMainCRTStartup" });
3535 }
3636 } else if (builtin.os == .uefi) {
37 if (!@hasDecl(root, "EfiMain")) @export("EfiMain", EfiMain, .Strong);
37 if (!@hasDecl(root, "EfiMain")) @export(EfiMain, .{ .name = "EfiMain" });
3838 } 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 });
4040 } 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 });
4242 }
4343 }
4444}
src/all_types.hpp+3-3
......@@ -526,7 +526,6 @@ struct TldVar {
526526
527527 ZigVar *var;
528528 Buf *extern_lib_name;
529 Buf *section_name;
530529 bool analyzing_type; // flag to detect dependency loops
531530};
532531
......@@ -2231,6 +2230,8 @@ struct ZigVar {
22312230 size_t mem_slot_index;
22322231 IrExecutable *owner_exec;
22332232
2233 Buf *section_name;
2234
22342235 // In an inline loop, multiple variables may be created,
22352236 // In this case, a reference to a variable should follow
22362237 // this pointer to the redefined variable.
......@@ -3785,9 +3786,8 @@ struct IrInstructionArgType {
37853786struct IrInstructionExport {
37863787 IrInstruction base;
37873788
3788 IrInstruction *name;
3789 IrInstruction *linkage;
37903789 IrInstruction *target;
3790 IrInstruction *options;
37913791};
37923792
37933793struct IrInstructionErrorReturnTrace {
src/analyze.cpp+2-2
......@@ -3955,8 +3955,8 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
39553955 }
39563956
39573957 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)) {
3959 tld_var->section_name = nullptr;
3958 if (!analyze_const_string(g, tld_var->base.parent_scope, var_decl->section_expr, &tld_var->var->section_name)) {
3959 tld_var->var->section_name = nullptr;
39603960 }
39613961 }
39623962
src/codegen.cpp+3-3
......@@ -7538,8 +7538,8 @@ static void do_code_gen(CodeGen *g) {
75387538 LLVMSetLinkage(global_value, to_llvm_linkage(linkage));
75397539 maybe_export_dll(g, global_value, GlobalLinkageIdStrong);
75407540 }
7541 if (tld_var->section_name) {
7542 LLVMSetSection(global_value, buf_ptr(tld_var->section_name));
7541 if (var->section_name) {
7542 LLVMSetSection(global_value, buf_ptr(var->section_name));
75437543 }
75447544 LLVMSetAlignment(global_value, var->align_bytes);
75457545
......@@ -8264,7 +8264,7 @@ static void define_builtin_fns(CodeGen *g) {
82648264 create_builtin_fn(g, BuiltinFnIdOpaqueType, "OpaqueType", 0);
82658265 create_builtin_fn(g, BuiltinFnIdSetAlignStack, "setAlignStack", 1);
82668266 create_builtin_fn(g, BuiltinFnIdArgType, "ArgType", 2);
8267 create_builtin_fn(g, BuiltinFnIdExport, "export", 3);
8267 create_builtin_fn(g, BuiltinFnIdExport, "export", 2);
82688268 create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0);
82698269 create_builtin_fn(g, BuiltinFnIdAtomicRmw, "atomicRmw", 5);
82708270 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
22272227}
22282228
22292229static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *source_node,
2230 IrInstruction *name, IrInstruction *target, IrInstruction *linkage)
2230 IrInstruction *target, IrInstruction *options)
22312231{
22322232 IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>(
22332233 irb, scope, source_node);
22342234 export_instruction->base.value->special = ConstValSpecialStatic;
22352235 export_instruction->base.value->type = irb->codegen->builtin_types.entry_void;
2236 export_instruction->name = name;
22372236 export_instruction->target = target;
2238 export_instruction->linkage = linkage;
2237 export_instruction->options = options;
22392238
2240 ir_ref_instruction(name, irb->current_basic_block);
22412239 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
22442242 return &export_instruction->base;
22452243}
......@@ -6272,22 +6270,26 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
62726270 }
62736271 case BuiltinFnIdExport:
62746272 {
6275 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
6276 IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope);
6277 if (arg0_value == irb->codegen->invalid_instruction)
6278 return arg0_value;
6279
6280 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
6281 IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope);
6282 if (arg1_value == irb->codegen->invalid_instruction)
6283 return arg1_value;
6284
6285 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);
6286 IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope);
6287 if (arg2_value == irb->codegen->invalid_instruction)
6288 return arg2_value;
6289
6290 IrInstruction *ir_export = ir_build_export(irb, scope, node, arg0_value, arg1_value, arg2_value);
6273 // Cast the options parameter to the options type
6274 ZigType *options_type = get_builtin_type(irb->codegen, "ExportOptions");
6275 IrInstruction *options_type_inst = ir_build_const_type(irb, scope, node, options_type);
6276 ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc());
6277
6278 AstNode *target_node = node->data.fn_call_expr.params.at(0);
6279 IrInstruction *target_value = ir_gen_node(irb, target_node, scope);
6280 if (target_value == irb->codegen->invalid_instruction)
6281 return target_value;
6282
6283 AstNode *options_node = node->data.fn_call_expr.params.at(1);
6284 IrInstruction *options_value = ir_gen_node_extra(irb, options_node,
6285 scope, LValNone, &result_loc_cast->base);
6286 if (options_value == irb->codegen->invalid_instruction)
6287 return options_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);
62916293 return ir_lval_wrap(irb, scope, ir_export, lval, result_loc);
62926294 }
62936295 case BuiltinFnIdErrorReturnTrace:
......@@ -16683,27 +16685,61 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
1668316685}
1668416686
1668516687static 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;
16689 Buf *symbol_name = ir_resolve_str(ira, name);
16690 if (symbol_name == nullptr) {
16692 IrInstruction *options = instruction->options->child;
16693 if (type_is_invalid(options->value->type))
1669116694 return ira->codegen->invalid_instruction;
16692 }
1669316695
16694 IrInstruction *target = instruction->target->child;
16695 if (type_is_invalid(target->value->type)) {
16696 ZigType *options_type = options->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))
1669616715 return ira->codegen->invalid_instruction;
16697 }
1669816716
16699 GlobalLinkageId global_linkage_id = GlobalLinkageIdStrong;
16700 if (instruction->linkage != nullptr) {
16701 IrInstruction *linkage_value = instruction->linkage->child;
16702 if (!ir_resolve_global_linkage(ira, linkage_value, &global_linkage_id)) {
16717 // The `section` field is optional, we have to unwrap it first
16718 IrInstruction *non_null_check = ir_analyze_test_non_null(ira, &instruction->base, section_inst);
16719 bool is_non_null;
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))
1670316727 return ira->codegen->invalid_instruction;
16704 }
1670516728 }
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
1670716743 // TODO: This function needs to be audited.
1670816744 // It's not clear how all the different types are supposed to be handled.
1670916745 // 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
1672116757 return ira->codegen->invalid_instruction;
1672216758 }
1672316759
16760 Error err;
1672416761 bool want_var_export = false;
1672516762 switch (target->value->type->id) {
1672616763 case ZigTypeIdInvalid:
......@@ -16755,6 +16792,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
1675516792 case CallingConventionAAPCS:
1675616793 case CallingConventionAAPCSVFP:
1675716794 add_fn_export(ira->codegen, fn_entry, buf_ptr(symbol_name), global_linkage_id, cc);
16795 fn_entry->section_name = section_name;
1675816796 break;
1675916797 }
1676016798 } break;
......@@ -16896,6 +16934,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
1689616934 IrInstructionVarPtr *var_ptr = reinterpret_cast<IrInstructionVarPtr *>(load_ptr->ptr);
1689716935 ZigVar *var = var_ptr->var;
1689816936 add_var_export(ira->codegen, var, buf_ptr(symbol_name), global_linkage_id);
16937 var->section_name = section_name;
1689916938 }
1690016939 }
1690116940
src/ir_print.cpp+5-15
......@@ -1893,21 +1893,11 @@ static void ir_print_enum_tag_type(IrPrint *irp, IrInstructionTagType *instructi
18931893}
18941894
18951895static void ir_print_export(IrPrint *irp, IrInstructionExport *instruction) {
1896 if (instruction->linkage == nullptr) {
1897 fprintf(irp->f, "@export(");
1898 ir_print_other_instruction(irp, instruction->name);
1899 fprintf(irp->f, ",");
1900 ir_print_other_instruction(irp, instruction->target);
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 }
1896 fprintf(irp->f, "@export(");
1897 ir_print_other_instruction(irp, instruction->target);
1898 fprintf(irp->f, ",");
1899 ir_print_other_instruction(irp, instruction->options);
1900 fprintf(irp->f, ")");
19111901}
19121902
19131903static 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 {
56505650 cases.add("wrong types given to @export",
56515651 \\fn entry() callconv(.C) void { }
56525652 \\comptime {
5653 \\ @export("entry", entry, @as(u32, 1234));
5653 \\ @export(entry, .{.name = "entry", .linkage = @as(u32, 1234) });
56545654 \\}
56555655 , &[_][]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'",
56575657 });
56585658
56595659 cases.add("struct with invalid field",
test/stage1/behavior/misc.zig+1-1
......@@ -16,7 +16,7 @@ test "empty function with comments" {
1616}
1717
1818comptime {
19 @export("disabledExternFn", disabledExternFn, builtin.GlobalLinkage.Internal);
19 @export(disabledExternFn, .{ .name = "disabledExternFn", .linkage = .Internal });
2020}
2121
2222fn disabledExternFn() callconv(.C) void {}