authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-28 02:36:16-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-28 14:51:56-05:00
logef24f2dd93729493531c427aaac54444597f6e66
treee78381294ccbf2d54c4f9c144f939e6d70a9039d
parentd45ea4d89d7232fc4bcf56a5e088d7d6b5004ebb
signaturelock-open Commit is signed but in an unrecognized format.

remove special darwin os version min handling

now it is integrated with zig's target OS range.

15 files changed, 95 insertions(+), 228 deletions(-)

lib/std/target.zig+18-3
...@@ -147,7 +147,6 @@ pub const Target = struct {...@@ -147,7 +147,6 @@ pub const Target = struct {
147 .cloudabi,147 .cloudabi,
148 .dragonfly,148 .dragonfly,
149 .fuchsia,149 .fuchsia,
150 .ios,
151 .kfreebsd,150 .kfreebsd,
152 .lv2,151 .lv2,
153 .solaris,152 .solaris,
...@@ -162,8 +161,6 @@ pub const Target = struct {...@@ -162,8 +161,6 @@ pub const Target = struct {
162 .amdhsa,161 .amdhsa,
163 .ps4,162 .ps4,
164 .elfiamcu,163 .elfiamcu,
165 .tvos,
166 .watchos,
167 .mesa3d,164 .mesa3d,
168 .contiki,165 .contiki,
169 .amdpal,166 .amdpal,
...@@ -187,6 +184,24 @@ pub const Target = struct {...@@ -187,6 +184,24 @@ pub const Target = struct {
187 .max = .{ .major = 10, .minor = 15, .patch = 3 },184 .max = .{ .major = 10, .minor = 15, .patch = 3 },
188 },185 },
189 },186 },
187 .ios => return .{
188 .semver = .{
189 .min = .{ .major = 12, .minor = 0 },
190 .max = .{ .major = 13, .minor = 4, .patch = 0 },
191 },
192 },
193 .watchos => return .{
194 .semver = .{
195 .min = .{ .major = 6, .minor = 0 },
196 .max = .{ .major = 6, .minor = 2, .patch = 0 },
197 },
198 },
199 .tvos => return .{
200 .semver = .{
201 .min = .{ .major = 13, .minor = 0 },
202 .max = .{ .major = 13, .minor = 4, .patch = 0 },
203 },
204 },
190 .netbsd => return .{205 .netbsd => return .{
191 .semver = .{206 .semver = .{
192 .min = .{ .major = 8, .minor = 0 },207 .min = .{ .major = 8, .minor = 0 },
lib/std/zig/cross_target.zig+3-3
...@@ -88,7 +88,6 @@ pub const CrossTarget = struct {...@@ -88,7 +88,6 @@ pub const CrossTarget = struct {
88 .cloudabi,88 .cloudabi,
89 .dragonfly,89 .dragonfly,
90 .fuchsia,90 .fuchsia,
91 .ios,
92 .kfreebsd,91 .kfreebsd,
93 .lv2,92 .lv2,
94 .solaris,93 .solaris,
...@@ -103,8 +102,6 @@ pub const CrossTarget = struct {...@@ -103,8 +102,6 @@ pub const CrossTarget = struct {
103 .amdhsa,102 .amdhsa,
104 .ps4,103 .ps4,
105 .elfiamcu,104 .elfiamcu,
106 .tvos,
107 .watchos,
108 .mesa3d,105 .mesa3d,
109 .contiki,106 .contiki,
110 .amdpal,107 .amdpal,
...@@ -121,8 +118,11 @@ pub const CrossTarget = struct {...@@ -121,8 +118,11 @@ pub const CrossTarget = struct {
121118
122 .freebsd,119 .freebsd,
123 .macosx,120 .macosx,
121 .ios,
124 .netbsd,122 .netbsd,
125 .openbsd,123 .openbsd,
124 .tvos,
125 .watchos,
126 => {126 => {
127 self.os_version_min = .{ .semver = os.version_range.semver.min };127 self.os_version_min = .{ .semver = os.version_range.semver.min };
128 self.os_version_max = .{ .semver = os.version_range.semver.max };128 self.os_version_max = .{ .semver = os.version_range.semver.max };
src-self-hosted/stage2.zig+26-13
...@@ -892,7 +892,7 @@ const Stage2Target = extern struct {...@@ -892,7 +892,7 @@ const Stage2Target = extern struct {
892892
893 is_native: bool,893 is_native: bool,
894894
895 glibc_version: ?*Stage2GLibCVersion, // null means default895 glibc_or_darwin_version: ?*Stage2SemVer,
896896
897 llvm_cpu_name: ?[*:0]const u8,897 llvm_cpu_name: ?[*:0]const u8,
898 llvm_cpu_features: ?[*:0]const u8,898 llvm_cpu_features: ?[*:0]const u8,
...@@ -1103,16 +1103,29 @@ const Stage2Target = extern struct {...@@ -1103,16 +1103,29 @@ const Stage2Target = extern struct {
1103 os_builtin_str_buffer.toSlice()[os_builtin_str_ver_start_index..os_builtin_str_buffer.len()],1103 os_builtin_str_buffer.toSlice()[os_builtin_str_ver_start_index..os_builtin_str_buffer.len()],
1104 );1104 );
11051105
1106 const glibc_version = if (target.isGnuLibC()) blk: {1106 const glibc_or_darwin_version = blk: {
1107 const stage1_glibc = try std.heap.c_allocator.create(Stage2GLibCVersion);1107 if (target.isGnuLibC()) {
1108 const stage2_glibc = target.os.version_range.linux.glibc;1108 const stage1_glibc = try std.heap.c_allocator.create(Stage2SemVer);
1109 stage1_glibc.* = .{1109 const stage2_glibc = target.os.version_range.linux.glibc;
1110 .major = stage2_glibc.major,1110 stage1_glibc.* = .{
1111 .minor = stage2_glibc.minor,1111 .major = stage2_glibc.major,
1112 .patch = stage2_glibc.patch,1112 .minor = stage2_glibc.minor,
1113 };1113 .patch = stage2_glibc.patch,
1114 break :blk stage1_glibc;1114 };
1115 } else null;1115 break :blk stage1_glibc;
1116 } else if (target.isDarwin()) {
1117 const stage1_semver = try std.heap.c_allocator.create(Stage2SemVer);
1118 const stage2_semver = target.os.version_range.semver.min;
1119 stage1_semver.* = .{
1120 .major = stage2_semver.major,
1121 .minor = stage2_semver.minor,
1122 .patch = stage2_semver.patch,
1123 };
1124 break :blk stage1_semver;
1125 } else {
1126 break :blk null;
1127 }
1128 };
11161129
1117 self.* = .{1130 self.* = .{
1118 .arch = @enumToInt(target.cpu.arch) + 1, // skip over ZigLLVM_UnknownArch1131 .arch = @enumToInt(target.cpu.arch) + 1, // skip over ZigLLVM_UnknownArch
...@@ -1125,7 +1138,7 @@ const Stage2Target = extern struct {...@@ -1125,7 +1138,7 @@ const Stage2Target = extern struct {
1125 .os_builtin_str = os_builtin_str_buffer.toOwnedSlice().ptr,1138 .os_builtin_str = os_builtin_str_buffer.toOwnedSlice().ptr,
1126 .cache_hash = cache_hash.toOwnedSlice().ptr,1139 .cache_hash = cache_hash.toOwnedSlice().ptr,
1127 .is_native = cross_target.isNative(),1140 .is_native = cross_target.isNative(),
1128 .glibc_version = glibc_version,1141 .glibc_or_darwin_version = glibc_or_darwin_version,
1129 .dynamic_linker = dynamic_linker,1142 .dynamic_linker = dynamic_linker,
1130 };1143 };
1131 }1144 }
...@@ -1179,7 +1192,7 @@ fn crossTargetToTarget(cross_target: CrossTarget, dynamic_linker_ptr: *?[*:0]u8)...@@ -1179,7 +1192,7 @@ fn crossTargetToTarget(cross_target: CrossTarget, dynamic_linker_ptr: *?[*:0]u8)
1179}1192}
11801193
1181// ABI warning1194// ABI warning
1182const Stage2GLibCVersion = extern struct {1195const Stage2SemVer = extern struct {
1183 major: u32,1196 major: u32,
1184 minor: u32,1197 minor: u32,
1185 patch: u32,1198 patch: u32,
src/all_types.hpp-2
...@@ -2250,8 +2250,6 @@ struct CodeGen {...@@ -2250,8 +2250,6 @@ struct CodeGen {
2250 bool test_is_evented;2250 bool test_is_evented;
2251 CodeModel code_model;2251 CodeModel code_model;
22522252
2253 Buf *mmacosx_version_min;
2254 Buf *mios_version_min;
2255 Buf *root_out_name;2253 Buf *root_out_name;
2256 Buf *test_filter;2254 Buf *test_filter;
2257 Buf *test_name_prefix;2255 Buf *test_name_prefix;
src/codegen.cpp+8-51
...@@ -32,31 +32,6 @@ enum ResumeId {...@@ -32,31 +32,6 @@ enum ResumeId {
32 ResumeIdCall,32 ResumeIdCall,
33};33};
3434
35static void init_darwin_native(CodeGen *g) {
36 char *osx_target = getenv("MACOSX_DEPLOYMENT_TARGET");
37 char *ios_target = getenv("IPHONEOS_DEPLOYMENT_TARGET");
38
39 // Allow conflicts among OSX and iOS, but choose the default platform.
40 if (osx_target && ios_target) {
41 if (g->zig_target->arch == ZigLLVM_arm ||
42 g->zig_target->arch == ZigLLVM_aarch64 ||
43 g->zig_target->arch == ZigLLVM_thumb)
44 {
45 osx_target = nullptr;
46 } else {
47 ios_target = nullptr;
48 }
49 }
50
51 if (osx_target) {
52 g->mmacosx_version_min = buf_create_from_str(osx_target);
53 } else if (ios_target) {
54 g->mios_version_min = buf_create_from_str(ios_target);
55 } else if (g->zig_target->os != OsIOS) {
56 g->mmacosx_version_min = buf_create_from_str("10.14");
57 }
58}
59
60static ZigPackage *new_package(const char *root_src_dir, const char *root_src_path, const char *pkg_path) {35static ZigPackage *new_package(const char *root_src_dir, const char *root_src_path, const char *pkg_path) {
61 ZigPackage *entry = heap::c_allocator.create<ZigPackage>();36 ZigPackage *entry = heap::c_allocator.create<ZigPackage>();
62 entry->package_table.init(4);37 entry->package_table.init(4);
...@@ -160,14 +135,6 @@ void codegen_add_framework(CodeGen *g, const char *framework) {...@@ -160,14 +135,6 @@ void codegen_add_framework(CodeGen *g, const char *framework) {
160 g->darwin_frameworks.append(buf_create_from_str(framework));135 g->darwin_frameworks.append(buf_create_from_str(framework));
161}136}
162137
163void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min) {
164 g->mmacosx_version_min = mmacosx_version_min;
165}
166
167void codegen_set_mios_version_min(CodeGen *g, Buf *mios_version_min) {
168 g->mios_version_min = mios_version_min;
169}
170
171void codegen_set_rdynamic(CodeGen *g, bool rdynamic) {138void codegen_set_rdynamic(CodeGen *g, bool rdynamic) {
172 g->linker_rdynamic = rdynamic;139 g->linker_rdynamic = rdynamic;
173}140}
...@@ -8655,10 +8622,10 @@ static Error define_builtin_compile_vars(CodeGen *g) {...@@ -8655,10 +8622,10 @@ static Error define_builtin_compile_vars(CodeGen *g) {
8655 if (g->zig_target->cache_hash != nullptr) {8622 if (g->zig_target->cache_hash != nullptr) {
8656 cache_str(&cache_hash, g->zig_target->cache_hash);8623 cache_str(&cache_hash, g->zig_target->cache_hash);
8657 }8624 }
8658 if (g->zig_target->glibc_version != nullptr) {8625 if (g->zig_target->glibc_or_darwin_version != nullptr) {
8659 cache_int(&cache_hash, g->zig_target->glibc_version->major);8626 cache_int(&cache_hash, g->zig_target->glibc_or_darwin_version->major);
8660 cache_int(&cache_hash, g->zig_target->glibc_version->minor);8627 cache_int(&cache_hash, g->zig_target->glibc_or_darwin_version->minor);
8661 cache_int(&cache_hash, g->zig_target->glibc_version->patch);8628 cache_int(&cache_hash, g->zig_target->glibc_or_darwin_version->patch);
8662 }8629 }
8663 cache_bool(&cache_hash, g->have_err_ret_tracing);8630 cache_bool(&cache_hash, g->have_err_ret_tracing);
8664 cache_bool(&cache_hash, g->libc_link_lib != nullptr);8631 cache_bool(&cache_hash, g->libc_link_lib != nullptr);
...@@ -10313,10 +10280,10 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {...@@ -10313,10 +10280,10 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
10313 if (g->zig_target->cache_hash != nullptr) {10280 if (g->zig_target->cache_hash != nullptr) {
10314 cache_str(ch, g->zig_target->cache_hash);10281 cache_str(ch, g->zig_target->cache_hash);
10315 }10282 }
10316 if (g->zig_target->glibc_version != nullptr) {10283 if (g->zig_target->glibc_or_darwin_version != nullptr) {
10317 cache_int(ch, g->zig_target->glibc_version->major);10284 cache_int(ch, g->zig_target->glibc_or_darwin_version->major);
10318 cache_int(ch, g->zig_target->glibc_version->minor);10285 cache_int(ch, g->zig_target->glibc_or_darwin_version->minor);
10319 cache_int(ch, g->zig_target->glibc_version->patch);10286 cache_int(ch, g->zig_target->glibc_or_darwin_version->patch);
10320 }10287 }
10321 cache_int(ch, detect_subsystem(g));10288 cache_int(ch, detect_subsystem(g));
10322 cache_bool(ch, g->strip_debug_symbols);10289 cache_bool(ch, g->strip_debug_symbols);
...@@ -10344,8 +10311,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {...@@ -10344,8 +10311,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
10344 cache_bool(ch, g->emit_bin);10311 cache_bool(ch, g->emit_bin);
10345 cache_bool(ch, g->emit_llvm_ir);10312 cache_bool(ch, g->emit_llvm_ir);
10346 cache_bool(ch, g->emit_asm);10313 cache_bool(ch, g->emit_asm);
10347 cache_buf_opt(ch, g->mmacosx_version_min);
10348 cache_buf_opt(ch, g->mios_version_min);
10349 cache_usize(ch, g->version_major);10314 cache_usize(ch, g->version_major);
10350 cache_usize(ch, g->version_minor);10315 cache_usize(ch, g->version_minor);
10351 cache_usize(ch, g->version_patch);10316 cache_usize(ch, g->version_patch);
...@@ -10662,9 +10627,6 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o...@@ -10662,9 +10627,6 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o
1066210627
10663 codegen_set_errmsg_color(child_gen, parent_gen->err_color);10628 codegen_set_errmsg_color(child_gen, parent_gen->err_color);
1066410629
10665 codegen_set_mmacosx_version_min(child_gen, parent_gen->mmacosx_version_min);
10666 codegen_set_mios_version_min(child_gen, parent_gen->mios_version_min);
10667
10668 child_gen->enable_cache = true;10630 child_gen->enable_cache = true;
1066910631
10670 return child_gen;10632 return child_gen;
...@@ -10772,11 +10734,6 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget...@@ -10772,11 +10734,6 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget
10772 g->each_lib_rpath = false;10734 g->each_lib_rpath = false;
10773 } else {10735 } else {
10774 g->each_lib_rpath = true;10736 g->each_lib_rpath = true;
10775
10776 if (target_os_is_darwin(g->zig_target->os)) {
10777 init_darwin_native(g);
10778 }
10779
10780 }10737 }
1078110738
10782 if (target_os_requires_libc(g->zig_target->os)) {10739 if (target_os_requires_libc(g->zig_target->os)) {
src/codegen.hpp-2
...@@ -35,8 +35,6 @@ LinkLib *codegen_add_link_lib(CodeGen *codegen, Buf *lib);...@@ -35,8 +35,6 @@ LinkLib *codegen_add_link_lib(CodeGen *codegen, Buf *lib);
35void codegen_add_framework(CodeGen *codegen, const char *name);35void codegen_add_framework(CodeGen *codegen, const char *name);
36void codegen_add_rpath(CodeGen *codegen, const char *name);36void codegen_add_rpath(CodeGen *codegen, const char *name);
37void codegen_set_rdynamic(CodeGen *g, bool rdynamic);37void codegen_set_rdynamic(CodeGen *g, bool rdynamic);
38void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min);
39void codegen_set_mios_version_min(CodeGen *g, Buf *mios_version_min);
40void codegen_set_linker_script(CodeGen *g, const char *linker_script);38void codegen_set_linker_script(CodeGen *g, const char *linker_script);
41void codegen_set_test_filter(CodeGen *g, Buf *filter);39void codegen_set_test_filter(CodeGen *g, Buf *filter);
42void codegen_set_test_name_prefix(CodeGen *g, Buf *prefix);40void codegen_set_test_name_prefix(CodeGen *g, Buf *prefix);
src/glibc.cpp+13-13
...@@ -55,7 +55,7 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo...@@ -55,7 +55,7 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo
55 Optional<Slice<uint8_t>> opt_component = SplitIterator_next(&it);55 Optional<Slice<uint8_t>> opt_component = SplitIterator_next(&it);
56 if (!opt_component.is_some) break;56 if (!opt_component.is_some) break;
57 Buf *ver_buf = buf_create_from_slice(opt_component.value);57 Buf *ver_buf = buf_create_from_slice(opt_component.value);
58 ZigGLibCVersion *this_ver = glibc_abi->all_versions.add_one();58 Stage2SemVer *this_ver = glibc_abi->all_versions.add_one();
59 if ((err = target_parse_glibc_version(this_ver, buf_ptr(ver_buf)))) {59 if ((err = target_parse_glibc_version(this_ver, buf_ptr(ver_buf)))) {
60 if (verbose) {60 if (verbose) {
61 fprintf(stderr, "Unable to parse glibc version '%s': %s\n", buf_ptr(ver_buf), err_str(err));61 fprintf(stderr, "Unable to parse glibc version '%s': %s\n", buf_ptr(ver_buf), err_str(err));
...@@ -186,9 +186,9 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con...@@ -186,9 +186,9 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
186 cache_buf(cache_hash, compiler_id);186 cache_buf(cache_hash, compiler_id);
187 cache_int(cache_hash, target->arch);187 cache_int(cache_hash, target->arch);
188 cache_int(cache_hash, target->abi);188 cache_int(cache_hash, target->abi);
189 cache_int(cache_hash, target->glibc_version->major);189 cache_int(cache_hash, target->glibc_or_darwin_version->major);
190 cache_int(cache_hash, target->glibc_version->minor);190 cache_int(cache_hash, target->glibc_or_darwin_version->minor);
191 cache_int(cache_hash, target->glibc_version->patch);191 cache_int(cache_hash, target->glibc_or_darwin_version->patch);
192192
193 Buf digest = BUF_INIT;193 Buf digest = BUF_INIT;
194 buf_resize(&digest, 0);194 buf_resize(&digest, 0);
...@@ -224,10 +224,10 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con...@@ -224,10 +224,10 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
224224
225 uint8_t target_ver_index = 0;225 uint8_t target_ver_index = 0;
226 for (;target_ver_index < glibc_abi->all_versions.length; target_ver_index += 1) {226 for (;target_ver_index < glibc_abi->all_versions.length; target_ver_index += 1) {
227 const ZigGLibCVersion *this_ver = &glibc_abi->all_versions.at(target_ver_index);227 const Stage2SemVer *this_ver = &glibc_abi->all_versions.at(target_ver_index);
228 if (this_ver->major == target->glibc_version->major &&228 if (this_ver->major == target->glibc_or_darwin_version->major &&
229 this_ver->minor == target->glibc_version->minor &&229 this_ver->minor == target->glibc_or_darwin_version->minor &&
230 this_ver->patch == target->glibc_version->patch)230 this_ver->patch == target->glibc_or_darwin_version->patch)
231 {231 {
232 break;232 break;
233 }233 }
...@@ -235,9 +235,9 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con...@@ -235,9 +235,9 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
235 if (target_ver_index == glibc_abi->all_versions.length) {235 if (target_ver_index == glibc_abi->all_versions.length) {
236 if (verbose) {236 if (verbose) {
237 fprintf(stderr, "Unrecognized glibc version: %d.%d.%d\n",237 fprintf(stderr, "Unrecognized glibc version: %d.%d.%d\n",
238 target->glibc_version->major,238 target->glibc_or_darwin_version->major,
239 target->glibc_version->minor,239 target->glibc_or_darwin_version->minor,
240 target->glibc_version->patch);240 target->glibc_or_darwin_version->patch);
241 }241 }
242 return ErrorUnknownABI;242 return ErrorUnknownABI;
243 }243 }
...@@ -246,7 +246,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con...@@ -246,7 +246,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
246 Buf *map_contents = buf_alloc();246 Buf *map_contents = buf_alloc();
247247
248 for (uint8_t ver_i = 0; ver_i < glibc_abi->all_versions.length; ver_i += 1) {248 for (uint8_t ver_i = 0; ver_i < glibc_abi->all_versions.length; ver_i += 1) {
249 const ZigGLibCVersion *ver = &glibc_abi->all_versions.at(ver_i);249 const Stage2SemVer *ver = &glibc_abi->all_versions.at(ver_i);
250 if (ver->patch == 0) {250 if (ver->patch == 0) {
251 buf_appendf(map_contents, "GLIBC_%d.%d { };\n", ver->major, ver->minor);251 buf_appendf(map_contents, "GLIBC_%d.%d { };\n", ver->major, ver->minor);
252 } else {252 } else {
...@@ -294,7 +294,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con...@@ -294,7 +294,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
294 uint8_t ver_index = ver_list->versions[ver_i];294 uint8_t ver_index = ver_list->versions[ver_i];
295295
296 Buf *stub_name;296 Buf *stub_name;
297 const ZigGLibCVersion *ver = &glibc_abi->all_versions.at(ver_index);297 const Stage2SemVer *ver = &glibc_abi->all_versions.at(ver_index);
298 const char *sym_name = buf_ptr(libc_fn->name);298 const char *sym_name = buf_ptr(libc_fn->name);
299 if (ver->patch == 0) {299 if (ver->patch == 0) {
300 stub_name = buf_sprintf("%s_%d_%d", sym_name, ver->major, ver->minor);300 stub_name = buf_sprintf("%s_%d_%d", sym_name, ver->major, ver->minor);
src/glibc.hpp+1-1
...@@ -32,7 +32,7 @@ struct ZigGLibCAbi {...@@ -32,7 +32,7 @@ struct ZigGLibCAbi {
32 Buf *abi_txt_path;32 Buf *abi_txt_path;
33 Buf *vers_txt_path;33 Buf *vers_txt_path;
34 Buf *fns_txt_path;34 Buf *fns_txt_path;
35 ZigList<ZigGLibCVersion> all_versions;35 ZigList<Stage2SemVer> all_versions;
36 ZigList<ZigGLibCFn> all_functions;36 ZigList<ZigGLibCFn> all_functions;
37 // The value is a pointer to all_functions.length items and each item is an index37 // The value is a pointer to all_functions.length items and each item is an index
38 // into all_functions.38 // into all_functions.
src/link.cpp+17-110
...@@ -2371,99 +2371,6 @@ static void construct_linker_job_coff(LinkJob *lj) {...@@ -2371,99 +2371,6 @@ static void construct_linker_job_coff(LinkJob *lj) {
2371 }2371 }
2372}2372}
23732373
2374
2375// Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and return the
2376// grouped values as integers. Numbers which are not provided are set to 0.
2377// return true if the entire string was parsed (9.2), or all groups were
2378// parsed (10.3.5extrastuff).
2379static bool darwin_get_release_version(const char *str, int *major, int *minor, int *micro, bool *had_extra) {
2380 *had_extra = false;
2381
2382 *major = 0;
2383 *minor = 0;
2384 *micro = 0;
2385
2386 if (*str == '\0')
2387 return false;
2388
2389 char *end;
2390 *major = (int)strtol(str, &end, 10);
2391 if (*str != '\0' && *end == '\0')
2392 return true;
2393 if (*end != '.')
2394 return false;
2395
2396 str = end + 1;
2397 *minor = (int)strtol(str, &end, 10);
2398 if (*str != '\0' && *end == '\0')
2399 return true;
2400 if (*end != '.')
2401 return false;
2402
2403 str = end + 1;
2404 *micro = (int)strtol(str, &end, 10);
2405 if (*str != '\0' && *end == '\0')
2406 return true;
2407 if (str == end)
2408 return false;
2409 *had_extra = true;
2410 return true;
2411}
2412
2413enum DarwinPlatformKind {
2414 MacOS,
2415 IPhoneOS,
2416 IPhoneOSSimulator,
2417};
2418
2419struct DarwinPlatform {
2420 DarwinPlatformKind kind;
2421 int major;
2422 int minor;
2423 int micro;
2424};
2425
2426static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) {
2427 CodeGen *g = lj->codegen;
2428
2429 if (g->mmacosx_version_min) {
2430 platform->kind = MacOS;
2431 } else if (g->mios_version_min) {
2432 platform->kind = IPhoneOS;
2433 } else if (g->zig_target->os == OsMacOSX) {
2434 platform->kind = MacOS;
2435 g->mmacosx_version_min = buf_create_from_str("10.14");
2436 } else {
2437 zig_panic("unable to infer -mmacosx-version-min or -mios-version-min");
2438 }
2439
2440 bool had_extra;
2441 if (platform->kind == MacOS) {
2442 if (!darwin_get_release_version(buf_ptr(g->mmacosx_version_min),
2443 &platform->major, &platform->minor, &platform->micro, &had_extra) ||
2444 had_extra || platform->major != 10 || platform->minor >= 100 || platform->micro >= 100)
2445 {
2446 zig_panic("invalid -mmacosx-version-min");
2447 }
2448 } else if (platform->kind == IPhoneOS) {
2449 if (!darwin_get_release_version(buf_ptr(g->mios_version_min),
2450 &platform->major, &platform->minor, &platform->micro, &had_extra) ||
2451 had_extra || platform->major >= 10 || platform->minor >= 100 || platform->micro >= 100)
2452 {
2453 zig_panic("invalid -mios-version-min");
2454 }
2455 } else {
2456 zig_unreachable();
2457 }
2458
2459 if (platform->kind == IPhoneOS &&
2460 (g->zig_target->arch == ZigLLVM_x86 ||
2461 g->zig_target->arch == ZigLLVM_x86_64))
2462 {
2463 platform->kind = IPhoneOSSimulator;
2464 }
2465}
2466
2467static void construct_linker_job_macho(LinkJob *lj) {2374static void construct_linker_job_macho(LinkJob *lj) {
2468 CodeGen *g = lj->codegen;2375 CodeGen *g = lj->codegen;
24692376
...@@ -2507,25 +2414,25 @@ static void construct_linker_job_macho(LinkJob *lj) {...@@ -2507,25 +2414,25 @@ static void construct_linker_job_macho(LinkJob *lj) {
2507 lj->args.append("-arch");2414 lj->args.append("-arch");
2508 lj->args.append(get_darwin_arch_string(g->zig_target));2415 lj->args.append(get_darwin_arch_string(g->zig_target));
25092416
2510 DarwinPlatform platform;2417 if (g->zig_target->glibc_or_darwin_version != nullptr) {
2511 get_darwin_platform(lj, &platform);2418 if (g->zig_target->os == OsMacOSX) {
2512 switch (platform.kind) {
2513 case MacOS:
2514 lj->args.append("-macosx_version_min");2419 lj->args.append("-macosx_version_min");
2515 break;2420 } else if (g->zig_target->os == OsIOS) {
2516 case IPhoneOS:2421 if (g->zig_target->arch == ZigLLVM_x86 || g->zig_target->arch == ZigLLVM_x86_64) {
2517 lj->args.append("-iphoneos_version_min");2422 lj->args.append("-ios_simulator_version_min");
2518 break;2423 } else {
2519 case IPhoneOSSimulator:2424 lj->args.append("-iphoneos_version_min");
2520 lj->args.append("-ios_simulator_version_min");2425 }
2521 break;2426 }
2522 }2427 Buf *version_string = buf_sprintf("%d.%d.%d",
2523 Buf *version_string = buf_sprintf("%d.%d.%d", platform.major, platform.minor, platform.micro);2428 g->zig_target->glibc_or_darwin_version->major,
2524 lj->args.append(buf_ptr(version_string));2429 g->zig_target->glibc_or_darwin_version->minor,
25252430 g->zig_target->glibc_or_darwin_version->patch);
2526 lj->args.append("-sdk_version");2431 lj->args.append(buf_ptr(version_string));
2527 lj->args.append(buf_ptr(version_string));
25282432
2433 lj->args.append("-sdk_version");
2434 lj->args.append(buf_ptr(version_string));
2435 }
25292436
2530 if (g->out_type == OutTypeExe) {2437 if (g->out_type == OutTypeExe) {
2531 lj->args.append("-pie");2438 lj->args.append("-pie");
src/main.cpp-20
...@@ -127,8 +127,6 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {...@@ -127,8 +127,6 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
127 " --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"127 " --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"
128 " -F[dir] (darwin) add search path for frameworks\n"128 " -F[dir] (darwin) add search path for frameworks\n"
129 " -framework [name] (darwin) link against framework\n"129 " -framework [name] (darwin) link against framework\n"
130 " -mios-version-min [ver] (darwin) set iOS deployment target\n"
131 " -mmacosx-version-min [ver] (darwin) set Mac OS X deployment target\n"
132 " --ver-major [ver] dynamic library semver major version\n"130 " --ver-major [ver] dynamic library semver major version\n"
133 " --ver-minor [ver] dynamic library semver minor version\n"131 " --ver-minor [ver] dynamic library semver minor version\n"
134 " --ver-patch [ver] dynamic library semver patch version\n"132 " --ver-patch [ver] dynamic library semver patch version\n"
...@@ -414,8 +412,6 @@ static int main0(int argc, char **argv) {...@@ -414,8 +412,6 @@ static int main0(int argc, char **argv) {
414 bool have_libc = false;412 bool have_libc = false;
415 const char *target_string = nullptr;413 const char *target_string = nullptr;
416 bool rdynamic = false;414 bool rdynamic = false;
417 const char *mmacosx_version_min = nullptr;
418 const char *mios_version_min = nullptr;
419 const char *linker_script = nullptr;415 const char *linker_script = nullptr;
420 Buf *version_script = nullptr;416 Buf *version_script = nullptr;
421 ZigList<const char *> rpath_list = {0};417 ZigList<const char *> rpath_list = {0};
...@@ -844,10 +840,6 @@ static int main0(int argc, char **argv) {...@@ -844,10 +840,6 @@ static int main0(int argc, char **argv) {
844 cache_dir = argv[i];840 cache_dir = argv[i];
845 } else if (strcmp(arg, "-target") == 0) {841 } else if (strcmp(arg, "-target") == 0) {
846 target_string = argv[i];842 target_string = argv[i];
847 } else if (strcmp(arg, "-mmacosx-version-min") == 0) {
848 mmacosx_version_min = argv[i];
849 } else if (strcmp(arg, "-mios-version-min") == 0) {
850 mios_version_min = argv[i];
851 } else if (strcmp(arg, "-framework") == 0) {843 } else if (strcmp(arg, "-framework") == 0) {
852 frameworks.append(argv[i]);844 frameworks.append(argv[i]);
853 } else if (strcmp(arg, "--linker-script") == 0) {845 } else if (strcmp(arg, "--linker-script") == 0) {
...@@ -1240,18 +1232,6 @@ static int main0(int argc, char **argv) {...@@ -1240,18 +1232,6 @@ static int main0(int argc, char **argv) {
1240 }1232 }
12411233
1242 codegen_set_rdynamic(g, rdynamic);1234 codegen_set_rdynamic(g, rdynamic);
1243 if (mmacosx_version_min && mios_version_min) {
1244 fprintf(stderr, "-mmacosx-version-min and -mios-version-min options not allowed together\n");
1245 return main_exit(root_progress_node, EXIT_FAILURE);
1246 }
1247
1248 if (mmacosx_version_min) {
1249 codegen_set_mmacosx_version_min(g, buf_create_from_str(mmacosx_version_min));
1250 }
1251
1252 if (mios_version_min) {
1253 codegen_set_mios_version_min(g, buf_create_from_str(mios_version_min));
1254 }
12551235
1256 if (test_filter) {1236 if (test_filter) {
1257 codegen_set_test_filter(g, buf_create_from_str(test_filter));1237 codegen_set_test_filter(g, buf_create_from_str(test_filter));
src/stage2.cpp+1-1
...@@ -186,7 +186,7 @@ static void get_native_target(ZigTarget *target) {...@@ -186,7 +186,7 @@ static void get_native_target(ZigTarget *target) {
186 target->abi = target_default_abi(target->arch, target->os);186 target->abi = target_default_abi(target->arch, target->os);
187 }187 }
188 if (target_is_glibc(target)) {188 if (target_is_glibc(target)) {
189 target->glibc_version = heap::c_allocator.create<ZigGLibCVersion>();189 target->glibc_or_darwin_version = heap::c_allocator.create<Stage2SemVer>();
190 target_init_default_glibc_version(target);190 target_init_default_glibc_version(target);
191 }191 }
192}192}
src/stage2.h+4-5
...@@ -270,14 +270,12 @@ enum Os {...@@ -270,14 +270,12 @@ enum Os {
270};270};
271271
272// ABI warning272// ABI warning
273struct ZigGLibCVersion {273struct Stage2SemVer {
274 uint32_t major; // always 2274 uint32_t major;
275 uint32_t minor;275 uint32_t minor;
276 uint32_t patch;276 uint32_t patch;
277};277};
278278
279struct Stage2TargetData;
280
281// ABI warning279// ABI warning
282struct ZigTarget {280struct ZigTarget {
283 enum ZigLLVM_ArchType arch;281 enum ZigLLVM_ArchType arch;
...@@ -288,7 +286,8 @@ struct ZigTarget {...@@ -288,7 +286,8 @@ struct ZigTarget {
288286
289 bool is_native;287 bool is_native;
290288
291 struct ZigGLibCVersion *glibc_version; // null means default289 // null means default. this is double-purposed to be darwin min version
290 struct Stage2SemVer *glibc_or_darwin_version;
292291
293 const char *llvm_cpu_name;292 const char *llvm_cpu_name;
294 const char *llvm_cpu_features;293 const char *llvm_cpu_features;
src/target.cpp+2-2
...@@ -347,7 +347,7 @@ const char *target_abi_name(ZigLLVM_EnvironmentType abi) {...@@ -347,7 +347,7 @@ const char *target_abi_name(ZigLLVM_EnvironmentType abi) {
347 return ZigLLVMGetEnvironmentTypeName(abi);347 return ZigLLVMGetEnvironmentTypeName(abi);
348}348}
349349
350Error target_parse_glibc_version(ZigGLibCVersion *glibc_ver, const char *text) {350Error target_parse_glibc_version(Stage2SemVer *glibc_ver, const char *text) {
351 glibc_ver->major = 2;351 glibc_ver->major = 2;
352 glibc_ver->minor = 0;352 glibc_ver->minor = 0;
353 glibc_ver->patch = 0;353 glibc_ver->patch = 0;
...@@ -371,7 +371,7 @@ Error target_parse_glibc_version(ZigGLibCVersion *glibc_ver, const char *text) {...@@ -371,7 +371,7 @@ Error target_parse_glibc_version(ZigGLibCVersion *glibc_ver, const char *text) {
371}371}
372372
373void target_init_default_glibc_version(ZigTarget *target) {373void target_init_default_glibc_version(ZigTarget *target) {
374 *target->glibc_version = {2, 17, 0};374 *target->glibc_or_darwin_version = {2, 17, 0};
375}375}
376376
377Error target_parse_arch(ZigLLVM_ArchType *out_arch, const char *arch_ptr, size_t arch_len) {377Error target_parse_arch(ZigLLVM_ArchType *out_arch, const char *arch_ptr, size_t arch_len) {
src/target.hpp+1-1
...@@ -46,7 +46,7 @@ Error target_parse_arch(ZigLLVM_ArchType *arch, const char *arch_ptr, size_t arc...@@ -46,7 +46,7 @@ Error target_parse_arch(ZigLLVM_ArchType *arch, const char *arch_ptr, size_t arc
46Error target_parse_os(Os *os, const char *os_ptr, size_t os_len);46Error target_parse_os(Os *os, const char *os_ptr, size_t os_len);
47Error target_parse_abi(ZigLLVM_EnvironmentType *abi, const char *abi_ptr, size_t abi_len);47Error target_parse_abi(ZigLLVM_EnvironmentType *abi, const char *abi_ptr, size_t abi_len);
4848
49Error target_parse_glibc_version(ZigGLibCVersion *out, const char *text);49Error target_parse_glibc_version(Stage2SemVer *out, const char *text);
50void target_init_default_glibc_version(ZigTarget *target);50void target_init_default_glibc_version(ZigTarget *target);
5151
52size_t target_arch_count(void);52size_t target_arch_count(void);
test/cli.zig+1-1
...@@ -92,7 +92,7 @@ fn testZigInitLib(zig_exe: []const u8, dir_path: []const u8) !void {...@@ -92,7 +92,7 @@ fn testZigInitLib(zig_exe: []const u8, dir_path: []const u8) !void {
92fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void {92fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void {
93 _ = try exec(dir_path, &[_][]const u8{ zig_exe, "init-exe" });93 _ = try exec(dir_path, &[_][]const u8{ zig_exe, "init-exe" });
94 const run_result = try exec(dir_path, &[_][]const u8{ zig_exe, "build", "run" });94 const run_result = try exec(dir_path, &[_][]const u8{ zig_exe, "build", "run" });
95 testing.expect(std.mem.eql(u8, run_result.stderr, "All your base are belong to us.\n"));95 testing.expect(std.mem.eql(u8, run_result.stderr, "All your codebase are belong to us.\n"));
96}96}
9797
98fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {98fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {