Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Adding basic support for an ilproj sdk #19066

Merged
merged 1 commit into from
Jul 26, 2018
Merged

Adding basic support for an ilproj sdk #19066

merged 1 commit into from
Jul 26, 2018

Conversation

tannergooding
Copy link
Member

This is a port of dotnet/arcade#317, which we determined should be in CoreCLR next to the ILAsm package, so that it can easily be used/consumed from source-build (and related efforts).

FYI. @tmat, @jaredpar, @rainersigwald, @eerhardt, @weshaggard, @alexperovich, @MichalStrehovsky (all the people who reviewed/commented on the previous PR).

<_OSArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</_OSArchitecture>

<MicrosoftNetCoreIlasmPackageRuntimeId Condition="'$(MicrosoftNetCoreIlasmPackageRuntimeId)' == ''">$(_OSPlatform)-$(_OSArchitecture.ToLower())</MicrosoftNetCoreIlasmPackageRuntimeId>
<MicrosoftNetCoreIlasmPackageVersion Condition="'$(MicrosoftNetCoreIlasmPackageVersion)' == ''">2.0.8</MicrosoftNetCoreIlasmPackageVersion>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long term, we should either come up with a mechanism to update this to have the current build version, or we should package ILAsm in this SDK.

I am leaning towards the latter, but that requires https://github.com/dotnet/coreclr/issues/15059 to be resolved first.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the mean-time you should just use the version in the repo

<PackageVersion Condition="'$(PackageVersion)' == ''">3.0.0</PackageVersion>
. I realize this has to be hard-coded but we can do some sort of find/replace to set it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

</ItemGroup>

<PropertyGroup>
<_IlasmDir>$(ToolsDir)\ilasm</_IlasmDir>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some cleanup to be done here, but doing a "clean import" followed by separate "refactoring/cleanup" was unanimously favored

@@ -23,6 +23,7 @@
<ItemGroup>
<Project Include="Microsoft.NETCore.ILAsm\Microsoft.NETCore.ILAsm.builds" />
<Project Include="Microsoft.NETCore.ILDAsm\Microsoft.NETCore.ILDAsm.builds" />
<Project Include="Microsoft.NET.Sdk.IL\Microsoft.NET.Sdk.IL.pkgproj" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything special required to ensure the nupkg is published?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No but you should scope this to only happen on one OS leg similar logic to when we build the identity package

<BuildIdentityPackage Condition="'$(BuildingAnOfficialBuildLeg)' == 'true' AND ('$(OS)' != 'Windows_NT' OR '$(BuildArch)' != 'x64')">false</BuildIdentityPackage>
. If you don't scope it then the official build will fail because it will build and try to publish it from all the legs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Condition="'$(BuildIdentityPackage)' == 'true'"

@AaronRobinsonMSFT
Copy link
Member

Are these files supposed to be under src/.nuget/?

<MicrosoftNetCoreIlasmPackageName>runtime.$(MicrosoftNetCoreIlasmPackageRuntimeId).microsoft.netcore.ilasm</MicrosoftNetCoreIlasmPackageName>
<MicrosoftNetCoreRuntimeCoreClrPackageName>runtime.$(MicrosoftNetCoreIlasmPackageRuntimeId).microsoft.netcore.runtime.coreclr</MicrosoftNetCoreRuntimeCoreClrPackageName>

<ToolsDir Condition="'$(ToolsDir)' == ''">$([System.IO.Path]::Combine($([System.IO.Path]::GetTempPath()), $([System.IO.Path]::GetRandomFileName())))</ToolsDir>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know other places use this ToolsDir property so I'd suggest you define some private property to use here. It is fine to use ToolsDir if it is set but I think setting it might cause some conflicts.

@weshaggard
Copy link
Member

Are these files supposed to be under src/.nuget/?

No they should be under a subdir.

@weshaggard
Copy link
Member

FYI @RussKeldorph

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<MSBuildAllProjects>$(MSBuildThisFileFullPath);$(MSBuildAllProjects)</MSBuildAllProjects>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file doesn't seem necessary. Can we remove it until we have stuff to put in it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment didn't appear to be addressed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, missed this. Will remove for the time being.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

<_OSPlatform Condition="$([MSBuild]::IsOSPlatform('osx'))">osx</_OSPlatform>
<_OSArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</_OSArchitecture>

<MicrosoftNetCoreIlasmPackageRuntimeId Condition="'$(MicrosoftNetCoreIlasmPackageRuntimeId)' == ''">$(_OSPlatform)-$(_OSArchitecture.ToLower())</MicrosoftNetCoreIlasmPackageRuntimeId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about linux-musl? We support that RID as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an existing API to get linux-musl as the OSPlatform?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the current runtime.json for ilasm, the same question applies to rhel.6 and tizen.4.0.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe IsOSPlatform('linux') == true is still correct here. We are still on linux, we just happen to be using a different libc. (And thus, requiring different native assets)

