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

IKVMReference on Linux #95

Closed
dylanlangston opened this issue Jul 6, 2022 · 8 comments · Fixed by #96
Closed

IKVMReference on Linux #95

dylanlangston opened this issue Jul 6, 2022 · 8 comments · Fixed by #96

Comments

@dylanlangston
Copy link

Hello, I'm using the IKVM 8.2.0 nuget and seeing an issue when trying to build a project that uses the IKVMReference tag on Linux. I've been able to reproduce on the following hosts:

Debian 11

dylan@debian11:~$ uname -a
Linux debian11 5.10.0-10-amd64 #1 SMP Debian 5.10.84-1 (2021-12-08) x86_64 GNU/Linux
dylan@debian11:~$ dotnet --version
6.0.101

Amazon Linux 2

[ec2-user@amzn2-dylan ~]$ uname -a
Linux amzn2-dylan 4.14.281-212.502.amzn2.x86_64 #1 SMP Thu May 26 09:52:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[ec2-user@amzn2-dylan ~]$ dotnet --version
6.0.301

When I go to build I'm seeing this:

dylan@debian11:~/Downloads/IKVM-TikadotNet-Harness/Tikadot6$ dotnet build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj (in 433 ms).
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018: The "IkvmCompiler" task failed unexpectedly. [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018: IKVM.Tool.IkvmToolException: Could not set user executable bit on '/home/dylan/.nuget/packages/ikvm/8.2.0/bin/ikvmc/netcoreapp3.1/linux-x64/ikvmc'. [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:  ---> System.DllNotFoundException: Unable to load shared library 'Mono.Unix' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libMono.Unix: cannot open shared object file: No such file or directory [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Mono.Unix.Native.Syscall.lstat(String file_name, Stat& buf) [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Mono.Unix.UnixFileSystemInfo.TryGetFileSystemEntry(String path, UnixFileSystemInfo& entry) [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Mono.Unix.UnixFileSystemInfo.GetFileSystemEntry(String path) [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at IKVM.Tool.Compiler.IkvmCompilerLauncher.ExecuteAsync(IkvmCompilerOptions options, CancellationToken cancellationToken) in D:\a\ikvm\ikvm\src\IKVM.Tool\Compiler\IkvmCompilerLauncher.cs:line 394 [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    --- End of inner exception stack trace --- [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at IKVM.Tool.Compiler.IkvmCompilerLauncher.ExecuteAsync(IkvmCompilerOptions options, CancellationToken cancellationToken) in D:\a\ikvm\ikvm\src\IKVM.Tool\Compiler\IkvmCompilerLauncher.cs:line 409 [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at IKVM.MSBuild.Tasks.IkvmCompiler.Execute() in D:\a\ikvm\ikvm\src\IKVM.MSBuild.Tasks\IkvmCompiler.cs:line 297 [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]

Build succeeded.

/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018: The "IkvmCompiler" task failed unexpectedly. [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018: IKVM.Tool.IkvmToolException: Could not set user executable bit on '/home/dylan/.nuget/packages/ikvm/8.2.0/bin/ikvmc/netcoreapp3.1/linux-x64/ikvmc'. [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:  ---> System.DllNotFoundException: Unable to load shared library 'Mono.Unix' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libMono.Unix: cannot open shared object file: No such file or directory [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Mono.Unix.Native.Syscall.lstat(String file_name, Stat& buf) [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Mono.Unix.UnixFileSystemInfo.TryGetFileSystemEntry(String path, UnixFileSystemInfo& entry) [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Mono.Unix.UnixFileSystemInfo.GetFileSystemEntry(String path) [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at IKVM.Tool.Compiler.IkvmCompilerLauncher.ExecuteAsync(IkvmCompilerOptions options, CancellationToken cancellationToken) in D:\a\ikvm\ikvm\src\IKVM.Tool\Compiler\IkvmCompilerLauncher.cs:line 394 [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    --- End of inner exception stack trace --- [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at IKVM.Tool.Compiler.IkvmCompilerLauncher.ExecuteAsync(IkvmCompilerOptions options, CancellationToken cancellationToken) in D:\a\ikvm\ikvm\src\IKVM.Tool\Compiler\IkvmCompilerLauncher.cs:line 409 [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at IKVM.MSBuild.Tasks.IkvmCompiler.Execute() in D:\a\ikvm\ikvm\src\IKVM.MSBuild.Tasks\IkvmCompiler.cs:line 297 [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
/home/dylan/.nuget/packages/ikvm/8.2.0/buildTransitive/netstandard2.0/IKVM.targets(100,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/home/dylan/Downloads/IKVM-TikadotNet-Harness/Tikadot6/Tikadot6.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.71
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: Request 5 expected to be in state Executing but state is actually Yielding
   at Microsoft.Build.Shared.ErrorUtilities.ThrowInternalError(String message, Object[] args)
   at Microsoft.Build.Shared.ErrorUtilities.VerifyThrow(Boolean condition, String unformattedMessage, Object arg0, Object arg1, Object arg2)
   at Microsoft.Build.BackEnd.SchedulableRequest.VerifyState(SchedulableRequestState requiredState)
   at Microsoft.Build.BackEnd.SchedulingData.ExpectScheduledRequestState(Int32 globalRequestId, SchedulableRequestState state)
   at Microsoft.Build.BackEnd.Scheduler.ReportResult(Int32 nodeId, BuildResult result)
   at Microsoft.Build.Execution.BuildManager.HandleResult(Int32 node, BuildResult result)
   at Microsoft.Build.Execution.BuildManager.ProcessPacket(Int32 node, INodePacket packet)
   at Microsoft.Build.Execution.BuildManager.<>c__DisplayClass76_0.<Microsoft.Build.BackEnd.INodePacketHandler.PacketReceived>b__0()
   at Microsoft.Build.Execution.BuildManager.ProcessWorkQueue(Action action)
--- End of stack trace from previous location ---
   at Microsoft.Build.Execution.BuildManager.EndBuild()
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, Boolean isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, String[] inputResultsCaches, String outputResultsCache)

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: Request 5 expected to be in state Executing but state is actually Yielding
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, Boolean isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, String[] inputResultsCaches, String outputResultsCache)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
Unhandled exception: Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: Request 5 expected to be in state Executing but state is actually Yielding
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, Boolean isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, String[] inputResultsCaches, String outputResultsCache)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
   at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
   at Microsoft.DotNet.Cli.Utils.MSBuildForwardingAppWithoutLogging.ExecuteInProc(String[] arguments)

It looks to be failing on line 403 of the IkvmCompilerLauncher when trying to load Mono.Unix. I've verified Mono is installed in both the environments I tested with however. Anyone else attempted building on a Linux host yet and had any success?

@NightOwl888
Copy link
Contributor

I don't believe the ikvmc compiler inside the NuGet package was intended for any other purpose than from <IkvmReference>. @wasabii - correct me if this is wrong.

The bin directory is missing the following DLLs that ikvmc depends on:

  • IKVM.Java.dll
  • IKVM.Runtime.dll
  • IKVM.Runtime.JNI.dll

The quick workaround for a build script would be to copy these 3 DLLs from the corresponding location in the lib directory for the target framework into the ikvmc directory you intend to use.

Alternatively, a stable place to download ikvmc from for build scripts is on the release page.

@wasabii - I realize this is most likely about preventing duplicates of IKVM.Java in the NuGet package to avoid bloating the package size. Could we use the AssemblyResolve event to make ikvmc probe for the missing dependencies in the lib folder so we don't have to have multiple copies of these DLLs in the package?

@wasabii
Copy link
Contributor

wasabii commented Jul 6, 2022

Looks like a native library isn't being loaded by the tool on Linux. Will check. Might have been left in the wrong place.

@wasabii
Copy link
Contributor

wasabii commented Jul 6, 2022

Nope. It's there. The story is that MSBuild tasks don't load the dep context properly, so still cannot resolve native libraries unassisted.

dotnet/msbuild#5037

Will have to load it by hand under the right circumstances it seems. Will have a patch shortly to test.

@wasabii
Copy link
Contributor

wasabii commented Jul 6, 2022

Oh. If anybody can figure out how else to make an executable in a NuGet package +x on extraction, let me know.

@dylanlangston
Copy link
Author

@wasabii Would running chmod +x work - something like this?

@wasabii
Copy link
Contributor

wasabii commented Jul 6, 2022

That's still a hack: that you have to write code to modify the extracted package at runtime is what I'm trying to avoid. The native library is no big deal.

@wasabii
Copy link
Contributor

wasabii commented Jul 6, 2022

If .nupkg's were tar files, for example, they would support simply marking the +x bit within the tar. But they're ZIP files. Which have no such standard mechanism.

@wasabii
Copy link
Contributor

wasabii commented Jul 6, 2022

Oh, @dylanlangston. You said this:

I've verified Mono is installed in both the environments I tested with however.

Mono isn't required. The issue is simply that it isn't loading a .so file in the NuGet package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants