Bug 42404 - AOT+LLVM Fails when NDK is installed in a path with spaces
Summary: AOT+LLVM Fails when NDK is installed in a path with spaces
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 6.1.0 (C7)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2016-07-07 17:58 UTC by Chris Ray
Modified: 2017-06-28 21:31 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Chris Ray 2016-07-07 17:58:13 UTC
AOT+LLVM Fails to call out to ld if the path to the NDK contains spaces, and Visual Studio installs the NDK to C:\Program Files\Android\ndk\android-ndk-r11c by default.

This can be reproduced with the HelloWorld sample project in the xamarin.android repo with the following command:
msbuild /t:Install HelloWorld.csproj /p:Configuration=Release /p:AotAssemblies=true /p:EnableLLVM=true /v:diag

================================================

Using "Aot" task from assembly "C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll".
Task "Aot" (TaskId:179)
  Task Parameter:AndroidAotMode=Normal (TaskId:179)
  Task Parameter:AndroidNdkDirectory=C:\Program Files\Android\ndk\android-ndk-r11c\ (TaskId:179)
  Task Parameter:AndroidApiLevel=23 (TaskId:179)
  Task Parameter:SdkBinDirectory=C:\Program Files (x86)\MSBuild\Xamarin\Android (TaskId:179)
  Task Parameter:SupportedAbis=armeabi-v7a (TaskId:179)
  Task Parameter:AndroidSequencePointsMode=Offline (TaskId:179)
  Task Parameter:
      ResolvedAssemblies=
          c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\HelloWorld.dll
          c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\Mono.Android.dll
          c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\mscorlib.dll
          c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.Core.dll
          c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.dll
          c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.Xml.dll
          c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.Runtime.Serialization.dll
          c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.ServiceModel.Internals.dll (TaskId:179)
  Task Parameter:AotOutputDirectory=obj\Release\aot (TaskId:179)
  Task Parameter:IntermediateAssemblyDir=obj\Release\assemblies\ (TaskId:179)
  Task Parameter:LinkMode=SdkOnly (TaskId:179)
  Task Parameter:EnableLLVM=True (TaskId:179)
  Aot: (TaskId:179)
    AndroidApiLevel: 23 (TaskId:179)
    AndroidAotMode: Normal (TaskId:179)
    AndroidSequencePointsMode: Offline (TaskId:179)
    AndroidNdkDirectory: C:\Program Files\Android\ndk\android-ndk-r11c\ (TaskId:179)
    AotOutputDirectory: obj\Release\aot (TaskId:179)
    EnableLLVM: True (TaskId:179)
    IntermediateAssemblyDir: obj\Release\assemblies\ (TaskId:179)
    LinkMode: SdkOnly (TaskId:179)
    SdkBinDirectory: C:\Program Files (x86)\MSBuild\Xamarin\Android (TaskId:179)
    SupportedAbis: armeabi-v7a (TaskId:179)
    ResolvedAssemblies: (TaskId:179)
      c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\HelloWorld.dll (TaskId:179)
      c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\Mono.Android.dll (TaskId:179)
      c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\mscorlib.dll (TaskId:179)
      c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.Core.dll (TaskId:179)
      c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.dll (TaskId:179)
      c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.Xml.dll (TaskId:179)
      c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.Runtime.Serialization.dll (TaskId:179)
      c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\System.ServiceModel.Internals.dll (TaskId:179)
    AdditionalNativeLibraryReferences: (TaskId:179)
  [AOT] c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\HelloWorld.dll (TaskId:179)
  Mono arguments: --llvm --aot=gen-seq-points-file,outfile=c:\depot\xa\samples\HelloWorld\obj\Release\aot\armeabi-v7a\libaot-HelloWorld.dll.so,asmwriter,mtriple=armv7-linux-gnueabi,tool-prefix="C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androidea
  bi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-",ld-flags="C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.9\libgcc.a";"C:\Program Files\Android\ndk\android-ndk-r11c\p
  latforms\android-21\arch-arm\usr\lib\libc.so";"C:\Program Files\Android\ndk\android-ndk-r11c\platforms\android-21\arch-arm\usr\lib\libm.so",llvm-path="C:\Program Files (x86)\MSBuild\Xamarin\Android",temp-path=c:\depot\xa\samples\HelloWorld\obj\Release\aot\armeabi-v7a
  c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\HelloWorld.dll (TaskId:179)
  MONO_PATH=c:\depot\xa\samples\HelloWorld\obj\Release\android\assets (TaskId:179)
  [aot-compiler stderr] C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld: error: cannot open C:\Program: No such file or directory (TaskId:179)
  [aot-compiler stderr] C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld: error: cannot open Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x
  86_64\lib\gcc\arm-linux-androideabi\4.9\libgcc.a: No such file or directory (TaskId:179)
  [aot-compiler stdout] Mono Ahead of Time compiler - compiling assembly c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\HelloWorld.dll (TaskId:179)
  [aot-compiler stdout] Executing opt: "C:\Program Files (x86)\MSBuild\Xamarin\Android\opt" -f -targetlibinfo -no-aa -basicaa -notti -instcombine -simplifycfg -inline-cost -inline -sroa -domtree -early-cse -lazy-value-info -correlated-propagation -simplifycfg -instcombi
  ne -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -indvars -loop-idiom -loop-deletion -loop-unroll -memdep -gvn -memdep -memcpyopt -sccp -instcombine -lazy-v
  alue-info -correlated-propagation -domtree -memdep -adce -simplifycfg -instcombine -strip-dead-prototypes -domtree -verify -o "c:\depot\xa\samples\HelloWorld\obj\Release\aot\armeabi-v7a\temp.opt.bc" "c:\depot\xa\samples\HelloWorld\obj\Release\aot\armeabi-v7a\temp.bc"
  (TaskId:179)
  [aot-compiler stderr] C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld: error: cannot open C:\Program: No such file or directory (TaskId:179)
  [aot-compiler stdout] Executing llc: "C:\Program Files (x86)\MSBuild\Xamarin\Android\llc"  -mattr=+vfp2,-neon,+d16 -asm-verbose=false -disable-gnu-eh-frame -enable-mono-eh-frame -mtriple=armv7-linux-gnueabi -mono-eh-frame-symbol=mono_aot_HelloWorld_eh_frame -relocatio
  n-model=pic -filetype=obj -o "c:\depot\xa\samples\HelloWorld\obj\Release\aot\armeabi-v7a\temp-llvm.o" "c:\depot\xa\samples\HelloWorld\obj\Release\aot\armeabi-v7a\temp.opt.bc" (TaskId:179)
  [aot-compiler stderr] C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld: error: cannot open Files\Android\ndk\android-ndk-r11c\platforms\android-21\arch-arm\usr\lib\libc.so: No such
  file or directory (TaskId:179)
  [aot-compiler stdout] Code: 784(43%) Info: 42(2%) Ex Info: 51(2%) Unwind Info: 57(3%) Class Info: 538(29%) PLT: 11(0%) GOT Info: 159(8%) Offsets: 172(9%) GOT: 96 (TaskId:179)
  [aot-compiler stdout] Compiled: 17/17 (100%), LLVM: 0 (0%), No GOT slots: 15 (88%), Direct calls: 0 (100%) (TaskId:179)
  [aot-compiler stdout] Executing the native assembler: "C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-as"   -mfpu=vfp3 -o C:\Users\cray\AppData\Local\Temp\mono_aot_a14084.o C:\Users\
  cray\AppData\Local\Temp\mono_aot_a14084 (TaskId:179)
  [aot-compiler stderr] C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld: error: cannot open C:\Program: No such file or directory (TaskId:179)
  [aot-compiler stderr] C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld: error: cannot open Files\Android\ndk\android-ndk-r11c\platforms\android-21\arch-arm\usr\lib\libm.so: No such
  file or directory (TaskId:179)
  [aot-compiler stdout] Executing the native linker: "C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld"  -shared -o c:\depot\xa\samples\HelloWorld\obj\Release\aot\armeabi-v7a\libaot-H
  elloWorld.dll.so.tmp c:\depot\xa\samples\HelloWorld\obj\Release\aot\armeabi-v7a\temp-llvm.o C:\Users\cray\AppData\Local\Temp\mono_aot_a14084.o C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\lib\gcc\arm-linux-
  androideabi\4.9\libgcc.a C:\Program Files\Android\ndk\android-ndk-r11c\platforms\android-21\arch-arm\usr\lib\libc.so C:\Program Files\Android\ndk\android-ndk-r11c\platforms\android-21\arch-arm\usr\lib\libm.so (TaskId:179)
  [aot-compiler stderr] AOT of image c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\HelloWorld.dll failed. (TaskId:179)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1965,3): error XA3001: Could not AOT the assembly: c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\HelloWorld.dll [c:\depot\xa\samples\HelloWorld\HelloWorld.csproj]
