X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Faot-compiler.c;h=dd2780edac9e524123b6483fca0e54cb4e5ff95b;hb=56ad8f4e5dfb8198e4671f631a3103b1e8b83dd3;hp=0622a8b334c806c51633a9ca35b35fa48f55a19b;hpb=6ce453f2cf8299a516e818ac287c07c35d8767e5;p=mono.git diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index 0622a8b334c..dd2780edac9 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -7001,6 +7001,15 @@ wrap_path (gchar * path) return clean; } +// Duplicate a char range and add it to a ptrarray, but only if it is nonempty +static void +ptr_array_add_range_if_nonempty(GPtrArray *args, gchar const *start, gchar const *end) +{ + ptrdiff_t len = end-start; + if (len > 0) + g_ptr_array_add (args, g_strndup (start, len)); +} + static GPtrArray * mono_aot_split_options (const char *aot_options) { @@ -7056,6 +7065,7 @@ mono_aot_split_options (const char *aot_options) next: aot_options++; + restart: // If the next character is end of string, then process the last option. if (*(aot_options) == '\0') { end_of_string = TRUE; @@ -7064,11 +7074,11 @@ mono_aot_split_options (const char *aot_options) continue; new_opt: - g_ptr_array_add (args, g_strndup (opt_start, aot_options - opt_start)); + ptr_array_add_range_if_nonempty (args, opt_start, aot_options); opt_start = ++aot_options; if (end_of_string) break; - goto next; + goto restart; // Check for null and continue loop } return args; @@ -9875,7 +9885,6 @@ compile_asm (MonoAotCompile *acfg) #define AS_OPTIONS "--64" #elif defined(TARGET_POWERPC64) #define AS_OPTIONS "-a64 -mppc64" -#define LD_OPTIONS "-m elf64ppc" #elif defined(sparc) && SIZEOF_VOID_P == 8 #define AS_OPTIONS "-xarch=v9" #elif defined(TARGET_X86) && defined(TARGET_MACH) && !defined(__native_client_codegen__) @@ -9896,22 +9905,30 @@ compile_asm (MonoAotCompile *acfg) #define AS_NAME "as" #endif -#ifndef LD_OPTIONS -#define LD_OPTIONS "" -#endif - #if defined(sparc) -#define LD_NAME "ld -shared -G" +#define LD_NAME "ld" +#define LD_OPTIONS "-shared -G" #elif defined(__ppc__) && defined(TARGET_MACH) -#define LD_NAME "gcc -dynamiclib" +#define LD_NAME "gcc" +#define LD_OPTIONS "-dynamiclib" #elif defined(TARGET_AMD64) && defined(TARGET_MACH) -#define LD_NAME "clang --shared" +#define LD_NAME "clang" +#define LD_OPTIONS "--shared" #elif defined(TARGET_WIN32) && !defined(TARGET_ANDROID) -#define LD_NAME "gcc -shared --dll" +#define LD_NAME "gcc" +#define LD_OPTIONS "-shared" #elif defined(TARGET_X86) && defined(TARGET_MACH) && !defined(__native_client_codegen__) -#define LD_NAME "clang -m32 -dynamiclib" +#define LD_NAME "clang" +#define LD_OPTIONS "-m32 -dynamiclib" #elif defined(TARGET_ARM) && !defined(TARGET_ANDROID) -#define LD_NAME "gcc --shared" +#define LD_NAME "gcc" +#define LD_OPTIONS "--shared" +#elif defined(TARGET_POWERPC64) +#define LD_OPTIONS "-m elf64ppc" +#endif + +#ifndef LD_OPTIONS +#define LD_OPTIONS "" #endif if (acfg->aot_opts.asm_only) { @@ -9987,10 +10004,11 @@ compile_asm (MonoAotCompile *acfg) ld_flags = g_strdup_printf ("%s %s", ld_flags, "-lstdc++"); #ifdef LD_NAME - command = g_strdup_printf ("%s -o %s %s %s %s", LD_NAME, + command = g_strdup_printf ("%s%s %s -o %s %s %s %s", tool_prefix, LD_NAME, LD_OPTIONS, wrap_path (tmp_outfile_name), wrap_path (llvm_ofile), wrap_path (g_strdup_printf ("%s.o", acfg->tmpfname)), ld_flags); #else + // Default (linux) command = g_strdup_printf ("\"%sld\" %s -shared -o %s %s %s %s", tool_prefix, LD_OPTIONS, wrap_path (tmp_outfile_name), wrap_path (llvm_ofile), wrap_path (g_strdup_printf ("%s.o", acfg->tmpfname)), ld_flags);