aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-08-30 17:01:14 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-08-30 17:01:14 -0400
commit021155db5b3cdbe524806ed549d96bb56e611a01 (patch)
tree5ba048db1f9220789b5f0cd06ed3e804a38395f2 /src
parent41da9fdb69065082f57c604b12eb02ca166cb18d (diff)
downloadzig-021155db5b3cdbe524806ed549d96bb56e611a01.tar.gz
zig-021155db5b3cdbe524806ed549d96bb56e611a01.zip
successfully cross-building behavior tests for windows
Diffstat (limited to 'src')
-rw-r--r--src/codegen.cpp6
-rw-r--r--src/ir_print.cpp6
-rw-r--r--src/link.cpp20
3 files changed, 24 insertions, 8 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index a57e33b51f..ef8169b789 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -4914,6 +4914,12 @@ static void define_builtin_compile_vars(CodeGen *g) {
static void init(CodeGen *g) {
if (g->module)
return;
+
+ if (g->is_test_build) {
+ g->windows_subsystem_windows = false;
+ g->windows_subsystem_console = true;
+ }
+
assert(g->root_out_name);
g->module = LLVMModuleCreateWithName(buf_ptr(g->root_out_name));
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 3c6154b21d..52fb675515 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -934,7 +934,11 @@ static void ir_print_set_eval_branch_quota(IrPrint *irp, IrInstructionSetEvalBra
static void ir_print_align_cast(IrPrint *irp, IrInstructionAlignCast *instruction) {
fprintf(irp->f, "@alignCast(");
- ir_print_other_instruction(irp, instruction->align_bytes);
+ if (instruction->align_bytes == nullptr) {
+ fprintf(irp->f, "null");
+ } else {
+ ir_print_other_instruction(irp, instruction->align_bytes);
+ }
fprintf(irp->f, ",");
ir_print_other_instruction(irp, instruction->target);
fprintf(irp->f, ")");
diff --git a/src/link.cpp b/src/link.cpp
index 6134a8f568..63f06af2cc 100644
--- a/src/link.cpp
+++ b/src/link.cpp
@@ -336,6 +336,16 @@ static bool is_target_cyg_mingw(const ZigTarget *target) {
(target->os == ZigLLVM_Win32 && target->env_type == ZigLLVM_GNU);
}
+static void coff_append_machine_arg(CodeGen *g, ZigList<const char *> *list) {
+ if (g->zig_target.arch.arch == ZigLLVM_x86) {
+ list->append("-MACHINE:X86");
+ } else if (g->zig_target.arch.arch == ZigLLVM_x86_64) {
+ list->append("-MACHINE:X64");
+ } else if (g->zig_target.arch.arch == ZigLLVM_arm) {
+ list->append("-MACHINE:ARM");
+ }
+}
+
static void construct_linker_job_coff(LinkJob *lj) {
CodeGen *g = lj->codegen;
@@ -345,13 +355,7 @@ static void construct_linker_job_coff(LinkJob *lj) {
lj->args.append("-NOLOGO");
- if (g->zig_target.arch.arch == ZigLLVM_x86) {
- lj->args.append("-MACHINE:X86");
- } else if (g->zig_target.arch.arch == ZigLLVM_x86_64) {
- lj->args.append("-MACHINE:X64");
- } else if (g->zig_target.arch.arch == ZigLLVM_arm) {
- lj->args.append("-MACHINE:ARM");
- }
+ coff_append_machine_arg(g, &lj->args);
if (g->windows_subsystem_windows) {
lj->args.append("/SUBSYSTEM:windows");
@@ -453,6 +457,8 @@ static void construct_linker_job_coff(LinkJob *lj) {
ZigList<const char *> args = {0};
args.append("link");
+
+ coff_append_machine_arg(g, &args);
args.append(buf_ptr(buf_sprintf("-DEF:%s", buf_ptr(def_path))));
args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(all_lib_path))));
Buf diag = BUF_INIT;