| author | |
| committer | |
| log | fbdcb2289b3fed28792474579625a977feca0ed1 |
| tree | 0d1a71aecb870f00948a211f8bee5412e68191ec |
| parent | 0dd0ebb6e2b9030b30a4333b3e79b88500fa6aff |
3 files changed, 32 insertions(+), 10 deletions(-)
src/link/Wasm/Flush.zig+7-6| ... | @@ -154,14 +154,15 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { | ... | @@ -154,14 +154,15 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 154 | if (nav_export.name.toOptional() == entry_name) | 154 | if (nav_export.name.toOptional() == entry_name) |
| 155 | wasm.entry_resolution = .fromIpNav(wasm, nav_export.nav_index); | 155 | wasm.entry_resolution = .fromIpNav(wasm, nav_export.nav_index); |
| 156 | } else { | 156 | } else { |
| 157 | try wasm.global_exports.append(gpa, .{ | 157 | // This is a data export because Zcu currently has no way to |
| 158 | .name = nav_export.name, | 158 | // export wasm globals. |
| 159 | .global_index = Wasm.GlobalIndex.fromIpNav(wasm, nav_export.nav_index).?, | ||
| 160 | }); | ||
| 161 | _ = f.missing_exports.swapRemove(nav_export.name); | 159 | _ = f.missing_exports.swapRemove(nav_export.name); |
| 162 | _ = f.data_imports.swapRemove(nav_export.name); | 160 | _ = f.data_imports.swapRemove(nav_export.name); |
| 163 | // `f.global_imports` is ignored because Zcu has no way to | 161 | if (!is_obj) { |
| 164 | // export wasm globals. | 162 | diags.addError("unable to export data symbol '{s}'; not emitting a relocatable", .{ |
| 163 | nav_export.name.slice(wasm), | ||
| 164 | }); | ||
| 165 | } | ||
| 165 | } | 166 | } |
| 166 | } | 167 | } |
| 167 | 168 |
test/behavior.zig+10-3| ... | @@ -31,8 +31,6 @@ test { | ... | @@ -31,8 +31,6 @@ test { |
| 31 | _ = @import("behavior/error.zig"); | 31 | _ = @import("behavior/error.zig"); |
| 32 | _ = @import("behavior/eval.zig"); | 32 | _ = @import("behavior/eval.zig"); |
| 33 | _ = @import("behavior/export_builtin.zig"); | 33 | _ = @import("behavior/export_builtin.zig"); |
| 34 | _ = @import("behavior/export_self_referential_type_info.zig"); | ||
| 35 | _ = @import("behavior/extern.zig"); | ||
| 36 | _ = @import("behavior/field_parent_ptr.zig"); | 34 | _ = @import("behavior/field_parent_ptr.zig"); |
| 37 | _ = @import("behavior/floatop.zig"); | 35 | _ = @import("behavior/floatop.zig"); |
| 38 | _ = @import("behavior/fn.zig"); | 36 | _ = @import("behavior/fn.zig"); |
| ... | @@ -45,7 +43,6 @@ test { | ... | @@ -45,7 +43,6 @@ test { |
| 45 | _ = @import("behavior/hasfield.zig"); | 43 | _ = @import("behavior/hasfield.zig"); |
| 46 | _ = @import("behavior/if.zig"); | 44 | _ = @import("behavior/if.zig"); |
| 47 | _ = @import("behavior/import.zig"); | 45 | _ = @import("behavior/import.zig"); |
| 48 | _ = @import("behavior/import_c_keywords.zig"); | ||
| 49 | _ = @import("behavior/incomplete_struct_param_tld.zig"); | 46 | _ = @import("behavior/incomplete_struct_param_tld.zig"); |
| 50 | _ = @import("behavior/inline_switch.zig"); | 47 | _ = @import("behavior/inline_switch.zig"); |
| 51 | _ = @import("behavior/int128.zig"); | 48 | _ = @import("behavior/int128.zig"); |
| ... | @@ -127,6 +124,16 @@ test { | ... | @@ -127,6 +124,16 @@ test { |
| 127 | { | 124 | { |
| 128 | _ = @import("behavior/export_keyword.zig"); | 125 | _ = @import("behavior/export_keyword.zig"); |
| 129 | } | 126 | } |
| 127 | |||
| 128 | if (!builtin.cpu.arch.isWasm()) { | ||
| 129 | // Due to lack of import/export of global support | ||
| 130 | // (https://github.com/ziglang/zig/issues/4866), these tests correctly | ||
| 131 | // cause linker errors, since a data symbol cannot be exported when | ||
| 132 | // building an executable. | ||
| 133 | _ = @import("behavior/export_self_referential_type_info.zig"); | ||
| 134 | _ = @import("behavior/extern.zig"); | ||
| 135 | _ = @import("behavior/import_c_keywords.zig"); | ||
| 136 | } | ||
| 130 | } | 137 | } |
| 131 | 138 | ||
| 132 | // This bug only repros in the root file | 139 | // This bug only repros in the root file |
test/behavior/export_builtin.zig+15-1| ... | @@ -6,6 +6,11 @@ test "exporting enum value" { | ... | @@ -6,6 +6,11 @@ test "exporting enum value" { |
| 6 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 6 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 7 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 7 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 8 | 8 | ||
| 9 | if (builtin.cpu.arch.isWasm()) { | ||
| 10 | // https://github.com/ziglang/zig/issues/4866 | ||
| 11 | return error.SkipZigTest; | ||
| 12 | } | ||
| 13 | |||
| 9 | const S = struct { | 14 | const S = struct { |
| 10 | const E = enum(c_int) { one, two }; | 15 | const E = enum(c_int) { one, two }; |
| 11 | const e: E = .two; | 16 | const e: E = .two; |
| ... | @@ -33,6 +38,11 @@ test "exporting using namespace access" { | ... | @@ -33,6 +38,11 @@ test "exporting using namespace access" { |
| 33 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 38 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 34 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 39 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 35 | 40 | ||
| 41 | if (builtin.cpu.arch.isWasm()) { | ||
| 42 | // https://github.com/ziglang/zig/issues/4866 | ||
| 43 | return error.SkipZigTest; | ||
| 44 | } | ||
| 45 | |||
| 36 | const S = struct { | 46 | const S = struct { |
| 37 | const Inner = struct { | 47 | const Inner = struct { |
| 38 | const x: u32 = 5; | 48 | const x: u32 = 5; |
| ... | @@ -46,7 +56,6 @@ test "exporting using namespace access" { | ... | @@ -46,7 +56,6 @@ test "exporting using namespace access" { |
| 46 | } | 56 | } |
| 47 | 57 | ||
| 48 | test "exporting comptime-known value" { | 58 | test "exporting comptime-known value" { |
| 49 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | ||
| 50 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 59 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 51 | if (builtin.zig_backend == .stage2_x86_64 and | 60 | if (builtin.zig_backend == .stage2_x86_64 and |
| 52 | (builtin.target.ofmt != .elf and | 61 | (builtin.target.ofmt != .elf and |
| ... | @@ -56,6 +65,11 @@ test "exporting comptime-known value" { | ... | @@ -56,6 +65,11 @@ test "exporting comptime-known value" { |
| 56 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 65 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 57 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | 66 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 58 | 67 | ||
| 68 | if (builtin.cpu.arch.isWasm()) { | ||
| 69 | // https://github.com/ziglang/zig/issues/4866 | ||
| 70 | return error.SkipZigTest; | ||
| 71 | } | ||
| 72 | |||
| 59 | const x: u32 = 10; | 73 | const x: u32 = 10; |
| 60 | @export(&x, .{ .name = "exporting_comptime_known_value_foo" }); | 74 | @export(&x, .{ .name = "exporting_comptime_known_value_foo" }); |
| 61 | const S = struct { | 75 | const S = struct { |