To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 3f898659 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano
Browse files

Added flags to pass to zebu

parent acb20a5e
......@@ -43,10 +43,38 @@ std::string file_name(const char* s) {
return res;
}
std::string escape_string(std::string s)
{
std::string output;
for (char c : s)
{
switch (c)
{
case '\t':
output += R"(\t)";
break;
case '\\':
output += R"(\\)";
break;
case '\n':
output += R"(\n)";
break;
case '\r':
output += R"(\r)";
break;
case '"':
output += R"(\")";
break;
default:
output += c;
}
}
return output;
}
int show_usage() {
std::cerr << "usage: " << std::endl;
std::cerr << "\tmuc -rcs [-f primordial-function] input_files... output_dir/boot_image_file" << std::endl;
std::cerr << "\tmuc -rcs [-f primordial-function] input_files... output_dir/boot_image_file [-- zebu_options...]" << std::endl;
return -1;
}
......@@ -56,8 +84,19 @@ int main(int argc, char* argv[]) {
char** input;
int n_input;
std::string output_file = file_name(argv[argc-1]);
std::string output_dir = directory_name(argv[argc-1]);
int last_arg = argc-1;
std::string extra_opts = "";
for (int i = 0; i < argc; i++) {
if (std::string(argv[i]) == "--") {
last_arg = i - 1;
for (int j = i + 1; j < argc; j++)
extra_opts += " " + std::string(argv[j]);
break;
}
}
std::string output_file = file_name(argv[last_arg]);
std::string output_dir = directory_name(argv[last_arg]);
const char* primordial; // the name of the primordial function
bool has_primordial;
if (argv[2] == "-f"s) {
......@@ -78,6 +117,7 @@ int main(int argc, char* argv[]) {
has_primordial = false;
}
::primordial_name = primordial;
std::string options = "init_mu --aot-emit-dir="s + output_dir + extra_opts;
if (argv[1] == "-s"s) {
for (int i = 0; i < n_input; i++)
......@@ -103,7 +143,6 @@ int main(int argc, char* argv[]) {
return -1;
} else if (argv[1] == "-r"s) {
#ifndef NO_MU
std::string options = "init_mu --aot-emit-dir="s + output_dir;
std::cerr << "options: " << options << std::endl;
MuVM* mvm = mu_fastimpl_new_with_opts(options.c_str());
......@@ -154,7 +193,7 @@ int main(int argc, char* argv[]) {
std::string ctx = "ctx"s; // the name of the MuCtx*
std::string irbuilder = "irbuilder"s; // the name of the MuIRBuilder*
std::cout << "\tMuVM* " << mvm << " = mu_fastimpl_new_with_opts(\"init_mu --aot-emit-dir="s + output_dir << "\");" << std::endl
std::cout << "\tMuVM* " << mvm << " = mu_fastimpl_new_with_opts(\"" << escape_string(options) << "\");" << std::endl
<< "\tMuCtx* " << ctx << " = " << mvm << "->new_context(" << mvm << ");" << std::endl
<< "\tMuIRBuilder* " << irbuilder << ";" << std::endl << std::endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment