[runtime] Fix tracking of dedup module in mkbundle
authorAlexander Kyte <alkyte@microsoft.com>
Mon, 7 Aug 2017 21:25:52 +0000 (17:25 -0400)
committerAlexander Kyte <alexmkyte@gmail.com>
Wed, 30 Aug 2017 16:55:24 +0000 (12:55 -0400)
mcs/tools/mkbundle/mkbundle.cs

index 9802735a5b812a4cf2adaf7d4ef33d8191d8695a..fe7121c470239a841e604852947b6a36121a60a5 100755 (executable)
@@ -83,7 +83,7 @@ class MakeBundle {
        static DirectoryInfo aot_temp_dir = null;
        static string aot_mode = "";
        static string aot_runtime = null;
-       static int? aot_dedup_assembly = null;
+       static string aot_dedup_assembly = null;
        static string cil_strip_path = null;
        static string managed_linker_path = null;
        static string sdk_path = null;
@@ -409,9 +409,12 @@ class MakeBundle {
                                        Console.WriteLine ("Usage: --aot-dedup <container_dll> ");
                                        return 1;
                                }
-                               var dedup_file = args [++i];
-                               sources.Add (dedup_file);
-                               aot_dedup_assembly = sources.Count () - 1;
+                               var rel_path = args [++i];
+                               var asm = LoadAssembly (rel_path);
+                               if (asm != null)
+                                       aot_dedup_assembly = new Uri(asm.CodeBase).LocalPath;
+
+                               sources.Add (rel_path);
                                aot_compile = true;
                                static_link = true;
                                break;
@@ -1516,26 +1519,25 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                Console.WriteLine ("Aoting files:");
 
                for (int i=0; i < files.Count; i++) {
-                       var fileName = files [i];
-                       string path = LocateFile (new Uri (fileName).LocalPath);
+                       var file_name = files [i];
+                       string path = LocateFile (new Uri (file_name).LocalPath);
                        string outPath = String.Format ("{0}.aot_out", path);
                        aot_paths.Add (outPath);
                        var name = System.Reflection.Assembly.LoadFrom(path).GetName().Name;
                        aot_names.Add (EncodeAotSymbol (name));
 
-                       if (aot_dedup_assembly != null && i != (int) aot_dedup_assembly) {
+                       if (aot_dedup_assembly != null) {
                                all_assemblies.Append (path);
                                all_assemblies.Append (" ");
-                               Execute (String.Format ("MONO_PATH={6} {0} --aot={1},outfile={2}{3}{4} {5}",
-                                       aot_runtime, aot_args, outPath, aot_mode_string, dedup_mode_string, path, Path.GetDirectoryName (path)));
+                               Execute (String.Format ("MONO_PATH={0} {1} --aot={2},outfile={3}{4}{5} {6}",
+                                       Path.GetDirectoryName (path), aot_runtime, aot_args, outPath, aot_mode_string, dedup_mode_string, path));
                        } else {
-                               Execute (String.Format ("MONO_PATH={5} {0} --aot={1},outfile={2}{3} {4}",
-                                       aot_runtime, aot_args, outPath, aot_mode_string, path, Path.GetDirectoryName (path)));
+                               Execute (String.Format ("MONO_PATH={0} {1} --aot={2},outfile={3}{4} {5}",
+                                       Path.GetDirectoryName (path), aot_runtime, aot_args, outPath, aot_mode_string, path));
                        }
                }
                if (aot_dedup_assembly != null) {
-                       string fileName = files [(int) aot_dedup_assembly];
-                       var filePath = new Uri (fileName).LocalPath;
+                       var filePath = new Uri (aot_dedup_assembly).LocalPath;
                        string path = LocateFile (filePath);
                        dedup_mode_string = String.Format (",dedup-include={0}", Path.GetFileName(filePath));
                        string outPath = String.Format ("{0}.aot_out", path);
@@ -1545,8 +1547,8 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
 
                if ((aot_mode == "full" || aot_mode == "llvmonly") && cil_strip_path != null) {
                        for (int i=0; i < files.Count; i++) {
-                               var inName = new Uri (files [i]).LocalPath;
-                               var cmd = String.Format ("{0} {1} {2}", aot_runtime, cil_strip_path, inName);
+                               var in_name = new Uri (files [i]).LocalPath;
+                               var cmd = String.Format ("{0} {1} {2}", aot_runtime, cil_strip_path, in_name);
                                Execute (cmd);
                        }
                }
@@ -1596,10 +1598,10 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
 
                // Fix file references
                for (int i=0; i < files.Count; i++) {
-                       var inName = new Uri (files [i]).LocalPath;
-                       var outName = Path.Combine (temp_dir_name, Path.GetFileName (inName));
-                       File.Copy (inName, outName);
-                       files [i] = outName;
+                       var in_name = new Uri (files [i]).LocalPath;
+                       var out_name = Path.Combine (temp_dir_name, Path.GetFileName (in_name));
+                       File.Copy (in_name, out_name);
+                       files [i] = out_name;
                        if (in_name == aot_dedup_assembly)
                                aot_dedup_assembly = out_name;
                }