Comment 1 Chris Ray 2016-07-07 18:06:31 UTC
Woops I looked at the log wrong, ld was failing to find some libraries.

  [aot-compiler stderr] C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld: error: cannot open C:\Program: No such file or directory (TaskId:179)
  [aot-compiler stderr] C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld: error: cannot open Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x
  86_64\lib\gcc\arm-linux-androideabi\4.9\libgcc.a: No such file or directory (TaskId:179)


At initial glance it seems like these library paths are quoted when they are passed to the aot-compiler, but not quoted when mini calls out to ld.

ld-flags="C:\Program Files\Android\ndk\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.9\libgcc.a";"C:\Program Files\Android\ndk\android-ndk-r11c\p
  latforms\android-21\arch-arm\usr\lib\libc.so";"C:\Program Files\Android\ndk\android-ndk-r11c\platforms\android-21\arch-arm\usr\lib\libm.so",llvm-path="C:\Program Files (x86)\MSBuild\Xamarin\Android",temp-path=c:\depot\xa\samples\HelloWorld\obj\Release\aot\armeabi-v7a
  c:\depot\xa\samples\HelloWorld\obj\Release\android\assets\HelloWorld.dll (TaskId:179)
Comment 2 John Miller [MSFT] 2017-06-28 21:31:05 UTC
Unfortunately, we’re unable to reproduce this report using the latest Xamarin.Android (7.3.1.2). If this issue is still occurring for you, please reopen this issue and attach a reproduction to the bug by starting with a clean Xamarin.Android project adding just the code necessary to demonstrate the issue. Please include the specific steps required to get the issue. Thanks!