How Do I Cross-Compile Go Binaries For S390x?

2025-09-03 10:17:32 99

3 Answers

Kieran
Kieran
2025-09-06 00:05:59
Quick tips I keep pinned: pure-Go cross-compiles are frictionless — GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build — and you can inspect the result with file to verify architecture. If you get an ELF header or illegal instruction at runtime, double-check GOARCH, re-run file, and ensure you didn’t accidentally copy an amd64 binary into an s390x host.

If you must use cgo, the headache is the cross toolchain: you need an s390x-targeting gcc and the right sysroot; set CC and CGO_ENABLED=1 and be ready for platform-specific build flags. For CI, either spin up an s390x runner or use qemu with binfmt_misc so your runners can execute s390x binaries. And remember little conveniences: add -ldflags='-s -w' to strip debug symbols, use module-aware builds (GOFLAGS or go env GOPROXY) so dependency resolution is stable, and test on real hardware when possible — emulators are great, but the hardware occasionally surprises me.
Nolan
Nolan
2025-09-07 00:24:45
Building Go for s390x is way easier than I used to expect — once you know the tiny set of knobs to flip. I’ve cross-compiled a couple of small services for IBM Z boxes and the trickiest part was simply remembering to disable cgo unless I had a proper cross-GCC toolchain.

Practically, for a pure Go program the canonical command I use is very simple: set GOOS=linux and GOARCH=s390x, and turn off CGO so the build doesn’t try to invoke a C compiler. For example:

GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build -o myprog_s390x ./...

That produces an s390x ELF binary you can check with file myprog_s390x. If you need smaller binaries I usually add ldflags like -ldflags='-s -w'. If your project uses cgo (native libs), you’ll need a cross-compiler for s390x and to set CC appropriately (e.g. CC=s390x-linux-gnu-gcc), but the package names and toolchain installation vary by distro. When I couldn’t access hardware I tested with qemu (qemu-system-s390x for full systems, or register qemu-user in binfmt_misc) to sanity-check startup.

I also sometimes use Docker buildx or CI (GitHub Actions) to cross-build images, but for pure Go binaries the env-variable approach is the fastest way to get a working s390x binary on an x86 machine. If you run into weird syscalls or platform-specific bugs, running the binary on a real s390x VM or CI runner usually tells you what to fix.
Zane
Zane
2025-09-09 09:41:21
Cutting to the chase: I like a compact, no-nonsense checklist when I need reproducible cross-builds. Start by deciding whether you need cgo. If not, the job is trivial: environment variables, go build, confirm with file.

Commands I run most often:
GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build -v -o ./build/myapp_s390x ./cmd/myapp
file ./build/myapp_s390x # should report ELF 64-bit LSB executable, s390x

If your app links to native libs (cgo), you’ll either install an s390x cross-toolchain on your build machine or build on an s390x builder. On Debian/Ubuntu the cross gcc often appears under names like s390x-linux-gnu-gcc (package names vary). Then set CC to that cross-compiler and keep CGO_ENABLED=1. Example:
CGO_ENABLED=1 CC=s390x-linux-gnu-gcc GOOS=linux GOARCH=s390x go build -o myprog_s390x

For CI or multi-arch Docker images I use Docker Buildx or GitHub Actions with a build matrix (GOARCH: s390x). Buildx can produce images for linux/s390x directly (docker buildx build --platform linux/s390x …), which is handy when you want the whole image to run on IBM Z hardware or emulators. When in doubt test on a real s390x VM or via qemu-system-s390x; that catches runtime behavior differences fast.
View All Answers
Scan code to download App

Related Books

