Skip to content

Source-build should support CBL Mariner #3654

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

Closed
Tracked by #3699
directhex opened this issue Oct 11, 2023 · 8 comments
Closed
Tracked by #3699

Source-build should support CBL Mariner #3654

directhex opened this issue Oct 11, 2023 · 8 comments
Assignees

Comments

@directhex
Copy link

The model used by CBL Mariner (the distro we use to build all official builds) is a minimal OS providing a compiler and tools, combined with a sysroot folder containing libraries and headers to compile/link against. This lets us use a consistent compiler, toolchain, etc, regardless of the target architecture or distribution, and easily use a compiler version which is newer than the old version bundled with the old distros we link against (for older glibc compatibility).

Right now, the VMR fails to build on mariner for two reasons:

  • There's no easy way to pass through the sysroot to the relevant repo builds which expect it (they're looking for a ROOTFS_DIR environment variable)
  • We need to make sure repos are coping with CBL Mariner eccentricities, particularly the lack of GNU ld linker (only LLVM lld is provided, and it must be opted in for every repo by passing -fuse-ld=lld to the linker flags)
    Right now, attempting to build with Mariner fails as follows:
$ docker run -e ROOTFS_DIR=/crossrootfs/x64 -w `pwd` --platform linux/amd64 -v `pwd`:`pwd` -it mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64 ./prep.sh
[..]
$ docker run -e ROOTFS_DIR=/crossrootfs/x64 -w `pwd` --platform linux/amd64 -v `pwd`:`pwd` -it mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64 ./build.sh --online -- /p:PortableBuild=true
[..]
      -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR) 
      CMake Error at /home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/src/native/libs/System.Security.Cryptography.Native/extra_libs.cmake:29 (message):
        !!! Cannot find libssl and System.Security.Cryptography.Native cannot build
        without it.  Try installing libssl-dev (on Linux, but this may vary by
        distro) or openssl (on macOS) !!!.  See the requirements document for your
        specific operating system:
        https://github.com/dotnet/runtime/tree/main/docs/workflow/requirements.
[..]
$ cat /home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/obj/coreclr/linux.x64.Release/CMakeFiles/CMakeError.log
[..]
clang-16: error: unable to execute command: Executable "ld" doesn't exist!
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
[..]

We also need to either check whether we need to be building the subsets we currently build, OR add the needed files to the sysroot folder, to ensure every expected lib/header is available (e.g. GSS.h isn't in our images)

@ghost ghost added area-build Improvements in source-build's own build process untriaged labels Oct 11, 2023
@MichaelSimons MichaelSimons moved this from Backlog to 9.0 in .NET Source Build Oct 12, 2023
@directhex
Copy link
Author

Forced the runtime build to go through (had to add __PortableBuild=1 to src/runtime/eng/native/build-commons.sh and EXTRA_LDFLAGS=-fuse-ld=lld to src/runtime/build.sh - figure out why those are not auto-detected or how to pass from source-build places instead). The good news is ROOTFS_DIR does seem to be taken from the system environment, so just building in a docker image w/ that env var defined for it will work. More or less.

@directhex
Copy link
Author

next problem repo is aspnetcore, which doesn't surprise me

@omajid
Copy link
Member

omajid commented Oct 13, 2023

Related issues include #745 and #238

@directhex
Copy link
Author

You're absolutely right, @omajid. Those are definitely related asks, and ought to be resolved in part or in whole as part of this effort.

@directhex
Copy link
Author

Heck, I can't reproduce runtime being buildable. The two changes noted above are insufficient.

@directhex
Copy link
Author

directhex commented Oct 16, 2023

OK, I got things going vs. this morning.

I had to modify ONE file, src/runtime/eng/native/build-commons.sh, to force portable build (I struggled to get that passed in via environment or repo-projects/runtime.proj

docker run -e CROSSCOMPILE=1 -e ROOTFS_DIR=/crossrootfs/x64 -w $(pwd) --platform linux/amd64 -v $(pwd):$(pwd) -it mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64 ./build.sh --online

Will switch to 8.0 branch and try to make progress with aspnet.

@directhex
Copy link
Author

aspnetcore passes on the release/8.0.1xx branch, with no further modification.

Installer fails.

@MichaelSimons MichaelSimons added area-unified-build and removed area-build Improvements in source-build's own build process labels Oct 19, 2023
@directhex
Copy link
Author

Made installer do something, and thus, the build finish building. Complete patch, with the above docker invocation, is:

diff --git a/src/runtime/eng/native/build-commons.sh b/src/runtime/eng/native/build-commons.sh
index d9eb04cd8a..3dcae0f254 100755
--- a/src/runtime/eng/native/build-commons.sh
+++ b/src/runtime/eng/native/build-commons.sh
@@ -514,6 +514,7 @@ while :; do
 
     shift
 done
+__PortableBuild=1
 
 if [[ -z "$__HostArch" ]]; then
     __HostArch=$__TargetArch
diff --git a/src/installer/src/redist/targets/GenerateLayout.targets b/src/installer/src/redist/targets/GenerateLayout.targets
index 899b46f78e..a93944767d 100644
--- a/src/installer/src/redist/targets/GenerateLayout.targets
+++ b/src/installer/src/redist/targets/GenerateLayout.targets
@@ -38,7 +38,7 @@
 
       <CoreSetupRid Condition="'$(CoreSetupRid)' == ''">$(HostRid)</CoreSetupRid>
       <CoreSetupRid Condition=" ('$(OSName)' == 'win' or '$(OSName)' == 'osx' or '$(OSName)' == 'freebsd') and '$(DotNetBuildFromSource)' != 'true' ">$(OSName)-$(Architecture)</CoreSetupRid>
-      <CoreSetupRid Condition="$(HostRid.StartsWith('mariner.2.0'))">$(HostRid.Replace('mariner.2.0', 'cm.2'))</CoreSetupRid>
+      <!-- wtf <CoreSetupRid Condition="$(HostRid.StartsWith('mariner.2.0'))">$(HostRid.Replace('mariner.2.0', 'cm.2'))</CoreSetupRid>-->
 
       <!-- only the runtime OSX .pkgs have a `-internal` suffix -->
       <InstallerStartSuffix Condition="$([MSBuild]::IsOSPlatform('OSX'))">-internal</InstallerStartSuffix>

Needs cleaning up, but for the most part, this was less invasive to make work than I feared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants