Add environment for mic_crossgen2 (#360)
author최종헌/Common Platform Lab(SR)/Engineer/삼성전자 <j-h.choi@samsung.com>
Thu, 6 Jan 2022 00:51:04 +0000 (09:51 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 6 Jan 2022 00:51:04 +0000 (09:51 +0900)
Change-Id: I996125b985c3a1383fd3c39eded96729eed9db91

NativeLauncher/tool/ni_common.cc

index 7abedcd..abf91d4 100644 (file)
@@ -67,9 +67,9 @@ static const char* __SYSTEM_BASE_FILE = __STR(SYSTEM_BASE_FILE);
 #undef __STR
 #undef __XSTR
 
-static const char* CORERUN_CMD = "/usr/share/dotnet.tizen/netcoreapp/corerun";
-static const char* CROSSGEN2_PATH = "/usr/share/dotnet.tizen/netcoreapp/crossgen2/crossgen2.dll";
-static const char* CLRJIT_PATH = "/usr/share/dotnet.tizen/netcoreapp/libclrjit.so";
+static std::string CORERUN_CMD = "/usr/share/dotnet.tizen/netcoreapp/corerun";
+static std::string CROSSGEN2_PATH = "/usr/share/dotnet.tizen/netcoreapp/crossgen2/crossgen2.dll";
+static std::string CLRJIT_PATH = "/usr/share/dotnet.tizen/netcoreapp/libclrjit.so";
 static const char* CROSSGEN_OPT_JITPATH = "--jitpath";
 static const char* CROSSGEN_OPT_TARGET_ARCH = "--targetarch";
 static const char* CROSSGEN_OPT_OUT_NEAR_INPUT = "--out-near-input";
@@ -289,10 +289,12 @@ static ni_error_e getTargetDllList(const std::string& path, std::vector<std::str
 
 static void makeArgs(std::vector<const char*>& args, const std::vector<std::string>& refPaths, NIOption* opt)
 {
-       args.push_back(CORERUN_CMD);
-       args.push_back(CROSSGEN2_PATH);
+       args.push_back(CORERUN_CMD.c_str());
+       if (CROSSGEN2_PATH != "") {
+               args.push_back(CROSSGEN2_PATH.c_str());
+       }
        args.push_back(CROSSGEN_OPT_JITPATH);
-       args.push_back(CLRJIT_PATH);
+       args.push_back(CLRJIT_PATH.c_str());
        args.push_back(CROSSGEN_OPT_TARGET_ARCH);
        args.push_back(ARCHITECTURE_IDENTIFIER);
        if (!(opt->flags & NI_FLAGS_NO_PIPELINE)) {
@@ -428,7 +430,6 @@ static ni_error_e crossgen2PipeLine(const std::vector<std::string>& dllList, con
                }
        } else {
                std::vector<const char*> argv;
-
                makeArgs(argv, refPaths, opt);
 
                // add input files at the end of parameter
@@ -437,6 +438,7 @@ static ni_error_e crossgen2PipeLine(const std::vector<std::string>& dllList, con
                        _SOUT("+ %s", input.c_str());
                }
 
+               // end param
                argv.push_back(nullptr);
 
                // print cmd
@@ -445,7 +447,7 @@ static ni_error_e crossgen2PipeLine(const std::vector<std::string>& dllList, con
                        for (auto &arg: argv) _SOUT("+ %s", arg);
                }
 
-               execv(CORERUN_CMD, const_cast<char* const*>(argv.data()));
+               execv(CORERUN_CMD.c_str(), const_cast<char* const*>(argv.data()));
 
                clearArgs(argv);
                exit(0);
@@ -504,7 +506,7 @@ static ni_error_e crossgen2NoPipeLine(const std::vector<std::string>& dllList, c
                                for (auto &arg: argv) _SOUT("+ %s", arg);
                        }
 
-                       execv(CORERUN_CMD, const_cast<char* const*>(argv.data()));
+                       execv(CORERUN_CMD.c_str(), const_cast<char* const*>(argv.data()));
 
                        clearArgs(argv);
                        exit(0);
@@ -620,6 +622,15 @@ static ni_error_e createCoreLibNI(NIOption* opt)
 ni_error_e initNICommon()
 {
 #if defined(__arm__) || defined(__aarch64__)
+
+       char *env = nullptr;
+       env = getenv("MIC_CROSSGEN2_ENABLED");
+       if (env != nullptr && !strcmp(env, "1")) {
+               CORERUN_CMD = std::string("/opt/usr/dotnet/mic/crossgen2");
+               CROSSGEN2_PATH = "";
+               CLRJIT_PATH = std::string("/opt/usr/dotnet/mic/libclrjit_unix_") + ARCHITECTURE_IDENTIFIER + std::string("_x64.so");
+       }
+
        // get interval value
        const static std::string intervalFile = concatPath(__NATIVE_LIB_DIR, "crossgen_interval.txt");
        std::ifstream inFile(intervalFile);