Obeying Master Cross
Obeying Master Cross
I met the Alpha who I vowed to never ever see again. I hate this world. I hate myself for being an Omega. I hate nature. I hate myself. I hate this Alpha who's looking at me like he owns me. I do not belong to anyone.
9
26 Chapters
Love's Double-Cross
Love's Double-Cross
Trevor Farren cheated on me—with a hostess, no less. He bought her a villa, handbags, necklaces, and even whisked her away to the Maldives. Everything I had, she had too. In my fury, I resolved to retaliate. I found myself in the smoky halls of a nightclub, learning shameful, provocative moves from the women there. I would seduce him and make him fall for me all over again. I vowed to crush him in the end. I'd ruin him. Strip him of everything he held dear until he tasted the bitterness of despair, the way I had. Standing before the mirror, I traced my curves with a sly smile. "Trevor, do you like what you see?"
10 Chapters
Letting go
Letting go
Molly's life was perfect. She was married to her high school sweetheart, surrounded by her friends and family and she was looking forward to the future. But that all ends one tragic night when her whole world is turned upside down. That fateful night leads to Molly and her best friend Tom holding a secret close to their hearts but keeping this secret could also mean destroying any chance of a new future for Molly When Tom's oldest brother Christian meets Molly his dislike for her is instant and he puts little effort into hiding it. The problem is he's attracted to her just as much as he dislikes her and staying away from her starts to become a battle, a battle that he's not sure he can win. When Molly's secret is revealed and she's forced to face the pain from her past can she find the strength to stay and work through the pain or will she run away from everything she knows including the one man who gives her hope for a happy future? Hope that she never thought she would feel again.
10
105 Chapters
Letting Go
Letting Go
A legend was written years ago of two white Lycans made to be mate, to love-hate, fight but also made to be together for the supernatural beings betterment. Kate David is a local who grew up without the devotion of a mother, father, and even by her brother expect by the woman she calls grandma. She anyhow believes that she doesn't need a mate for it causes agony and weakness. Lawrence Clifford, King of Kings has been waiting for his mate but gave up about founding his mate. What happens when these two are meant to be together, will kate ever learn to love, and would both accept each other, or would they run away from fate. Join Kate and Lawrence in their adventure through grief, wrath, and most importantly love. A story full with heartbreak and betrayal.
Not enough ratings
5 Chapters
GO ROGUE
GO ROGUE
Zoya Ironwood was nothing significant. Just a star fighter at Shadow Rings. She didn't have to be significant to survive. Zoya hid her identity as an omega for years. She was mated to Alpha Xander. Everything was fine. Until her whole world collided with Ragnar Throne, the cold immortal Lycan, or in simpler terms, pure evil and destruction. In one day, everything she struggles to build comes crashing down. She is left rejected and alone. She is forced to do his bidding and endure his manipulate ways if she wants to survive. It's almost bearable... But doesn't he know the meaning of personal space? Zoya can't imagine why he is coming close to her. But if she wants her freedom, then she must study her enemy very closely. Playing a dangerous game of love is the only way to end him. But whoever falls first looses.
10
10 Chapters
May I Go ?
May I Go ?
Even though this longing keeps coming to say hello, I still hope to be able to let go of this longing. With you I know, that happy turns out to be as simple as this Aahhh... This warm spring restores me to memories of three years ago. It's been that long but it still sticks in my mind. A sweet girl with a brown hair and hazel eyes haunted my mind. I don't know what magic she did to me cause I can't stop thinking about her. Not to least how long I sat in the Moidef cafe, next to the table on it there were three empty cups that were then filled with coffee in this morning. If she is here, surely she will scold me. I smile considering that. I didn't want to be dissolved in the thoughts, I immediately saw the watch in my hand that had shown a figure of three. Ah... three hours in the spring. Triple hour. I and her. In the spring. Unseen my memory back at the backlash of the past. 15th of December, 2017 ' Let's increase the speed...!' She shouted.
10
13 Chapters

Related Questions

How Does S390x Performance Compare To X86_64?

