From 36968f12feb57366ea564338ecde1d6ed63454d9 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 16 Sep 2020 11:43:55 -0400 Subject: [PATCH] Make the contracts generated with --allow-names usable. --- tools/external/wabt/src/tools/postpass.cc | 8 +++++++- tools/include/compiler_options.hpp.in | 1 - tools/ld/eosio-ld.cpp.in | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/external/wabt/src/tools/postpass.cc b/tools/external/wabt/src/tools/postpass.cc index 94693a28fc..10cbc5ea3e 100644 --- a/tools/external/wabt/src/tools/postpass.cc +++ b/tools/external/wabt/src/tools/postpass.cc @@ -68,6 +68,12 @@ static void ParseOptions(int argc, char** argv) { s_outfile = argument; ConvertBackslashToSlash(&s_outfile); }); + parser.AddOption( + 'n', "allow-names", + "Preserve the name section", + []() { + s_write_binary_options.write_debug_names = true; + }); parser.AddArgument("filename", OptionParser::ArgumentCount::One, [](const char* argument) { s_infile = argument; @@ -145,7 +151,7 @@ int ProgramMain(int argc, char** argv) { Module module; const bool kStopOnFirstError = true; ReadBinaryOptions options(s_features, s_log_stream_s.get(), - stub, kStopOnFirstError, + s_write_binary_options.write_debug_names, kStopOnFirstError, stub); result = ReadBinaryIr(s_infile.c_str(), file_data.data(), file_data.size(), &options, &error_handler, &module); diff --git a/tools/include/compiler_options.hpp.in b/tools/include/compiler_options.hpp.in index 6b7c8e55c3..88f08c04c9 100644 --- a/tools/include/compiler_options.hpp.in +++ b/tools/include/compiler_options.hpp.in @@ -579,7 +579,6 @@ static Options CreateOptions(bool add_defaults=true) { if (fquery_client_opt) ldopts.emplace_back("-fquery-client"); if (allow_names_opt) { - ldopts.emplace_back("-fno-post-pass"); ldopts.emplace_back("--allow-names"); } #endif diff --git a/tools/ld/eosio-ld.cpp.in b/tools/ld/eosio-ld.cpp.in index f1df961db2..232a1019ff 100644 --- a/tools/ld/eosio-ld.cpp.in +++ b/tools/ld/eosio-ld.cpp.in @@ -46,8 +46,12 @@ int main(int argc, const char **argv) { std::cerr << "Error: eosio.pp not found! (Try reinstalling eosio.cdt)" << std::endl; return -1; } - - if (!eosio::cdt::environment::exec_subprogram("eosio-pp", {opts.output_fn})) { + std::vector pp_opts; + if(allow_names_opt) { + pp_opts.push_back("--allow-names"); + } + pp_opts.push_back(opts.output_fn); + if (!eosio::cdt::environment::exec_subprogram("eosio-pp", pp_opts)) { std::cerr << "eosio-pp failed" << std::endl; return -1; }