msquic icon indicating copy to clipboard operation
msquic copied to clipboard

crude support for cross-arm build

Open wfurt opened this issue 3 years ago • 5 comments

Description

This allows to cross-compile msquic using sysroot & clang. There are other ways how to do that. This is based on approach used by .NET runtime. It also uses same tools to improve chances of compatibility. (building with gcc or other compliers still should be fine) It also opens avenues for cross-compiling other targets -> like Alpine Linux

Besides bare minimum, I also changed behavior or --Arch to default to native machine Arch. It was really weird to run build.ps1 on arm machine and arm binaries in 'x64' directory.

Testing

For testing I used mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-cross-arm64-20220808192756-6e40d49 container. The build tools & packaging runs on x64 platform and the container provides tools and libraries to produce arm32/64 binaries.

pwsh scripts/build.ps1 --arch arm64 --SysRoot /crossrootfs/arm64
furt@cbcc49cd1a8f:~/github/wfurt-msquic$ uname -a
Linux cbcc49cd1a8f 4.15.0-189-generic #200-Ubuntu SMP Wed Jun 22 19:53:37 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
furt@cbcc49cd1a8f:~/github/wfurt-msquic$ file artifacts/bin/linux/arm64_Debug_openssl/msquictest
artifacts/bin/linux/arm64_Debug_openssl/msquictest: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=27081dbfaa8b3164c78e0877d3a3a83e9e506054, with debug_info, not stripped



./scripts/make-packages.sh -arch arm64 -config Debug
Created package {:path=>"artifacts/packages/linux/arm64_Debug_openssl/libmsquic-debug-2.2.0-1.aarch64.rpm"}
Created package {:path=>"artifacts/packages/linux/arm64_Debug_openssl/libmsquic-debug_2.2.0_arm64.deb"}
``
## Documentation

We may update BUILD notes with instructions. (mat be good when we have full circle verification) 

wfurt avatar Aug 10 '22 06:08 wfurt

Is there a way for us to onboard a build to our CI for this?

nibanks avatar Aug 10 '22 11:08 nibanks

This is breaking in our CI:

/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/home/vsts/work/_temp/c112971c-a10b-46bc-867b-42daf5a408b5.ps1'
[08/10/2022 06:12:28] Generating files...
CMake-Generate: /home/vsts/work/1/s/scripts/build.ps1:528
Line |
 528 |  CMake-Generate
     |  ~~~~~~~~~~~~~~
     | SysRoot must be set for cross-compilation.

nibanks avatar Aug 10 '22 12:08 nibanks

Our azure pipeline isn't onboarded with MCR. I am not sure if we are able to pull this docker. Onebranch pipeline might be able to use it though. mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-cross-arm64-20220808192756-6e40d49

csujedihy avatar Aug 10 '22 17:08 csujedihy

I'll take a look @nibanks. I can make the check optional. What I wanted to avid is case when you say --Arch XYZ and it does nothing.

wfurt avatar Aug 10 '22 18:08 wfurt

All the builds are clean @nibanks and @csujedihy. reasons learned:

  • IsLinux is true for Android as well but we need to treat it as separate platform. We may be bale to unify cross build support more but for now I left is special case as it was before.
  • CMAKE_OSX_ARCHITECTURES has special meaning for cmake beyond what is visible in the file. Attempt to make it platform neutral and use same name for Linux as well failed

As it is now, it would allow up to build ARM binaries in dotnet/msquic and run functional .NET tests on platforms where we do it in containers. We can look into reconciling this with work @csujedihy did. I can also look into spinning containers or installing pre-reqs in msquic as separate change.

wfurt avatar Aug 10 '22 20:08 wfurt