mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 00:35:10 +00:00
add --eh-frame-hdr conditionally
This commit is contained in:
parent
599213463d
commit
8e57dd57ca
@ -40,6 +40,7 @@ pub const Builder = struct {
|
|||||||
verbose_ir: bool,
|
verbose_ir: bool,
|
||||||
verbose_llvm_ir: bool,
|
verbose_llvm_ir: bool,
|
||||||
verbose_cimport: bool,
|
verbose_cimport: bool,
|
||||||
|
link_eh_frame_hdr: bool,
|
||||||
invalid_user_input: bool,
|
invalid_user_input: bool,
|
||||||
zig_exe: []const u8,
|
zig_exe: []const u8,
|
||||||
default_step: *Step,
|
default_step: *Step,
|
||||||
@ -136,6 +137,7 @@ pub const Builder = struct {
|
|||||||
.verbose_ir = false,
|
.verbose_ir = false,
|
||||||
.verbose_llvm_ir = false,
|
.verbose_llvm_ir = false,
|
||||||
.verbose_cimport = false,
|
.verbose_cimport = false,
|
||||||
|
.link_eh_frame_hdr = false,
|
||||||
.invalid_user_input = false,
|
.invalid_user_input = false,
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.native_system_lib_paths = ArrayList([]const u8).init(allocator),
|
.native_system_lib_paths = ArrayList([]const u8).init(allocator),
|
||||||
@ -1175,6 +1177,8 @@ pub const LibExeObjStep = struct {
|
|||||||
|
|
||||||
valgrind_support: ?bool = null,
|
valgrind_support: ?bool = null,
|
||||||
|
|
||||||
|
link_eh_frame_hdr: bool = false,
|
||||||
|
|
||||||
/// Uses system Wine installation to run cross compiled Windows build artifacts.
|
/// Uses system Wine installation to run cross compiled Windows build artifacts.
|
||||||
enable_wine: bool = false,
|
enable_wine: bool = false,
|
||||||
|
|
||||||
@ -1623,6 +1627,10 @@ pub const LibExeObjStep = struct {
|
|||||||
self.verbose_cc = value;
|
self.verbose_cc = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn setLinkEhFrameHdr(self: *LibExeObjStep, value: bool) void {
|
||||||
|
self.link_eh_frame_hdr = value;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn setBuildMode(self: *LibExeObjStep, mode: builtin.Mode) void {
|
pub fn setBuildMode(self: *LibExeObjStep, mode: builtin.Mode) void {
|
||||||
self.build_mode = mode;
|
self.build_mode = mode;
|
||||||
}
|
}
|
||||||
@ -1908,6 +1916,7 @@ pub const LibExeObjStep = struct {
|
|||||||
if (builder.verbose_llvm_ir) zig_args.append("--verbose-llvm-ir") catch unreachable;
|
if (builder.verbose_llvm_ir) zig_args.append("--verbose-llvm-ir") catch unreachable;
|
||||||
if (builder.verbose_link or self.verbose_link) zig_args.append("--verbose-link") catch unreachable;
|
if (builder.verbose_link or self.verbose_link) zig_args.append("--verbose-link") catch unreachable;
|
||||||
if (builder.verbose_cc or self.verbose_cc) zig_args.append("--verbose-cc") catch unreachable;
|
if (builder.verbose_cc or self.verbose_cc) zig_args.append("--verbose-cc") catch unreachable;
|
||||||
|
if (builder.link_eh_frame_hdr or self.link_eh_frame_hdr) zig_args.append("--eh-frame-hdr") catch unreachable;
|
||||||
|
|
||||||
if (self.strip) {
|
if (self.strip) {
|
||||||
zig_args.append("--strip") catch unreachable;
|
zig_args.append("--strip") catch unreachable;
|
||||||
|
|||||||
@ -170,6 +170,8 @@ pub const Compilation = struct {
|
|||||||
verbose_llvm_ir: bool = false,
|
verbose_llvm_ir: bool = false,
|
||||||
verbose_link: bool = false,
|
verbose_link: bool = false,
|
||||||
|
|
||||||
|
link_eh_frame_hdr: bool = false,
|
||||||
|
|
||||||
darwin_version_min: DarwinVersionMin = .None,
|
darwin_version_min: DarwinVersionMin = .None,
|
||||||
|
|
||||||
test_filters: []const []const u8 = &[_][]const u8{},
|
test_filters: []const []const u8 = &[_][]const u8{},
|
||||||
|
|||||||
@ -144,7 +144,9 @@ fn constructLinkerArgsElf(ctx: *Context) !void {
|
|||||||
// lj->args.append(g->linker_script);
|
// lj->args.append(g->linker_script);
|
||||||
//}
|
//}
|
||||||
try ctx.args.append("--gc-sections");
|
try ctx.args.append("--gc-sections");
|
||||||
try ctx.args.append("--eh-frame-hdr");
|
if (ctx.comp.link_eh_frame_hdr) {
|
||||||
|
try ctx.args.append("--eh-frame-hdr");
|
||||||
|
}
|
||||||
|
|
||||||
//lj->args.append("-m");
|
//lj->args.append("-m");
|
||||||
//lj->args.append(getLDMOption(&g->zig_target));
|
//lj->args.append(getLDMOption(&g->zig_target));
|
||||||
|
|||||||
@ -154,6 +154,7 @@ const usage_build_generic =
|
|||||||
\\ --static Output will be statically linked
|
\\ --static Output will be statically linked
|
||||||
\\ --strip Exclude debug symbols
|
\\ --strip Exclude debug symbols
|
||||||
\\ -target [name] <arch><sub>-<os>-<abi> see the targets command
|
\\ -target [name] <arch><sub>-<os>-<abi> see the targets command
|
||||||
|
\\ --eh-frame-hdr enable C++ exception handling by passing --eh-frame-hdr to linker
|
||||||
\\ --verbose-tokenize Turn on compiler debug output for tokenization
|
\\ --verbose-tokenize Turn on compiler debug output for tokenization
|
||||||
\\ --verbose-ast-tree Turn on compiler debug output for parsing into an AST (tree view)
|
\\ --verbose-ast-tree Turn on compiler debug output for parsing into an AST (tree view)
|
||||||
\\ --verbose-ast-fmt Turn on compiler debug output for parsing into an AST (render source)
|
\\ --verbose-ast-fmt Turn on compiler debug output for parsing into an AST (render source)
|
||||||
@ -207,6 +208,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
|
|||||||
var verbose_llvm_ir = false;
|
var verbose_llvm_ir = false;
|
||||||
var verbose_cimport = false;
|
var verbose_cimport = false;
|
||||||
var linker_rdynamic = false;
|
var linker_rdynamic = false;
|
||||||
|
var link_eh_frame_hdr = false;
|
||||||
var macosx_version_min: ?[]const u8 = null;
|
var macosx_version_min: ?[]const u8 = null;
|
||||||
var ios_version_min: ?[]const u8 = null;
|
var ios_version_min: ?[]const u8 = null;
|
||||||
|
|
||||||
@ -369,6 +371,8 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
|
|||||||
verbose_ir = true;
|
verbose_ir = true;
|
||||||
} else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {
|
} else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {
|
||||||
verbose_llvm_ir = true;
|
verbose_llvm_ir = true;
|
||||||
|
} else if (mem.eql(u8, arg, "--eh-frame-hdr")) {
|
||||||
|
link_eh_frame_hdr = true;
|
||||||
} else if (mem.eql(u8, arg, "--verbose-cimport")) {
|
} else if (mem.eql(u8, arg, "--verbose-cimport")) {
|
||||||
verbose_cimport = true;
|
verbose_cimport = true;
|
||||||
} else if (mem.eql(u8, arg, "-rdynamic")) {
|
} else if (mem.eql(u8, arg, "-rdynamic")) {
|
||||||
@ -498,6 +502,8 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
|
|||||||
comp.verbose_llvm_ir = verbose_llvm_ir;
|
comp.verbose_llvm_ir = verbose_llvm_ir;
|
||||||
comp.verbose_cimport = verbose_cimport;
|
comp.verbose_cimport = verbose_cimport;
|
||||||
|
|
||||||
|
comp.link_eh_frame_hdr = link_eh_frame_hdr;
|
||||||
|
|
||||||
comp.err_color = color;
|
comp.err_color = color;
|
||||||
|
|
||||||
comp.linker_rdynamic = linker_rdynamic;
|
comp.linker_rdynamic = linker_rdynamic;
|
||||||
|
|||||||
@ -2131,6 +2131,7 @@ struct CodeGen {
|
|||||||
bool have_winmain_crt_startup;
|
bool have_winmain_crt_startup;
|
||||||
bool have_dllmain_crt_startup;
|
bool have_dllmain_crt_startup;
|
||||||
bool have_err_ret_tracing;
|
bool have_err_ret_tracing;
|
||||||
|
bool link_eh_frame_hdr;
|
||||||
bool c_want_stdint;
|
bool c_want_stdint;
|
||||||
bool c_want_stdbool;
|
bool c_want_stdbool;
|
||||||
bool verbose_tokenize;
|
bool verbose_tokenize;
|
||||||
|
|||||||
@ -8629,6 +8629,7 @@ static Error define_builtin_compile_vars(CodeGen *g) {
|
|||||||
cache_bool(&cache_hash, g->have_err_ret_tracing);
|
cache_bool(&cache_hash, g->have_err_ret_tracing);
|
||||||
cache_bool(&cache_hash, g->libc_link_lib != nullptr);
|
cache_bool(&cache_hash, g->libc_link_lib != nullptr);
|
||||||
cache_bool(&cache_hash, g->valgrind_support);
|
cache_bool(&cache_hash, g->valgrind_support);
|
||||||
|
cache_bool(&cache_hash, g->link_eh_frame_hdr);
|
||||||
cache_int(&cache_hash, detect_subsystem(g));
|
cache_int(&cache_hash, detect_subsystem(g));
|
||||||
|
|
||||||
Buf digest = BUF_INIT;
|
Buf digest = BUF_INIT;
|
||||||
@ -9510,6 +9511,7 @@ Error create_c_object_cache(CodeGen *g, CacheHash **out_cache_hash, bool verbose
|
|||||||
cache_int(cache_hash, g->build_mode);
|
cache_int(cache_hash, g->build_mode);
|
||||||
cache_bool(cache_hash, g->have_pic);
|
cache_bool(cache_hash, g->have_pic);
|
||||||
cache_bool(cache_hash, g->have_sanitize_c);
|
cache_bool(cache_hash, g->have_sanitize_c);
|
||||||
|
cache_bool(cache_hash, g->link_eh_frame_hdr);
|
||||||
cache_bool(cache_hash, want_valgrind_support(g));
|
cache_bool(cache_hash, want_valgrind_support(g));
|
||||||
cache_bool(cache_hash, g->function_sections);
|
cache_bool(cache_hash, g->function_sections);
|
||||||
for (size_t arg_i = 0; arg_i < g->clang_argv_len; arg_i += 1) {
|
for (size_t arg_i = 0; arg_i < g->clang_argv_len; arg_i += 1) {
|
||||||
@ -10279,6 +10281,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
|
|||||||
cache_buf_opt(ch, g->test_filter);
|
cache_buf_opt(ch, g->test_filter);
|
||||||
cache_buf_opt(ch, g->test_name_prefix);
|
cache_buf_opt(ch, g->test_name_prefix);
|
||||||
}
|
}
|
||||||
|
cache_bool(ch, g->link_eh_frame_hdr);
|
||||||
cache_bool(ch, g->is_single_threaded);
|
cache_bool(ch, g->is_single_threaded);
|
||||||
cache_bool(ch, g->linker_rdynamic);
|
cache_bool(ch, g->linker_rdynamic);
|
||||||
cache_bool(ch, g->each_lib_rpath);
|
cache_bool(ch, g->each_lib_rpath);
|
||||||
|
|||||||
@ -1647,7 +1647,9 @@ static void construct_linker_job_elf(LinkJob *lj) {
|
|||||||
lj->args.append("--gc-sections");
|
lj->args.append("--gc-sections");
|
||||||
}
|
}
|
||||||
|
|
||||||
lj->args.append("--eh-frame-hdr");
|
if (g->link_eh_frame_hdr) {
|
||||||
|
lj->args.append("--eh-frame-hdr");
|
||||||
|
}
|
||||||
|
|
||||||
lj->args.append("-m");
|
lj->args.append("-m");
|
||||||
lj->args.append(getLDMOption(g->zig_target));
|
lj->args.append(getLDMOption(g->zig_target));
|
||||||
|
|||||||
@ -55,6 +55,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
|
|||||||
" --color [auto|off|on] enable or disable colored error messages\n"
|
" --color [auto|off|on] enable or disable colored error messages\n"
|
||||||
" --disable-gen-h do not generate a C header file (.h)\n"
|
" --disable-gen-h do not generate a C header file (.h)\n"
|
||||||
" --disable-valgrind omit valgrind client requests in debug builds\n"
|
" --disable-valgrind omit valgrind client requests in debug builds\n"
|
||||||
|
" --eh-frame-hdr enable C++ exception handling by passing --eh-frame-hdr to linker\n"
|
||||||
" --enable-valgrind include valgrind client requests release builds\n"
|
" --enable-valgrind include valgrind client requests release builds\n"
|
||||||
" -fstack-check enable stack probing in unsafe builds\n"
|
" -fstack-check enable stack probing in unsafe builds\n"
|
||||||
" -fno-stack-check disable stack probing in safe builds\n"
|
" -fno-stack-check disable stack probing in safe builds\n"
|
||||||
@ -477,6 +478,7 @@ int main(int argc, char **argv) {
|
|||||||
bool verbose_llvm_ir = false;
|
bool verbose_llvm_ir = false;
|
||||||
bool verbose_cimport = false;
|
bool verbose_cimport = false;
|
||||||
bool verbose_cc = false;
|
bool verbose_cc = false;
|
||||||
|
bool link_eh_frame_hdr = false;
|
||||||
ErrColor color = ErrColorAuto;
|
ErrColor color = ErrColorAuto;
|
||||||
CacheOpt enable_cache = CacheOptAuto;
|
CacheOpt enable_cache = CacheOptAuto;
|
||||||
Buf *dynamic_linker = nullptr;
|
Buf *dynamic_linker = nullptr;
|
||||||
@ -715,6 +717,8 @@ int main(int argc, char **argv) {
|
|||||||
valgrind_support = ValgrindSupportEnabled;
|
valgrind_support = ValgrindSupportEnabled;
|
||||||
} else if (strcmp(arg, "--disable-valgrind") == 0) {
|
} else if (strcmp(arg, "--disable-valgrind") == 0) {
|
||||||
valgrind_support = ValgrindSupportDisabled;
|
valgrind_support = ValgrindSupportDisabled;
|
||||||
|
} else if (strcmp(arg, "--eh-frame-hdr") == 0) {
|
||||||
|
link_eh_frame_hdr = true;
|
||||||
} else if (strcmp(arg, "-fPIC") == 0) {
|
} else if (strcmp(arg, "-fPIC") == 0) {
|
||||||
want_pic = WantPICEnabled;
|
want_pic = WantPICEnabled;
|
||||||
} else if (strcmp(arg, "-fno-PIC") == 0) {
|
} else if (strcmp(arg, "-fno-PIC") == 0) {
|
||||||
@ -1191,6 +1195,7 @@ int main(int argc, char **argv) {
|
|||||||
override_lib_dir, libc, cache_dir_buf, cmd == CmdTest, root_progress_node);
|
override_lib_dir, libc, cache_dir_buf, cmd == CmdTest, root_progress_node);
|
||||||
if (llvm_argv.length >= 2) codegen_set_llvm_argv(g, llvm_argv.items + 1, llvm_argv.length - 2);
|
if (llvm_argv.length >= 2) codegen_set_llvm_argv(g, llvm_argv.items + 1, llvm_argv.length - 2);
|
||||||
g->valgrind_support = valgrind_support;
|
g->valgrind_support = valgrind_support;
|
||||||
|
g->link_eh_frame_hdr = link_eh_frame_hdr;
|
||||||
g->want_pic = want_pic;
|
g->want_pic = want_pic;
|
||||||
g->want_stack_check = want_stack_check;
|
g->want_stack_check = want_stack_check;
|
||||||
g->want_sanitize_c = want_sanitize_c;
|
g->want_sanitize_c = want_sanitize_c;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user