From 24de80ecb8fcbf2d1897ad1648d5202c530ef974 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Tue, 1 Jun 2021 10:07:18 +0100 Subject: [PATCH] [Xamarin.Android.Build.Tasks] Quote Aot Paths (again) Fixes #5964 We missed a few paths which might need to be quoted in order to handle spaces in the paths. ``` 2021-05-28T22:15:09.3191452Z [aot-compiler stdout] Executing the native linker: "C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE" -Bsymbolic -shared -o obj\Release\110\aot\armeabi-v7a\libaot-Xamarin.AndroidX.CardView.dll.so.tmp "obj\Release\110\aot\armeabi-v7a\Xamarin.AndroidX.CardView.dll\temp-llvm.o" obj\Release\110\aot\armeabi-v7a\Xamarin.AndroidX.CardView.dll\temp.s.o -LC:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.9.x -LC:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm\usr\lib -LC:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\..\sysroot\usr\lib\arm-linux-androideabi "C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.9.x\libgcc.a" "C:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm\usr\lib\libc.so" "C:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm\usr\lib\libm.so" 2021-05-28T22:15:09.3195848Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot open Files: No such file or directory 2021-05-28T22:15:09.3197593Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot open (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.9.x: No such file or directory 2021-05-28T22:15:09.3199375Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot open Files: No such file or directory 2021-05-28T22:15:09.3200935Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot open (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm\usr\lib: No such file or directory 2021-05-28T22:15:09.3202549Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot open Files: No such file or directory 2021-05-28T22:15:09.3204244Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot open (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\..\sysroot\usr\lib\arm-linux-androideabi: No such file or directory 2021-05-28T22:15:09.3205865Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot find -lunwind 2021-05-28T22:15:09.3207138Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot find -lcompiler_rt-extras 2021-05-28T22:15:09.3208785Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot find -lgcc_real 2021-05-28T22:15:09.3210086Z [aot-compiler stderr] C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.EXE: error: cannot find -ldl ``` So lets quote ALL the things. --- src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs index 97d7388e193..fe9e601afde 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs @@ -304,7 +304,7 @@ IEnumerable GetAotConfigs () outdir = Path.Combine (AotOutputDirectory, "arm64-v8a"); mtriple = "aarch64-linux-android"; arch = AndroidTargetArch.Arm64; - break; + break; case "x86": aotCompiler = Path.Combine (sdkBinDirectory, "cross-x86"); @@ -366,13 +366,13 @@ IEnumerable GetAotConfigs () var libs = new List(); if (NdkUtil.UsingClangNDK) { - libs.Add ($"-L{toolchainLibDir}"); - libs.Add ($"-L{androidLibPath}"); + libs.Add ($"-L\\\"{toolchainLibDir}\\\""); + libs.Add ($"-L\\\"{androidLibPath}\\\""); if (arch == AndroidTargetArch.Arm) { // Needed for -lunwind to work string compilerLibDir = Path.Combine (toolchainPath, "..", "sysroot", "usr", "lib", NdkUtil.GetArchDirName (arch)); - libs.Add ($"-L{compilerLibDir}"); + libs.Add ($"-L\\\"{compilerLibDir}\\\""); } } @@ -432,7 +432,7 @@ IEnumerable GetAotConfigs () if (!String.IsNullOrEmpty (ldName)) { // MUST be before `ld-flags`, otherwise Mono fails to parse it on Windows - aotOptions.Add ($"ld-name={ldName}"); + aotOptions.Add ($"ld-name=\\\"{ldName}\\\""); } aotOptions.Add ($"ld-flags={ldFlags}"); @@ -466,7 +466,7 @@ IEnumerable GetAotConfigs () } } } - + bool RunAotCompiler (string assembliesPath, string aotCompiler, string aotOptions, string assembly, string responseFile) { var stdout_completed = new ManualResetEvent (false); @@ -487,7 +487,7 @@ bool RunAotCompiler (string assembliesPath, string aotCompiler, string aotOption WindowStyle=ProcessWindowStyle.Hidden, WorkingDirectory = WorkingDirectory, }; - + // we do not want options to be provided out of band to the cross compilers psi.EnvironmentVariables ["MONO_ENV_OPTIONS"] = String.Empty; // the C code cannot parse all the license details, including the activation code that tell us which license level is allowed