Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!-- Licensed to the .NET Foundation under one or more agreements.
The .NET Foundation licenses this file to you under the MIT license. -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="SetupOSSpecificProps" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)">
<Error Condition="'$(_targetOS)' != 'wasi'" Text="NativeAOT WebAssembly linking is not supported for '$(_targetOS)'." />
<Error Condition="'$(NativeLib)' == 'Shared'" Text="NativeAOT WebAssembly shared libraries are not supported." />
<Error Condition="'$(IlcMultiModule)' == 'true'" Text="NativeAOT WebAssembly multi-module compilation is not supported." />
<Error Condition="'$(IlcDehydrate)' == 'true'" Text="NativeAOT WebAssembly data dehydration is not supported." />
<Error Condition="'$(StackTraceSupport)' == 'true'" Text="NativeAOT WebAssembly managed stack traces are not supported." />
<Error Condition="'$(WASI_SDK_PATH)' == ''" Text="Set WASI_SDK_PATH to the WASI SDK root to link NativeAOT WASI applications." />

<PropertyGroup>
<_WasiToolExeSuffix Condition="$([MSBuild]::IsOSPlatform('Windows'))">.exe</_WasiToolExeSuffix>
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == ''">$(WASI_SDK_PATH)/bin/clang$(_WasiToolExeSuffix)</CppCompilerAndLinker>
<CppLinker>$(CppCompilerAndLinker)</CppLinker>
<CppLibCreator>$(WASI_SDK_PATH)/bin/llvm-ar$(_WasiToolExeSuffix)</CppLibCreator>
<IlcDefaultStackSize Condition="'$(IlcDefaultStackSize)' == ''">8388608</IlcDefaultStackSize>
<LinkStandardCPlusPlusLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' == '' and '$(InvariantGlobalization)' != 'true'">true</LinkStandardCPlusPlusLibrary>
</PropertyGroup>

<Error Condition="!Exists('$(CppLinker)')" Text="The WASI compiler was not found at '$(CppLinker)'." />
<Error Condition="!Exists('$(CppLibCreator)')" Text="The WASI archive tool was not found at '$(CppLibCreator)'." />

<ItemGroup>
<NetCoreAppNativeLibrary Include="System.Native" />
<NetCoreAppNativeLibrary Include="System.Globalization.Native" Condition="'$(InvariantGlobalization)' != 'true'" />
<NetCoreAppNativeLibrary Include="System.IO.Compression.Native" />
</ItemGroup>

<ItemGroup>
<DirectPInvoke Include="@(NetCoreAppNativeLibrary)" />
</ItemGroup>

<ItemGroup>
<NativeLibrary Include="@(NetCoreAppNativeLibrary->'$(IlcFrameworkNativePath)lib%(Identity).a')" />
<NativeLibrary Include="$(IlcSdkPath)libbootstrapper.o" Condition="'$(NativeLib)' == '' and '$(CustomNativeMain)' != 'true'" />
<NativeLibrary Include="$(IlcSdkPath)libbootstrapperdll.o" Condition="'$(NativeLib)' != '' or '$(CustomNativeMain)' == 'true'" />
<NativeLibrary Include="$(IlcSdkPath)libPortableRuntime.a" />
<NativeLibrary Include="$(IlcSdkPath)libstandalonegc-disabled.a" />
<NativeLibrary Include="$(IlcSdkPath)libaotminipal.a" />
<NativeLibrary Include="$(IlcSdkPath)libstdc++compat.a" Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true'" />
<NativeLibrary Include="$(IlcFrameworkNativePath)libSystem.Native.TimeZoneData.a" Condition="'$(InvariantTimezone)' != 'true'" />
<NativeLibrary Include="$(IlcFrameworkNativePath)libSystem.Native.TimeZoneData.Invariant.a" Condition="'$(InvariantTimezone)' == 'true'" />
<NativeLibrary Include="$(IlcFrameworkNativePath)libicui18n.a;$(IlcFrameworkNativePath)libicuuc.a;$(IlcFrameworkNativePath)libicudata.a" Condition="'$(InvariantGlobalization)' != 'true'" />
<NativeLibrary Include="$(IlcFrameworkNativePath)libz.a;$(IlcFrameworkNativePath)libzstd.a" />
</ItemGroup>

