From cfedd3aca286881510e4a298756d4a5676e22137 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 30 Mar 2020 17:42:30 -0400 Subject: [PATCH] revert detection of rtti and exceptions This caused link errors in c++ code because it was not correct to pass these flags to child codegens. And that was the only reason to detect these flags. Otherwise we can safely rely on non-explicitly-detected flag forwarding. --- src-self-hosted/clang_options_data.zig | 36 +++----------------------- src-self-hosted/stage2.zig | 4 --- src/all_types.hpp | 2 -- src/codegen.cpp | 16 ------------ src/main.cpp | 18 ------------- src/stage2.h | 4 --- tools/update_clang_options.zig | 16 ------------ 7 files changed, 4 insertions(+), 92 deletions(-) diff --git a/src-self-hosted/clang_options_data.zig b/src-self-hosted/clang_options_data.zig index 14dcec4fb..d8bd02043 100644 --- a/src-self-hosted/clang_options_data.zig +++ b/src-self-hosted/clang_options_data.zig @@ -2554,14 +2554,7 @@ flagpd1("femulated-tls"), flagpd1("fencode-extended-block-signature"), sepd1("ferror-limit"), flagpd1("fescaping-block-tail-calls"), -.{ - .name = "fexceptions", - .syntax = .flag, - .zig_equivalent = .exceptions, - .pd1 = true, - .pd2 = false, - .psl = false, -}, +flagpd1("fexceptions"), flagpd1("fexperimental-isel"), flagpd1("fexperimental-new-constant-interpreter"), flagpd1("fexperimental-new-pass-manager"), @@ -2765,14 +2758,7 @@ flagpd1("fno-elide-type"), flagpd1("fno-eliminate-unused-debug-symbols"), flagpd1("fno-emulated-tls"), flagpd1("fno-escaping-block-tail-calls"), -.{ - .name = "fno-exceptions", - .syntax = .flag, - .zig_equivalent = .no_exceptions, - .pd1 = true, - .pd2 = false, - .psl = false, -}, +flagpd1("fno-exceptions"), flagpd1("fno-experimental-isel"), flagpd1("fno-experimental-new-pass-manager"), flagpd1("fno-fast-math"), @@ -2861,14 +2847,7 @@ flagpd1("fno-rewrite-includes"), flagpd1("fno-ropi"), flagpd1("fno-rounding-math"), flagpd1("fno-rtlib-add-rpath"), -.{ - .name = "fno-rtti", - .syntax = .flag, - .zig_equivalent = .no_rtti, - .pd1 = true, - .pd2 = false, - .psl = false, -}, +flagpd1("fno-rtti"), flagpd1("fno-rtti-data"), flagpd1("fno-rwpi"), flagpd1("fno-sanitize-address-poison-custom-array-cookie"), @@ -3016,14 +2995,7 @@ flagpd1("fno-frontend-optimize"), flagpd1("fropi"), flagpd1("frounding-math"), flagpd1("frtlib-add-rpath"), -.{ - .name = "frtti", - .syntax = .flag, - .zig_equivalent = .rtti, - .pd1 = true, - .pd2 = false, - .psl = false, -}, +flagpd1("frtti"), flagpd1("frwpi"), flagpd1("fsanitize-address-globals-dead-stripping"), flagpd1("fsanitize-address-poison-custom-array-cookie"), diff --git a/src-self-hosted/stage2.zig b/src-self-hosted/stage2.zig index 8e7a0150a..fcf963409 100644 --- a/src-self-hosted/stage2.zig +++ b/src-self-hosted/stage2.zig @@ -1286,10 +1286,6 @@ pub const ClangArgIterator = extern struct { sanitize, linker_script, verbose_cmds, - exceptions, - no_exceptions, - rtti, - no_rtti, for_linker, linker_input_z, }; diff --git a/src/all_types.hpp b/src/all_types.hpp index 6c7b46502..f51a9c057 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -2262,8 +2262,6 @@ struct CodeGen { bool emit_asm; bool emit_llvm_ir; bool test_is_evented; - bool cpp_rtti; - bool cpp_exceptions; CodeModel code_model; Buf *root_out_name; diff --git a/src/codegen.cpp b/src/codegen.cpp index f02253fb1..d36e398bf 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8784,8 +8784,6 @@ static Error define_builtin_compile_vars(CodeGen *g) { cache_bool(&cache_hash, g->is_test_build); cache_bool(&cache_hash, g->is_single_threaded); cache_bool(&cache_hash, g->test_is_evented); - cache_bool(&cache_hash, g->cpp_rtti); - cache_bool(&cache_hash, g->cpp_exceptions); cache_int(&cache_hash, g->code_model); cache_int(&cache_hash, g->zig_target->is_native_os); cache_int(&cache_hash, g->zig_target->is_native_cpu); @@ -9259,14 +9257,6 @@ void add_cc_args(CodeGen *g, ZigList &args, const char *out_dep_pa case CSourceKindAsm: break; } - if (source_kind == CSourceKindCpp) { - if (!g->cpp_rtti) { - args.append("-fno-rtti"); - } - if (!g->cpp_exceptions) { - args.append("-fno-exceptions"); - } - } for (size_t i = 0; i < g->zig_target->llvm_cpu_features_asm_len; i += 1) { args.append(g->zig_target->llvm_cpu_features_asm_ptr[i]); } @@ -9714,8 +9704,6 @@ Error create_c_object_cache(CodeGen *g, CacheHash **out_cache_hash, bool verbose cache_bool(cache_hash, g->have_sanitize_c); cache_bool(cache_hash, want_valgrind_support(g)); cache_bool(cache_hash, g->function_sections); - cache_bool(cache_hash, g->cpp_rtti); - cache_bool(cache_hash, g->cpp_exceptions); cache_int(cache_hash, g->code_model); for (size_t arg_i = 0; arg_i < g->clang_argv_len; arg_i += 1) { @@ -10550,8 +10538,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { cache_bool(ch, g->emit_bin); cache_bool(ch, g->emit_llvm_ir); cache_bool(ch, g->emit_asm); - cache_bool(ch, g->cpp_rtti); - cache_bool(ch, g->cpp_exceptions); cache_usize(ch, g->version_major); cache_usize(ch, g->version_minor); cache_usize(ch, g->version_patch); @@ -10856,8 +10842,6 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o parent_gen->build_mode, parent_gen->zig_lib_dir, libc, get_global_cache_dir(), false, child_progress_node); child_gen->root_out_name = buf_create_from_str(name); child_gen->disable_gen_h = true; - child_gen->cpp_rtti = parent_gen->cpp_rtti; - child_gen->cpp_exceptions = parent_gen->cpp_exceptions; child_gen->want_stack_check = WantStackCheckDisabled; child_gen->want_sanitize_c = WantCSanitizeDisabled; child_gen->verbose_tokenize = parent_gen->verbose_tokenize; diff --git a/src/main.cpp b/src/main.cpp index 05ba1ab40..c95a51221 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -458,8 +458,6 @@ static int main0(int argc, char **argv) { bool only_preprocess = false; bool ensure_libc_on_non_freestanding = false; bool ensure_libcpp_on_non_freestanding = false; - bool cpp_rtti = true; - bool cpp_exceptions = true; ZigList llvm_argv = {0}; llvm_argv.append("zig (LLVM option parsing)"); @@ -724,18 +722,6 @@ static int main0(int argc, char **argv) { verbose_cc = true; verbose_link = true; break; - case Stage2ClangArgExceptions: - cpp_exceptions = true; - break; - case Stage2ClangArgNoExceptions: - cpp_exceptions = false; - break; - case Stage2ClangArgRtti: - cpp_rtti = true; - break; - case Stage2ClangArgNoRtti: - cpp_rtti = false; - break; case Stage2ClangArgForLinker: linker_args.append(buf_create_from_str(it.only_arg)); break; @@ -1331,8 +1317,6 @@ static int main0(int argc, char **argv) { LinkLib *link_lib = codegen_add_link_lib(g, buf_create_from_str(link_libs.at(i))); link_lib->provided_explicitly = true; } - g->cpp_rtti = cpp_rtti; - g->cpp_exceptions = cpp_exceptions; g->subsystem = subsystem; g->valgrind_support = valgrind_support; g->want_pic = want_pic; @@ -1481,8 +1465,6 @@ static int main0(int argc, char **argv) { } CodeGen *g = codegen_create(main_pkg_path, zig_root_source_file, &target, out_type, build_mode, override_lib_dir, libc, cache_dir_buf, cmd == CmdTest, root_progress_node); - g->cpp_rtti = cpp_rtti; - g->cpp_exceptions = cpp_exceptions; if (llvm_argv.length >= 2) codegen_set_llvm_argv(g, llvm_argv.items + 1, llvm_argv.length - 2); g->valgrind_support = valgrind_support; g->link_eh_frame_hdr = link_eh_frame_hdr; diff --git a/src/stage2.h b/src/stage2.h index 5cea30dba..54355ea73 100644 --- a/src/stage2.h +++ b/src/stage2.h @@ -345,10 +345,6 @@ enum Stage2ClangArg { Stage2ClangArgSanitize, Stage2ClangArgLinkerScript, Stage2ClangArgVerboseCmds, - Stage2ClangArgExceptions, - Stage2ClangArgNoExceptions, - Stage2ClangArgRtti, - Stage2ClangArgNoRtti, Stage2ClangArgForLinker, Stage2ClangArgLinkerInputZ, }; diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index 1baf4fbea..f5b483e66 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -174,22 +174,6 @@ const known_options = [_]KnownOpt{ .name = "###", .ident = "verbose_cmds", }, - .{ - .name = "fexceptions", - .ident = "exceptions", - }, - .{ - .name = "fno-exceptions", - .ident = "no_exceptions", - }, - .{ - .name = "frtti", - .ident = "rtti", - }, - .{ - .name = "fno-rtti", - .ident = "no_rtti", - }, }; const blacklisted_options = [_][]const u8{};