Commit 888e42f
committed
[MonoAOTCompiler] more properties & custom WorkingDirectory
Fixes: dotnet#56163
PR dotnet#58523 fixed something on Windows, but it didn't actually address
our issues on Android.
A directory name like `foo Ümläüts` fails:
* `mkdir 'foo Ümläüts' ; cd 'foo Ümläüts'`
* `dotnet new android`
* `dotnet build -c Release -p:RunAOTCompilation=true` (adding
`-p:EnableLLVM=true` complicates further)
The error:
Precompiling failed for C:\src\foo Ümläüts\obj\Release\android-arm64\linked\System.Private.CoreLib.dll: Error: Loaded assembly 'C:\src\foo ├£ml├ñ├╝ts\obj\Release\android-arm64\linked\System.Private.CoreLib.dll' doesn't match original file name 'C:\foo ▄mlΣⁿts\obj\Release\android-arm64\linked\System.Private.CoreLib.dll'. Set MONO_PATH to the assembly's location.
Reviewing the existing AOT implementation in Xamarin.Android, I found
out *why* Xamarin.Android works:
[AOT] response file obj\Release\120\aot\arm64-v8a\App36.dll\response.txt: --llvm "--aot=temp-path=obj\Release\120\aot\arm64-v8a\App36.dll,llvm-path=C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Xamarin\Android,outfile=obj\Release\120\aot\arm64-v8a\libaot-App36.dll.so,msym-dir=obj\Release\120\aot\arm64-v8a,asmwriter,mtriple=aarch64-linux-android,tool-prefix=C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android-,ld-name=ld.EXE,ld-flags=\"-LC:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\lib\gcc\aarch64-linux-android\4.9.x\";\"-LC:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm64\usr\lib\";\"C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\lib\gcc\aarch64-linux-android\4.9.x\libgcc.a\";\"C:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm64\usr\lib\libc.so\";\"C:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm64\usr\lib\libm.so\"" C:\Users\jopepper\source\repos\App36\App36\obj\Release\120\android\assets\shrunk\App36.dll
1. Xamarin.Android passes *relative* paths. The `foo Ümläüts`
directory name doesn't even come into play for some arguments.
2. With LLVM, `ld-flags` contains a `;`.
The existing code splits on `;` and joins on `,`:
https://github.com/dotnet/runtime/blob/25c207351c4f57cf2daa98caaf327a8b8d83edb8/src/tasks/AotCompilerTask/MonoAOTCompiler.cs#L505-L509
So we lose any `;` delimiters for the `ld-flags` value, they get
replaced by `,`.
I think the solution here is:
1. Add several missing properties to `<MonoAOTCompiler/>` so we don't
have to rely on the `%(AotArguments)` item metadata. No splitting
on `;` would be required, `ld-flags` can be passed in and used as-is.
2. Add a new `WorkingDirectory` property. When this is set, assume
paths passed in might be relative -- and don't transform paths by
calling `Path.GetFullPath()`.
Lastly, I fixed a place where the UTF8 encoding wasn't passed when
MSBuild logging the response file.
These changes I tried to make in a way where this shouldn't break
other .NET workloads like wasm. If existing MSBuild targets call this
task (not using the new properties), the behavior should remain
unchanged.
I tested these changes by commiting a modified `MonoAOTCompiler.dll`:
dotnet/android#6562
I'm able to enable several AOT tests related to dotnet#56163.1 parent 25c2073 commit 888e42f
1 file changed
+63
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
194 | 219 | | |
195 | 220 | | |
196 | 221 | | |
197 | 222 | | |
198 | 223 | | |
199 | 224 | | |
| 225 | + | |
| 226 | + | |
200 | 227 | | |
201 | 228 | | |
202 | 229 | | |
| |||
225 | 252 | | |
226 | 253 | | |
227 | 254 | | |
228 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
229 | 258 | | |
230 | 259 | | |
231 | 260 | | |
| |||
682 | 711 | | |
683 | 712 | | |
684 | 713 | | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
685 | 734 | | |
686 | 735 | | |
687 | 736 | | |
| |||
694 | 743 | | |
695 | 744 | | |
696 | 745 | | |
697 | | - | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
698 | 756 | | |
699 | 757 | | |
700 | 758 | | |
| |||
706 | 764 | | |
707 | 765 | | |
708 | 766 | | |
709 | | - | |
| 767 | + | |
710 | 768 | | |
711 | 769 | | |
712 | 770 | | |
713 | 771 | | |
714 | 772 | | |
715 | 773 | | |
716 | | - | |
| 774 | + | |
717 | 775 | | |
718 | 776 | | |
719 | 777 | | |
| |||
741 | 799 | | |
742 | 800 | | |
743 | 801 | | |
744 | | - | |
| 802 | + | |
745 | 803 | | |
746 | 804 | | |
747 | 805 | | |
| |||
0 commit comments