4 ms·
The .NET SDK has some options to integrate NativeAOT with a larger application. You can reference libraries (static or dynamic) and object files during the buil
by MarkSweep 3y ago
The .NET SDK has some options to integrate NativeAOT with a larger application. You can reference libraries (static or dynamic) and object files during the build to link into the final executable. You can also configure NativeAOT to generate a static or dynamic library that you can link into another executable.
https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/interop https://learn.microsoft.com/en-us/dotnet/core/deploying/nati...
- jmillikin 3y agoNotice how that page describes how to configure the toolchain using XML. That's the thing I don't like -- instead of just building up an args list like cl.exe, I need to write my own intermediate tooling that synthesizes a .csproj and spits it out into the build sandbox before launching their magic do-everything binary. There's clearly something else underneath, the <LinkerArg> element is exactly what I would want to generate when running link.exe, but most of the configuration options are wrapped in a layer of gunk. Ideally it would be possible to invoke a command directly to convert a bunch of *.cs files into a .dll (or .a), then I could use existing logic to link it with link.exe (or ld).
- pjc50 3y agoFWIW, the relevant gunk: C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.DotNet.ILCompiler\build\Microsoft.NETCore.Native.targets And C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.DotNet.ILCompiler\build\Microsoft.NETCore.Native.Unix.targets (where the linker is selected) See the area around and after this chunk <CustomLinkerArg Include=""$(NativeObject)"" /> <CustomLinkerArg Include="-o "$(NativeBinary)"" Condition="'$(TargetOS)' != 'windows'" /> <CustomLinkerArg Include="/OUT:"$(NativeBinary)"" Condition="'$(TargetOS)' == 'windows'" /> <CustomLinkerArg Include="/DEF:"$(ExportsFile)"" Condition="'$(TargetOS)' == 'windows' and $(ExportsFile) != ''" /> <CustomLinkerArg Include="/LIBPATH:"%(AdditionalNativeLibraryDirectories.Identity)"" Condition="'$(TargetOS)' == 'windows' and '@(AdditionalNativeLibraryDirectories->Count())' > 0" /> <CustomLinkerArg Include="-exported_symbols_list "$(ExportsFile)"" Condition="'$(TargetOS)' == 'OSX' and $(ExportsFile) != ''" /> <CustomLinkerArg Include="-Wl,--version-script=$(ExportsFile)" Condition="'$(TargetOS)' != 'windows' and '$(TargetOS)' != 'OSX' and $(ExportsFile) != ''" /> <CustomLinkerArg Condition="Exists('$(_Win32ResFile)')" Include=""$(_Win32ResFile)"" /> <CustomLinkerArg Include="@(LinkerArg)" />
- pjmlp 3y agoThe old ways of command line arguments are no longer available, nowadays project files have to be used.