Skip to content

Commit

Permalink
update zig sources to 0.10.0-dev.3524+74673b7f6
Browse files Browse the repository at this point in the history
also revert build back to stage1/stage2 combo because stage3 on windows
is buggy.
  • Loading branch information
andrewrk committed Aug 11, 2022
1 parent 80432f5 commit abf42a0
Show file tree
Hide file tree
Showing 26 changed files with 353 additions and 164 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ to find and inspect the patch diffs.

* LLVM, LLD, Clang 14.0.6
* zlib 1.2.12
* zig 0.10.0-dev.3530+d2ecb0d7c
* zig 0.10.0-dev.3524+74673b7f6

For other versions, check the git tags of this repository.

Expand Down
32 changes: 20 additions & 12 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TARGET="$2" # Example: riscv64-linux-gnu
MCPU="$3" # Examples: `baseline`, `native`, `generic+v7a`, or `arm1176jzf_s`

ROOTDIR="$(pwd)"
ZIG_VERSION="0.10.0-dev.3530+d2ecb0d7c"
ZIG_VERSION="0.10.0-dev.3524+74673b7f6"

TARGET_OS_AND_ABI=${TARGET#*-} # Example: linux-gnu

Expand Down Expand Up @@ -118,14 +118,22 @@ cd "$ROOTDIR/out/build-llvm-$TARGET-$MCPU"
make "$JOBS" install-llvm-headers install-clang-headers install-LLVMSupport install-LLVMDemangle

# Finally, we can cross compile Zig itself, with Zig.
cd "$ROOTDIR/zig"
$ZIG build \
--prefix "$ROOTDIR/out/zig-$TARGET-$MCPU" \
--search-prefix "$ROOTDIR/out/$TARGET-$MCPU" \
-Dstatic-llvm \
-Drelease \
-Dstrip \
-Dtarget="$TARGET" \
-Dcpu="$MCPU" \
-Dversion-string="$ZIG_VERSION" \
-Denable-stage1
mkdir -p "$ROOTDIR/out/build-zig-$TARGET-$MCPU"
cd "$ROOTDIR/out/build-zig-$TARGET-$MCPU"
cmake "$ROOTDIR/zig" \
-DCMAKE_INSTALL_PREFIX="$ROOTDIR/out/zig-$TARGET-$MCPU" \
-DCMAKE_PREFIX_PATH="$ROOTDIR/out/$TARGET-$MCPU" \
-DCMAKE_CROSSCOMPILING=True \
-DCMAKE_SYSTEM_NAME="$TARGET_OS_CMAKE" \
-DCMAKE_AR="$ROOTDIR/out/host/bin/llvm-ar" \
-DCMAKE_RANLIB="$ROOTDIR/out/host/bin/llvm-ranlib" \
-DCMAKE_BUILD_TYPE=Release \
-DZIG_TARGET_TRIPLE="$TARGET" \
-DZIG_TARGET_MCPU="$MCPU" \
-DZIG_EXECUTABLE="$ZIG" \
-DZIG_VERSION="$ZIG_VERSION" \
-DZIG_USE_LLVM_CONFIG=OFF \
-DZIG_STATIC_ZLIB=ON
unset CC
unset CXX
make "$JOBS" install
2 changes: 1 addition & 1 deletion zig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage2" CACHE STRING
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage1" CACHE STRING
"Directory to install zig to" FORCE)
endif()

Expand Down
30 changes: 19 additions & 11 deletions zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ pub fn build(b: *Builder) !void {

const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;

const have_stage1 = b.option(bool, "enable-stage1", "Include the stage1 compiler behind a feature flag") orelse false;
const is_stage1 = b.option(bool, "stage1", "Build the stage1 compiler, put stage2 behind a feature flag") orelse false;
const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false;
const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false;
const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (have_stage1 or static_llvm);
const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm);
const llvm_has_m68k = b.option(
bool,
"llvm-has-m68k",
Expand Down Expand Up @@ -136,7 +137,7 @@ pub fn build(b: *Builder) !void {
};

const main_file: ?[]const u8 = mf: {
if (!have_stage1) break :mf "src/main.zig";
if (!is_stage1) break :mf "src/main.zig";
if (use_zig0) break :mf null;
break :mf "src/stage1.zig";
};
Expand Down Expand Up @@ -247,7 +248,7 @@ pub fn build(b: *Builder) !void {
}
};

