diff --git a/src/Options.cc b/src/Options.cc index 6f5cfc7705..e6bc9a8f58 100644 --- a/src/Options.cc +++ b/src/Options.cc @@ -162,7 +162,6 @@ static void set_analysis_option(const char* opt, Options& opts) fprintf(stderr, " add-C++ generate private C++ for any missing script bodies\n"); fprintf(stderr, " dump-uds dump use-defs to stdout; implies xform\n"); fprintf(stderr, " dump-xform dump transformed scripts to stdout; implies xform\n"); - fprintf(stderr, " force-use-C++ use available C++ script bodies, warning about missing ones\n"); fprintf(stderr, " gen-C++ generate C++ script bodies\n"); fprintf(stderr, " gen-standalone-C++ generate \"standalone\" C++ script bodies\n"); fprintf(stderr, " help print this list\n"); @@ -184,8 +183,6 @@ static void set_analysis_option(const char* opt, Options& opts) a_o.activate = a_o.dump_uds = true; else if ( util::streq(opt, "dump-xform") ) a_o.activate = a_o.dump_xform = true; - else if ( util::streq(opt, "force-use-C++") ) - a_o.force_use_CPP = true; else if ( util::streq(opt, "gen-C++") ) a_o.gen_CPP = true; else if ( util::streq(opt, "gen-standalone-C++") ) diff --git a/src/script_opt/CPP/Compile.h b/src/script_opt/CPP/Compile.h index 74a953a75f..0f0f9d5de8 100644 --- a/src/script_opt/CPP/Compile.h +++ b/src/script_opt/CPP/Compile.h @@ -63,14 +63,12 @@ // the test suite. // // Zeek invocations specifying "-O use-C++" will activate any code compiled -// into the zeek binary; otherwise, the code lies dormant. "-O force-use-C++" -// does the same but generates warnings for script functions not found in -// compiled in. This is useful for debugging the compiled code, to ensure -// that it's indeed being run. +// into the zeek binary; otherwise, the code lies dormant. // // "-O report-C++" reports on which compiled functions will/won't be used // (including ones that are available but not relevant to the scripts loaded -// on the command line). +// on the command line). This can be useful when debugging to make sure +// that you're indeed running compiled code when you expect to be. // // We partition the methods of the compiler into a number of groups, // the definitions of each having their own source file: diff --git a/src/script_opt/CPP/README.md b/src/script_opt/CPP/README.md index 6cabc2cd7c..1a8d1e4d9d 100644 --- a/src/script_opt/CPP/README.md +++ b/src/script_opt/CPP/README.md @@ -80,18 +80,11 @@ event handler pulled in by `target.zeek` replaced with its compiled version. Instead of the last line above, you can use the following variants: -5. `./src/zeek -O force-use-C++ target.zeek` -Same as `use-C++`, but also -warns about any `target.zeek` functions that didn't have corresponding -compiled-to-C++ versions. - -Or: - 5. `./src/zeek -O report-C++ target.zeek` For each function body in `target.zeek`, reports which ones have compiled-to-C++ bodies available, and also any compiled-to-C++ bodies present in the `zeek` binary that -`target.zeek` does not use. +`target.zeek` does not use. Useful for debugging. The above workflows require the subsequent `zeek` execution to include the `target.zeek` script. You can avoid this by replacing the first step with: diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index 7e44582194..1d53ed6ef2 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -219,15 +219,10 @@ void analyze_scripts() analysis_options.gen_standalone_CPP); check_env_opt("ZEEK_REPORT_CPP", analysis_options.report_CPP); check_env_opt("ZEEK_USE_CPP", analysis_options.use_CPP); - check_env_opt("ZEEK_FORCE_USE_CPP", - analysis_options.force_use_CPP); if ( analysis_options.gen_standalone_CPP ) analysis_options.gen_CPP = true; - if ( analysis_options.force_use_CPP ) - analysis_options.use_CPP = true; - if ( analysis_options.gen_CPP ) { if ( analysis_options.add_CPP ) @@ -372,74 +367,6 @@ void analyze_scripts() h->SetUsed(); } } - - else if ( analysis_options.force_use_CPP ) - reporter->Warning("no C++ available for %s", f.Func()->Name()); - } - - // Now that we've loaded all of the compiled scripts - // relevant for the AST, activate standalone ones. - for ( auto cb : standalone_activations ) - (*cb)(); - } - - if ( generating_CPP ) - { - auto hm = std::make_unique(hash_name.c_str(), - analysis_options.add_CPP); - - if ( ! analysis_options.gen_CPP ) - { - for ( auto& func : funcs ) - { - auto hash = func.Profile()->HashVal(); - if ( compiled_scripts.count(hash) > 0 || - hm->HasHash(hash) ) - func.SetSkip(true); - } - - // Now that we've presumably marked a lot of functions - // as skippable, recompute the global profile. - pfs = std::make_unique(funcs, is_CPP_compilable, false); - } - - CPPCompile cpp(funcs, *pfs, gen_name.c_str(), *hm, - analysis_options.gen_CPP || - analysis_options.update_CPP, - analysis_options.gen_standalone_CPP); - - exit(0); - } - - if ( analysis_options.use_CPP ) - { - for ( auto& f : funcs ) - { - auto hash = f.Profile()->HashVal(); - auto s = compiled_scripts.find(hash); - - if ( s == compiled_scripts.end() ) - { // Look for script-specific body. - hash = script_specific_hash(f.Body(), hash); - s = compiled_scripts.find(hash); - } - - if ( s != compiled_scripts.end() ) - { - auto b = s->second.body; - b->SetHash(hash); - f.Func()->ReplaceBody(f.Body(), b); - f.SetBody(b); - - for ( auto& e : s->second.events ) - { - auto h = event_registry->Register(e); - h->SetUsed(); - } - } - - else if ( analysis_options.force_use_CPP ) - reporter->Warning("no C++ available for %s", f.Func()->Name()); } // Now that we've loaded all of the compiled scripts diff --git a/src/script_opt/ScriptOpt.h b/src/script_opt/ScriptOpt.h index d650d091c9..0fa254a1d3 100644 --- a/src/script_opt/ScriptOpt.h +++ b/src/script_opt/ScriptOpt.h @@ -61,9 +61,6 @@ struct AnalyOpt { // If true, use C++ bodies if available. bool use_CPP = false; - // Same, but complain about missing bodies. - bool force_use_CPP = false; - // If true, report on available C++ bodies. bool report_CPP = false;