| ... | @@ -26970,7 +26970,7 @@ fn resolveExternOptions( | ... | @@ -26970,7 +26970,7 @@ fn resolveExternOptions( |
| 26970 | library_name: InternPool.OptionalNullTerminatedString = .none, | 26970 | library_name: InternPool.OptionalNullTerminatedString = .none, |
| 26971 | linkage: std.builtin.GlobalLinkage = .strong, | 26971 | linkage: std.builtin.GlobalLinkage = .strong, |
| 26972 | is_thread_local: bool = false, | 26972 | is_thread_local: bool = false, |
| 26973 | dll_storage_class: std.builtin.DllStorageClass = .default, | 26973 | is_dll_import: bool = false, |
| 26974 | } { | 26974 | } { |
| 26975 | const pt = sema.pt; | 26975 | const pt = sema.pt; |
| 26976 | const zcu = pt.zcu; | 26976 | const zcu = pt.zcu; |
| ... | @@ -26984,7 +26984,7 @@ fn resolveExternOptions( | ... | @@ -26984,7 +26984,7 @@ fn resolveExternOptions( |
| 26984 | const library_src = block.src(.{ .init_field_library = src.offset.node_offset_builtin_call_arg.builtin_call_node }); | 26984 | const library_src = block.src(.{ .init_field_library = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| 26985 | const linkage_src = block.src(.{ .init_field_linkage = src.offset.node_offset_builtin_call_arg.builtin_call_node }); | 26985 | const linkage_src = block.src(.{ .init_field_linkage = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| 26986 | const thread_local_src = block.src(.{ .init_field_thread_local = src.offset.node_offset_builtin_call_arg.builtin_call_node }); | 26986 | const thread_local_src = block.src(.{ .init_field_thread_local = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| 26987 | const dll_storage_class_src = block.src(.{ .init_field_dll_storage_class = src.offset.node_offset_builtin_call_arg.builtin_call_node }); | 26987 | const dll_import_src = block.src(.{ .init_field_dll_import = src.offset.node_offset_builtin_call_arg.builtin_call_node }); |
| 26988 | | 26988 | |
| 26989 | const name_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "name", .no_embedded_nulls), name_src); | 26989 | const name_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "name", .no_embedded_nulls), name_src); |
| 26990 | const name = try sema.toConstString(block, name_src, name_ref, .{ | 26990 | const name = try sema.toConstString(block, name_src, name_ref, .{ |
| ... | @@ -27018,11 +27018,10 @@ fn resolveExternOptions( | ... | @@ -27018,11 +27018,10 @@ fn resolveExternOptions( |
| 27018 | break :library_name library_name; | 27018 | break :library_name library_name; |
| 27019 | } else null; | 27019 | } else null; |
| 27020 | | 27020 | |
| 27021 | const dll_storage_class_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "dll_storage_class", .no_embedded_nulls), dll_storage_class_src); | 27021 | const is_dll_import_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "is_dll_import", .no_embedded_nulls), dll_import_src); |
| 27022 | const dll_storage_class_val = try sema.resolveConstDefinedValue(block, dll_storage_class_src, dll_storage_class_ref, .{ | 27022 | const is_dll_import_val = try sema.resolveConstDefinedValue(block, dll_import_src, is_dll_import_ref, .{ |
| 27023 | .needed_comptime_reason = "dll_storage_class of the extern symbol must be comptime-known", | 27023 | .needed_comptime_reason = "it must be comptime-known if the symbol is imported from a dll", |
| 27024 | }); | 27024 | }); |
| 27025 | const dll_storage_class = zcu.toEnum(std.builtin.DllStorageClass, dll_storage_class_val); | | |
| 27026 | | 27025 | |
| 27027 | if (name.len == 0) { | 27026 | if (name.len == 0) { |
| 27028 | return sema.fail(block, name_src, "extern symbol name cannot be empty", .{}); | 27027 | return sema.fail(block, name_src, "extern symbol name cannot be empty", .{}); |
| ... | @@ -27032,16 +27031,12 @@ fn resolveExternOptions( | ... | @@ -27032,16 +27031,12 @@ fn resolveExternOptions( |
| 27032 | return sema.fail(block, linkage_src, "extern symbol must use strong or weak linkage", .{}); | 27031 | return sema.fail(block, linkage_src, "extern symbol must use strong or weak linkage", .{}); |
| 27033 | } | 27032 | } |
| 27034 | | 27033 | |
| 27035 | if (dll_storage_class == .@"export") { | | |
| 27036 | return sema.fail(block, dll_storage_class_src, "extern symbol cannot have export dll storage class", .{}); | | |
| 27037 | } | | |
| 27038 | | | |
| 27039 | return .{ | 27034 | return .{ |
| 27040 | .name = try ip.getOrPutString(gpa, pt.tid, name, .no_embedded_nulls), | 27035 | .name = try ip.getOrPutString(gpa, pt.tid, name, .no_embedded_nulls), |
| 27041 | .library_name = try ip.getOrPutStringOpt(gpa, pt.tid, library_name, .no_embedded_nulls), | 27036 | .library_name = try ip.getOrPutStringOpt(gpa, pt.tid, library_name, .no_embedded_nulls), |
| 27042 | .linkage = linkage, | 27037 | .linkage = linkage, |
| 27043 | .is_thread_local = is_thread_local_val.toBool(), | 27038 | .is_thread_local = is_thread_local_val.toBool(), |
| 27044 | .dll_storage_class = dll_storage_class, | 27039 | .is_dll_import = is_dll_import_val.toBool(), |
| 27045 | }; | 27040 | }; |
| 27046 | } | 27041 | } |
| 27047 | | 27042 | |
| ... | @@ -27087,7 +27082,7 @@ fn zirBuiltinExtern( | ... | @@ -27087,7 +27082,7 @@ fn zirBuiltinExtern( |
| 27087 | .is_const = ptr_info.flags.is_const, | 27082 | .is_const = ptr_info.flags.is_const, |
| 27088 | .is_threadlocal = options.is_thread_local, | 27083 | .is_threadlocal = options.is_thread_local, |
| 27089 | .is_weak_linkage = options.linkage == .weak, | 27084 | .is_weak_linkage = options.linkage == .weak, |
| 27090 | .is_dll_import = options.dll_storage_class == .import, | 27085 | .is_dll_import = options.is_dll_import, |
| 27091 | .alignment = ptr_info.flags.alignment, | 27086 | .alignment = ptr_info.flags.alignment, |
| 27092 | .@"addrspace" = ptr_info.flags.address_space, | 27087 | .@"addrspace" = ptr_info.flags.address_space, |
| 27093 | // This instruction is just for source locations. | 27088 | // This instruction is just for source locations. |