runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Overriding the RID for build.sh

Open vellozzi opened this issue 9 years ago • 14 comments

I'm building the coreclr, corefx, and cli repos for Amazon Linux.

When I build the corefx repo I run into issues because the build scripts and tools don't handle the RID 'amzn.2015.09-x64' properly.

I originally tried to fix the build scripts in the corefx repo to override the RID, instead of deriving from /etc/os-release. But there are scripts and tools that get downloaded as part of the build that reference the /etc/os-release file too.

The temporary workaround I'm using is to change the /etc/os-release file to make the tools think they're running on 'rhel.7-x64', since Amazon Linux is closest to that distro. When I change /etc/os-release the build and tests work.

That's not a long term solution though, since it's not safe to change that file permanently. Do you have any suggestions on how to override the RID globally for the duration of the build?

vellozzi avatar Jul 21 '17 21:07 vellozzi

@weshaggard

danmoseley avatar Jul 22 '17 01:07 danmoseley

By default everything in coreclr/corefx repo assumes it is a portable linux build. Is there a reason you need to specify the amzn RID?

weshaggard avatar Jul 24 '17 16:07 weshaggard

We need to specify the 'rhel.7-x64' RID while building on Amazon Linux. The build scripts concatenate values from /etc/os-release and get 'amzn.2015.09-x64' as the RID. But 'amzn.2015.09-x64' isn't a supported RID so the build errors out.

Here's the error I get when I run build.sh in the corefx repo:

/home/ec2-user/git/corefx/Tools/dotnetcli/sdk/2.0.0-preview1-005977/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.targets(94,5): error : Assets file '/home/ec2-user/git/corefx/packages/microsoft.dotnet.buildtools/2.0.0-prerelease-01616-05/lib/tool-runtime/obj/project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0/amzn.2015.09-x64'. Ensure you have restored this project for TargetFramework='netcoreapp2.0' and RuntimeIdentifier='amzn.2015.09-x64'. [/home/ec2-user/git/corefx/packages/microsoft.dotnet.buildtools/2.0.0-prerelease-01616-05/lib/tool-runtime/project.csproj]

My workaround has been to hack the /etc/os-release file so that the build thinks the RuntimeIdentifier is rhel.7-x64. But I can't use that as a long term solution.

In case it matters, I'm building the release/2.0.0 branch.

vellozzi avatar Jul 24 '17 20:07 vellozzi

@vellozzi have you pulled the latest version of release/2.0.0 branch? In directly there was a BuildTools update that would eliminate that problem because the tool-runtime/project.csproj no longer depends on a RID.

weshaggard avatar Jul 24 '17 20:07 weshaggard

I pulled the latest and that specific error is gone. But there's a new one: /home/ec2-user/git/corefx/Tools/depProj.targets(83,5): error : Error no assets were resolved from NuGet packages. [/home/ec2-user/git/corefx/external/ilasm/ilasm.depproj]

This is also fixed by hacking the /etc/os-release file to make the build think it's rhel.7-x64

vellozzi avatar Jul 24 '17 20:07 vellozzi

That issue and a couple more similar were fixed with https://github.com/dotnet/corefx/pull/21032 but those changes are only in master. You can probably cherry-pick that change if you want to see if that helps get you past this current set of issues.

weshaggard avatar Jul 24 '17 20:07 weshaggard

That issue and a couple more similar were fixed with https://github.com/dotnet/corefx/pull/21032 but those changes are only in master. You can probably cherry-pick that change if you want to see if that helps get you past this current set of issues.

weshaggard avatar Jul 24 '17 20:07 weshaggard

Cherry picking that PR definitely works. But when I was reading through the PR I noticed another setting that solves our problem without the need for cherry picking the PR.

If I run ./build.sh -RuntimeOS=rhel.7 against the latest of release/2.0.0 branch it works.

Is the -RuntimeOS switch something we can rely on? (at least, until master and release/2.0.0 converge)

vellozzi avatar Jul 24 '17 23:07 vellozzi

Is the -RuntimeOS switch something we can rely on? (at least, until master and release/2.0.0 converge)

Yes RuntimeOS is the property we use to store the OS for we are running on and so if you want to mimic it you can set it explicitly like you are doing.

weshaggard avatar Jul 24 '17 23:07 weshaggard

I'm closing this issue now but don't hesitate to ask follow-up questions.

weshaggard avatar Jul 24 '17 23:07 weshaggard

So we use -RuntimeOS=rhel.7, and the build and tests complete successfully.
How can we gain confidence that our build will work correctly on Amazon Linux? How is that rhel.7 value being used in the build? Are there decision points in the build, or conditional compilation points in the source code that we'll need to handle in order to support Amazon Linux?

vellozzi avatar Jul 25 '17 21:07 vellozzi

I suspect you can also get this to work by setting RuntimeOS=linux. All it ends up doing is using that RID to pick native assets for the tools and for the runtime to run tests against.

The only way to test that it works correctly on Amazon Linux is to run the output there.

weshaggard avatar Jul 25 '17 22:07 weshaggard

Using RuntimeOS=Linux works, and feels a lot better than using rhel.7. Thanks. Thanks for the clarification on its use in building and testing.

Is there any conditional compilation in the C, C++, or C# code that's specific to any particular flavor of Linux? Or are the native and managed bits the same for any Linux flavor? (Is the answer the same for the coreclr?)

We're trying to understand how to find areas of the code that may need to be specialized for Amazon Linux without having to rely only on unit test failures.

vellozzi avatar Jul 26 '17 18:07 vellozzi

Is there any conditional compilation in the C, C++, or C# code that's specific to any particular flavor of Linux? Or are the native and managed bits the same for any Linux flavor?

We are trying very hard to make sure the bits are the same for any linux flavor.

(Is the answer the same for the coreclr?)

Yes the answer is the same for coreclr as well. Although I don't think they use the same property RuntimeOS, but they do build for linux by default.

We're trying to understand how to find areas of the code that may need to be specialized for Amazon Linux without having to rely only on unit test failures.

Hopefully nothing.

weshaggard avatar Jul 26 '17 18:07 weshaggard