<ItemGroup>
<LinkerArg Include="--target=wasm32-wasip2" />
<LinkerArg Include="--sysroot=&quot;$(WASI_SDK_PATH)/share/wasi-sysroot&quot;" />
<LinkerArg Include="@(NativeLibrary->'&quot;%(Identity)&quot;')" />
<LinkerArg Include="-Wl,-z,stack-size=$(IlcDefaultStackSize)" />
<LinkerArg Include="-lwasi-emulated-process-clocks;-lwasi-emulated-signal;-lwasi-emulated-mman" />
<LinkerArg Include="-lstdc++" Condition="'$(LinkStandardCPlusPlusLibrary)' == 'true'" />
<LinkerArg Include="-g" Condition="'$(NativeDebugSymbols)' == 'true'" />
</ItemGroup>
</Target>

<Target Name="CreateShimExes">
<Error Condition="'$(_AggregateExecutable)' == 'true'" Text="NativeAOT WebAssembly aggregate executables are not supported." />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ The .NET Foundation licenses this file to you under the MIT license.
<UseSizeOptimizedLinq Condition="'$(UseSizeOptimizedLinq)' == ''">true</UseSizeOptimizedLinq>
</PropertyGroup>

<!-- These formats encode function pointers as relative linear-memory addresses, not WASM table indices. -->
<PropertyGroup Condition="'$(_targetArchitecture)' == 'wasm'">
<IlcDehydrate Condition="'$(IlcDehydrate)' == ''">false</IlcDehydrate>
<StackTraceSupport Condition="'$(StackTraceSupport)' == ''">false</StackTraceSupport>
</PropertyGroup>

<!-- Configure LINQ expressions -->
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Linq.Expressions.CanEmitObjectArrayDelegate"
Expand All @@ -65,6 +71,7 @@ The .NET Foundation licenses this file to you under the MIT license.

<NativeBinaryExt Condition="'$(IsNativeExecutable)' == 'true' and '$(_targetOS)' == 'win'">.exe</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' == 'true' and '$(_targetOS)' != 'win'"></NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' == 'true' and '$(_targetArchitecture)' == 'wasm'">.wasm</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(_targetOS)' == 'win' and '$(NativeLib)' == 'Shared'">.dll</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(_IsApplePlatform)' == 'true' and '$(NativeLib)' == 'Shared'">.dylib</NativeBinaryExt>
<NativeBinaryExt Condition="'$(IsNativeExecutable)' != 'true' and '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(NativeLib)' == 'Shared'">.so</NativeBinaryExt>
Expand All @@ -86,6 +93,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<_LinkNativeOutputs>$(NativeBinary)</_LinkNativeOutputs>
<_LinkNativeOutputs Condition="'$(_targetOS)' == 'win' and '$(NativeLib)' == 'Shared' and '$(NativeImportLibrary)' != ''">$(NativeBinary);$(NativeImportLibrary)</_LinkNativeOutputs>
<NativeExecutableExt Condition="'$(NativeExecutableExt)' == '' and '$(_targetOS)' == 'win'">.exe</NativeExecutableExt>
<NativeExecutableExt Condition="'$(NativeExecutableExt)' == '' and '$(_targetArchitecture)' == 'wasm'">.wasm</NativeExecutableExt>
<NativeExecutableExt Condition="'$(NativeExecutableExt)' == ''"></NativeExecutableExt>
<IlcExportUnmanagedEntrypoints Condition="'$(IlcExportUnmanagedEntrypoints)' == '' and '$(NativeLib)' == 'Shared'">true</IlcExportUnmanagedEntrypoints>
<ExportsFile Condition="$(ExportsFile) == '' and '$(BuildingFrameworkLibrary)' != 'true'">$(NativeIntermediateOutputPath)$(TargetName)$(ExportsFileExt)</ExportsFile>
Expand Down Expand Up @@ -279,7 +287,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<IlcArg Condition="'$(CustomNativeMain)' == 'true'" Include="--splitinit" />
<IlcArg Condition="'$(ExportsFile)' != ''" Include="--exportsfile:$(ExportsFile)" />
<IlcArg Condition="'$(_targetOS)' == 'win' and '$(DebuggerSupport)' != 'false'" Include="--export-dynamic-symbol:DotNetRuntimeContractDescriptor,DATA" />
<IlcArg Condition="'$(_targetOS)' != 'win' and '$(_targetOS)' != 'browser' and '$(DebuggerSupport)' != 'false'" Include="--export-dynamic-symbol:DotNetRuntimeContractDescriptor" />
<IlcArg Condition="'$(_targetOS)' != 'win' and '$(_targetArchitecture)' != 'wasm' and '$(DebuggerSupport)' != 'false'" Include="--export-dynamic-symbol:DotNetRuntimeContractDescriptor" />
<IlcArg Condition="'$(_targetOS)' == 'freebsd' and '$(IsNativeExecutable)' == 'true'" Include="--export-dynamic-symbol:__progname;--export-dynamic-symbol:environ" />
<IlcArg Condition="'$(IlcExportUnmanagedEntrypoints)' == 'true'" Include="--export-unmanaged-entrypoints" />
<IlcArg Include="@(AutoInitializedAssemblies->'--initassembly:%(Identity)')" />
Expand Down Expand Up @@ -363,7 +371,8 @@ The .NET Foundation licenses this file to you under the MIT license.
</Target>

<Import Project="$(MSBuildThisFileDirectory)Microsoft.NETCore.Native.Windows.targets" Condition="'$(_targetOS)' == 'win'" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NETCore.Native.Unix.targets" Condition="'$(_targetOS)' != 'win'" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NETCore.Native.Unix.targets" Condition="'$(_targetOS)' != 'win' and '$(_targetArchitecture)' != 'wasm'" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NETCore.Native.Wasm.targets" Condition="'$(_targetArchitecture)' == 'wasm'" />

<Target Name="MultiFileCopyNative"
Inputs="@(NativeObjects)"
Expand All @@ -387,13 +396,13 @@ The .NET Foundation licenses this file to you under the MIT license.
<CustomLinkerArg Include="/LIBPATH:&quot;%(AdditionalNativeLibraryDirectories.Identity)&quot;" Condition="'$(_targetOS)' == 'win' and '@(AdditionalNativeLibraryDirectories->Count())' &gt; 0" />
<CustomLinkerArg Include="-exported_symbols_list &quot;$(ExportsFile)&quot;" Condition="'$(_IsApplePlatform)' == 'true' and '$(ExportsFile)' != ''" />
<CustomLinkerArg Include="-exported_symbols_list /dev/null" Condition="'$(OutputType)' == 'exe' and '$(_IsApplePlatform)' == 'true' and '$(ExportsFile)' == ''" />
<CustomLinkerArg Include="-Wl,--version-script=&quot;$(ExportsFile)&quot;" Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(ExportsFile)' != ''" />
<CustomLinkerArg Include="-Wl,--export-dynamic" Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(ExportsFile)' != ''" />
<CustomLinkerArg Include="-Wl,-u,DotNetRuntimeContractDescriptor" Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(_targetOS)' != 'browser' and '$(DebuggerSupport)' != 'false'" />
<CustomLinkerArg Include="-Wl,--version-script=&quot;$(ExportsFile)&quot;" Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(_targetArchitecture)' != 'wasm' and '$(ExportsFile)' != ''" />
<CustomLinkerArg Include="-Wl,--export-dynamic" Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(_targetArchitecture)' != 'wasm' and '$(ExportsFile)' != ''" />
<CustomLinkerArg Include="-Wl,-u,DotNetRuntimeContractDescriptor" Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(_targetArchitecture)' != 'wasm' and '$(DebuggerSupport)' != 'false'" />
<CustomLinkerArg Include="-Wl,-dead_strip" Condition="'$(_IsApplePlatform)' == 'true'" />
<CustomLinkerArg Include="@(LinkerArg)" />
</ItemGroup>
<ItemGroup Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true'">
<ItemGroup Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(_targetArchitecture)' != 'wasm'">
<CustomLinkerArg Include="-Wl,--discard-all" />
<CustomLinkerArg Include="-Wl,--gc-sections" Condition="'$(LinkerFlavor)' == '' or '$(LinkerFlavor)' == 'bfd' or '$(LinkerFlavor)' == 'lld'" />
<CustomLinkerArg Include="-Wl,-T,&quot;$(NativeIntermediateOutputPath)sections.ld&quot;" Condition="'$(LinkerFlavor)' == 'lld' and '$(_LinkerVersion)' &gt; '12'" />
Expand All @@ -413,7 +422,7 @@ The .NET Foundation licenses this file to you under the MIT license.
</PropertyGroup>

