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