Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build with NativeAOT on Windows #21808

Open
rolfbjarne opened this issue Dec 13, 2024 · 3 comments
Open

Can't build with NativeAOT on Windows #21808

rolfbjarne opened this issue Dec 13, 2024 · 3 comments
Assignees
Labels
bug If an issue is a bug or a pull request a bug fix nativeaot
Milestone

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented Dec 13, 2024

Apple platform

iOS

Framework version

net9.0-*

Affected platform version

.NET 9

Description

Publishing a project on Windows with PublishAot=true yields:

d:\AzDO_work\8\s\xamarin-macios\packages\microsoft.dotnet.ilcompiler\9.0.0\build\Microsoft.NETCore.Native.Unix.targets(115): error: 'xcrun' not found in PATH. Make sure 'xcrun' is available in PATH.

Steps to Reproduce

dotnet new ios
dotnet build /p:_IsPublishing=true /p:PublishAot=true /p:RuntimeIdentifier=ios-arm64 /p:ServerAddress=... /p:ServerUser=... /p:ServerPassword=...

There's a test case in this PR: #21800

Build logs

The binlog contains secrets, so I can provide it upon request (or re-create one).

The target that fails:

Target Name=SetupOSSpecificProps Project=d:\AzDO\_work\8\s\xamarin-macios\tests\dotnet\MySimpleApp\iOS\MySimpleApp.csproj
    UseSystemZlib = true
    FullRuntimeName = libRuntime.WorkstationGC
    CrossCompileRid = 
    CrossCompileRid = ios-arm64
    CrossCompileArch = 
    CrossCompileArch = arm64
    CrossCompileAbi = gnu
    Task "Exec" skipped, due to false condition; ('$(CrossCompileArch)' != '' and '$(SysRoot)' != '') was evaluated as ('arm64' != '' and '' != '').
    TargetTriple = 
    TargetTriple = arm64-linux-gnu
    IlcRPath = @executable_path
    EventPipeName = libeventpipe-disabled
    LinkStandardCPlusPlusLibrary = true
    VxSortSupportName = libRuntime.VxsortEnabled
    StandaloneGCSupportName = libstandalonegc-disabled
    AppleMinOSVersion = 12.2
    _AppleSdkName = iphoneos
    _AppleTripleOS = ios
    _AppleTripleAbi = macho
    TargetTriple = arm64-apple-ios12.2-macho
    Task "Error" skipped, due to false condition; ('$(_IsiOSLikePlatform)' == 'true' and ('$(_AppleSdkName)' == '' or '$(CrossCompileArch)' == '' or '$(_AppleTripleOS)' == ''  or '$(AppleMinOSVersion)' == '' or '$(_AppleTripleAbi)' == '')) was evaluated as ('true' == 'true' and ('iphoneos' == '' or 'arm64' == '' or 'ios' == ''  or '12.2' == '' or 'macho' == '')).
    Xcrun = xcrun
    _WhereXcrun = 0
    Exec
        Assembly = D:\AzDO\_work\8\s\xamarin-macios\tests\dotnet\Windows\bin\dotnet\packs\Microsoft.iOS.Sdk.net9.0_18.1\18.1.9220-ci.pr.gh21800\tools\msbuild\Xamarin.MacDev.Tasks.dll
        Parameters
            Command = command -v "xcrun"
            IgnoreExitCode = True
            StandardOutputImportance = Low
        CommandLineArguments = command -v "xcrun"
        'command' is not recognized as an internal or external command,
        operable program or batch file.
        The command "command -v "xcrun"" exited with code 9009.
        OutputProperties
            _WhereXcrun = 9009
    Error
        Assembly = D:\AzDO\_work\8\s\xamarin-macios\tests\dotnet\Windows\bin\dotnet\sdk\9.0.102\Microsoft.Build.Tasks.Core.dll
        Parameters
            Text = 'xcrun' not found in PATH. Make sure 'xcrun' is available in PATH.
        Errors
            d:\AzDO\_work\8\s\xamarin-macios\packages\microsoft.dotnet.ilcompiler\9.0.0\build\Microsoft.NETCore.Native.Unix.targets(115,5): 'xcrun' not found in PATH. Make sure 'xcrun' is available in PATH. [d:\AzDO\_work\8\s\xamarin-macios\tests\dotnet\MySimpleApp\iOS\MySimpleApp.csproj]
@rolfbjarne rolfbjarne added bug If an issue is a bug or a pull request a bug fix nativeaot labels Dec 13, 2024
@rolfbjarne rolfbjarne added this to the .NET 10 milestone Dec 13, 2024
@rolfbjarne
Copy link
Member Author

This is where it fails, which obviously won't work on Windows:

https://github.com/dotnet/runtime/blob/7927a192be28c8562a54becdbe0a665837022eaa/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets#L116-L118

The logic seems to want to verify that xcrun is in PATH, and then goes on to use xcrun to compute SysRoot:

https://github.com/dotnet/runtime/blob/7927a192be28c8562a54becdbe0a665837022eaa/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets#L122-L124

which is then used to add -isysroot ... to LinkerArg:

https://github.com/dotnet/runtime/blob/7927a192be28c8562a54becdbe0a665837022eaa/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets#L232

which is never used again...

There seems to be few possible solutions here:

  • Figure out a way to tell the NativeAOT build logic to not bother computing LinkerArg, because it's not going to be used.
  • Support setting SysRoot before the SetupOSSpecificProps target, so that it won't be necessary to run xcrun to detect it (and then also not detect if xcrun is in PATH either).

CC @ivanpovazan is this something you can help with?

@ivanpovazan
Copy link
Contributor

ivanpovazan commented Dec 13, 2024

Yes, definitely! :)

Was this found internally or by a customer?

Sounds like we will have to service the fix.

@ivanpovazan ivanpovazan self-assigned this Dec 13, 2024
@rolfbjarne
Copy link
Member Author

Was this found internally or by a customer?

By a customer: #21795 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix nativeaot
Projects
None yet
Development

No branches or pull requests

2 participants