<!-- write linker script for lld (13+) to retain the __modules section -->
<WriteLinesToFile File="$(NativeIntermediateOutputPath)sections.ld" Lines="OVERWRITE_SECTIONS { __modules : { KEEP(*(__modules)) } }" Overwrite="true" Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(LinkerFlavor)' == 'lld' and '$(_LinkerVersion)' &gt; '12'" />
<WriteLinesToFile File="$(NativeIntermediateOutputPath)sections.ld" Lines="OVERWRITE_SECTIONS { __modules : { KEEP(*(__modules)) } }" Overwrite="true" Condition="'$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(_targetArchitecture)' != 'wasm' and '$(LinkerFlavor)' == 'lld' and '$(_LinkerVersion)' &gt; '12'" />

<Exec Command="&quot;$(CppLinker)&quot; @(CustomLinkerArg, ' ')"
Condition="'$(_targetOS)' != 'win' and '$(NativeLib)' != 'Static'"
Expand All @@ -432,11 +441,11 @@ The .NET Foundation licenses this file to you under the MIT license.
<Exec Command="chmod 644 &quot;$(NativeBinary)&quot;" Condition="'$(NativeLib)' == 'Shared' and !$([MSBuild]::IsOSPlatform('Windows'))" />

<!-- strip symbols, see https://github.com/dotnet/runtime/blob/5d3288d/eng/native/functions.cmake#L374 -->
<Exec Condition="'$(StripSymbols)' == 'true' and '$(NativeDebugSymbols)' == 'true' and '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true'"
<Exec Condition="'$(StripSymbols)' == 'true' and '$(NativeDebugSymbols)' == 'true' and '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(_targetArchitecture)' != 'wasm'"
Command="&quot;$(ObjCopyName)&quot; --only-keep-debug &quot;$(NativeBinary)&quot; &quot;$(NativeBinary)$(NativeSymbolExt)&quot;" />
<Exec Condition="'$(StripSymbols)' == 'true' and '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true'"
<Exec Condition="'$(StripSymbols)' == 'true' and '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(_targetArchitecture)' != 'wasm'"
Command="&quot;$(ObjCopyName)&quot; --strip-debug --strip-unneeded &quot;$(NativeBinary)&quot;" />
<Exec Condition="'$(StripSymbols)' == 'true' and '$(NativeDebugSymbols)' == 'true' and '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true'"
<Exec Condition="'$(StripSymbols)' == 'true' and '$(NativeDebugSymbols)' == 'true' and '$(_targetOS)' != 'win' and '$(_IsApplePlatform)' != 'true' and '$(_targetArchitecture)' != 'wasm'"
Command="&quot;$(ObjCopyName)&quot; --add-gnu-debuglink=&quot;$(NativeBinary)$(NativeSymbolExt)&quot; &quot;$(NativeBinary)&quot;" />

<Exec Condition="'$(StripSymbols)' == 'true' and '$(_IsApplePlatform)' == 'true' and '$(NativeLib)' != 'Static'"
Expand Down
Loading