authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-30 17:01:14-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-30 17:01:14-04:00
log021155db5b3cdbe524806ed549d96bb56e611a01
tree5ba048db1f9220789b5f0cd06ed3e804a38395f2
parent41da9fdb69065082f57c604b12eb02ca166cb18d

successfully cross-building behavior tests for windows


4 files changed, 25 insertions(+), 9 deletions(-)

src/codegen.cpp+6
...@@ -4914,6 +4914,12 @@ static void define_builtin_compile_vars(CodeGen *g) {...@@ -4914,6 +4914,12 @@ static void define_builtin_compile_vars(CodeGen *g) {
4914static void init(CodeGen *g) {4914static void init(CodeGen *g) {
4915 if (g->module)4915 if (g->module)
4916 return;4916 return;
4917
4918 if (g->is_test_build) {
4919 g->windows_subsystem_windows = false;
4920 g->windows_subsystem_console = true;
4921 }
4922
4917 assert(g->root_out_name);4923 assert(g->root_out_name);
4918 g->module = LLVMModuleCreateWithName(buf_ptr(g->root_out_name));4924 g->module = LLVMModuleCreateWithName(buf_ptr(g->root_out_name));
49194925
src/ir_print.cpp+5-1
...@@ -934,7 +934,11 @@ static void ir_print_set_eval_branch_quota(IrPrint *irp, IrInstructionSetEvalBra...@@ -934,7 +934,11 @@ static void ir_print_set_eval_branch_quota(IrPrint *irp, IrInstructionSetEvalBra
934934
935static void ir_print_align_cast(IrPrint *irp, IrInstructionAlignCast *instruction) {935static void ir_print_align_cast(IrPrint *irp, IrInstructionAlignCast *instruction) {
936 fprintf(irp->f, "@alignCast(");936 fprintf(irp->f, "@alignCast(");
937 ir_print_other_instruction(irp, instruction->align_bytes);937 if (instruction->align_bytes == nullptr) {
938 fprintf(irp->f, "null");
939 } else {
940 ir_print_other_instruction(irp, instruction->align_bytes);
941 }
938 fprintf(irp->f, ",");942 fprintf(irp->f, ",");
939 ir_print_other_instruction(irp, instruction->target);943 ir_print_other_instruction(irp, instruction->target);
940 fprintf(irp->f, ")");944 fprintf(irp->f, ")");
src/link.cpp+13-7
...@@ -336,6 +336,16 @@ static bool is_target_cyg_mingw(const ZigTarget *target) {...@@ -336,6 +336,16 @@ static bool is_target_cyg_mingw(const ZigTarget *target) {
336 (target->os == ZigLLVM_Win32 && target->env_type == ZigLLVM_GNU);336 (target->os == ZigLLVM_Win32 && target->env_type == ZigLLVM_GNU);
337}337}
338338
339static void coff_append_machine_arg(CodeGen *g, ZigList<const char *> *list) {
340 if (g->zig_target.arch.arch == ZigLLVM_x86) {
341 list->append("-MACHINE:X86");
342 } else if (g->zig_target.arch.arch == ZigLLVM_x86_64) {
343 list->append("-MACHINE:X64");
344 } else if (g->zig_target.arch.arch == ZigLLVM_arm) {
345 list->append("-MACHINE:ARM");
346 }
347}
348
339static void construct_linker_job_coff(LinkJob *lj) {349static void construct_linker_job_coff(LinkJob *lj) {
340 CodeGen *g = lj->codegen;350 CodeGen *g = lj->codegen;
341351
...@@ -345,13 +355,7 @@ static void construct_linker_job_coff(LinkJob *lj) {...@@ -345,13 +355,7 @@ static void construct_linker_job_coff(LinkJob *lj) {
345355
346 lj->args.append("-NOLOGO");356 lj->args.append("-NOLOGO");
347357
348 if (g->zig_target.arch.arch == ZigLLVM_x86) {358 coff_append_machine_arg(g, &lj->args);
349 lj->args.append("-MACHINE:X86");
350 } else if (g->zig_target.arch.arch == ZigLLVM_x86_64) {
351 lj->args.append("-MACHINE:X64");
352 } else if (g->zig_target.arch.arch == ZigLLVM_arm) {
353 lj->args.append("-MACHINE:ARM");
354 }
355359
356 if (g->windows_subsystem_windows) {360 if (g->windows_subsystem_windows) {
357 lj->args.append("/SUBSYSTEM:windows");361 lj->args.append("/SUBSYSTEM:windows");
...@@ -453,6 +457,8 @@ static void construct_linker_job_coff(LinkJob *lj) {...@@ -453,6 +457,8 @@ static void construct_linker_job_coff(LinkJob *lj) {
453457
454 ZigList<const char *> args = {0};458 ZigList<const char *> args = {0};
455 args.append("link");459 args.append("link");
460
461 coff_append_machine_arg(g, &args);
456 args.append(buf_ptr(buf_sprintf("-DEF:%s", buf_ptr(def_path))));462 args.append(buf_ptr(buf_sprintf("-DEF:%s", buf_ptr(def_path))));
457 args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(all_lib_path))));463 args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(all_lib_path))));
458 Buf diag = BUF_INIT;464 Buf diag = BUF_INIT;
std/os/index.zig+1-1
...@@ -210,7 +210,7 @@ pub fn windowsIsTty(handle: windows.HANDLE) -> bool {...@@ -210,7 +210,7 @@ pub fn windowsIsTty(handle: windows.HANDLE) -> bool {
210210
211pub fn windowsIsCygwinPty(handle: windows.HANDLE) -> bool {211pub fn windowsIsCygwinPty(handle: windows.HANDLE) -> bool {
212 const size = @sizeOf(windows.FILE_NAME_INFO);212 const size = @sizeOf(windows.FILE_NAME_INFO);
213 var name_info_bytes = []u8{0} ** (size + windows.MAX_PATH);213 var name_info_bytes align(@alignOf(windows.FILE_NAME_INFO)) = []u8{0} ** (size + windows.MAX_PATH);
214214
215 if (!windows.GetFileInformationByHandleEx(handle, windows.FileNameInfo,215 if (!windows.GetFileInformationByHandleEx(handle, windows.FileNameInfo,
216 @ptrCast(&c_void, &name_info_bytes[0]), u32(name_info_bytes.len)))216 @ptrCast(&c_void, &name_info_bytes[0]), u32(name_info_bytes.len)))