2 Answers2025-09-03 16:48:12
I’m often torn between geeky delight and pragmatic analysis when comparing s390x to x86_64, and honestly the differences read like two different design philosophies trying to solve the same problems. On paper, s390x (the IBM Z 64-bit architecture) is built for massive, predictable throughput, top-tier reliability, and hardware-assisted services: think built-in crypto, compression, and I/O plumbing that shine in transaction-heavy environments. That pays off in real-world workloads like large-scale OLTP, mainframe-hosted JVM applications, and legacy enterprise stacks where consistent latency, hardware offloads (zIIP-like processors), and crazy dense virtualization are the priorities. Benchmarks you hear about often favor s390x for throughput-per-chassis and for workloads that leverage those special features and the mainframe’s I/O subsystem; it’s also built to keep the lights on with near-zero interruptions, which changes how you measure “performance” compared to raw speed. By contrast, x86_64 CPUs from Intel and AMD are the everyman champions: higher clock speeds, aggressive single-thread boosts, and a monstrous software ecosystem tuned for them. For single-threaded tasks, developer tooling, desktop-like responsiveness, and the vast majority of open-source binaries, x86_64 usually feels faster and is far easier to optimize for. The compilers, libraries, and prebuilt packages are more mature and more frequently tuned for these chips, which translates to better out-of-the-box performance for many workloads. If you’re running microservices, cloud-native stacks, or latency-insensitive batch jobs, x86_64 gives you flexibility, cheaper entry costs, and a huge talent pool. Power efficiency per core and raw FLOPS at consumer prices also often lean in x86_64’s favor, especially at smaller scales. When I’m actually tuning systems, I think about practical trade-offs: if I need predictable 24/7 transaction processing with hardware crypto and great virtualization density, I’ll favor s390x; if I need rapid scaling, a broad toolchain, and cheap instances, x86_64 wins. Porting code to s390x means paying attention to endianness, recompiling with architecture flags, and sometimes rethinking assumptions about atomic operations or third-party binaries. On the flip side, s390x’s specialty engines and massive memory bandwidth can make it surprisingly efficient per transaction, even if its per-thread peak may not match the highest-clocked x86 cores. Honestly, the best choice often comes down to workload characteristics, ecosystem needs, and cost model — not a simple “better-or-worse” verdict — so I tend to prototype both where possible and measure real transactions rather than relying on synthetic numbers. I’ve had projects where a JVM app moved to s390x and suddenly cryptographic-heavy endpoints got cheaper and faster thanks to on-chip crypto, and I’ve also seen microservice farms on x86_64 scale out at way lower upfront cost. If you’re curious, try running your critical path on each architecture in a constrained test and look at latency distributions, throughput under contention, and operational overhead — that’s where the truth lives.

How Can I Optimize PostgreSQL On S390x Servers?

3 Answers2025-09-03 21:37:57
Okay, let's get hands-on — I love digging into this kind of system-level tuning. Running PostgreSQL on s390x (IBM Z) gives you a beast of a platform if you respect a few hardware and kernel quirks, so I usually start by getting a solid baseline: capture CPU, memory, IO, and PostgreSQL stats during representative workloads (iostat, sar, vmstat, pg_stat_activity, pg_stat_statements). Knowing whether your I/O is zFCP-backed storage, NVMe, or something virtualized under z/VM makes a huge difference to what follows. For PostgreSQL parameters, I lean on a few rules that work well on large-memory s390x hosts: set shared_buffers to a conservative chunk (I often start around 25% of RAM and iterate), effective_cache_size to 50–75% depending on how much the OS will cache, and tune work_mem per-connection carefully to avoid memory explosions. Increase maintenance_work_mem for faster VACUUM/CREATE INDEX operations, and push max_wal_size up to reduce checkpoint storms — paired with checkpoint_completion_target around 0.7 to smooth writes. Autovacuum needs love here: lower autovacuum_vacuum_scale_factor and raise autovacuum_max_workers if you have many DBs and heavy churn. On the kernel and storage side, check THP and either disable Transparent Huge Pages or move to explicit hugepages depending on your latency profile — THP can introduce pauses. Adjust vm.swappiness (10 or lower), vm.dirty_background_ratio/dirty_ratio and vm.dirty_expire_centisecs to tune writeback behavior. Use a modern I/O scheduler appropriate for your device (noop or mq-deadline for SSDs, test with fio). Mount data volumes with noatime and consider XFS for large DBs. If you control the build, enabling architecture-optimized compiler flags for s390x can help, and watch out for endianness when using custom binary formats or extensions. Finally, add connection pooling (pgbouncer), replicate with streaming replication for read-scaling, and automate monitoring and alerting — once you have metrics, incremental tuning becomes much less scary.

Why Do CI Pipelines Fail For S390x Builds?