Copy link
Member

@eerhardt eerhardt Jul 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears in corefx, the RID is normally passed in from the outside of the build:

https://github.com/dotnet/corefx/search?q=linux-musl&unscoped_q=linux-musl

The only place it is actually detected is:

https://github.com/dotnet/corefx/blob/a53adfc55bcb028d36a8647e45c66f7be5374f92/init-tools.sh#L97

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I suspect it is not going to be sufficient. I suspect as soon as you try to move to using this package in corefx we won't even get past CI because the linux-musl leg will fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we won't even get past CI because the linux-musl leg will fail.

For this, (on alpine, tizen, rhel6) I was indicating that we would continue passing it in from outside the build, as we are today.

An alternative would be to have the .targets file duplicate this logic: https://github.com/dotnet/corefx/blob/a53adfc55bcb028d36a8647e45c66f7be5374f92/init-tools.sh#L94

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I missed that connection. In that case I think we can live with it for now so long as we can actually consume it I think we should be good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested locally and everything is working correctly when explicitly passing in the RID.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tools use ldd --version to figure out the libc flavor. Based on that, there could be an MSBuild target to detect glibc vs. musl-libc, for example:

Inspired by https://github.com/justjake/encabulator/blob/34b587b/unison/linux_env.go

<?xml version="1.0" encoding="utf-8"?>
<Project>
  <Target Name="DetectLibcFlavor" Condition="!$([MSBuild]::IsOSPlatform('windows'))">
    <Exec Command="ldd --version" ConsoleToMSBuild="true" ContinueOnError="true" StandardOutputImportance="low" StandardErrorImportance="low">
      <Output TaskParameter="ConsoleOutput" PropertyName="LddOutput" />
    </Exec>

    <Message Importance="high" Text="using glibc"
      Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch($(LddOutput), `glibc|GNU libc|EGLIBC`)) " />
    <Message Importance="high" Text="using musl-libc"
      Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch(`$(LddOutput)`, `musl`)) " />
  </Target>
</Project>

Tested with dotnet msbuild DetectLibcFlavor.proj.

Sample ldd --version output on Alpine:

musl libc (x86_64)
Version 1.1.18
Dynamic Program Loader
Usage: ldd [options] [--] pathname

and on Ubuntu:

ldd (Ubuntu EGLIBC 2.15-0ubuntu10.7) 2.15
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

(would be super helpful if MSBuild provides information about libc via some intrincis method next to [MSBuild]::IsOSPlatform and friends, which we have today)

@tannergooding
Copy link
Member Author

I believe all feedback, given so far, has now been addressed.

There is some follow up work for some general cleanup

  • This is going into a second PR so that the first is a "clean" port of the existing code

There is some follow up work after https://github.com/dotnet/coreclr/issues/15059 is resolved to remove the secondary nuget reference and corresponding copy logic.

There is some follow up work after https://github.com/dotnet/corefx/issues/31002 is resolved to remove the RID construction logic.

Does anyone have anything further needed here, or am I good to merge?

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with moving forward with this.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<MSBuildAllProjects>$(MSBuildThisFileFullPath);$(MSBuildAllProjects)</MSBuildAllProjects>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment didn't appear to be addressed.

@tannergooding
Copy link
Member Author

Looks like the build failures are occurring across multiple PRs.

@weshaggard
Copy link
Member

@chsienki those issues look related to your testing changes are you looking into them?

@chsienki
Copy link

I have a PR here #19130

Trying to figure out why the OSX corefx tests are failing still, and if its related

@tannergooding
Copy link
Member Author

Rebased now that #19130 has been merged.

@tannergooding
Copy link
Member Author

@weshaggard, are the perf lab tests doing something different that prevents them from recognizing MSBuild ItemMetadata exposed as XML attributes (rather than nested tags)?

@chsienki
Copy link

I think the perf lab runs are done on VS2015, so presumably an earlier version of MSBuild. For instance I had to add the xmlns= to the project element in the target files, or those runs wouldn't see them as valid MSBuild files.

@tannergooding
Copy link
Member Author

OSX has timed-out 3 times now. It has built successfully locally (on my MacBook Pro), so I am merging.

@tannergooding tannergooding merged commit 3077c95 into dotnet:master Jul 26, 2018
@weshaggard
Copy link
Member

@tannergooding do you know how you plan to consume this package in coreclr and corefx yet?

@tannergooding
Copy link
Member Author

@weshaggard, as soon as a package gets published (will check in the morning) I will add the PR to CoreFX for its consumption (I've already tested most of it locally).

@tannergooding
Copy link
Member Author

CoreFX side is here: dotnet/corefx#31512

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

Successfully merging this pull request may close these issues.

6 participants