authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-15 19:20:30-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-16 18:43:45-07:00
log25a70256138c06a3b00412b4ad7122dab9decf9e
tree6d2262e7f90af8e295e1216a68a102ad7a3a48de
parentcc9eb9e90fec961a74e90e1ab3d66a7b8ec14f47

ci: use zig-bootstrap for windows


9 files changed, 1084 insertions(+), 118 deletions(-)

ci/azure/build.zig created+978
...@@ -0,0 +1,978 @@
1const std = @import("std");
2const builtin = std.builtin;
3const Builder = std.build.Builder;
4const BufMap = std.BufMap;
5const mem = std.mem;
6const ArrayList = std.ArrayList;
7const io = std.io;
8const fs = std.fs;
9const InstallDirectoryOptions = std.build.InstallDirectoryOptions;
10const assert = std.debug.assert;
11
12const zig_version = std.builtin.Version{ .major = 0, .minor = 10, .patch = 0 };
13
14pub fn build(b: *Builder) !void {
15 b.setPreferredReleaseMode(.ReleaseFast);
16 const mode = b.standardReleaseOptions();
17 const target = b.standardTargetOptions(.{});
18 const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");
19 const use_zig_libcxx = b.option(bool, "use-zig-libcxx", "If libc++ is needed, use zig's bundled version, don't try to integrate with the system") orelse false;
20
21 const docgen_exe = b.addExecutable("docgen", "doc/docgen.zig");
22 docgen_exe.single_threaded = single_threaded;
23
24 const rel_zig_exe = try fs.path.relative(b.allocator, b.build_root, b.zig_exe);
25 const langref_out_path = fs.path.join(
26 b.allocator,
27 &[_][]const u8{ b.cache_root, "langref.html" },
28 ) catch unreachable;
29 const docgen_cmd = docgen_exe.run();
30 docgen_cmd.addArgs(&[_][]const u8{
31 rel_zig_exe,
32 "doc" ++ fs.path.sep_str ++ "langref.html.in",
33 langref_out_path,
34 });
35 docgen_cmd.step.dependOn(&docgen_exe.step);
36
37 const docs_step = b.step("docs", "Build documentation");
38 docs_step.dependOn(&docgen_cmd.step);
39
40 const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false;
41 const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false;
42 const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false;
43 const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm);
44 const llvm_has_m68k = b.option(
45 bool,
46 "llvm-has-m68k",
47 "Whether LLVM has the experimental target m68k enabled",
48 ) orelse false;
49 const llvm_has_csky = b.option(
50 bool,
51 "llvm-has-csky",
52 "Whether LLVM has the experimental target csky enabled",
53 ) orelse false;
54 const llvm_has_ve = b.option(
55 bool,
56 "llvm-has-ve",
57 "Whether LLVM has the experimental target ve enabled",
58 ) orelse false;
59 const llvm_has_arc = b.option(
60 bool,
61 "llvm-has-arc",
62 "Whether LLVM has the experimental target arc enabled",
63 ) orelse false;
64 const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h");
65
66 b.installDirectory(InstallDirectoryOptions{
67 .source_dir = "lib",
68 .install_dir = .lib,
69 .install_subdir = "zig",
70 .exclude_extensions = &[_][]const u8{
71 // exclude files from lib/std/compress/
72 ".gz",
73 ".z.0",
74 ".z.9",
75 "rfc1951.txt",
76 "rfc1952.txt",
77 // exclude files from lib/std/compress/deflate/testdata
78 ".expect",
79 ".expect-noinput",
80 ".golden",
81 ".input",
82 "compress-e.txt",
83 "compress-gettysburg.txt",
84 "compress-pi.txt",
85 "rfc1951.txt",
86 // exclude files from lib/std/tz/
87 ".tzif",
88 // others
89 "README.md",
90 },
91 .blank_extensions = &[_][]const u8{
92 "test.zig",
93 },
94 });
95
96 const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source");
97 const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse false;
98 const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse false;
99 const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false;
100 const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse enable_llvm;
101 const strip = b.option(bool, "strip", "Omit debug information") orelse false;
102
103 const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: {
104 if (strip) break :blk @as(u32, 0);
105 if (mode != .Debug) break :blk 0;
106 break :blk 4;
107 };
108
109 const main_file: ?[]const u8 = if (is_stage1) null else "src/main.zig";
110
111 const exe = b.addExecutable("zig", main_file);
112 exe.strip = strip;
113 exe.install();
114 exe.setBuildMode(mode);
115 exe.setTarget(target);
116
117 b.default_step.dependOn(&exe.step);
118 exe.single_threaded = single_threaded;
119
120 if (target.isWindows() and target.getAbi() == .gnu) {
121 // LTO is currently broken on mingw, this can be removed when it's fixed.
122 exe.want_lto = false;
123 }
124
125 const exe_options = b.addOptions();
126 exe.addOptions("build_options", exe_options);
127
128 exe_options.addOption(u32, "mem_leak_frames", mem_leak_frames);
129 exe_options.addOption(bool, "skip_non_native", false);
130 exe_options.addOption(bool, "have_llvm", enable_llvm);
131 exe_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
132 exe_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
133 exe_options.addOption(bool, "llvm_has_ve", llvm_has_ve);
134 exe_options.addOption(bool, "llvm_has_arc", llvm_has_arc);
135 exe_options.addOption(bool, "force_gpa", force_gpa);
136
137 if (link_libc) {
138 exe.linkLibC();
139 }
140
141 const is_debug = mode == .Debug;
142 const enable_logging = b.option(bool, "log", "Enable debug logging with --debug-log") orelse is_debug;
143 const enable_link_snapshots = b.option(bool, "link-snapshot", "Whether to enable linker state snapshots") orelse false;
144
145 const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git.");
146 const version = if (opt_version_string) |version| version else v: {
147 const version_string = b.fmt("{d}.{d}.{d}", .{ zig_version.major, zig_version.minor, zig_version.patch });
148
149 var code: u8 = undefined;
150 const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{
151 "git", "-C", b.build_root, "describe", "--match", "*.*.*", "--tags",
152 }, &code, .Ignore) catch {
153 break :v version_string;
154 };
155 const git_describe = mem.trim(u8, git_describe_untrimmed, " \n\r");
156
157 switch (mem.count(u8, git_describe, "-")) {
158 0 => {
159 // Tagged release version (e.g. 0.9.0).
160 if (!mem.eql(u8, git_describe, version_string)) {
161 std.debug.print("Zig version '{s}' does not match Git tag '{s}'\n", .{ version_string, git_describe });
162 std.process.exit(1);
163 }
164 break :v version_string;
165 },
166 2 => {
167 // Untagged development build (e.g. 0.9.0-dev.2025+ecf0050a9).
168 var it = mem.split(u8, git_describe, "-");
169 const tagged_ancestor = it.next() orelse unreachable;
170 const commit_height = it.next() orelse unreachable;
171 const commit_id = it.next() orelse unreachable;
172
173 const ancestor_ver = try std.builtin.Version.parse(tagged_ancestor);
174 if (zig_version.order(ancestor_ver) != .gt) {
175 std.debug.print("Zig version '{}' must be greater than tagged ancestor '{}'\n", .{ zig_version, ancestor_ver });
176 std.process.exit(1);
177 }
178
179 // Check that the commit hash is prefixed with a 'g' (a Git convention).
180 if (commit_id.len < 1 or commit_id[0] != 'g') {
181 std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
182 break :v version_string;
183 }
184
185 // The version is reformatted in accordance with the https://semver.org specification.
186 break :v b.fmt("{s}-dev.{s}+{s}", .{ version_string, commit_height, commit_id[1..] });
187 },
188 else => {
189 std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe});
190 break :v version_string;
191 },
192 }
193 };
194 exe_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));
195
196 if (enable_llvm) {
197 const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option);
198
199 if (is_stage1) {
200 const softfloat = b.addStaticLibrary("softfloat", null);
201 softfloat.setBuildMode(.ReleaseFast);
202 softfloat.setTarget(target);
203 softfloat.addIncludeDir("deps/SoftFloat-3e-prebuilt");
204 softfloat.addIncludeDir("deps/SoftFloat-3e/source/8086");
205 softfloat.addIncludeDir("deps/SoftFloat-3e/source/include");
206 softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" });
207 softfloat.single_threaded = single_threaded;
208
209 const zig0 = b.addExecutable("zig0", null);
210 zig0.addCSourceFiles(&.{"src/stage1/zig0.cpp"}, &exe_cflags);
211 zig0.addIncludeDir("zig-cache/tmp"); // for config.h
212 zig0.defineCMacro("ZIG_VERSION_MAJOR", b.fmt("{d}", .{zig_version.major}));
213 zig0.defineCMacro("ZIG_VERSION_MINOR", b.fmt("{d}", .{zig_version.minor}));
214 zig0.defineCMacro("ZIG_VERSION_PATCH", b.fmt("{d}", .{zig_version.patch}));
215 zig0.defineCMacro("ZIG_VERSION_STRING", b.fmt("\"{s}\"", .{version}));
216
217 for ([_]*std.build.LibExeObjStep{ zig0, exe }) |artifact| {
218 artifact.addIncludeDir("src");
219 artifact.addIncludeDir("deps/SoftFloat-3e/source/include");
220 artifact.addIncludeDir("deps/SoftFloat-3e-prebuilt");
221
222 artifact.defineCMacro("ZIG_LINK_MODE", "Static");
223
224 artifact.addCSourceFiles(&stage1_sources, &exe_cflags);
225 artifact.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" });
226
227 artifact.linkLibrary(softfloat);
228 artifact.linkLibCpp();
229 }
230
231 try addStaticLlvmOptionsToExe(zig0);
232
233 const zig1_obj_ext = target.getObjectFormat().fileExt(target.getCpuArch());
234 const zig1_obj_path = b.pathJoin(&.{ "zig-cache", "tmp", b.fmt("zig1{s}", .{zig1_obj_ext}) });
235 const zig1_compiler_rt_path = b.pathJoin(&.{ b.pathFromRoot("lib"), "std", "special", "compiler_rt.zig" });
236
237 const zig1_obj = zig0.run();
238 zig1_obj.addArgs(&.{
239 "src/stage1.zig",
240 "-target",
241 try target.zigTriple(b.allocator),
242 "-mcpu=baseline",
243 "--name",
244 "zig1",
245 "--zig-lib-dir",
246 b.pathFromRoot("lib"),
247 b.fmt("-femit-bin={s}", .{b.pathFromRoot(zig1_obj_path)}),
248 "-fcompiler-rt",
249 "-lc",
250 });
251 {
252 zig1_obj.addArgs(&.{ "--pkg-begin", "build_options" });
253 zig1_obj.addFileSourceArg(exe_options.getSource());
254 zig1_obj.addArgs(&.{ "--pkg-end", "--pkg-begin", "compiler_rt", zig1_compiler_rt_path, "--pkg-end" });
255 }
256 switch (mode) {
257 .Debug => {},
258 .ReleaseFast => {
259 zig1_obj.addArg("-OReleaseFast");
260 zig1_obj.addArg("--strip");
261 },
262 .ReleaseSafe => {
263 zig1_obj.addArg("-OReleaseSafe");
264 zig1_obj.addArg("--strip");
265 },
266 .ReleaseSmall => {
267 zig1_obj.addArg("-OReleaseSmall");
268 zig1_obj.addArg("--strip");
269 },
270 }
271 if (single_threaded orelse false) {
272 zig1_obj.addArg("-fsingle-threaded");
273 }
274
275 exe.step.dependOn(&zig1_obj.step);
276 exe.addObjectFile(zig1_obj_path);
277
278 // This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case
279 // of being built by cmake. But when built by zig it's gonna get a compiler_rt so that
280 // is pointless.
281 exe.addPackagePath("compiler_rt", "src/empty.zig");
282 }
283 if (cmake_cfg) |cfg| {
284 // Inside this code path, we have to coordinate with system packaged LLVM, Clang, and LLD.
285 // That means we also have to rely on stage1 compiled c++ files. We parse config.h to find
286 // the information passed on to us from cmake.
287 if (cfg.cmake_prefix_path.len > 0) {
288 b.addSearchPrefix(cfg.cmake_prefix_path);
289 }
290
291 try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx);
292 } else {
293 // Here we are -Denable-llvm but no cmake integration.
294 try addStaticLlvmOptionsToExe(exe);
295 }
296 }
297
298 const semver = try std.SemanticVersion.parse(version);
299 exe_options.addOption(std.SemanticVersion, "semver", semver);
300
301 exe_options.addOption(bool, "enable_logging", enable_logging);
302 exe_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);
303 exe_options.addOption(bool, "enable_tracy", tracy != null);
304 exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack);
305 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
306 exe_options.addOption(bool, "is_stage1", is_stage1);
307 exe_options.addOption(bool, "omit_stage2", omit_stage2);
308 if (tracy) |tracy_path| {
309 const client_cpp = fs.path.join(
310 b.allocator,
311 &[_][]const u8{ tracy_path, "TracyClient.cpp" },
312 ) catch unreachable;
313
314 // On mingw, we need to opt into windows 7+ to get some features required by tracy.
315 const tracy_c_flags: []const []const u8 = if (target.isWindows() and target.getAbi() == .gnu)
316 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" }
317 else
318 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
319
320 exe.addIncludeDir(tracy_path);
321 exe.addCSourceFile(client_cpp, tracy_c_flags);
322 if (!enable_llvm) {
323 exe.linkSystemLibraryName("c++");
324 }
325 exe.linkLibC();
326
327 if (target.isWindows()) {
328 exe.linkSystemLibrary("dbghelp");
329 exe.linkSystemLibrary("ws2_32");
330 }
331 }
332}
333
334const exe_cflags = [_][]const u8{
335 "-std=c++14",
336 "-D__STDC_CONSTANT_MACROS",
337 "-D__STDC_FORMAT_MACROS",
338 "-D__STDC_LIMIT_MACROS",
339 "-D_GNU_SOURCE",
340 "-fvisibility-inlines-hidden",
341 "-fno-exceptions",
342 "-fno-rtti",
343 "-Werror=type-limits",
344 "-Wno-missing-braces",
345 "-Wno-comment",
346};
347
348fn addCmakeCfgOptionsToExe(
349 b: *Builder,
350 cfg: CMakeConfig,
351 exe: *std.build.LibExeObjStep,
352 use_zig_libcxx: bool,
353) !void {
354 exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
355 cfg.cmake_binary_dir,
356 "zigcpp",
357 b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }),
358 }) catch unreachable);
359 assert(cfg.lld_include_dir.len != 0);
360 exe.addIncludeDir(cfg.lld_include_dir);
361 addCMakeLibraryList(exe, cfg.clang_libraries);
362 addCMakeLibraryList(exe, cfg.lld_libraries);
363 addCMakeLibraryList(exe, cfg.llvm_libraries);
364
365 if (use_zig_libcxx) {
366 exe.linkLibCpp();
367 } else {
368 const need_cpp_includes = true;
369
370 // System -lc++ must be used because in this code path we are attempting to link
371 // against system-provided LLVM, Clang, LLD.
372 if (exe.target.getOsTag() == .linux) {
373 // First we try to static link against gcc libstdc++. If that doesn't work,
374 // we fall back to -lc++ and cross our fingers.
375 addCxxKnownPath(b, cfg, exe, "libstdc++.a", "", need_cpp_includes) catch |err| switch (err) {
376 error.RequiredLibraryNotFound => {
377 exe.linkSystemLibrary("c++");
378 },
379 else => |e| return e,
380 };
381 exe.linkSystemLibrary("unwind");
382 } else if (exe.target.isFreeBSD()) {
383 try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes);
384 exe.linkSystemLibrary("pthread");
385 } else if (exe.target.getOsTag() == .openbsd) {
386 try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes);
387 try addCxxKnownPath(b, cfg, exe, "libc++abi.a", null, need_cpp_includes);
388 } else if (exe.target.isDarwin()) {
389 exe.linkSystemLibrary("c++");
390 }
391 }
392
393 if (cfg.dia_guids_lib.len != 0) {
394 exe.addObjectFile(cfg.dia_guids_lib);
395 }
396}
397
398fn addStaticLlvmOptionsToExe(
399 exe: *std.build.LibExeObjStep,
400) !void {
401 // Adds the Zig C++ sources which both stage1 and stage2 need.
402 //
403 // We need this because otherwise zig_clang_cc1_main.cpp ends up pulling
404 // in a dependency on llvm::cfg::Update<llvm::BasicBlock*>::dump() which is
405 // unavailable when LLVM is compiled in Release mode.
406 const zig_cpp_cflags = exe_cflags ++ [_][]const u8{"-DNDEBUG=1"};
407 exe.addCSourceFiles(&zig_cpp_sources, &zig_cpp_cflags);
408
409 for (clang_libs) |lib_name| {
410 exe.linkSystemLibrary(lib_name);
411 }
412
413 for (lld_libs) |lib_name| {
414 exe.linkSystemLibrary(lib_name);
415 }
416
417 for (llvm_libs) |lib_name| {
418 exe.linkSystemLibrary(lib_name);
419 }
420
421 exe.linkSystemLibrary("z");
422
423 // This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries.
424 exe.linkSystemLibrary("c++");
425
426 if (exe.target.getOs().tag == .windows) {
427 exe.linkSystemLibrary("version");
428 exe.linkSystemLibrary("uuid");
429 exe.linkSystemLibrary("ole32");
430 }
431}
432
433fn addCxxKnownPath(
434 b: *Builder,
435 ctx: CMakeConfig,
436 exe: *std.build.LibExeObjStep,
437 objname: []const u8,
438 errtxt: ?[]const u8,
439 need_cpp_includes: bool,
440) !void {
441 const path_padded = try b.exec(&[_][]const u8{
442 ctx.cxx_compiler,
443 b.fmt("-print-file-name={s}", .{objname}),
444 });
445 const path_unpadded = mem.tokenize(u8, path_padded, "\r\n").next().?;
446 if (mem.eql(u8, path_unpadded, objname)) {
447 if (errtxt) |msg| {
448 std.debug.print("{s}", .{msg});
449 } else {
450 std.debug.print("Unable to determine path to {s}\n", .{objname});
451 }
452 return error.RequiredLibraryNotFound;
453 }
454 exe.addObjectFile(path_unpadded);
455
456 // TODO a way to integrate with system c++ include files here
457 // cc -E -Wp,-v -xc++ /dev/null
458 if (need_cpp_includes) {
459 // I used these temporarily for testing something but we obviously need a
460 // more general purpose solution here.
461 //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0");
462 //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/x86_64-unknown-linux-gnu");
463 //exe.addIncludeDir("/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-gnu/9.3.0/../../../../include/c++/9.3.0/backward");
464 }
465}
466
467fn addCMakeLibraryList(exe: *std.build.LibExeObjStep, list: []const u8) void {
468 var it = mem.tokenize(u8, list, ";");
469 while (it.next()) |lib| {
470 if (mem.startsWith(u8, lib, "-l")) {
471 exe.linkSystemLibrary(lib["-l".len..]);
472 } else {
473 exe.addObjectFile(lib);
474 }
475 }
476}
477
478const CMakeConfig = struct {
479 cmake_binary_dir: []const u8,
480 cmake_prefix_path: []const u8,
481 cxx_compiler: []const u8,
482 lld_include_dir: []const u8,
483 lld_libraries: []const u8,
484 clang_libraries: []const u8,
485 llvm_libraries: []const u8,
486 dia_guids_lib: []const u8,
487};
488
489const max_config_h_bytes = 1 * 1024 * 1024;
490
491fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeConfig {
492 const config_h_text: []const u8 = if (config_h_path_option) |config_h_path| blk: {
493 break :blk fs.cwd().readFileAlloc(b.allocator, config_h_path, max_config_h_bytes) catch unreachable;
494 } else blk: {
495 // TODO this should stop looking for config.h once it detects we hit the
496 // zig source root directory.
497 var check_dir = fs.path.dirname(b.zig_exe).?;
498 while (true) {
499 var dir = fs.cwd().openDir(check_dir, .{}) catch unreachable;
500 defer dir.close();
501
502 break :blk dir.readFileAlloc(b.allocator, "config.h", max_config_h_bytes) catch |err| switch (err) {
503 error.FileNotFound => {
504 const new_check_dir = fs.path.dirname(check_dir);
505 if (new_check_dir == null or mem.eql(u8, new_check_dir.?, check_dir)) {
506 return null;
507 }
508 check_dir = new_check_dir.?;
509 continue;
510 },
511 else => unreachable,
512 };
513 } else unreachable; // TODO should not need `else unreachable`.
514 };
515
516 var ctx: CMakeConfig = .{
517 .cmake_binary_dir = undefined,
518 .cmake_prefix_path = undefined,
519 .cxx_compiler = undefined,
520 .lld_include_dir = undefined,
521 .lld_libraries = undefined,
522 .clang_libraries = undefined,
523 .llvm_libraries = undefined,
524 .dia_guids_lib = undefined,
525 };
526
527 const mappings = [_]struct { prefix: []const u8, field: []const u8 }{
528 .{
529 .prefix = "#define ZIG_CMAKE_BINARY_DIR ",
530 .field = "cmake_binary_dir",
531 },
532 .{
533 .prefix = "#define ZIG_CMAKE_PREFIX_PATH ",
534 .field = "cmake_prefix_path",
535 },
536 .{
537 .prefix = "#define ZIG_CXX_COMPILER ",
538 .field = "cxx_compiler",
539 },
540 .{
541 .prefix = "#define ZIG_LLD_INCLUDE_PATH ",
542 .field = "lld_include_dir",
543 },
544 .{
545 .prefix = "#define ZIG_LLD_LIBRARIES ",
546 .field = "lld_libraries",
547 },
548 .{
549 .prefix = "#define ZIG_CLANG_LIBRARIES ",
550 .field = "clang_libraries",
551 },
552 .{
553 .prefix = "#define ZIG_LLVM_LIBRARIES ",
554 .field = "llvm_libraries",
555 },
556 .{
557 .prefix = "#define ZIG_DIA_GUIDS_LIB ",
558 .field = "dia_guids_lib",
559 },
560 };
561
562 var lines_it = mem.tokenize(u8, config_h_text, "\r\n");
563 while (lines_it.next()) |line| {
564 inline for (mappings) |mapping| {
565 if (mem.startsWith(u8, line, mapping.prefix)) {
566 var it = mem.split(u8, line, "\"");
567 _ = it.next().?; // skip the stuff before the quote
568 const quoted = it.next().?; // the stuff inside the quote
569 @field(ctx, mapping.field) = toNativePathSep(b, quoted);
570 }
571 }
572 }
573 return ctx;
574}
575
576fn toNativePathSep(b: *Builder, s: []const u8) []u8 {
577 const duplicated = b.allocator.dupe(u8, s) catch unreachable;
578 for (duplicated) |*byte| switch (byte.*) {
579 '/' => byte.* = fs.path.sep,
580 else => {},
581 };
582 return duplicated;
583}
584
585const softfloat_sources = [_][]const u8{
586 "deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c",
587 "deps/SoftFloat-3e/source/8086/extF80M_isSignalingNaN.c",
588 "deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c",
589 "deps/SoftFloat-3e/source/8086/s_commonNaNToExtF80M.c",
590 "deps/SoftFloat-3e/source/8086/s_commonNaNToF16UI.c",
591 "deps/SoftFloat-3e/source/8086/s_commonNaNToF32UI.c",
592 "deps/SoftFloat-3e/source/8086/s_commonNaNToF64UI.c",
593 "deps/SoftFloat-3e/source/8086/s_f128MToCommonNaN.c",
594 "deps/SoftFloat-3e/source/8086/s_extF80MToCommonNaN.c",
595 "deps/SoftFloat-3e/source/8086/s_f16UIToCommonNaN.c",
596 "deps/SoftFloat-3e/source/8086/s_f32UIToCommonNaN.c",
597 "deps/SoftFloat-3e/source/8086/s_f64UIToCommonNaN.c",
598 "deps/SoftFloat-3e/source/8086/s_propagateNaNF128M.c",
599 "deps/SoftFloat-3e/source/8086/s_propagateNaNExtF80M.c",
600 "deps/SoftFloat-3e/source/8086/s_propagateNaNF16UI.c",
601 "deps/SoftFloat-3e/source/8086/softfloat_raiseFlags.c",
602 "deps/SoftFloat-3e/source/f128M_add.c",
603 "deps/SoftFloat-3e/source/f128M_div.c",
604 "deps/SoftFloat-3e/source/f128M_eq.c",
605 "deps/SoftFloat-3e/source/f128M_eq_signaling.c",
606 "deps/SoftFloat-3e/source/f128M_le.c",
607 "deps/SoftFloat-3e/source/f128M_le_quiet.c",
608 "deps/SoftFloat-3e/source/f128M_lt.c",
609 "deps/SoftFloat-3e/source/f128M_lt_quiet.c",
610 "deps/SoftFloat-3e/source/f128M_mul.c",
611 "deps/SoftFloat-3e/source/f128M_mulAdd.c",
612 "deps/SoftFloat-3e/source/f128M_rem.c",
613 "deps/SoftFloat-3e/source/f128M_roundToInt.c",
614 "deps/SoftFloat-3e/source/f128M_sqrt.c",
615 "deps/SoftFloat-3e/source/f128M_sub.c",
616 "deps/SoftFloat-3e/source/f128M_to_f16.c",
617 "deps/SoftFloat-3e/source/f128M_to_f32.c",
618 "deps/SoftFloat-3e/source/f128M_to_f64.c",
619 "deps/SoftFloat-3e/source/f128M_to_extF80M.c",
620 "deps/SoftFloat-3e/source/f128M_to_i32.c",
621 "deps/SoftFloat-3e/source/f128M_to_i32_r_minMag.c",
622 "deps/SoftFloat-3e/source/f128M_to_i64.c",
623 "deps/SoftFloat-3e/source/f128M_to_i64_r_minMag.c",
624 "deps/SoftFloat-3e/source/f128M_to_ui32.c",
625 "deps/SoftFloat-3e/source/f128M_to_ui32_r_minMag.c",
626 "deps/SoftFloat-3e/source/f128M_to_ui64.c",
627 "deps/SoftFloat-3e/source/f128M_to_ui64_r_minMag.c",
628 "deps/SoftFloat-3e/source/extF80M_add.c",
629 "deps/SoftFloat-3e/source/extF80M_div.c",
630 "deps/SoftFloat-3e/source/extF80M_eq.c",
631 "deps/SoftFloat-3e/source/extF80M_le.c",
632 "deps/SoftFloat-3e/source/extF80M_lt.c",
633 "deps/SoftFloat-3e/source/extF80M_mul.c",
634 "deps/SoftFloat-3e/source/extF80M_rem.c",
635 "deps/SoftFloat-3e/source/extF80M_roundToInt.c",
636 "deps/SoftFloat-3e/source/extF80M_sqrt.c",
637 "deps/SoftFloat-3e/source/extF80M_sub.c",
638 "deps/SoftFloat-3e/source/extF80M_to_f16.c",
639 "deps/SoftFloat-3e/source/extF80M_to_f32.c",
640 "deps/SoftFloat-3e/source/extF80M_to_f64.c",
641 "deps/SoftFloat-3e/source/extF80M_to_f128M.c",
642 "deps/SoftFloat-3e/source/f16_add.c",
643 "deps/SoftFloat-3e/source/f16_div.c",
644 "deps/SoftFloat-3e/source/f16_eq.c",
645 "deps/SoftFloat-3e/source/f16_isSignalingNaN.c",
646 "deps/SoftFloat-3e/source/f16_lt.c",
647 "deps/SoftFloat-3e/source/f16_mul.c",
648 "deps/SoftFloat-3e/source/f16_mulAdd.c",
649 "deps/SoftFloat-3e/source/f16_rem.c",
650 "deps/SoftFloat-3e/source/f16_roundToInt.c",
651 "deps/SoftFloat-3e/source/f16_sqrt.c",
652 "deps/SoftFloat-3e/source/f16_sub.c",
653 "deps/SoftFloat-3e/source/f16_to_extF80M.c",
654 "deps/SoftFloat-3e/source/f16_to_f128M.c",
655 "deps/SoftFloat-3e/source/f16_to_f64.c",
656 "deps/SoftFloat-3e/source/f32_to_extF80M.c",
657 "deps/SoftFloat-3e/source/f32_to_f128M.c",
658 "deps/SoftFloat-3e/source/f64_to_extF80M.c",
659 "deps/SoftFloat-3e/source/f64_to_f128M.c",
660 "deps/SoftFloat-3e/source/f64_to_f16.c",
661 "deps/SoftFloat-3e/source/i32_to_f128M.c",
662 "deps/SoftFloat-3e/source/s_add256M.c",
663 "deps/SoftFloat-3e/source/s_addCarryM.c",
664 "deps/SoftFloat-3e/source/s_addComplCarryM.c",
665 "deps/SoftFloat-3e/source/s_addF128M.c",
666 "deps/SoftFloat-3e/source/s_addExtF80M.c",
667 "deps/SoftFloat-3e/source/s_addM.c",
668 "deps/SoftFloat-3e/source/s_addMagsF16.c",
669 "deps/SoftFloat-3e/source/s_addMagsF32.c",
670 "deps/SoftFloat-3e/source/s_addMagsF64.c",
671 "deps/SoftFloat-3e/source/s_approxRecip32_1.c",
672 "deps/SoftFloat-3e/source/s_approxRecipSqrt32_1.c",
673 "deps/SoftFloat-3e/source/s_approxRecipSqrt_1Ks.c",
674 "deps/SoftFloat-3e/source/s_approxRecip_1Ks.c",
675 "deps/SoftFloat-3e/source/s_compare128M.c",
676 "deps/SoftFloat-3e/source/s_compare96M.c",
677 "deps/SoftFloat-3e/source/s_compareNonnormExtF80M.c",
678 "deps/SoftFloat-3e/source/s_countLeadingZeros16.c",
679 "deps/SoftFloat-3e/source/s_countLeadingZeros32.c",
680 "deps/SoftFloat-3e/source/s_countLeadingZeros64.c",
681 "deps/SoftFloat-3e/source/s_countLeadingZeros8.c",
682 "deps/SoftFloat-3e/source/s_eq128.c",
683 "deps/SoftFloat-3e/source/s_invalidF128M.c",
684 "deps/SoftFloat-3e/source/s_invalidExtF80M.c",
685 "deps/SoftFloat-3e/source/s_isNaNF128M.c",
686 "deps/SoftFloat-3e/source/s_le128.c",
687 "deps/SoftFloat-3e/source/s_lt128.c",
688 "deps/SoftFloat-3e/source/s_mul128MTo256M.c",
689 "deps/SoftFloat-3e/source/s_mul64To128M.c",
690 "deps/SoftFloat-3e/source/s_mulAddF128M.c",
691 "deps/SoftFloat-3e/source/s_mulAddF16.c",
692 "deps/SoftFloat-3e/source/s_mulAddF32.c",
693 "deps/SoftFloat-3e/source/s_mulAddF64.c",
694 "deps/SoftFloat-3e/source/s_negXM.c",
695 "deps/SoftFloat-3e/source/s_normExtF80SigM.c",
696 "deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c",
697 "deps/SoftFloat-3e/source/s_normRoundPackMToExtF80M.c",
698 "deps/SoftFloat-3e/source/s_normRoundPackToF16.c",
699 "deps/SoftFloat-3e/source/s_normRoundPackToF32.c",
700 "deps/SoftFloat-3e/source/s_normRoundPackToF64.c",
701 "deps/SoftFloat-3e/source/s_normSubnormalF128SigM.c",
702 "deps/SoftFloat-3e/source/s_normSubnormalF16Sig.c",
703 "deps/SoftFloat-3e/source/s_normSubnormalF32Sig.c",
704 "deps/SoftFloat-3e/source/s_normSubnormalF64Sig.c",
705 "deps/SoftFloat-3e/source/s_remStepMBy32.c",
706 "deps/SoftFloat-3e/source/s_roundMToI64.c",
707 "deps/SoftFloat-3e/source/s_roundMToUI64.c",
708 "deps/SoftFloat-3e/source/s_roundPackMToExtF80M.c",
709 "deps/SoftFloat-3e/source/s_roundPackMToF128M.c",
710 "deps/SoftFloat-3e/source/s_roundPackToF16.c",
711 "deps/SoftFloat-3e/source/s_roundPackToF32.c",
712 "deps/SoftFloat-3e/source/s_roundPackToF64.c",
713 "deps/SoftFloat-3e/source/s_roundToI32.c",
714 "deps/SoftFloat-3e/source/s_roundToI64.c",
715 "deps/SoftFloat-3e/source/s_roundToUI32.c",
716 "deps/SoftFloat-3e/source/s_roundToUI64.c",
717 "deps/SoftFloat-3e/source/s_shiftLeftM.c",
718 "deps/SoftFloat-3e/source/s_shiftNormSigF128M.c",
719 "deps/SoftFloat-3e/source/s_shiftRightJam256M.c",
720 "deps/SoftFloat-3e/source/s_shiftRightJam32.c",
721 "deps/SoftFloat-3e/source/s_shiftRightJam64.c",
722 "deps/SoftFloat-3e/source/s_shiftRightJamM.c",
723 "deps/SoftFloat-3e/source/s_shiftRightM.c",
724 "deps/SoftFloat-3e/source/s_shortShiftLeft64To96M.c",
725 "deps/SoftFloat-3e/source/s_shortShiftLeftM.c",
726 "deps/SoftFloat-3e/source/s_shortShiftRightExtendM.c",
727 "deps/SoftFloat-3e/source/s_shortShiftRightJam64.c",
728 "deps/SoftFloat-3e/source/s_shortShiftRightJamM.c",
729 "deps/SoftFloat-3e/source/s_shortShiftRightM.c",
730 "deps/SoftFloat-3e/source/s_sub1XM.c",
731 "deps/SoftFloat-3e/source/s_sub256M.c",
732 "deps/SoftFloat-3e/source/s_subM.c",
733 "deps/SoftFloat-3e/source/s_subMagsF16.c",
734 "deps/SoftFloat-3e/source/s_subMagsF32.c",
735 "deps/SoftFloat-3e/source/s_subMagsF64.c",
736 "deps/SoftFloat-3e/source/s_tryPropagateNaNF128M.c",
737 "deps/SoftFloat-3e/source/s_tryPropagateNaNExtF80M.c",
738 "deps/SoftFloat-3e/source/softfloat_state.c",
739 "deps/SoftFloat-3e/source/ui32_to_f128M.c",
740 "deps/SoftFloat-3e/source/ui64_to_f128M.c",
741 "deps/SoftFloat-3e/source/ui32_to_extF80M.c",
742 "deps/SoftFloat-3e/source/ui64_to_extF80M.c",
743};
744
745const stage1_sources = [_][]const u8{
746 "src/stage1/analyze.cpp",
747 "src/stage1/astgen.cpp",
748 "src/stage1/bigfloat.cpp",
749 "src/stage1/bigint.cpp",
750 "src/stage1/buffer.cpp",
751 "src/stage1/codegen.cpp",
752 "src/stage1/dump_analysis.cpp",
753 "src/stage1/errmsg.cpp",
754 "src/stage1/error.cpp",
755 "src/stage1/heap.cpp",
756 "src/stage1/ir.cpp",
757 "src/stage1/ir_print.cpp",
758 "src/stage1/mem.cpp",
759 "src/stage1/os.cpp",
760 "src/stage1/parser.cpp",
761 "src/stage1/range_set.cpp",
762 "src/stage1/stage1.cpp",
763 "src/stage1/target.cpp",
764 "src/stage1/tokenizer.cpp",
765 "src/stage1/util.cpp",
766 "src/stage1/softfloat_ext.cpp",
767};
768const optimized_c_sources = [_][]const u8{
769 "src/stage1/parse_f128.c",
770};
771const zig_cpp_sources = [_][]const u8{
772 // These are planned to stay even when we are self-hosted.
773 "src/zig_llvm.cpp",
774 "src/zig_clang.cpp",
775 "src/zig_llvm-ar.cpp",
776 "src/zig_clang_driver.cpp",
777 "src/zig_clang_cc1_main.cpp",
778 "src/zig_clang_cc1as_main.cpp",
779 // https://github.com/ziglang/zig/issues/6363
780 "src/windows_sdk.cpp",
781};
782
783const clang_libs = [_][]const u8{
784 "clangFrontendTool",
785 "clangCodeGen",
786 "clangFrontend",
787 "clangDriver",
788 "clangSerialization",
789 "clangSema",
790 "clangStaticAnalyzerFrontend",
791 "clangStaticAnalyzerCheckers",
792 "clangStaticAnalyzerCore",
793 "clangAnalysis",
794 "clangASTMatchers",
795 "clangAST",
796 "clangParse",
797 "clangSema",
798 "clangBasic",
799 "clangEdit",
800 "clangLex",
801 "clangARCMigrate",
802 "clangRewriteFrontend",
803 "clangRewrite",
804 "clangCrossTU",
805 "clangIndex",
806 "clangToolingCore",
807};
808const lld_libs = [_][]const u8{
809 "lldDriver",
810 "lldMinGW",
811 "lldELF",
812 "lldCOFF",
813 "lldMachO",
814 "lldWasm",
815 "lldReaderWriter",
816 "lldCore",
817 "lldYAML",
818 "lldCommon",
819};
820// This list can be re-generated with `llvm-config --libfiles` and then
821// reformatting using your favorite text editor. Note we do not execute
822// `llvm-config` here because we are cross compiling. Also omit LLVMTableGen
823// from these libs.
824const llvm_libs = [_][]const u8{
825 "LLVMWindowsManifest",
826 "LLVMXRay",
827 "LLVMLibDriver",
828 "LLVMDlltoolDriver",
829 "LLVMCoverage",
830 "LLVMLineEditor",
831 "LLVMXCoreDisassembler",
832 "LLVMXCoreCodeGen",
833 "LLVMXCoreDesc",
834 "LLVMXCoreInfo",
835 "LLVMX86Disassembler",
836 "LLVMX86AsmParser",
837 "LLVMX86CodeGen",
838 "LLVMX86Desc",
839 "LLVMX86Info",
840 "LLVMWebAssemblyDisassembler",
841 "LLVMWebAssemblyAsmParser",
842 "LLVMWebAssemblyCodeGen",
843 "LLVMWebAssemblyDesc",
844 "LLVMWebAssemblyUtils",
845 "LLVMWebAssemblyInfo",
846 "LLVMSystemZDisassembler",
847 "LLVMSystemZAsmParser",
848 "LLVMSystemZCodeGen",
849 "LLVMSystemZDesc",
850 "LLVMSystemZInfo",
851 "LLVMSparcDisassembler",
852 "LLVMSparcAsmParser",
853 "LLVMSparcCodeGen",
854 "LLVMSparcDesc",
855 "LLVMSparcInfo",
856 "LLVMRISCVDisassembler",
857 "LLVMRISCVAsmParser",
858 "LLVMRISCVCodeGen",
859 "LLVMRISCVDesc",
860 "LLVMRISCVInfo",
861 "LLVMPowerPCDisassembler",
862 "LLVMPowerPCAsmParser",
863 "LLVMPowerPCCodeGen",
864 "LLVMPowerPCDesc",
865 "LLVMPowerPCInfo",
866 "LLVMNVPTXCodeGen",
867 "LLVMNVPTXDesc",
868 "LLVMNVPTXInfo",
869 "LLVMMSP430Disassembler",
870 "LLVMMSP430AsmParser",
871 "LLVMMSP430CodeGen",
872 "LLVMMSP430Desc",
873 "LLVMMSP430Info",
874 "LLVMMipsDisassembler",
875 "LLVMMipsAsmParser",
876 "LLVMMipsCodeGen",
877 "LLVMMipsDesc",
878 "LLVMMipsInfo",
879 "LLVMLanaiDisassembler",
880 "LLVMLanaiCodeGen",
881 "LLVMLanaiAsmParser",
882 "LLVMLanaiDesc",
883 "LLVMLanaiInfo",
884 "LLVMHexagonDisassembler",
885 "LLVMHexagonCodeGen",
886 "LLVMHexagonAsmParser",
887 "LLVMHexagonDesc",
888 "LLVMHexagonInfo",
889 "LLVMBPFDisassembler",
890 "LLVMBPFAsmParser",
891 "LLVMBPFCodeGen",
892 "LLVMBPFDesc",
893 "LLVMBPFInfo",
894 "LLVMAVRDisassembler",
895 "LLVMAVRAsmParser",
896 "LLVMAVRCodeGen",
897 "LLVMAVRDesc",
898 "LLVMAVRInfo",
899 "LLVMARMDisassembler",
900 "LLVMARMAsmParser",
901 "LLVMARMCodeGen",
902 "LLVMARMDesc",
903 "LLVMARMUtils",
904 "LLVMARMInfo",
905 "LLVMAMDGPUDisassembler",
906 "LLVMAMDGPUAsmParser",
907 "LLVMAMDGPUCodeGen",
908 "LLVMAMDGPUDesc",
909 "LLVMAMDGPUUtils",
910 "LLVMAMDGPUInfo",
911 "LLVMAArch64Disassembler",
912 "LLVMAArch64AsmParser",
913 "LLVMAArch64CodeGen",
914 "LLVMAArch64Desc",
915 "LLVMAArch64Utils",
916 "LLVMAArch64Info",
917 "LLVMOrcJIT",
918 "LLVMMCJIT",
919 "LLVMJITLink",
920 "LLVMInterpreter",
921 "LLVMExecutionEngine",
922 "LLVMRuntimeDyld",
923 "LLVMOrcTargetProcess",
924 "LLVMOrcShared",
925 "LLVMDWP",
926 "LLVMSymbolize",
927 "LLVMDebugInfoPDB",
928 "LLVMDebugInfoGSYM",
929 "LLVMOption",
930 "LLVMObjectYAML",
931 "LLVMMCA",
932 "LLVMMCDisassembler",
933 "LLVMLTO",
934 "LLVMPasses",
935 "LLVMCFGuard",
936 "LLVMCoroutines",
937 "LLVMObjCARCOpts",
938 "LLVMipo",
939 "LLVMVectorize",
940 "LLVMLinker",
941 "LLVMInstrumentation",
942 "LLVMFrontendOpenMP",
943 "LLVMFrontendOpenACC",
944 "LLVMExtensions",
945 "LLVMDWARFLinker",
946 "LLVMGlobalISel",
947 "LLVMMIRParser",
948 "LLVMAsmPrinter",
949 "LLVMDebugInfoMSF",
950 "LLVMDebugInfoDWARF",
951 "LLVMSelectionDAG",
952 "LLVMCodeGen",
953 "LLVMIRReader",
954 "LLVMAsmParser",
955 "LLVMInterfaceStub",
956 "LLVMFileCheck",
957 "LLVMFuzzMutate",
958 "LLVMTarget",
959 "LLVMScalarOpts",
960 "LLVMInstCombine",
961 "LLVMAggressiveInstCombine",
962 "LLVMTransformUtils",
963 "LLVMBitWriter",
964 "LLVMAnalysis",
965 "LLVMProfileData",
966 "LLVMObject",
967 "LLVMTextAPI",
968 "LLVMMCParser",
969 "LLVMMC",
970 "LLVMDebugInfoCodeView",
971 "LLVMBitReader",
972 "LLVMCore",
973 "LLVMRemarks",
974 "LLVMBitstreamReader",
975 "LLVMBinaryFormat",
976 "LLVMSupport",
977 "LLVMDemangle",
978};
ci/azure/pipelines.yml+1-1
...@@ -42,7 +42,7 @@ jobs:...@@ -42,7 +42,7 @@ jobs:
42 - task: DownloadSecureFile@142 - task: DownloadSecureFile@1
43 inputs:43 inputs:
44 secureFile: s3cfg44 secureFile: s3cfg
45 - script: ci/azure/windows_msvc_script.bat45 - script: ci/azure/windows_script.bat
46 name: main46 name: main
47 displayName: 'Build and test'47 displayName: 'Build and test'
48- job: OnMasterSuccess48- job: OnMasterSuccess
ci/azure/windows_msvc_install deleted-16
...@@ -1,16 +0,0 @@
1#!/bin/sh
2
3set -x
4set -e
5
6pacman -Suy --needed --noconfirm
7pacman -S --needed --noconfirm wget p7zip python3-pip tar xz
8
9TARBALL="llvm+clang+lld-13.0.0-x86_64-windows-msvc-release-mt.tar.xz"
10
11pip install s3cmd
12wget -nv "https://ziglang.org/deps/$TARBALL"
13# If the first extraction fails, re-try it once; this can happen if the tarball
14# contains symlinks that are in the table of contents before the files that
15# they point to.
16tar -xf $TARBALL || tar --overwrite -xf $TARBALL
ci/azure/windows_msvc_script.bat deleted-39
...@@ -1,39 +0,0 @@
1@echo on
2SET "SRCROOT=%cd%"
3SET "PREVPATH=%PATH%"
4SET "PREVMSYSTEM=%MSYSTEM%"
5
6set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
7SET "MSYSTEM=MINGW64"
8bash -lc "cd ${SRCROOT} && ci/azure/windows_msvc_install" || exit /b
9SET "PATH=%PREVPATH%"
10SET "MSYSTEM=%PREVMSYSTEM%"
11
12SET "ZIGBUILDDIR=%SRCROOT%\build"
13SET "ZIGINSTALLDIR=%ZIGBUILDDIR%\dist"
14SET "ZIGPREFIXPATH=%SRCROOT%\llvm+clang+lld-13.0.0-x86_64-windows-msvc-release-mt"
15
16call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
17
18REM Make the `zig version` number consistent.
19REM This will affect the cmake command below.
20git.exe config core.abbrev 9
21git.exe fetch --unshallow
22git.exe fetch --tags
23
24mkdir %ZIGBUILDDIR%
25cd %ZIGBUILDDIR%
26cmake.exe .. -Thost=x64 -G"Visual Studio 16 2019" -A x64 "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release -DZIG_OMIT_STAGE2=ON || exit /b
27msbuild /maxcpucount /p:Configuration=Release INSTALL.vcxproj || exit /b
28
29REM Sadly, stage2 is omitted from this build to save memory on the CI server. Once self-hosted is
30REM built with itself and does not gobble as much memory, we can enable these tests.
31REM "%ZIGINSTALLDIR%\bin\zig.exe" test "..\test\behavior.zig" -fno-stage1 -fLLVM -I "..\test" || exit /b
32
33"%ZIGINSTALLDIR%\bin\zig.exe" build test-toolchain -Dskip-non-native -Dskip-stage2-tests || exit /b
34"%ZIGINSTALLDIR%\bin\zig.exe" build test-std -Dskip-non-native || exit /b
35"%ZIGINSTALLDIR%\bin\zig.exe" build docs || exit /b
36
37set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
38SET "MSYSTEM=MINGW64"
39bash -lc "cd ${SRCROOT} && ci/azure/windows_upload" || exit /b
ci/azure/windows_script created+94
...@@ -0,0 +1,94 @@
1#!/bin/sh
2
3set -x
4set -e
5
6pacman -Suy --needed --noconfirm
7pacman -S --needed --noconfirm wget p7zip python3-pip git
8pip install s3cmd
9
10ZIGDIR="$(pwd)"
11ARCH="x86_64"
12TARGET="$ARCH-windows-gnu"
13CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.9.1"
14PREFIX="$HOME/$CACHE_BASENAME"
15ZIG="$PREFIX/bin/zig.exe"
16
17rm -rf $PREFIX
18cd $HOME
19
20wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.zip"
217z x "$CACHE_BASENAME.zip"
22
23cd $ZIGDIR
24
25# Make the `zig version` number consistent.
26# This will affect the `zig build` command below.
27git config core.abbrev 9
28git fetch --unshallow || true
29git fetch --tags
30
31# The dev kit zip file that we have here is old, and may be incompatible with
32# the build.zig script of master branch. So we keep an old version of build.zig
33# here in the CI directory.
34mv build.zig build.zig.master
35mv ci/azure/build.zig build.zig
36
37# stage2 is omitted until we resolve https://github.com/ziglang/zig/issues/6485
38$ZIG build \
39 --prefix dist \
40 --search-prefix "$PREFIX" \
41 -Dstage1 \
42 -Domit-stage2 \
43 -Dstatic-llvm \
44 -Drelease \
45 -Dstrip \
46 -Duse-zig-libcxx \
47 -Dtarget=$TARGET
48
49# Now that we have built an up-to-date zig.exe, we restore the original
50# build script from master branch.
51mv build.zig.master build.zig
52
53dist/bin/zig.exe build test-toolchain -Dskip-non-native -Dskip-stage2-tests
54dist/bin/zig.exe build test-std -Dskip-non-native
55dist/bin/zig.exe build docs
56
57if [ "${BUILD_REASON}" != "PullRequest" ]; then
58 mv LICENSE dist/
59 mv zig-cache/langref.html dist/
60 mv dist/bin/zig.exe dist/
61 rmdir dist/bin
62
63 # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
64 mv dist/lib/zig dist/lib2
65 rmdir dist/lib
66 mv dist/lib2 dist/lib
67
68 VERSION=$(dist/zig.exe version)
69 DIRNAME="zig-windows-x86_64-$VERSION"
70 TARBALL="$DIRNAME.zip"
71 mv dist "$DIRNAME"
72 7z a "$TARBALL" "$DIRNAME"
73
74 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
75
76 SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
77 BYTESIZE=$(wc -c < $TARBALL)
78
79 JSONFILE="windows-$GITBRANCH.json"
80 touch $JSONFILE
81 echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
82 echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
83 echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
84
85 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
86 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$VERSION.json"
87
88 # `set -x` causes these variables to be mangled.
89 # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
90 set +x
91 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
92 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
93 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
94fi
ci/azure/windows_script.bat created+8
...@@ -0,0 +1,8 @@
1@echo on
2SET "SRCROOT=%cd%"
3SET "PREVPATH=%PATH%"
4SET "PREVMSYSTEM=%MSYSTEM%"
5
6set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
7SET "MSYSTEM=MINGW64"
8bash -lc "cd ${SRCROOT} && ci/azure/windows_script" || exit /b
ci/azure/windows_upload deleted-46
...@@ -1,46 +0,0 @@
1#!/bin/sh
2
3set -x
4set -e
5
6if [ "${BUILD_REASON}" != "PullRequest" ]; then
7 cd "$ZIGBUILDDIR"
8
9 mv ../LICENSE dist/
10 mv ../zig-cache/langref.html dist/
11 mv dist/bin/zig.exe dist/
12 rmdir dist/bin
13
14 # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
15 mv dist/lib/zig dist/lib2
16 rmdir dist/lib
17 mv dist/lib2 dist/lib
18
19 VERSION=$(dist/zig.exe version)
20 DIRNAME="zig-windows-x86_64-$VERSION"
21 TARBALL="$DIRNAME.zip"
22 mv dist "$DIRNAME"
23 7z a "$TARBALL" "$DIRNAME"
24
25 # mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
26 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
27
28 SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
29 BYTESIZE=$(wc -c < $TARBALL)
30
31 JSONFILE="windows-$GITBRANCH.json"
32 touch $JSONFILE
33 echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
34 echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
35 echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
36
37 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
38 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$VERSION.json"
39
40 # `set -x` causes these variables to be mangled.
41 # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
42 set +x
43 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
44 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
45 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
46fi
cmake/Findllvm.cmake+1-13
...@@ -181,19 +181,7 @@ else()...@@ -181,19 +181,7 @@ else()
181181
182 macro(FIND_AND_ADD_LLVM_LIB _libname_)182 macro(FIND_AND_ADD_LLVM_LIB _libname_)
183 string(TOUPPER ${_libname_} _prettylibname_)183 string(TOUPPER ${_libname_} _prettylibname_)
184 find_library(LLVM_${_prettylibname_}_LIB NAMES ${_libname_}184 find_library(LLVM_${_prettylibname_}_LIB NAMES ${_libname_} PATHS ${LLVM_LIBDIRS})
185 PATHS
186 ${LLVM_LIBDIRS}
187 /usr/lib/llvm/13/lib
188 /usr/lib/llvm-13/lib
189 /usr/lib/llvm-13.0/lib
190 /usr/local/llvm130/lib
191 /usr/local/llvm13/lib
192 /usr/local/opt/llvm@13/lib
193 /opt/homebrew/opt/llvm@13/lib
194 /mingw64/lib
195 /c/msys64/mingw64/lib
196 c:\\msys64\\mingw64\\lib)
197 set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})185 set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})
198 endmacro(FIND_AND_ADD_LLVM_LIB)186 endmacro(FIND_AND_ADD_LLVM_LIB)
199187
src/stage1/zig0.cpp+2-3
...@@ -18,10 +18,9 @@...@@ -18,10 +18,9 @@
18#include "buffer.hpp"18#include "buffer.hpp"
19#include "os.hpp"19#include "os.hpp"
2020
21// This is the only file allowed to include config.h because config.h is21#ifndef ZIG_VERSION_STRING
22// only produced when building with cmake. When using the zig build system,
23// zig0.cpp is never touched.
24#include "config.h"22#include "config.h"
23#endif
2524
26#include <stdio.h>25#include <stdio.h>
27#include <string.h>26#include <string.h>