3 Answers2025-09-03 23:13:31
This one always feels like peeling an onion of tiny architecture quirks — s390x builds fail in CI for a handful of recurring, predictable reasons, and I usually see several stacked at once. First, classic hardware and emulator gaps: there simply aren’t as many native runners for IBM Z, so teams rely on QEMU user/system emulation or cross-compilation. Emulation is slower and more fragile — long test runtimes hit CI timeouts, and subtle qemu version mismatches (or broken binfmt_misc registration) can cause weird exec failures. Then there’s the big-endian twist: s390x is big‑endian, so any code or tests that assume little-endian byte order (serialization, hashing, bit-twiddling, network code) will misbehave. Low-level code also trips up — use of architecture-specific assembly, atomic ops, or CPU features (SIMD/AVX assumptions from x86 land) will fail at build or runtime. Beyond that, package and toolchain availability matters. Docker images and prebuilt dependencies for s390x are less common, so CI jobs often break because a required binary or library isn’t available for that arch. Language runtimes sometimes need special flags: Rust/C/C++ cross toolchains must be set up correctly, Go needs GOARCH= s390x and matching C toolchains for cgo, Java JITs may produce different behavior. Finally, flaky tests and insufficient logging make diagnosis slow — you can get a “build failed” with little actionable output, especially under emulation. If I’m triaging this on a project I’ll prioritize getting a minimal reproduction on real hardware or a well-configured qemu runner, add arch-specific CI stages, and audit endian- and platform-specific assumptions in code and tests so failures become understandable rather than magical.

Is QEMU Emulation Reliable For S390x Development?

3 Answers2025-09-03 19:01:19
I've been using QEMU for s390x work for years, and honestly, for most development tasks it's impressively dependable. For bringing up kernels, testing initramfs changes, and iterating on system services, QEMU will save you endless time: fast cycles with snapshots, easy serial logs, and straightforward debugging with gdb. The system emulation supports the common channel-attached (CCW) devices and block/network backends well enough to boot mainstream distributions, run systemd, and validate functionality without needing iron in the room. That said, reliability depends on what you mean by "reliable." If you need functional correctness—does the kernel boot, do filesystems mount, do userspace services run—QEMU is solid. If you need hardware-accurate behavior, cycle-exact timing, or access to specialized on-chip accelerators (cryptographic units, proprietary telemetry, or mainframe-specific features), QEMU's TCG emulation will fall short. KVM on real IBM Z hardware is the path for performance parity and hardware feature exposure, but of course that requires access to real machines. My usual workflow is to iterate fast in QEMU, use lightweight reproducible images, write tests that run in that environment, then smoke-test on actual hardware before merging big changes. For everyday development it's a huge productivity boost, but I always treat the emulator as the first step, not the final authority.

Can I Run Docker Containers On S390x Machines?

2 Answers2025-09-03 04:02:24
Oh, yes — you can run containers on s390x machines, but there are some practical things to keep in mind before you dive in. I've run Linux on big iron and toyed with containers there enough to know the main checklist: the machine needs a Linux distro built for s390x (think SLES, RHEL, Ubuntu on IBM Z or LinuxONE), and the container runtime must be available for that architecture. Many modern distros provide Docker or Podman packages for s390x directly through their repositories. I usually reach for Podman these days on enterprise Linux because it’s packaged well for s390x and works rootless, but plain Docker Engine is also possible — just install the distro-specific package rather than expecting Docker Desktop binaries. A technical caveat that trips people up is image architecture. Containers are not magically architecture-agnostic: if you pull an image built for amd64 it won’t run natively on s390x. The good news is many official images are multi-arch (manifest lists) and include an s390x variant; you can do things like docker pull --platform linux/s390x image:tag or let Docker/Podman pick the right one automatically. If an s390x build doesn't exist, you can either build an s390x image yourself or use emulation with qemu-user-static and buildx. Emulation works (I’ve used qemu via buildx to cross-build and test), but expect a performance hit compared to native s390x images. Other practical tips: ensure the kernel supports required container features (cgroups and overlayfs usually), check docker info to confirm the architecture, and if you plan to build multi-arch images, set up buildx and register qemu with binfmt_misc (multiarch/qemu-user-static is handy). Also, don’t assume Docker Desktop workflows will apply — you’ll be working with CLI tooling on a server. Running containers on IBM Z is surprisingly smooth once images are available; it’s a powerful way to get modern workloads on mainframes and LinuxONE hardware, and it can feel oddly satisfying spinning up a tiny container on such a massive machine.

Which Cloud Providers Offer S390x Virtual Instances?

