-
Notifications
You must be signed in to change notification settings - Fork 53
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
[Java.Interop-PerformanceTests] Support .NET Core 3.1 #808
Conversation
23be554
to
c8bed5e
Compare
After lots of hair pulling, the repro for the Mac - .NET Core failure requires two steps;
Also note that What appears to be happening is that A previous version used
Fixing this warning doesn't fix the build failure. |
The problem is the |
1ce027f
to
6b69342
Compare
While using Additionally, the Windows |
…or all native compilation on Windows is possibly "out", as
|
25ae7d8
to
98e79ff
Compare
getting
Which is…something. Trying a Horrible Hack in which I explicitly set variables:
VSInstallDir: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
Cl64Path: $(VSInstallDir)\VC\Tools\MSVC\14.28.29334\bin\Hostx64\x64
jobs:
- job: windows_build
…
steps:
- script: >
echo "##vso[task.setvariable variable=PATH]%PATH%;$(Cl64Path)"
displayName: 'Add cl to PATH' which is guaranteed to break every time the VM is changed… |
Perhaps unsurprisingly, setting Surprisingly (to me), the build logs don't print out what |
Build `Java.Interop-PerformanceTests.csproj` for `netcoreapp3.1`, and run it using `dotnet test`. This in turn requires building the `tests/NativeTiming` native library for .NET Core, which in turn requires moving away from the Visual Studio for Mac (née Xamarin Studio) -based `.cproj` file. Replace `NativeTiming.cproj` with a `Microsoft.Build.NoTargets`- based `NativeTiming.csproj` file, so that it can be referenced and built by `msbuild` and `dotnet build`. Add a `cmake`+"Makefile"-based build system for `tests/NativeTiming`. Update `core-tests.yaml` so that `dotnet test` is used to run both the net472 and netcoreapp3.1 versions of `Java.Interop-PerformanceTests.dll.` Note (for posterity): if a `.*proj` file depends upon `$(Configuration)`, it *must also* be added to `Java.Interop.sln`. Failure to do so will mean that when building the project in *Release* configuration, the *new* project will instead be built in *Debug* configuration, resulting in all manner of head-scratching.
98e79ff
to
a14a39d
Compare
find all `**\cl.exe` files under the VS install dir?
[Last attempt][0] found a compiler! cmake -G "NMake Makefiles" -S . -B obj\\Release\ "-DJDK_INCLUDE_LIST=C:\Program Files\Java\jdk8u282-b08\include;C:\Program Files\Java\jdk8u282-b08\include\win32" "-DCMAKE_C_COMPILER=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x64\cl.exe" It still failed: Syntax error in cmake code at D:/a/1/s/tests/NativeTiming/obj/Release/CMakeFiles/3.19.4/CMakeCCompiler.cmake:1 when parsing string C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x64\cl.exe Invalid escape sequence \P `cmake` doesn't like DOS directory separators (`\`). Replace with Unix dir separators (`/`). [0]: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4505481&view=logs&j=f31c9f97-4411-58e7-49ac-fc73f645e6b6&t=cbeb8522-7b64-5cc0-7bee-eff0e164a409
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
…and now we hit: https://stackoverflow.com/questions/9356135/link-fatal-error-lnk-1104-cannot-open-file-libcmt-lib
Looks like I need to run Maybe if I try the "item group search" idea and run it inside the |
After following: https://docs.microsoft.com/en-us/azure/devops/pipelines/apps/windows/cpp?view=azure-devops The pipeline YAML is: # .NET Desktop # Build and run tests for .NET Desktop or Windows classic desktop solutions. # Add steps that publish symbols, save build artifacts, and more: # https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net trigger: - master pool: vmImage: 'windows-latest' variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' steps: - task: NuGetToolInstaller@1 - task: NuGetCommand@2 inputs: restoreSolution: '$(solution)' - task: VSBuild@1 inputs: solution: '$(solution)' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' - task: VSTest@2 inputs: platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' Meaning it looks like the *important* bit is to use `VSBuild@1`, not `MSBuild@1`, presumably because `VSBuild` ensures that the C++ toolchain actually works… Time to test that guess. Plus other cleanup, e.g. declare "private" properties, etc.
Is `cl` in path (6da1e49)? ***NO***. Furthermore, based on the sample docs: * https://docs.microsoft.com/en-us/azure/devops/pipelines/apps/windows/cpp?view=azure-devops * https://github.com/adventworks/cpp-sample/tree/master/cpp-sample The sample doesn't invoke `cl` directly. It uses a `.vcxproj`. Let's Try That? Update `cmake` to emit a `.vcxproj` file. Let's see where *that* leads.
Context: dotnet#808 (comment) Context: https://github.com/dotnet/runtime/blob/e1e46a8d2ca9c2c932c8ceb61f884c7c82351442/eng/native/init-compiler-and-cmake.cmd Context: https://github.com/dotnet/runtime/blob/e1e46a8d2ca9c2c932c8ceb61f884c7c82351442/src/mono/mono.proj#L362 We tried calling `vcvars64.bat` during an earlier invocation, which failed, but we were attempting to call it from YAML. Instead, take a page out of the dotnet/runtime build system: Instead of calling `vcvars64.bat` from YAML, instead call it *from within MSBuild*, via `call path\to\vcvars64.bat && …`. Thus, on Windows, we do: call "%VSINSTALLROOT%\VC\Auxiliary\Build\vcvarsall.bat x86_amd64 && ^ cmake -G "NMake Makefiles" -S . -B obj\Debug -DJDK_INCLUDE_LIST=…" … call "%VSINSTALLROOT%\VC\Auxiliary\Build\vcvarsall.bat x86_amd64 && ^ cd obj\Debug && ^ nmake VERSION=1 This *appears* to work from a "clean" shell. What about CI?
Commit 93872cf worked, in that Windows built! macOS, not so much, because `$VSINSTALLROOT` was set via YAML, so macOS was *also* trying to `call path\to\vcvarsall.bat`, which couldn't possibly work. Remove the `VSSInstallRoot` setting in YAML; it *appears* that `msbuild` will set this -- at least it does on *my* Windows box -- and return to using `MSBuild@1` and not `VSBuild@1`.
Current iteration has everything building except Windows + .NET Core. |
My guess is that on Windows - .NET Framework, What's funny is that the Windows .NET Core build does have some environment variables with
|
Commit 9b2d23b worked when using .NET Framework on Windows and on macOS, but failed when using Windows + .NET Core, because `dotnet build` *doesn't* define `%VSINSTALLROOT%` in that environment. Update the `windows_dotnet_build` job so that `VSInstallRoot` is defined. Update the `NativeTiming` build so that it verifies that `$(VSINSTALLROOT)` exists before trying to do anything with it.
Commit b66fc2f's attempt to only define `VSInstallRoot` for `windows_dotnet_build` didn't work, in that `%VSINSTALLROOT%` wasn't set, causing the build to fail. Return to declaring `VSInstallRoot` as a global variable. The `Exists('$(VSINSTALLROOT)')` guard from b66fc2f should prevent macOS builds from failing.
Squash-and-merge commit message body: Context: https://github.com/xamarin/java.interop/pull/808#issuecomment-786370513
Context: https://github.com/dotnet/runtime/blob/e1e46a8d2ca9c2c932c8ceb61f884c7c82351442/eng/native/init-compiler-and-cmake.cmd
Context: https://github.com/dotnet/runtime/blob/e1e46a8d2ca9c2c932c8ceb61f884c7c82351442/src/mono/mono.proj#L362
Build `Java.Interop-PerformanceTests.csproj` for `netstandard2.0`, and
run it using `dotnet test`.
This in turn requires building the `tests/NativeTiming` native library
for .NET Core, which in turn requires moving away from the
Visual Studio for Mac (née Xamarin Studio) -based `.cproj` file.
Replace `NativeTiming.cproj` with a `Microsoft.Build.NoTargets`-
based `NativeTiming.csproj` file, so that it can be referenced and
built by `msbuild` and `dotnet build`.
Update `core-tests.yaml` so that `dotnet test` is used to run both
the net472 and netcoreapp3.1 versions of
`Java.Interop-PerformanceTests.dll.`
Note (for posterity): if a `.*proj` file depends upon
`$(Configuration)`, it *must also* be added to `Java.Interop.sln`.
Failure to do so will mean that when building the project in
*Release* configuration, the *new* project will instead be built in
*Debug* configuration, resulting in all manner of head-scratching.
~~ cmake & Windows & C, Oh My! ~~
Add a `cmake`+"Makefile"-based build system for `tests/NativeTiming`.
Note that in order to build on Windows, `vcvarsall.bat` *must* be
executed *before* using any "native Visual Studio toolchain" commands
such as `cl.exe`. Additionally, for reasons not currently understood,
running `vcvarsall.bat` *from YAML* -- on the hope/assumption that
this would add`cl.exe`/etc. to `%PATH%` and usable everywhere --
*did not work*. (Note that `vcvarsall.bat` requires that you specify
which CPU architecture to support; we currently use `x86_amd64`.)
In order for the .NET Core-based build to *find* `vcvarsall.bat`, add
a new `VSInstallRoot` YAML variable. The .NET Framework-based builds
already have a `%VSINSTALLROOT%` environmemnt variable, as do the
**Developer Command Prompt for VS\*** commands.
Thus, on Windows, we do:
call "%VSINSTALLROOT%\VC\Auxiliary\Build\vcvarsall.bat x86_amd64 && ^
cmake -G "NMake Makefiles" -S . -B obj\Debug -DJDK_INCLUDE_LIST=…"
…
call "%VSINSTALLROOT%\VC\Auxiliary\Build\vcvarsall.bat x86_amd64 && ^
cd obj\Debug && ^
nmake VERSION=1 |
@@ -6,10 +6,10 @@ steps: | |||
displayName: Prepare Solution | |||
inputs: | |||
projects: Java.Interop.sln | |||
arguments: '-c $(Build.Configuration) -target:Prepare' | |||
arguments: '-c $(Build.Configuration) -target:Prepare /v:diag' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not to add diag
, as 99% of the time it just makes the logs harder to read. We can look at recording a binlog
and saving it as an artifact.
Build
Java.Interop-PerformanceTests.csproj
fornetcoreapp3.1
, andrun it using
dotnet test
.This in turn requires building the
tests/NativeTiming
native libraryfor .NET Core.
Add a
cmake
-based build system fortests/NativeTiming
.Update
core-tests.yaml
so thatdotnet test
is used to run boththe net472 and netcoreapp3.1 versions of
Java.Interop-PerformanceTests.dll.