return __ni_option;
}
-static bool isCoreLibPrepared()
-{
- std::string coreLibBackup = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll.Backup");
- if (isFile(coreLibBackup)) {
- return true;
- } else {
- _SERR("The native image of System.Private.CoreLib does not exist\n"
- "Run the command to create the native image\n"
- "# dotnettool --ni-dll /usr/share/dotnet.tizen/netcoreapp/System.Private.CoreLib.dll\n");
- return false;
- }
-}
-
-static bool hasCoreLibNI()
-{
- std::string ildasm = concatPath(__pm->getRuntimePath(), "ildasm");
- std::string coreLib = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll");
- std::string cmd = ildasm + " " + coreLib + " -noil -stats | grep '.rsrc'";
-
- FILE *fp;
- fp = popen(cmd.c_str(), "r");
- if (fp != NULL) {
- char buff[1024];
- if (fgets(buff, sizeof(buff), fp) != NULL) {
- pclose(fp);
- return false;
- }
- pclose(fp);
- }
- return true;
-}
-
static void waitInterval()
{
// by the recommand, ignore small value for performance.
// native image of System.Private.CoreLib.dll should have to overwrite
// original file to support new coreclr
if (absDllPath.find("System.Private.CoreLib.dll") != std::string::npos) {
- if (hasCoreLibNI()) {
- return true;
- }
+ return isR2RImage(absDllPath);
}
return false;
* Get the list of managed files in the specific directory
* Absolute paths of managed files are stored at the result list.
* If native image already exist in the same directory, managed file is ignored.
- *
- * Note: System.Private.CoreLib is excluded from the result list.
*/
static ni_error_e getTargetDllList(const std::string& path, std::vector<std::string>& fileList)
{
auto func = [&fileList](const std::string& f_path, const std::string& f_name) {
if (isManagedAssembly(f_path) && !checkNIExistence(f_path)) {
- if (f_path.find("System.Private.CoreLib") == std::string::npos) {
- fileList.push_back(getAbsolutePath(f_path));
- }
+ fileList.push_back(getAbsolutePath(f_path));
}
};
return NI_ERROR_NONE;
}
+static ni_error_e createCoreLibNI(NIOption* opt)
+{
+ std::string coreLib = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll");
+ std::string niCoreLib = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.ni.dll");
+ std::string coreLibBackup = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll.Backup");
+
+ std::vector<std::string> dllList;
+ std::vector<std::string> refPaths;
+ dllList.push_back(getAbsolutePath(coreLib));
+
+ if (!isFile(coreLibBackup) && !isR2RImage(coreLib)) {
+ if (crossgen2NoPipeLine(dllList, refPaths, opt) == NI_ERROR_NONE && exist(niCoreLib)) {
+ if (rename(coreLib.c_str(), coreLibBackup.c_str())) {
+ _SERR("Failed to rename System.Private.CoreLib.dll");
+ return NI_ERROR_CORE_NI_FILE;
+ }
+ if (rename(niCoreLib.c_str(), coreLib.c_str())) {
+ _SERR("Failed to rename System.Private.CoreLib.ni.dll");
+ return NI_ERROR_CORE_NI_FILE;
+ }
+ } else {
+ _SERR("Failed to create native image for %s", coreLib.c_str());
+ return NI_ERROR_CORE_NI_FILE;
+ }
+ }
+ return NI_ERROR_NONE;
+}
+
static ni_error_e doAOTList(std::vector<std::string>& dllList, const std::string& refPaths, NIOption* opt)
{
+ ni_error_e ret = NI_ERROR_NONE;
+
if (dllList.empty()) {
return NI_ERROR_INVALID_PARAMETER;
}
// When performing AOT for one Dll, an error is returned when an error occurs.
// However, when processing multiple dlls at once, only the log for errors is output and skipped.
+ std::string coreLib = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll");
+ bool hasSPC = false;
+
for (auto it = dllList.begin(); it != dllList.end(); it++) {
std::string f = *it;
if (!isFile(f)) {
_SERR("Input file is not a dll file : %s", f.c_str());
dllList.erase(it--);
}
+ // handle System.Private.CoreLib.dll separately.
+ // dllList and path manager contain absolute path. So, there is no need to change path to absolute path
+ if (f == coreLib) {
+ hasSPC = true;
+ dllList.erase(it--);
+ }
+ }
+
+ // In the case of SPC, post-processing is required to change the name of the native image.
+ // In order to avoid repeatedly checking whether the generated native image is an SPC,
+ // the SPC native image generation is performed separately.
+ if (hasSPC) {
+ ret = createCoreLibNI(opt);
+ if (ret != NI_ERROR_NONE) {
+ return ret;
+ }
+ }
+
+ // if there is no proper input after processing dll list
+ if (dllList.empty()) {
+ if (hasSPC) {
+ return ret;
+ } else {
+ return NI_ERROR_INVALID_PARAMETER;
+ }
}
std::vector<std::string> paths;
splitPath(refPaths, paths);
if (opt->flags & NI_FLAGS_NO_PIPELINE) {
- crossgen2NoPipeLine(dllList, paths, opt);
+ ret = crossgen2NoPipeLine(dllList, paths, opt);
} else {
- crossgen2PipeLine(dllList, paths, opt);
+ ret = crossgen2PipeLine(dllList, paths, opt);
}
- return NI_ERROR_NONE;
+ return ret;
}
static ni_error_e doAOTFile(const std::string& dllFile, const std::string& refPaths, NIOption* opt)
return NI_ERROR_INVALID_PARAMETER;
}
+ if (checkNIExistence(dllFile)) {
+ _SERR("Native image file is already exist : %s", dllFile.c_str());
+ return NI_ERROR_ALREADY_EXIST;
+ }
+
std::vector<std::string> dllList;
dllList.push_back(getAbsolutePath(dllFile));
return doAOTList(dllList, refPaths, opt);
return 0;
}
-static ni_error_e createCoreLibNI(NIOption* opt)
-{
- std::string coreLib = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll");
- std::string niCoreLib = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.ni.dll");
- std::string coreLibBackup = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll.Backup");
-
- if (!isFile(coreLibBackup) && !hasCoreLibNI()) {
- if (doAOTFile(coreLib, std::string(), opt) == NI_ERROR_NONE && exist(niCoreLib)) {
- if (rename(coreLib.c_str(), coreLibBackup.c_str())) {
- _SERR("Failed to rename System.Private.CoreLib.dll");
- return NI_ERROR_CORE_NI_FILE;
- }
- if (rename(niCoreLib.c_str(), coreLib.c_str())) {
- _SERR("Failed to rename System.Private.CoreLib.ni.dll");
- return NI_ERROR_CORE_NI_FILE;
- }
- } else {
- _SERR("Failed to create native image for %s", coreLib.c_str());
- return NI_ERROR_CORE_NI_FILE;
- }
- }
- return NI_ERROR_NONE;
-}
-
ni_error_e initNICommon()
{
#if defined(__arm__) || defined(__aarch64__)
ni_error_e createNIPlatform(NIOption* opt)
{
- ni_error_e ret = createCoreLibNI(opt);
- if (ret != NI_ERROR_NONE) {
- return ret;
- }
-
- ret = createNIUnderDirs(__pm->getRuntimePath(), opt);
+ ni_error_e ret = createNIUnderDirs(__pm->getRuntimePath(), opt);
if (ret != NI_ERROR_NONE) {
return ret;
}
ni_error_e createNIDll(const std::string& dllPath, NIOption* opt)
{
- if (dllPath.find("System.Private.CoreLib.dll") != std::string::npos) {
- return createCoreLibNI(opt);
- }
-
- if (!isCoreLibPrepared()) {
- return NI_ERROR_CORE_NI_FILE;
- }
-
return doAOTFile(dllPath, std::string(), opt);
}
ni_error_e createNIUnderDirs(const std::string& rootPaths, NIOption* opt)
{
ni_error_e ret = NI_ERROR_NONE;
- if (!isCoreLibPrepared()) {
- return NI_ERROR_CORE_NI_FILE;
- }
std::vector<std::string> fileList;
std::vector<std::string> paths;
std::string coreLib = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll");
std::string coreLibBackup = concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll.Backup");
- if (hasCoreLibNI()) {
+ if (isR2RImage(coreLib)) {
if (!isFile(coreLibBackup)) {
return;
}
ni_error_e regenerateAppNI(NIOption* opt)
{
- if (!isCoreLibPrepared()) {
- return NI_ERROR_CORE_NI_FILE;
- }
-
int ret = 0;
pkgmgrinfo_appinfo_metadata_filter_h handle;
ni_error_e regenerateTACNI(NIOption* opt)
{
- if (!isCoreLibPrepared()) {
- return NI_ERROR_CORE_NI_FILE;
- }
-
removeNIUnderDirs(__DOTNET_DIR);
pkgmgrinfo_appinfo_metadata_filter_h handle;