3 Answers2025-09-03 15:26:25
I've spent a lot of late nights tinkering with odd architectures, and the short story is: if you want true s390x (IBM Z / LinuxONE) hardware in the cloud, IBM is the real, production-ready option. IBM Cloud exposes LinuxONE and z Systems resources—both bare-metal and virtualized offerings that run on s390x silicon. There's also the 'LinuxONE Community Cloud', which is great if you're experimenting or teaching, because it gives developers time on real mainframe hardware without the full enterprise procurement dance. Outside of IBM's own public cloud, you'll find a handful of specialized managed service providers and system integrators (think the folks who historically supported mainframes) who will host s390x guests or provide z/VM access on dedicated hardware. Names change thanks to mergers and spinoffs, but searching for managed LinuxONE or z/VM hosting usually surfaces options like Kyndryl partners or regional IBM partners who do rent time on mainframe systems. If you don't strictly need physical s390x hardware, a practical alternative is emulation: you can run s390x under QEMU on ordinary x86 VMs from AWS, GCP, or Azure for development and CI. It’s slower but surprisingly workable for builds and tests, and a lot of open-source projects publish multi-arch s390x images on Docker Hub. So for production-grade s390x VMs, go IBM Cloud or a mainframe hosting partner; for dev, consider 'LinuxONE Community Cloud' or QEMU emulation on common clouds.

What Linux Distros Officially Support S390x Today?

3 Answers2025-09-03 10:53:11
Honestly, if you're digging into s390x support today, the landscape is surprisingly tidy compared to other niche architectures. In plain terms: the big mainstream distributions offer official support, because IBM Z and LinuxONE are widely used in enterprise settings. The names you should know: Debian (official s390x port with regular images and repos), Fedora (s390x is an official Fedora architecture with regular composes), openSUSE/Leap and Tumbleweed (plus SUSE Linux Enterprise which is the commercial offering) and Red Hat Enterprise Linux (RHEL) all provide official builds for s390x. Canonical also ships Ubuntu images for IBM Z (s390x) for supported releases. Gentoo has maintained s390x support too, though its workflow is source-based rather than binary-focused. These are the ones you can reasonably point to as officially supported by their projects or vendors. Beyond that, some distributions provide community or experimental s390x images — Alpine and certain RHEL rebuilds or downstreams may have builds contributed by their communities, and projects like Rocky or AlmaLinux occasionally have community efforts, but their s390x coverage is more hit-or-miss and varies by release. If you need production stability, stick with Debian, Fedora, SUSE/SLES, Ubuntu, RHEL, or Gentoo depending on your preferred model (binary vs source). For getting started, look for images labeled 's390x' on each distro's download or cloud image pages, and check release notes for kernel and z/VM compatibility. I'm always tickled by how resilient these platforms are on mainframe iron — it's a different vibe from desktop Linux, but super solid if you need uptime.

What Kernel Versions Best Support S390x Features?

3 Answers2025-09-03 18:48:05
When I dive into s390x support, I tend to look at two things: how mature a feature is in upstream mainline, and what enterprise distributions have backported. Historically, s390x has been part of the kernel for a long time (the s390/s390x tree matured through the 2.6 and 3.x eras), but the real message is that modern LTS kernels are where you'll find the best, most polished support for contemporary mainframe features. If you want concrete guidance: pick a modern long-term-stable kernel — think 5.10, 5.15, or 6.1 — or newer 6.x kernels if you need bleeding-edge fixes. Those LTS lines collect important fixes for KVM on s390x, DASD/CCW improvements, zfcp (Fibre Channel) robustness, zcrypt and CPACF crypto support, and paravirtual I/O enhancements. Enterprise distros (RHEL, SLES, Ubuntu LTS) often backport features into their kernel trees, so a distribution-provided LTS kernel can be the safest route for production while still giving you modern hardware support. Practically, if I’m deploying to a z15/z16 or running heavy KVM workloads, I’ll test on the latest upstream stable or a 6.x kernel to catch recently merged performance and crypto improvements, then switch to the distribution LTS that includes those backports for production. Also check kernel config options (look for s390, CCW, DASD, zcrypt-related flags) and read the s390-specific changelogs in the kernel git to verify feature flags you rely on.
Explore and read good novels for free
Free access to a vast number of good novels on GoodNovel app. Download the books you like and read anywhere & anytime.
Read books for free on the app
SCAN CODE TO READ ON APP
DMCA.com Protection Status