Commit 938f9dea37
Changed files (14)
lib
std
Build
Step
lib/std/Build/Step/Compile.zig
@@ -1853,7 +1853,11 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
if (self.global_base) |global_base| {
try zig_args.append(b.fmt("--global-base={d}", .{global_base}));
}
- try addFlag(&zig_args, "entry", self.no_entry);
+ // invert the value due to naming so when `no_entry` is set to 'true'
+ // we actually emit the flag `-fno_entry`.
+ if (self.no_entry) |no_entry| {
+ try addFlag(&zig_args, "entry", !no_entry);
+ }
if (self.code_model != .default) {
try zig_args.append("-mcmodel");
test/link/wasm/archive/build.zig
@@ -15,12 +15,13 @@ pub fn build(b: *std.Build) void {
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
// The code in question will pull-in compiler-rt,
// and therefore link with its archive file.
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "main",
.root_source_file = .{ .path = "main.zig" },
.optimize = optimize,
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
});
+ lib.no_entry = true;
lib.use_llvm = false;
lib.use_lld = false;
lib.strip = false;
test/link/wasm/basic-features/build.zig
@@ -4,7 +4,7 @@ pub const requires_stage2 = true;
pub fn build(b: *std.Build) void {
// Library with explicitly set cpu features
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "main.zig" },
.optimize = .Debug,
@@ -15,6 +15,7 @@ pub fn build(b: *std.Build) void {
.os_tag = .freestanding,
},
});
+ lib.no_entry = true;
lib.use_llvm = false;
lib.use_lld = false;
test/link/wasm/bss/build.zig
@@ -14,12 +14,13 @@ pub fn build(b: *std.Build) void {
fn add(b: *std.Build, test_step: *std.Build.Step, optimize_mode: std.builtin.OptimizeMode, is_safe: bool) void {
{
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "lib.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize_mode,
});
+ lib.no_entry = true;
lib.use_llvm = false;
lib.use_lld = false;
lib.strip = false;
@@ -60,12 +61,13 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize_mode: std.builtin.Opt
// verify zero'd declaration is stored in bss for all optimization modes.
{
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "lib2.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize_mode,
});
+ lib.no_entry = true;
lib.use_llvm = false;
lib.use_lld = false;
lib.strip = false;
test/link/wasm/export/build.zig
@@ -13,31 +13,34 @@ pub fn build(b: *std.Build) void {
}
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
- const no_export = b.addSharedLibrary(.{
+ const no_export = b.addExecutable(.{
.name = "no-export",
.root_source_file = .{ .path = "main.zig" },
.optimize = optimize,
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
});
+ no_export.no_entry = true;
no_export.use_llvm = false;
no_export.use_lld = false;
- const dynamic_export = b.addSharedLibrary(.{
+ const dynamic_export = b.addExecutable(.{
.name = "dynamic",
.root_source_file = .{ .path = "main.zig" },
.optimize = optimize,
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
});
+ dynamic_export.no_entry = true;
dynamic_export.rdynamic = true;
dynamic_export.use_llvm = false;
dynamic_export.use_lld = false;
- const force_export = b.addSharedLibrary(.{
+ const force_export = b.addExecutable(.{
.name = "force",
.root_source_file = .{ .path = "main.zig" },
.optimize = optimize,
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
});
+ force_export.no_entry = true;
force_export.export_symbol_names = &.{"foo"};
force_export.use_llvm = false;
force_export.use_lld = false;
test/link/wasm/export-data/build.zig
@@ -9,12 +9,13 @@ pub fn build(b: *std.Build) void {
return;
}
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "lib.zig" },
.optimize = .ReleaseSafe, // to make the output deterministic in address positions
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
});
+ lib.no_entry = true;
lib.use_lld = false;
lib.export_symbol_names = &.{ "foo", "bar" };
lib.global_base = 0; // put data section at address 0 to make data symbols easier to parse
test/link/wasm/extern-mangle/build.zig
@@ -11,12 +11,13 @@ pub fn build(b: *std.Build) void {
}
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "lib.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize,
});
+ lib.no_entry = true;
lib.import_symbols = true; // import `a` and `b`
lib.rdynamic = true; // export `foo`
test/link/wasm/function-table/build.zig
@@ -13,32 +13,35 @@ pub fn build(b: *std.Build) void {
}
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
- const import_table = b.addSharedLibrary(.{
+ const import_table = b.addExecutable(.{
.name = "import_table",
.root_source_file = .{ .path = "lib.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize,
});
+ import_table.no_entry = true;
import_table.use_llvm = false;
import_table.use_lld = false;
import_table.import_table = true;
- const export_table = b.addSharedLibrary(.{
+ const export_table = b.addExecutable(.{
.name = "export_table",
.root_source_file = .{ .path = "lib.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize,
});
+ export_table.no_entry = true;
export_table.use_llvm = false;
export_table.use_lld = false;
export_table.export_table = true;
- const regular_table = b.addSharedLibrary(.{
+ const regular_table = b.addExecutable(.{
.name = "regular_table",
.root_source_file = .{ .path = "lib.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize,
});
+ regular_table.no_entry = true;
regular_table.use_llvm = false;
regular_table.use_lld = false;
test/link/wasm/infer-features/build.zig
@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
// Wasm library that doesn't have any features specified. This will
// infer its featureset from other linked object files.
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "main.zig" },
.optimize = .Debug,
@@ -27,6 +27,7 @@ pub fn build(b: *std.Build) void {
.os_tag = .freestanding,
},
});
+ lib.no_entry = true;
lib.use_llvm = false;
lib.use_lld = false;
lib.addObject(c_obj);
test/link/wasm/producers/build.zig
@@ -14,12 +14,13 @@ pub fn build(b: *std.Build) void {
}
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "lib.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize,
});
+ lib.no_entry = true;
lib.use_llvm = false;
lib.use_lld = false;
lib.strip = false;
test/link/wasm/segments/build.zig
@@ -13,12 +13,13 @@ pub fn build(b: *std.Build) void {
}
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "lib.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize,
});
+ lib.no_entry = true;
lib.use_llvm = false;
lib.use_lld = false;
lib.strip = false;
test/link/wasm/stack_pointer/build.zig
@@ -13,12 +13,13 @@ pub fn build(b: *std.Build) void {
}
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "lib.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize,
});
+ lib.no_entry = true;
lib.use_llvm = false;
lib.use_lld = false;
lib.strip = false;
test/link/wasm/type/build.zig
@@ -13,12 +13,13 @@ pub fn build(b: *std.Build) void {
}
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
- const lib = b.addSharedLibrary(.{
+ const lib = b.addExecutable(.{
.name = "lib",
.root_source_file = .{ .path = "lib.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .freestanding },
.optimize = optimize,
});
+ lib.no_entry = true;
lib.use_llvm = false;
lib.use_lld = false;
lib.strip = false;