aboutsummaryrefslogtreecommitdiff
path: root/src/link.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-26 15:51:32 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-26 15:58:10 -0500
commitade10387a583351fe597b58c4c9ceb97d959adf5 (patch)
tree5e508bc243ec6e65c1d2a11908d7e28bcf0b8c48 /src/link.cpp
parent1ec1097bd389b9af1b3e40d9edbc4c1c0b65f6a1 (diff)
downloadzig-ade10387a583351fe597b58c4c9ceb97d959adf5.tar.gz
zig-ade10387a583351fe597b58c4c9ceb97d959adf5.zip
breaking changes to the way targets work in zig
* CLI: `-target [name]` instead of `--target-*` args. This matches clang's API. * `builtin.Environ` renamed to `builtin.Abi` - likewise `builtin.environ` renamed to `builtin.abi` * stop hiding the concept of sub-arch. closes #1526 * `zig targets` only shows available targets. closes #438 * include all targets in readme, even those that don't print with `zig targets` but note they are Tier 4 * refactor target.cpp and make the naming conventions more consistent * introduce the concept of a "default C ABI" for a given OS/Arch combo. As a rule of thumb, if the system compiler is clang or gcc then the default C ABI is the gnu ABI.
Diffstat (limited to 'src/link.cpp')
-rw-r--r--src/link.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/link.cpp b/src/link.cpp
index f52eaa1374..df2eb37f0a 100644
--- a/src/link.cpp
+++ b/src/link.cpp
@@ -96,7 +96,7 @@ static Buf *build_compiler_rt(CodeGen *parent_gen) {
}
static const char *get_darwin_arch_string(const ZigTarget *t) {
- switch (t->arch.arch) {
+ switch (t->arch) {
case ZigLLVM_aarch64:
return "arm64";
case ZigLLVM_thumb:
@@ -109,13 +109,13 @@ static const char *get_darwin_arch_string(const ZigTarget *t) {
case ZigLLVM_ppc64le:
return "ppc64le";
default:
- return ZigLLVMGetArchTypeName(t->arch.arch);
+ return ZigLLVMGetArchTypeName(t->arch);
}
}
static const char *getLDMOption(const ZigTarget *t) {
- switch (t->arch.arch) {
+ switch (t->arch) {
case ZigLLVM_x86:
return "elf_i386";
case ZigLLVM_aarch64:
@@ -149,7 +149,7 @@ static const char *getLDMOption(const ZigTarget *t) {
case ZigLLVM_systemz:
return "elf64_s390";
case ZigLLVM_x86_64:
- if (t->env_type == ZigLLVM_GNUX32) {
+ if (t->abi == ZigLLVM_GNUX32) {
return "elf32_x86_64";
}
// Any target elf will use the freebsd osabi if suffixed with "_fbsd".
@@ -191,8 +191,8 @@ static void construct_linker_job_elf(LinkJob *lj) {
bool shared = !g->is_static && is_lib;
Buf *soname = nullptr;
if (g->is_static) {
- if (g->zig_target->arch.arch == ZigLLVM_arm || g->zig_target->arch.arch == ZigLLVM_armeb ||
- g->zig_target->arch.arch == ZigLLVM_thumb || g->zig_target->arch.arch == ZigLLVM_thumbeb)
+ if (g->zig_target->arch == ZigLLVM_arm || g->zig_target->arch == ZigLLVM_armeb ||
+ g->zig_target->arch == ZigLLVM_thumb || g->zig_target->arch == ZigLLVM_thumbeb)
{
lj->args.append("-Bstatic");
} else {
@@ -375,16 +375,16 @@ static void construct_linker_job_wasm(LinkJob *lj) {
}
//static bool is_target_cyg_mingw(const ZigTarget *target) {
-// return (target->os == ZigLLVM_Win32 && target->env_type == ZigLLVM_Cygnus) ||
-// (target->os == ZigLLVM_Win32 && target->env_type == ZigLLVM_GNU);
+// return (target->os == ZigLLVM_Win32 && target->abi == ZigLLVM_Cygnus) ||
+// (target->os == ZigLLVM_Win32 && target->abi == ZigLLVM_GNU);
//}
static void coff_append_machine_arg(CodeGen *g, ZigList<const char *> *list) {
- if (g->zig_target->arch.arch == ZigLLVM_x86) {
+ if (g->zig_target->arch == ZigLLVM_x86) {
list->append("-MACHINE:X86");
- } else if (g->zig_target->arch.arch == ZigLLVM_x86_64) {
+ } else if (g->zig_target->arch == ZigLLVM_x86_64) {
list->append("-MACHINE:X64");
- } else if (g->zig_target->arch.arch == ZigLLVM_arm) {
+ } else if (g->zig_target->arch == ZigLLVM_arm) {
list->append("-MACHINE:ARM");
}
}
@@ -470,7 +470,7 @@ static void add_nt_link_args(LinkJob *lj, bool is_library) {
// lj->args.append("-Bdynamic");
// if (dll || shared) {
// lj->args.append("-e");
-// if (g->zig_target.arch.arch == ZigLLVM_x86) {
+// if (g->zig_target.arch == ZigLLVM_x86) {
// lj->args.append("_DllMainCRTStartup@12");
// } else {
// lj->args.append("DllMainCRTStartup");
@@ -496,7 +496,7 @@ static void add_nt_link_args(LinkJob *lj, bool is_library) {
//lj->args.append("-lmingw32");
//lj->args.append("-lgcc");
-//bool is_android = (g->zig_target.env_type == ZigLLVM_Android);
+//bool is_android = (g->zig_target.abi == ZigLLVM_Android);
//bool is_cyg_ming = is_target_cyg_mingw(&g->zig_target);
//if (!g->is_static && !is_android) {
// if (!is_cyg_ming) {
@@ -637,7 +637,7 @@ static void construct_linker_job_coff(LinkJob *lj) {
continue;
}
if (link_lib->provided_explicitly) {
- if (lj->codegen->zig_target->env_type == ZigLLVM_GNU) {
+ if (lj->codegen->zig_target->abi == ZigLLVM_GNU) {
Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib->name));
lj->args.append(buf_ptr(arg));
}
@@ -764,8 +764,8 @@ static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) {
}
if (platform->kind == IPhoneOS &&
- (g->zig_target->arch.arch == ZigLLVM_x86 ||
- g->zig_target->arch.arch == ZigLLVM_x86_64))
+ (g->zig_target->arch == ZigLLVM_x86 ||
+ g->zig_target->arch == ZigLLVM_x86_64))
{
platform->kind = IPhoneOSSimulator;
}
@@ -886,7 +886,7 @@ static void construct_linker_job_macho(LinkJob *lj) {
}
break;
case IPhoneOS:
- if (g->zig_target->arch.arch == ZigLLVM_aarch64) {
+ if (g->zig_target->arch == ZigLLVM_aarch64) {
// iOS does not need any crt1 files for arm64
} else if (darwin_version_lt(&platform, 3, 1)) {
lj->args.append("-lcrt1.o");