mirror of
https://github.com/ziglang/zig.git
synced 2024-12-13 06:37:30 +00:00
stage2: improvements to entry point handling
* rename `entry` to `entry_symbol_name` for the zig build API * integrate with `zig cc` command line options * integrate with COFF linking with LLD * integrate with self-hosted ELF linker * don't put it in the hash for MachO since it is ignored
This commit is contained in:
parent
5ae3e4e9bd
commit
fd6d1fe015
@ -1554,8 +1554,7 @@ pub const LibExeObjStep = struct {
|
||||
|
||||
subsystem: ?std.Target.SubSystem = null,
|
||||
|
||||
/// Entrypoint symbol name
|
||||
entry: ?[]const u8 = null,
|
||||
entry_symbol_name: ?[]const u8 = null,
|
||||
|
||||
/// Overrides the default stack size
|
||||
stack_size: ?u64 = null,
|
||||
@ -2258,7 +2257,7 @@ pub const LibExeObjStep = struct {
|
||||
try zig_args.append(@tagName(builder.color));
|
||||
}
|
||||
|
||||
if (self.entry) |entry| {
|
||||
if (self.entry_symbol_name) |entry| {
|
||||
try zig_args.append("--entry");
|
||||
try zig_args.append(entry);
|
||||
}
|
||||
|
@ -1655,7 +1655,7 @@ flagpsl("MT"),
|
||||
.{
|
||||
.name = "entry",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .other,
|
||||
.zig_equivalent = .entry,
|
||||
.pd1 = false,
|
||||
.pd2 = true,
|
||||
.psl = false,
|
||||
@ -6701,7 +6701,14 @@ joinpd1("Z"),
|
||||
joinpd1("a"),
|
||||
jspd1("b"),
|
||||
joinpd1("d"),
|
||||
jspd1("e"),
|
||||
.{
|
||||
.name = "e",
|
||||
.syntax = .joined_or_separate,
|
||||
.zig_equivalent = .entry,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "l",
|
||||
.syntax = .joined_or_separate,
|
||||
|
@ -1071,6 +1071,10 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
|
||||
try argv.append("-DLL");
|
||||
}
|
||||
|
||||
if (self.base.options.entry) |entry| {
|
||||
try argv.append(try allocPrint(arena, "-ENTRY:{s}", .{entry}));
|
||||
}
|
||||
|
||||
if (self.base.options.tsaware) {
|
||||
try argv.append("-tsaware");
|
||||
}
|
||||
|
@ -2889,7 +2889,8 @@ pub fn updateDeclExports(
|
||||
const stb_bits: u8 = switch (exp.options.linkage) {
|
||||
.Internal => elf.STB_LOCAL,
|
||||
.Strong => blk: {
|
||||
if (mem.eql(u8, exp.options.name, "_start")) {
|
||||
const entry_name = self.base.options.entry orelse "_start";
|
||||
if (mem.eql(u8, exp.options.name, entry_name)) {
|
||||
self.entry_addr = decl_sym.st_value;
|
||||
}
|
||||
break :blk elf.STB_GLOBAL;
|
||||
|
@ -509,7 +509,6 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void {
|
||||
try man.addOptionalFile(module_obj_path);
|
||||
// We can skip hashing libc and libc++ components that we are in charge of building from Zig
|
||||
// installation sources because they are always a product of the compiler version + target information.
|
||||
man.hash.addOptionalBytes(self.base.options.entry);
|
||||
man.hash.add(stack_size);
|
||||
man.hash.addListOfBytes(self.base.options.lib_dirs);
|
||||
man.hash.addListOfBytes(self.base.options.framework_dirs);
|
||||
|
@ -1485,6 +1485,9 @@ fn buildOutputType(
|
||||
.sysroot => {
|
||||
sysroot = it.only_arg;
|
||||
},
|
||||
.entry => {
|
||||
entry = it.only_arg;
|
||||
},
|
||||
}
|
||||
}
|
||||
// Parse linker args.
|
||||
@ -4156,6 +4159,7 @@ pub const ClangArgIterator = struct {
|
||||
exec_model,
|
||||
emit_llvm,
|
||||
sysroot,
|
||||
entry,
|
||||
};
|
||||
|
||||
const Args = struct {
|
||||
|
@ -416,6 +416,14 @@ const known_options = [_]KnownOpt{
|
||||
.name = "sysroot",
|
||||
.ident = "sysroot",
|
||||
},
|
||||
.{
|
||||
.name = "entry",
|
||||
.ident = "entry",
|
||||
},
|
||||
.{
|
||||
.name = "e",
|
||||
.ident = "entry",
|
||||
},
|
||||
};
|
||||
|
||||
const blacklisted_options = [_][]const u8{};
|
||||
|
Loading…
Reference in New Issue
Block a user