-
Notifications
You must be signed in to change notification settings - Fork 389
Conversation
Linker flags set in src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets in SetupOSSpecificProps do not consider platform specifics, which are set in toolchain.cmake. At the same time, LocateNativeCompiler in ./eng/toolAot.targets does similar job to get linker, and now GetCrossToolchainInfoAot in ./eng/toolAot.targets does same to get linker flags based on toolchain.cmake. toolchain.cmake is already used this way in src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj
gbalykov
commented
Jun 24, 2026
am11
commented
Jun 24, 2026
Can you show the error and which runtime commit you were trying with (latest main in runtime should have all the changes which we have here)? This is exactly what we had before, so I'm not sure how is it broken.
Related PR: dotnet/dotnet#6802
That PR moved the code to a shared location without changing the logic except for include semantics. It's unclear what has it broken that we are fixing here.
gbalykov
commented
Jun 24, 2026
Can you show the error and which runtime commit you were trying with (latest main in runtime should have all the changes which we have here)? This is exactly what we had before, so I'm not sure how is it broken.
Sorry for confusion, this is not a newly introduced issue. dotnet/dotnet#6802 is related only in sense that it moves similar logic to eng/common/native/LocateNativeCompiler.targets, and changes should get here and not in runtime repo. Actually, this issue is present in release/10.0 branch of runtime too.
Error below happens during tizen cross build, because tizen rootfs requires additional linker flags, which are specified in toolchain.cmake.
Generating native code
ld.lld : error : /home/runtime/.tools/rootfs/x64/usr/lib/../lib64/libc.so:5: unable to find libc.so.6 [/home/runtime/src/coreclr/tools/aot/ILCompiler/ILCompiler_publish.csproj]
>>> GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-x86-64.so.2 ) )
>>> ^
am11
commented
Jun 24, 2026
Thanks for the clarification.
because tizen rootfs requires additional linker flags
The linker flags in LocateNativeCompiler is basically just to capture a high-level "which compiler and which linker to use" (name/path and version). The actual linker flags per-platform are coded in runtime/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets. All other platform's cross-build rootfs are mimicking the actual OS structure, so whether we are publishing an AOT app locally on the platform or cross-publishing via this rootfs (or any other "standard-looking" cross-build toolchain), it works. Is tizen rootfs following the structure of original operating system? If so, we can just encode them in Microsoft.NETCore.Native.Unix.targets like we have for FreeBSD, OpenBSD etc.
gbalykov
commented
Jun 24, 2026
Is tizen rootfs following the structure of original operating system?
Yes
If so, we can just encode them in Microsoft.NETCore.Native.Unix.targets like we have for FreeBSD, OpenBSD etc.
There would be some duplication in toolchain.cmake and src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets. Maybe GetCrossToolchainInfoAot can be called in case of native build too (currently it has cross build check), then FreeBSD, OpenBSD etc. won't need explicit -L flags in src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets.
Another problem I see with this is that _targetOS is just linux in src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets, not tizen.
am11
commented
Jun 24, 2026
We already have duplication in BuildIntegration, because we ship it in nuget package for PublishAot, that's why we were very careful about depending on anything outside the directory (except for LocateNativeCompiler for .NET CI/CD minimal overrides).
_targetOSis justlinuxin src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets, not tizen.
We can sub-classify Tizen like this https://github.com/dotnet/runtime/blob/5e3dadb4a2b39e6e32127ecd0038854a338773e7/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets#L63.
gbalykov
commented
Jun 24, 2026
Thanks for explanation, I'll update based on your suggestions
gbalykov
commented
Jun 25, 2026
Closing this in favor of dotnet/runtime#129844
Linker flags set in src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets in SetupOSSpecificProps do not consider platform specifics, which are set in toolchain.cmake. At the same time, LocateNativeCompiler in ./eng/toolAot.targets does similar job to get linker, and now GetCrossToolchainInfoAot in ./eng/toolAot.targets does same to get linker flags based on toolchain.cmake.
toolchain.cmake is already used this way in src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj
Related PR: dotnet/dotnet#6802