-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
- Document info originally from https://github.com/microsoft/go-lab/issues/60
To make it easier to read (and public 🙂), here are the most critical parts from my raw notes about how I got a program to depend on an old glibc and how to build systemcrypto cross-arch.
Overview of this approach: .NET Linux build methodology
https://github.com/dotnet/dotnet-buildtools-prereqs-docker builds the images that include a rootfs.
Usage guides:
https://github.com/dotnet/runtime/blob/main/docs/workflow/using-docker.md
https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/containers.md
I used meta-build code like this to drive a properly configured go build command:
cmd.Env = append(
os.Environ(),
"GOEXPERIMENT=systemcrypto",
"CGO_ENABLED=1",
"GOOS="+goOS,
"GOARCH="+goArch,
)
if *sysroot != "" {
var linuxArch string
switch goArch {
case "amd64":
linuxArch = "x86_64"
case "arm64":
linuxArch = "aarch64"
default:
return fmt.Errorf("unsupported architecture %q for sysroot", goArch)
}
ccPlatform := linuxArch + "-linux-gnu"
cmd.Env = append(
cmd.Env,
// Set up for the compiler we expect to see in azurelinux-3.0-cross-* images.
"CC="+joinSpace(
"clang",
"--target="+ccPlatform,
"--sysroot="+*sysroot,
),
"CGO_LDFLAGS="+joinSpace(
// Use lld: ld is not present.
"-fuse-ld=lld",
),
)
}
In the pipeline yml, I used these containers:
containers:
cross-amd64:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-amd64
cross-arm64:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-arm64On linux amd64: -sysroot /crossrootfs/x64
On linux arm64: -sysroot /crossrootfs/arm64
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation