struct CrtBasenames [src]
These are basenames. This data is produced with a pure function. See also
CsuPaths.
Fields
crt0: ?[]const u8 = null
crti: ?[]const u8 = null
crtbegin: ?[]const u8 = null
crtend: ?[]const u8 = null
crtn: ?[]const u8 = null
Members
Source
pub const CrtBasenames = struct {
crt0: ?[]const u8 = null,
crti: ?[]const u8 = null,
crtbegin: ?[]const u8 = null,
crtend: ?[]const u8 = null,
crtn: ?[]const u8 = null,
pub const GetArgs = struct {
target: std.Target,
link_libc: bool,
output_mode: std.builtin.OutputMode,
link_mode: std.builtin.LinkMode,
pie: bool,
};
/// Determine file system path names of C runtime startup objects for supported
/// link modes.
pub fn get(args: GetArgs) CrtBasenames {
// crt objects are only required for libc.
if (!args.link_libc) return .{};
// Flatten crt cases.
const mode: enum {
dynamic_lib,
dynamic_exe,
dynamic_pie,
static_exe,
static_pie,
} = switch (args.output_mode) {
.Obj => return .{},
.Lib => switch (args.link_mode) {
.dynamic => .dynamic_lib,
.static => return .{},
},
.Exe => switch (args.link_mode) {
.dynamic => if (args.pie) .dynamic_pie else .dynamic_exe,
.static => if (args.pie) .static_pie else .static_exe,
},
};
const target = args.target;
if (target.abi.isAndroid()) return switch (mode) {
.dynamic_lib => .{
.crtbegin = "crtbegin_so.o",
.crtend = "crtend_so.o",
},
.dynamic_exe, .dynamic_pie => .{
.crtbegin = "crtbegin_dynamic.o",
.crtend = "crtend_android.o",
},
.static_exe, .static_pie => .{
.crtbegin = "crtbegin_static.o",
.crtend = "crtend_android.o",
},
};
return switch (target.os.tag) {
.linux => switch (mode) {
.dynamic_lib => .{
.crti = "crti.o",
.crtn = "crtn.o",
},
.dynamic_exe => .{
.crt0 = "crt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
},
.dynamic_pie => .{
.crt0 = "Scrt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
},
.static_exe => .{
.crt0 = "crt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
},
.static_pie => .{
.crt0 = "rcrt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
},
},
.dragonfly => switch (mode) {
.dynamic_lib => .{
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
.dynamic_exe => .{
.crt0 = "crt1.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o",
.crtend = "crtend.o",
.crtn = "crtn.o",
},
.dynamic_pie => .{
.crt0 = "Scrt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
.static_exe => .{
.crt0 = "crt1.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o",
.crtend = "crtend.o",
.crtn = "crtn.o",
},
.static_pie => .{
.crt0 = "Scrt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
},
.freebsd => switch (mode) {
.dynamic_lib => .{
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
.dynamic_exe => .{
.crt0 = "crt1.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o",
.crtend = "crtend.o",
.crtn = "crtn.o",
},
.dynamic_pie => .{
.crt0 = "Scrt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
.static_exe => .{
.crt0 = "crt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginT.o",
.crtend = "crtend.o",
.crtn = "crtn.o",
},
.static_pie => .{
.crt0 = "Scrt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
},
.netbsd => switch (mode) {
.dynamic_lib => .{
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
.dynamic_exe => .{
.crt0 = "crt0.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o",
.crtend = "crtend.o",
.crtn = "crtn.o",
},
.dynamic_pie => .{
.crt0 = "crt0.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
.static_exe => .{
.crt0 = "crt0.o",
.crti = "crti.o",
.crtbegin = "crtbeginT.o",
.crtend = "crtend.o",
.crtn = "crtn.o",
},
.static_pie => .{
.crt0 = "crt0.o",
.crti = "crti.o",
.crtbegin = "crtbeginT.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
},
.openbsd => switch (mode) {
.dynamic_lib => .{
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
},
.dynamic_exe, .dynamic_pie => .{
.crt0 = "crt0.o",
.crtbegin = "crtbegin.o",
.crtend = "crtend.o",
},
.static_exe, .static_pie => .{
.crt0 = "rcrt0.o",
.crtbegin = "crtbegin.o",
.crtend = "crtend.o",
},
},
.haiku => switch (mode) {
.dynamic_lib => .{
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
.dynamic_exe => .{
.crt0 = "start_dyn.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o",
.crtend = "crtend.o",
.crtn = "crtn.o",
},
.dynamic_pie => .{
.crt0 = "start_dyn.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
.static_exe => .{
.crt0 = "start_dyn.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o",
.crtend = "crtend.o",
.crtn = "crtn.o",
},
.static_pie => .{
.crt0 = "start_dyn.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o",
.crtend = "crtendS.o",
.crtn = "crtn.o",
},
},
.solaris, .illumos => switch (mode) {
.dynamic_lib => .{
.crti = "crti.o",
.crtn = "crtn.o",
},
.dynamic_exe, .dynamic_pie => .{
.crt0 = "crt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
},
.static_exe, .static_pie => .{},
},
else => .{},
};
}
}