How to obtain a big-endian CPU machine

Last week, I wanted to test whether a trivial function works OK on big-endian CPU. I have ARM and X86_64 machines at hand, but both them are little-endian. After searching online, I come across Running a emulated SparcStation 20 with qemu-sparc, though I heard about qemu before, but never used it, so wanted to give it a spin.

The installation of qemu is straightforward, then I created a NetBSD-10.1-sparc machine in just 3 steps (omit some configurations unneeded for me):

$ qemu-img create -f qcow2 ss20.image 4G
$ qemu-system-sparc -M SS-20 -m 256 -drive file=NetBSD-10.1-sparc.iso,bus=0,unit=2,media=cdrom,readonly=on -drive file=ss20.image,bus=0,unit=0,media=disk -full-screen -boot d
$ qemu-system-sparc -M SS-20 -m 256 -drive file=ss20.image,bus=0,unit=0,media=disk -full-screen -boot c

Then the machine booted successfully and met my requirement perfectly!

Compare error prompts of different awk flavours

Awk requires the opening brace of an action must be on the same line as the pattern it accompanies. I compared error prompts of different awk flavours, and my OS is NetBSD.

(1) awk shipped in NetBSD:

# awk 'BEGIN
> {print "Hello Awk!"}'
awk: syntax error at source line 2
 context is
        BEGIN >>>
 <<<
awk: bailing out at source line 2

(2) nawk:

# nawk 'BEGIN
{print "Hello Awk!"}'
nawk: syntax error at source line 2
 context is
        BEGIN >>>
 <<<
nawk: bailing out at source line 2

(3) mawk:

# mawk 'BEGIN
{print "Hello Awk!"}'
mawk: line 1: syntax error at or near end of line

(4) gawk:

# gawk 'BEGIN
{print "Hello Awk!"}'
gawk: cmd. line:2: BEGIN blocks must have an action part

IMHO, gawk gives more clear clues for this error.

Be aware of using gmake or make on BSD systems

When working on BSD systems, you should be aware of using gmake or make. E.g., I met a weird error using make on NetBSD today:

# make
.....
/usr/lib/crt0.o: In function `___start':
(.text+0xf7): undefined reference to `main'
collect2: error: ld returned 1 exit status
*** Error code 1
......

But using gmake, the compilation is OK.