mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 13:58:27 +00:00
remove special darwin os version min handling
now it is integrated with zig's target OS range.
This commit is contained in:
parent
d45ea4d89d
commit
ef24f2dd93
@ -147,7 +147,6 @@ pub const Target = struct {
|
||||
.cloudabi,
|
||||
.dragonfly,
|
||||
.fuchsia,
|
||||
.ios,
|
||||
.kfreebsd,
|
||||
.lv2,
|
||||
.solaris,
|
||||
@ -162,8 +161,6 @@ pub const Target = struct {
|
||||
.amdhsa,
|
||||
.ps4,
|
||||
.elfiamcu,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.mesa3d,
|
||||
.contiki,
|
||||
.amdpal,
|
||||
@ -187,6 +184,24 @@ pub const Target = struct {
|
||||
.max = .{ .major = 10, .minor = 15, .patch = 3 },
|
||||
},
|
||||
},
|
||||
.ios => return .{
|
||||
.semver = .{
|
||||
.min = .{ .major = 12, .minor = 0 },
|
||||
.max = .{ .major = 13, .minor = 4, .patch = 0 },
|
||||
},
|
||||
},
|
||||
.watchos => return .{
|
||||
.semver = .{
|
||||
.min = .{ .major = 6, .minor = 0 },
|
||||
.max = .{ .major = 6, .minor = 2, .patch = 0 },
|
||||
},
|
||||
},
|
||||
.tvos => return .{
|
||||
.semver = .{
|
||||
.min = .{ .major = 13, .minor = 0 },
|
||||
.max = .{ .major = 13, .minor = 4, .patch = 0 },
|
||||
},
|
||||
},
|
||||
.netbsd => return .{
|
||||
.semver = .{
|
||||
.min = .{ .major = 8, .minor = 0 },
|
||||
|
||||
@ -88,7 +88,6 @@ pub const CrossTarget = struct {
|
||||
.cloudabi,
|
||||
.dragonfly,
|
||||
.fuchsia,
|
||||
.ios,
|
||||
.kfreebsd,
|
||||
.lv2,
|
||||
.solaris,
|
||||
@ -103,8 +102,6 @@ pub const CrossTarget = struct {
|
||||
.amdhsa,
|
||||
.ps4,
|
||||
.elfiamcu,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.mesa3d,
|
||||
.contiki,
|
||||
.amdpal,
|
||||
@ -121,8 +118,11 @@ pub const CrossTarget = struct {
|
||||
|
||||
.freebsd,
|
||||
.macosx,
|
||||
.ios,
|
||||
.netbsd,
|
||||
.openbsd,
|
||||
.tvos,
|
||||
.watchos,
|
||||
=> {
|
||||
self.os_version_min = .{ .semver = os.version_range.semver.min };
|
||||
self.os_version_max = .{ .semver = os.version_range.semver.max };
|
||||
|
||||
@ -892,7 +892,7 @@ const Stage2Target = extern struct {
|
||||
|
||||
is_native: bool,
|
||||
|
||||
glibc_version: ?*Stage2GLibCVersion, // null means default
|
||||
glibc_or_darwin_version: ?*Stage2SemVer,
|
||||
|
||||
llvm_cpu_name: ?[*:0]const u8,
|
||||
llvm_cpu_features: ?[*:0]const u8,
|
||||
@ -1103,16 +1103,29 @@ const Stage2Target = extern struct {
|
||||
os_builtin_str_buffer.toSlice()[os_builtin_str_ver_start_index..os_builtin_str_buffer.len()],
|
||||
);
|
||||
|
||||
const glibc_version = if (target.isGnuLibC()) blk: {
|
||||
const stage1_glibc = try std.heap.c_allocator.create(Stage2GLibCVersion);
|
||||
const stage2_glibc = target.os.version_range.linux.glibc;
|
||||
stage1_glibc.* = .{
|
||||
.major = stage2_glibc.major,
|
||||
.minor = stage2_glibc.minor,
|
||||
.patch = stage2_glibc.patch,
|
||||
};
|
||||
break :blk stage1_glibc;
|
||||
} else null;
|
||||
const glibc_or_darwin_version = blk: {
|
||||
if (target.isGnuLibC()) {
|
||||
const stage1_glibc = try std.heap.c_allocator.create(Stage2SemVer);
|
||||
const stage2_glibc = target.os.version_range.linux.glibc;
|
||||
stage1_glibc.* = .{
|
||||
.major = stage2_glibc.major,
|
||||
.minor = stage2_glibc.minor,
|
||||
.patch = stage2_glibc.patch,
|
||||
};
|
||||
break :blk stage1_glibc;
|
||||
} else if (target.isDarwin()) {
|
||||
const stage1_semver = try std.heap.c_allocator.create(Stage2SemVer);
|
||||
const stage2_semver = target.os.version_range.semver.min;
|
||||
stage1_semver.* = .{
|
||||
.major = stage2_semver.major,
|
||||
.minor = stage2_semver.minor,
|
||||
.patch = stage2_semver.patch,
|
||||
};
|
||||
break :blk stage1_semver;
|
||||
} else {
|
||||
break :blk null;
|
||||
}
|
||||
};
|
||||
|
||||
self.* = .{
|
||||
.arch = @enumToInt(target.cpu.arch) + 1, // skip over ZigLLVM_UnknownArch
|
||||
@ -1125,7 +1138,7 @@ const Stage2Target = extern struct {
|
||||
.os_builtin_str = os_builtin_str_buffer.toOwnedSlice().ptr,
|
||||
.cache_hash = cache_hash.toOwnedSlice().ptr,
|
||||
.is_native = cross_target.isNative(),
|
||||
.glibc_version = glibc_version,
|
||||
.glibc_or_darwin_version = glibc_or_darwin_version,
|
||||
.dynamic_linker = dynamic_linker,
|
||||
};
|
||||
}
|
||||
@ -1179,7 +1192,7 @@ fn crossTargetToTarget(cross_target: CrossTarget, dynamic_linker_ptr: *?[*:0]u8)
|
||||
}
|
||||
|
||||
// ABI warning
|
||||
const Stage2GLibCVersion = extern struct {
|
||||
const Stage2SemVer = extern struct {
|
||||
major: u32,
|
||||
minor: u32,
|
||||
patch: u32,
|
||||
|
||||
@ -2250,8 +2250,6 @@ struct CodeGen {
|
||||
bool test_is_evented;
|
||||
CodeModel code_model;
|
||||
|
||||
Buf *mmacosx_version_min;
|
||||
Buf *mios_version_min;
|
||||
Buf *root_out_name;
|
||||
Buf *test_filter;
|
||||
Buf *test_name_prefix;
|
||||
|
||||
@ -32,31 +32,6 @@ enum ResumeId {
|
||||
ResumeIdCall,
|
||||
};
|
||||
|
||||
static void init_darwin_native(CodeGen *g) {
|
||||
char *osx_target = getenv("MACOSX_DEPLOYMENT_TARGET");
|
||||
char *ios_target = getenv("IPHONEOS_DEPLOYMENT_TARGET");
|
||||
|
||||
// Allow conflicts among OSX and iOS, but choose the default platform.
|
||||
if (osx_target && ios_target) {
|
||||
if (g->zig_target->arch == ZigLLVM_arm ||
|
||||
g->zig_target->arch == ZigLLVM_aarch64 ||
|
||||
g->zig_target->arch == ZigLLVM_thumb)
|
||||
{
|
||||
osx_target = nullptr;
|
||||
} else {
|
||||
ios_target = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (osx_target) {
|
||||
g->mmacosx_version_min = buf_create_from_str(osx_target);
|
||||
} else if (ios_target) {
|
||||
g->mios_version_min = buf_create_from_str(ios_target);
|
||||
} else if (g->zig_target->os != OsIOS) {
|
||||
g->mmacosx_version_min = buf_create_from_str("10.14");
|
||||
}
|
||||
}
|
||||
|
||||
static ZigPackage *new_package(const char *root_src_dir, const char *root_src_path, const char *pkg_path) {
|
||||
ZigPackage *entry = heap::c_allocator.create<ZigPackage>();
|
||||
entry->package_table.init(4);
|
||||
@ -160,14 +135,6 @@ void codegen_add_framework(CodeGen *g, const char *framework) {
|
||||
g->darwin_frameworks.append(buf_create_from_str(framework));
|
||||
}
|
||||
|
||||
void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min) {
|
||||
g->mmacosx_version_min = mmacosx_version_min;
|
||||
}
|
||||
|
||||
void codegen_set_mios_version_min(CodeGen *g, Buf *mios_version_min) {
|
||||
g->mios_version_min = mios_version_min;
|
||||
}
|
||||
|
||||
void codegen_set_rdynamic(CodeGen *g, bool rdynamic) {
|
||||
g->linker_rdynamic = rdynamic;
|
||||
}
|
||||
@ -8655,10 +8622,10 @@ static Error define_builtin_compile_vars(CodeGen *g) {
|
||||
if (g->zig_target->cache_hash != nullptr) {
|
||||
cache_str(&cache_hash, g->zig_target->cache_hash);
|
||||
}
|
||||
if (g->zig_target->glibc_version != nullptr) {
|
||||
cache_int(&cache_hash, g->zig_target->glibc_version->major);
|
||||
cache_int(&cache_hash, g->zig_target->glibc_version->minor);
|
||||
cache_int(&cache_hash, g->zig_target->glibc_version->patch);
|
||||
if (g->zig_target->glibc_or_darwin_version != nullptr) {
|
||||
cache_int(&cache_hash, g->zig_target->glibc_or_darwin_version->major);
|
||||
cache_int(&cache_hash, g->zig_target->glibc_or_darwin_version->minor);
|
||||
cache_int(&cache_hash, g->zig_target->glibc_or_darwin_version->patch);
|
||||
}
|
||||
cache_bool(&cache_hash, g->have_err_ret_tracing);
|
||||
cache_bool(&cache_hash, g->libc_link_lib != nullptr);
|
||||
@ -10313,10 +10280,10 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
|
||||
if (g->zig_target->cache_hash != nullptr) {
|
||||
cache_str(ch, g->zig_target->cache_hash);
|
||||
}
|
||||
if (g->zig_target->glibc_version != nullptr) {
|
||||
cache_int(ch, g->zig_target->glibc_version->major);
|
||||
cache_int(ch, g->zig_target->glibc_version->minor);
|
||||
cache_int(ch, g->zig_target->glibc_version->patch);
|
||||
if (g->zig_target->glibc_or_darwin_version != nullptr) {
|
||||
cache_int(ch, g->zig_target->glibc_or_darwin_version->major);
|
||||
cache_int(ch, g->zig_target->glibc_or_darwin_version->minor);
|
||||
cache_int(ch, g->zig_target->glibc_or_darwin_version->patch);
|
||||
}
|
||||
cache_int(ch, detect_subsystem(g));
|
||||
cache_bool(ch, g->strip_debug_symbols);
|
||||
@ -10344,8 +10311,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
|
||||
cache_bool(ch, g->emit_bin);
|
||||
cache_bool(ch, g->emit_llvm_ir);
|
||||
cache_bool(ch, g->emit_asm);
|
||||
cache_buf_opt(ch, g->mmacosx_version_min);
|
||||
cache_buf_opt(ch, g->mios_version_min);
|
||||
cache_usize(ch, g->version_major);
|
||||
cache_usize(ch, g->version_minor);
|
||||
cache_usize(ch, g->version_patch);
|
||||
@ -10662,9 +10627,6 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o
|
||||
|
||||
codegen_set_errmsg_color(child_gen, parent_gen->err_color);
|
||||
|
||||
codegen_set_mmacosx_version_min(child_gen, parent_gen->mmacosx_version_min);
|
||||
codegen_set_mios_version_min(child_gen, parent_gen->mios_version_min);
|
||||
|
||||
child_gen->enable_cache = true;
|
||||
|
||||
return child_gen;
|
||||
@ -10772,11 +10734,6 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget
|
||||
g->each_lib_rpath = false;
|
||||
} else {
|
||||
g->each_lib_rpath = true;
|
||||
|
||||
if (target_os_is_darwin(g->zig_target->os)) {
|
||||
init_darwin_native(g);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (target_os_requires_libc(g->zig_target->os)) {
|
||||
|
||||
@ -35,8 +35,6 @@ LinkLib *codegen_add_link_lib(CodeGen *codegen, Buf *lib);
|
||||
void codegen_add_framework(CodeGen *codegen, const char *name);
|
||||
void codegen_add_rpath(CodeGen *codegen, const char *name);
|
||||
void codegen_set_rdynamic(CodeGen *g, bool rdynamic);
|
||||
void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min);
|
||||
void codegen_set_mios_version_min(CodeGen *g, Buf *mios_version_min);
|
||||
void codegen_set_linker_script(CodeGen *g, const char *linker_script);
|
||||
void codegen_set_test_filter(CodeGen *g, Buf *filter);
|
||||
void codegen_set_test_name_prefix(CodeGen *g, Buf *prefix);
|
||||
|
||||
@ -55,7 +55,7 @@ Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbo
|
||||
Optional<Slice<uint8_t>> opt_component = SplitIterator_next(&it);
|
||||
if (!opt_component.is_some) break;
|
||||
Buf *ver_buf = buf_create_from_slice(opt_component.value);
|
||||
ZigGLibCVersion *this_ver = glibc_abi->all_versions.add_one();
|
||||
Stage2SemVer *this_ver = glibc_abi->all_versions.add_one();
|
||||
if ((err = target_parse_glibc_version(this_ver, buf_ptr(ver_buf)))) {
|
||||
if (verbose) {
|
||||
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
|
||||
cache_buf(cache_hash, compiler_id);
|
||||
cache_int(cache_hash, target->arch);
|
||||
cache_int(cache_hash, target->abi);
|
||||
cache_int(cache_hash, target->glibc_version->major);
|
||||
cache_int(cache_hash, target->glibc_version->minor);
|
||||
cache_int(cache_hash, target->glibc_version->patch);
|
||||
cache_int(cache_hash, target->glibc_or_darwin_version->major);
|
||||
cache_int(cache_hash, target->glibc_or_darwin_version->minor);
|
||||
cache_int(cache_hash, target->glibc_or_darwin_version->patch);
|
||||
|
||||
Buf digest = BUF_INIT;
|
||||
buf_resize(&digest, 0);
|
||||
@ -224,10 +224,10 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
|
||||
|
||||
uint8_t target_ver_index = 0;
|
||||
for (;target_ver_index < glibc_abi->all_versions.length; target_ver_index += 1) {
|
||||
const ZigGLibCVersion *this_ver = &glibc_abi->all_versions.at(target_ver_index);
|
||||
if (this_ver->major == target->glibc_version->major &&
|
||||
this_ver->minor == target->glibc_version->minor &&
|
||||
this_ver->patch == target->glibc_version->patch)
|
||||
const Stage2SemVer *this_ver = &glibc_abi->all_versions.at(target_ver_index);
|
||||
if (this_ver->major == target->glibc_or_darwin_version->major &&
|
||||
this_ver->minor == target->glibc_or_darwin_version->minor &&
|
||||
this_ver->patch == target->glibc_or_darwin_version->patch)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -235,9 +235,9 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
|
||||
if (target_ver_index == glibc_abi->all_versions.length) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Unrecognized glibc version: %d.%d.%d\n",
|
||||
target->glibc_version->major,
|
||||
target->glibc_version->minor,
|
||||
target->glibc_version->patch);
|
||||
target->glibc_or_darwin_version->major,
|
||||
target->glibc_or_darwin_version->minor,
|
||||
target->glibc_or_darwin_version->patch);
|
||||
}
|
||||
return ErrorUnknownABI;
|
||||
}
|
||||
@ -246,7 +246,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
|
||||
Buf *map_contents = buf_alloc();
|
||||
|
||||
for (uint8_t ver_i = 0; ver_i < glibc_abi->all_versions.length; ver_i += 1) {
|
||||
const ZigGLibCVersion *ver = &glibc_abi->all_versions.at(ver_i);
|
||||
const Stage2SemVer *ver = &glibc_abi->all_versions.at(ver_i);
|
||||
if (ver->patch == 0) {
|
||||
buf_appendf(map_contents, "GLIBC_%d.%d { };\n", ver->major, ver->minor);
|
||||
} else {
|
||||
@ -294,7 +294,7 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
|
||||
uint8_t ver_index = ver_list->versions[ver_i];
|
||||
|
||||
Buf *stub_name;
|
||||
const ZigGLibCVersion *ver = &glibc_abi->all_versions.at(ver_index);
|
||||
const Stage2SemVer *ver = &glibc_abi->all_versions.at(ver_index);
|
||||
const char *sym_name = buf_ptr(libc_fn->name);
|
||||
if (ver->patch == 0) {
|
||||
stub_name = buf_sprintf("%s_%d_%d", sym_name, ver->major, ver->minor);
|
||||
|
||||
@ -32,7 +32,7 @@ struct ZigGLibCAbi {
|
||||
Buf *abi_txt_path;
|
||||
Buf *vers_txt_path;
|
||||
Buf *fns_txt_path;
|
||||
ZigList<ZigGLibCVersion> all_versions;
|
||||
ZigList<Stage2SemVer> all_versions;
|
||||
ZigList<ZigGLibCFn> all_functions;
|
||||
// The value is a pointer to all_functions.length items and each item is an index
|
||||
// into all_functions.
|
||||
|
||||
127
src/link.cpp
127
src/link.cpp
@ -2371,99 +2371,6 @@ static void construct_linker_job_coff(LinkJob *lj) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and return the
|
||||
// grouped values as integers. Numbers which are not provided are set to 0.
|
||||
// return true if the entire string was parsed (9.2), or all groups were
|
||||
// parsed (10.3.5extrastuff).
|
||||
static bool darwin_get_release_version(const char *str, int *major, int *minor, int *micro, bool *had_extra) {
|
||||
*had_extra = false;
|
||||
|
||||
*major = 0;
|
||||
*minor = 0;
|
||||
*micro = 0;
|
||||
|
||||
if (*str == '\0')
|
||||
return false;
|
||||
|
||||
char *end;
|
||||
*major = (int)strtol(str, &end, 10);
|
||||
if (*str != '\0' && *end == '\0')
|
||||
return true;
|
||||
if (*end != '.')
|
||||
return false;
|
||||
|
||||
str = end + 1;
|
||||
*minor = (int)strtol(str, &end, 10);
|
||||
if (*str != '\0' && *end == '\0')
|
||||
return true;
|
||||
if (*end != '.')
|
||||
return false;
|
||||
|
||||
str = end + 1;
|
||||
*micro = (int)strtol(str, &end, 10);
|
||||
if (*str != '\0' && *end == '\0')
|
||||
return true;
|
||||
if (str == end)
|
||||
return false;
|
||||
*had_extra = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
enum DarwinPlatformKind {
|
||||
MacOS,
|
||||
IPhoneOS,
|
||||
IPhoneOSSimulator,
|
||||
};
|
||||
|
||||
struct DarwinPlatform {
|
||||
DarwinPlatformKind kind;
|
||||
int major;
|
||||
int minor;
|
||||
int micro;
|
||||
};
|
||||
|
||||
static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) {
|
||||
CodeGen *g = lj->codegen;
|
||||
|
||||
if (g->mmacosx_version_min) {
|
||||
platform->kind = MacOS;
|
||||
} else if (g->mios_version_min) {
|
||||
platform->kind = IPhoneOS;
|
||||
} else if (g->zig_target->os == OsMacOSX) {
|
||||
platform->kind = MacOS;
|
||||
g->mmacosx_version_min = buf_create_from_str("10.14");
|
||||
} else {
|
||||
zig_panic("unable to infer -mmacosx-version-min or -mios-version-min");
|
||||
}
|
||||
|
||||
bool had_extra;
|
||||
if (platform->kind == MacOS) {
|
||||
if (!darwin_get_release_version(buf_ptr(g->mmacosx_version_min),
|
||||
&platform->major, &platform->minor, &platform->micro, &had_extra) ||
|
||||
had_extra || platform->major != 10 || platform->minor >= 100 || platform->micro >= 100)
|
||||
{
|
||||
zig_panic("invalid -mmacosx-version-min");
|
||||
}
|
||||
} else if (platform->kind == IPhoneOS) {
|
||||
if (!darwin_get_release_version(buf_ptr(g->mios_version_min),
|
||||
&platform->major, &platform->minor, &platform->micro, &had_extra) ||
|
||||
had_extra || platform->major >= 10 || platform->minor >= 100 || platform->micro >= 100)
|
||||
{
|
||||
zig_panic("invalid -mios-version-min");
|
||||
}
|
||||
} else {
|
||||
zig_unreachable();
|
||||
}
|
||||
|
||||
if (platform->kind == IPhoneOS &&
|
||||
(g->zig_target->arch == ZigLLVM_x86 ||
|
||||
g->zig_target->arch == ZigLLVM_x86_64))
|
||||
{
|
||||
platform->kind = IPhoneOSSimulator;
|
||||
}
|
||||
}
|
||||
|
||||
static void construct_linker_job_macho(LinkJob *lj) {
|
||||
CodeGen *g = lj->codegen;
|
||||
|
||||
@ -2507,25 +2414,25 @@ static void construct_linker_job_macho(LinkJob *lj) {
|
||||
lj->args.append("-arch");
|
||||
lj->args.append(get_darwin_arch_string(g->zig_target));
|
||||
|
||||
DarwinPlatform platform;
|
||||
get_darwin_platform(lj, &platform);
|
||||
switch (platform.kind) {
|
||||
case MacOS:
|
||||
if (g->zig_target->glibc_or_darwin_version != nullptr) {
|
||||
if (g->zig_target->os == OsMacOSX) {
|
||||
lj->args.append("-macosx_version_min");
|
||||
break;
|
||||
case IPhoneOS:
|
||||
lj->args.append("-iphoneos_version_min");
|
||||
break;
|
||||
case IPhoneOSSimulator:
|
||||
lj->args.append("-ios_simulator_version_min");
|
||||
break;
|
||||
} else if (g->zig_target->os == OsIOS) {
|
||||
if (g->zig_target->arch == ZigLLVM_x86 || g->zig_target->arch == ZigLLVM_x86_64) {
|
||||
lj->args.append("-ios_simulator_version_min");
|
||||
} else {
|
||||
lj->args.append("-iphoneos_version_min");
|
||||
}
|
||||
}
|
||||
Buf *version_string = buf_sprintf("%d.%d.%d",
|
||||
g->zig_target->glibc_or_darwin_version->major,
|
||||
g->zig_target->glibc_or_darwin_version->minor,
|
||||
g->zig_target->glibc_or_darwin_version->patch);
|
||||
lj->args.append(buf_ptr(version_string));
|
||||
|
||||
lj->args.append("-sdk_version");
|
||||
lj->args.append(buf_ptr(version_string));
|
||||
}
|
||||
Buf *version_string = buf_sprintf("%d.%d.%d", platform.major, platform.minor, platform.micro);
|
||||
lj->args.append(buf_ptr(version_string));
|
||||
|
||||
lj->args.append("-sdk_version");
|
||||
lj->args.append(buf_ptr(version_string));
|
||||
|
||||
|
||||
if (g->out_type == OutTypeExe) {
|
||||
lj->args.append("-pie");
|
||||
|
||||
20
src/main.cpp
20
src/main.cpp
@ -127,8 +127,6 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
|
||||
" --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"
|
||||
" -F[dir] (darwin) add search path for frameworks\n"
|
||||
" -framework [name] (darwin) link against framework\n"
|
||||
" -mios-version-min [ver] (darwin) set iOS deployment target\n"
|
||||
" -mmacosx-version-min [ver] (darwin) set Mac OS X deployment target\n"
|
||||
" --ver-major [ver] dynamic library semver major version\n"
|
||||
" --ver-minor [ver] dynamic library semver minor version\n"
|
||||
" --ver-patch [ver] dynamic library semver patch version\n"
|
||||
@ -414,8 +412,6 @@ static int main0(int argc, char **argv) {
|
||||
bool have_libc = false;
|
||||
const char *target_string = nullptr;
|
||||
bool rdynamic = false;
|
||||
const char *mmacosx_version_min = nullptr;
|
||||
const char *mios_version_min = nullptr;
|
||||
const char *linker_script = nullptr;
|
||||
Buf *version_script = nullptr;
|
||||
ZigList<const char *> rpath_list = {0};
|
||||
@ -844,10 +840,6 @@ static int main0(int argc, char **argv) {
|
||||
cache_dir = argv[i];
|
||||
} else if (strcmp(arg, "-target") == 0) {
|
||||
target_string = argv[i];
|
||||
} else if (strcmp(arg, "-mmacosx-version-min") == 0) {
|
||||
mmacosx_version_min = argv[i];
|
||||
} else if (strcmp(arg, "-mios-version-min") == 0) {
|
||||
mios_version_min = argv[i];
|
||||
} else if (strcmp(arg, "-framework") == 0) {
|
||||
frameworks.append(argv[i]);
|
||||
} else if (strcmp(arg, "--linker-script") == 0) {
|
||||
@ -1240,18 +1232,6 @@ static int main0(int argc, char **argv) {
|
||||
}
|
||||
|
||||
codegen_set_rdynamic(g, rdynamic);
|
||||
if (mmacosx_version_min && mios_version_min) {
|
||||
fprintf(stderr, "-mmacosx-version-min and -mios-version-min options not allowed together\n");
|
||||
return main_exit(root_progress_node, EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (mmacosx_version_min) {
|
||||
codegen_set_mmacosx_version_min(g, buf_create_from_str(mmacosx_version_min));
|
||||
}
|
||||
|
||||
if (mios_version_min) {
|
||||
codegen_set_mios_version_min(g, buf_create_from_str(mios_version_min));
|
||||
}
|
||||
|
||||
if (test_filter) {
|
||||
codegen_set_test_filter(g, buf_create_from_str(test_filter));
|
||||
|
||||
@ -186,7 +186,7 @@ static void get_native_target(ZigTarget *target) {
|
||||
target->abi = target_default_abi(target->arch, target->os);
|
||||
}
|
||||
if (target_is_glibc(target)) {
|
||||
target->glibc_version = heap::c_allocator.create<ZigGLibCVersion>();
|
||||
target->glibc_or_darwin_version = heap::c_allocator.create<Stage2SemVer>();
|
||||
target_init_default_glibc_version(target);
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,14 +270,12 @@ enum Os {
|
||||
};
|
||||
|
||||
// ABI warning
|
||||
struct ZigGLibCVersion {
|
||||
uint32_t major; // always 2
|
||||
struct Stage2SemVer {
|
||||
uint32_t major;
|
||||
uint32_t minor;
|
||||
uint32_t patch;
|
||||
};
|
||||
|
||||
struct Stage2TargetData;
|
||||
|
||||
// ABI warning
|
||||
struct ZigTarget {
|
||||
enum ZigLLVM_ArchType arch;
|
||||
@ -288,7 +286,8 @@ struct ZigTarget {
|
||||
|
||||
bool is_native;
|
||||
|
||||
struct ZigGLibCVersion *glibc_version; // null means default
|
||||
// null means default. this is double-purposed to be darwin min version
|
||||
struct Stage2SemVer *glibc_or_darwin_version;
|
||||
|
||||
const char *llvm_cpu_name;
|
||||
const char *llvm_cpu_features;
|
||||
|
||||
@ -347,7 +347,7 @@ const char *target_abi_name(ZigLLVM_EnvironmentType abi) {
|
||||
return ZigLLVMGetEnvironmentTypeName(abi);
|
||||
}
|
||||
|
||||
Error target_parse_glibc_version(ZigGLibCVersion *glibc_ver, const char *text) {
|
||||
Error target_parse_glibc_version(Stage2SemVer *glibc_ver, const char *text) {
|
||||
glibc_ver->major = 2;
|
||||
glibc_ver->minor = 0;
|
||||
glibc_ver->patch = 0;
|
||||
@ -371,7 +371,7 @@ Error target_parse_glibc_version(ZigGLibCVersion *glibc_ver, const char *text) {
|
||||
}
|
||||
|
||||
void target_init_default_glibc_version(ZigTarget *target) {
|
||||
*target->glibc_version = {2, 17, 0};
|
||||
*target->glibc_or_darwin_version = {2, 17, 0};
|
||||
}
|
||||
|
||||
Error target_parse_arch(ZigLLVM_ArchType *out_arch, const char *arch_ptr, size_t arch_len) {
|
||||
|
||||
@ -46,7 +46,7 @@ Error target_parse_arch(ZigLLVM_ArchType *arch, const char *arch_ptr, size_t arc
|
||||
Error target_parse_os(Os *os, const char *os_ptr, size_t os_len);
|
||||
Error target_parse_abi(ZigLLVM_EnvironmentType *abi, const char *abi_ptr, size_t abi_len);
|
||||
|
||||
Error target_parse_glibc_version(ZigGLibCVersion *out, const char *text);
|
||||
Error target_parse_glibc_version(Stage2SemVer *out, const char *text);
|
||||
void target_init_default_glibc_version(ZigTarget *target);
|
||||
|
||||
size_t target_arch_count(void);
|
||||
|
||||
@ -92,7 +92,7 @@ fn testZigInitLib(zig_exe: []const u8, dir_path: []const u8) !void {
|
||||
fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void {
|
||||
_ = try exec(dir_path, &[_][]const u8{ zig_exe, "init-exe" });
|
||||
const run_result = try exec(dir_path, &[_][]const u8{ zig_exe, "build", "run" });
|
||||
testing.expect(std.mem.eql(u8, run_result.stderr, "All your base are belong to us.\n"));
|
||||
testing.expect(std.mem.eql(u8, run_result.stderr, "All your codebase are belong to us.\n"));
|
||||
}
|
||||
|
||||
fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user