if (have_stage1) {
if (is_stage1) {
const softfloat = b.addStaticLibrary("softfloat", null);
softfloat.setBuildMode(.ReleaseFast);
softfloat.setTarget(target);
Expand Down Expand Up @@ -359,7 +360,8 @@ pub fn build(b: *Builder) !void {
exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack);
exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
exe_options.addOption(bool, "value_tracing", value_tracing);
exe_options.addOption(bool, "have_stage1", have_stage1);
exe_options.addOption(bool, "is_stage1", is_stage1);
exe_options.addOption(bool, "omit_stage2", omit_stage2);
if (tracy) |tracy_path| {
const client_cpp = fs.path.join(
b.allocator,
Expand Down Expand Up @@ -394,7 +396,8 @@ pub fn build(b: *Builder) !void {
test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);
test_cases_options.addOption(bool, "skip_non_native", skip_non_native);
test_cases_options.addOption(bool, "skip_stage1", skip_stage1);
test_cases_options.addOption(bool, "have_stage1", have_stage1);
test_cases_options.addOption(bool, "is_stage1", is_stage1);
test_cases_options.addOption(bool, "omit_stage2", omit_stage2);
test_cases_options.addOption(bool, "have_llvm", enable_llvm);
test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
Expand Down Expand Up @@ -454,7 +457,8 @@ pub fn build(b: *Builder) !void {
skip_non_native,
skip_libc,
skip_stage1,
false,
omit_stage2,
is_stage1,
));

toolchain_step.dependOn(tests.addPkgTests(
Expand All @@ -468,7 +472,8 @@ pub fn build(b: *Builder) !void {
skip_non_native,
true, // skip_libc
skip_stage1,
true, // TODO get these all passing
omit_stage2 or true, // TODO get these all passing
is_stage1,
));

toolchain_step.dependOn(tests.addPkgTests(
Expand All @@ -482,7 +487,8 @@ pub fn build(b: *Builder) !void {
skip_non_native,
true, // skip_libc
skip_stage1,
true, // TODO get these all passing
omit_stage2 or true, // TODO get these all passing
is_stage1,
));

toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
Expand All @@ -493,13 +499,14 @@ pub fn build(b: *Builder) !void {
skip_non_native,
enable_macos_sdk,
target,
omit_stage2,
b.enable_darling,
b.enable_qemu,
b.enable_rosetta,
b.enable_wasmtime,
b.enable_wine,
));
toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk));
toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, omit_stage2));
toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes));
toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
Expand All @@ -521,7 +528,8 @@ pub fn build(b: *Builder) !void {
skip_non_native,
skip_libc,
skip_stage1,
true, // TODO get these all passing
omit_stage2 or true, // TODO get these all passing
is_stage1,
);

const test_step = b.step("test", "Run all the tests");
Expand Down
31 changes: 0 additions & 31 deletions zig/doc/docgen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ const Code = struct {
link_objects: []const []const u8,
target_str: ?[]const u8,
link_libc: bool,
backend_stage1: bool,
link_mode: ?std.builtin.LinkMode,
disable_cache: bool,
verbose_cimport: bool,
Expand Down Expand Up @@ -555,7 +554,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
var link_mode: ?std.builtin.LinkMode = null;
var disable_cache = false;
var verbose_cimport = false;
var backend_stage1 = false;

const source_token = while (true) {
const content_tok = try eatToken(tokenizer, Token.Id.Content);
Expand Down Expand Up @@ -588,8 +586,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
link_libc = true;
} else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) {
link_mode = .Dynamic;
} else if (mem.eql(u8, end_tag_name, "backend_stage1")) {
backend_stage1 = true;
} else if (mem.eql(u8, end_tag_name, "code_end")) {
_ = try eatToken(tokenizer, Token.Id.BracketClose);
break content_tok;
Expand All @@ -613,7 +609,6 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
.link_objects = link_objects.toOwnedSlice(),
.target_str = target_str,
.link_libc = link_libc,
.backend_stage1 = backend_stage1,
.link_mode = link_mode,
.disable_cache = disable_cache,
.verbose_cimport = verbose_cimport,
Expand Down Expand Up @@ -1192,9 +1187,6 @@ fn printShell(out: anytype, shell_content: []const u8) !void {
try out.writeAll("</samp></pre></figure>");
}

// Override this to skip to later tests
const debug_start_line = 0;

fn genHtml(
allocator: Allocator,
tokenizer: *Tokenizer,
Expand Down Expand Up @@ -1274,13 +1266,6 @@ fn genHtml(
continue;
}

if (debug_start_line > 0) {
const loc = tokenizer.getTokenLocation(code.source_token);
if (debug_start_line > loc.line) {
continue;
}
}

const raw_source = tokenizer.buffer[code.source_token.start..code.source_token.end];
const trimmed_raw_source = mem.trim(u8, raw_source, " \n");
const tmp_source_file_name = try fs.path.join(
Expand Down Expand Up @@ -1326,10 +1311,6 @@ fn genHtml(
try build_args.append("-lc");
try shell_out.print("-lc ", .{});
}
if (code.backend_stage1) {
try build_args.append("-fstage1");
try shell_out.print("-fstage1", .{});
}
const target = try std.zig.CrossTarget.parse(.{
.arch_os_abi = code.target_str orelse "native",
});
Expand Down Expand Up @@ -1462,10 +1443,6 @@ fn genHtml(
try test_args.append("-lc");
try shell_out.print("-lc ", .{});
}
if (code.backend_stage1) {
try test_args.append("-fstage1");
try shell_out.print("-fstage1", .{});
}
if (code.target_str) |triple| {
try test_args.appendSlice(&[_][]const u8{ "-target", triple });
try shell_out.print("-target {s} ", .{triple});
Expand Down Expand Up @@ -1513,14 +1490,6 @@ fn genHtml(
try shell_out.print("-O {s} ", .{@tagName(code.mode)});
},
}
if (code.link_libc) {
try test_args.append("-lc");
try shell_out.print("-lc ", .{});
}
if (code.backend_stage1) {
try test_args.append("-fstage1");
try shell_out.print("-fstage1", .{});
}
const result = try ChildProcess.exec(.{
.allocator = allocator,
.argv = test_args.items,
Expand Down
Loading

0 comments on commit abf42a0

Please sign in to comment.