diff options
| author | Matt Knight <mattnite@protonmail.com> | 2022-12-25 17:19:50 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-25 20:19:50 -0500 |
| commit | cf822c6ddd7e56b248ab217d38907aad38935b2f (patch) | |
| tree | c92c28d8305ba760f3f661fd1685d904c97f1c4c /src | |
| parent | f5b6019646fe76678c993596130f03116989eb12 (diff) | |
| download | zig-cf822c6ddd7e56b248ab217d38907aad38935b2f.tar.gz zig-cf822c6ddd7e56b248ab217d38907aad38935b2f.zip | |
@export() with linksection option (#14035)
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 9aaa27368f..2b4ef94a8f 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -20328,8 +20328,13 @@ fn resolveExportOptions( const linkage_val = try sema.resolveConstValue(block, linkage_src, linkage_operand, "linkage of exported value must be comptime-known"); const linkage = linkage_val.toEnum(std.builtin.GlobalLinkage); - const section = try sema.fieldVal(block, src, options, "section", section_src); - const section_val = try sema.resolveConstValue(block, section_src, section, "linksection of exported value must be comptime-known"); + const section_operand = try sema.fieldVal(block, src, options, "section", section_src); + const section_opt_val = try sema.resolveConstValue(block, section_src, section_operand, "linksection of exported value must be comptime-known"); + const section_ty = Type.initTag(.const_slice_u8); + const section = if (section_opt_val.optionalValue()) |section_val| + try section_val.toAllocatedBytes(section_ty, sema.arena, sema.mod) + else + null; const visibility_operand = try sema.fieldVal(block, src, options, "visibility", visibility_src); const visibility_val = try sema.resolveConstValue(block, visibility_src, visibility_operand, "visibility of exported value must be comptime-known"); @@ -20345,14 +20350,10 @@ fn resolveExportOptions( }); } - if (!section_val.isNull()) { - return sema.fail(block, section_src, "TODO: implement exporting with linksection", .{}); - } - return std.builtin.ExportOptions{ .name = name, .linkage = linkage, - .section = null, // TODO + .section = section, .visibility = visibility, }; } |
