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) {
49144914static void init(CodeGen *g) {
49154915 if (g->module)
49164916 return;
4917
4918 if (g->is_test_build) {
4919 g->windows_subsystem_windows = false;
4920 g->windows_subsystem_console = true;
4921 }
4922
49174923 assert(g->root_out_name);
49184924 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
934934
935935static void ir_print_align_cast(IrPrint *irp, IrInstructionAlignCast *instruction) {
936936 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 }
938942 fprintf(irp->f, ",");
939943 ir_print_other_instruction(irp, instruction->target);
940944 fprintf(irp->f, ")");
src/link.cpp+13-7
......@@ -336,6 +336,16 @@ static bool is_target_cyg_mingw(const ZigTarget *target) {
336336 (target->os == ZigLLVM_Win32 && target->env_type == ZigLLVM_GNU);
337337}
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
339349static void construct_linker_job_coff(LinkJob *lj) {
340350 CodeGen *g = lj->codegen;
341351
......@@ -345,13 +355,7 @@ static void construct_linker_job_coff(LinkJob *lj) {
345355
346356 lj->args.append("-NOLOGO");
347357
348 if (g->zig_target.arch.arch == ZigLLVM_x86) {
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 }
358 coff_append_machine_arg(g, &lj->args);
355359
356360 if (g->windows_subsystem_windows) {
357361 lj->args.append("/SUBSYSTEM:windows");
......@@ -453,6 +457,8 @@ static void construct_linker_job_coff(LinkJob *lj) {
453457
454458 ZigList<const char *> args = {0};
455459 args.append("link");
460
461 coff_append_machine_arg(g, &args);
456462 args.append(buf_ptr(buf_sprintf("-DEF:%s", buf_ptr(def_path))));
457463 args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(all_lib_path))));
458464 Buf diag = BUF_INIT;
std/os/index.zig+1-1
......@@ -210,7 +210,7 @@ pub fn windowsIsTty(handle: windows.HANDLE) -> bool {
210210
211211pub fn windowsIsCygwinPty(handle: windows.HANDLE) -> bool {
212212 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
215215 if (!windows.GetFileInformationByHandleEx(handle, windows.FileNameInfo,
216216 @ptrCast(&c_void, &name_info_bytes[0]), u32(name_info_bytes.len)))