-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix macOS host + linux-bionic-arm64 target cross-compile build (#9)
Context: dotnet/runtime#101727 Previously, trying to use `dotnet publish` from a macOS host would result in obscure build failures, e.g. % dotnet publish -c Release … clang : error : invalid linker name in argument '-fuse-ld=lld' Apply the workaround from dotnet/runtime#101727 to workaround this. The `$(ANDROID_NDK_HOME)` environment variable requuired: # we're all xamarin-android devs here, right? ;-) % export ANDROID_NDK_HOME=$HOME/android-toolchain/ndk % dotnet publish -c Release # Creates DotNet/bin/Release/net8.0/linux-bionic-arm64/publish/libdotnet.so * Set `$ANDROID_NDK_HOME` from `devcontainer.json` Co-authored-by: Jonathan Peppers <[email protected]>
- Loading branch information
1 parent
0e9b75b
commit a2fd74c
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<_NdkSysrootAbi Condition=" '$(RuntimeIdentifier)' == 'linux-bionic-arm64' ">aarch64-linux-android</_NdkSysrootAbi> | ||
<_NdkClangPrefix Condition=" '$(RuntimeIdentifier)' == 'linux-bionic-arm64' ">aarch64-linux-android21-</_NdkClangPrefix> | ||
<_NdkPrebuiltAbi Condition=" '$(NETCoreSdkRuntimeIdentifier)' == 'osx-x64' ">darwin-x86_64</_NdkPrebuiltAbi> | ||
<_NdkPrebuiltAbi Condition=" '$(NETCoreSdkRuntimeIdentifier)' == 'linux-x64' ">linux-x86_64</_NdkPrebuiltAbi> | ||
<_NdkSysrootDir>$(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(_NdkPrebuiltAbi)/sysroot/usr/lib/$(_NdkSysrootAbi)</_NdkSysrootDir> | ||
<_NdkBinDir>$(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(_NdkPrebuiltAbi)/bin</_NdkBinDir> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith('linux-bionic'))"> | ||
<LinkStandardCPlusPlusLibrary>true</LinkStandardCPlusPlusLibrary> | ||
<CppCompilerAndLinker>$(_NdkBinDir)/$(_NdkClangPrefix)clang++</CppCompilerAndLinker> | ||
<ObjCopyName>$(_NdkBinDir)/llvm-objcopy</ObjCopyName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="$(RuntimeIdentifier.StartsWith('linux-bionic'))"> | ||
<LinkerArg Include="-Wl,--defsym,_init=__libc_init" /> | ||
<LinkerArg Include="-Wl,--defsym,_fini=__libc_fini" /> | ||
<LinkerArg Include="-L "$(_NdkSysrootDir)"" /> | ||
<NativeSystemLibrary Include="c" /> | ||
</ItemGroup> | ||
|
||
<Target Name="_ValidateEnvironment" | ||
BeforeTargets="Build"> | ||
<Error | ||
Condition=" '$(ANDROID_NDK_HOME)' == '' Or !Exists($(ANDROID_NDK_HOME)) " | ||
Text="Set the %24ANDROID_NDK_HOME environment variable to the path of the Android NDK." | ||
/> | ||
<Error | ||
Condition=" !Exists($(_NdkSysrootDir))" | ||
Text="NDK 'sysroot' dir `$(_NdkSysrootDir)` does not exist. You're on your own." | ||
/> | ||
</Target> | ||
</Project> |