MacOS Computer Systems: A Programmer's Perspective labs setup

246 views Asked by At

I'm going to study this Computer Systems: A Programmer's Perspective, and do labs from http://csapp.cs.cmu.edu/3e/labs.html

But I can't figure out how to start, when I'm running "make" to compile lab, for example "datalab" I got an error

gcc -O -Wall -m32 -lm -o btest bits.c btest.c decl.c tests.c
ld: unknown/unsupported architecture name for: -arch armv4t
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [btest] Error 1

As I understand the problem with my system (MacOS m1), anyone find a solution for this?

2

There are 2 answers

0
Dmitry On BEST ANSWER

I found a solution using docker, I created a repository where I described the entire installation process, can be found here

0
Peter Cordes On

No version of MacOS new enough to run on M1 hardware supports 32-bit x86; that was dropped a while ago. (You're on AArch64 hardware so x86-64 binaries only run using Rosetta 2 software emulation; it doesn't support old 32-bit binaries either.)

And M1 hardware doesn't support AArch32 state (32-bit mode), so native binaries can also only be 64-bit. That's why your AArch64 clang complained that -arch armv4t wasn't supported. (On MacOS, gcc actually runs Clang unless you've installed real GCC, e.g. via Brew. That wouldn't help, you'd just get a different error message.)


For any of the CS:APP labs that need you to run or single-step 32-bit x86 code, you'll need to run some other OS inside an emulator, like perhaps QEMU if that can run on AArch64 MacOS. A lightweight Linux install could work well, maybe just one you SSH into or use a text console (not a GUI desktop).

Or maybe qemu-user can emulate things for a single x86 Linux process under MacOS (instead of emulating a full system an running a full OS inside the guest).
Connecting to it as a GDB-remote is less simple than just running GDB on a binary. How to single step ARM assembly in GDB on QEMU? is the opposite question, using QEMU to single-step an ARM Linux binary on an x86-64 Linux desktop. But there's no cross-OS aspect to that or How to run a single line of assembly, then see [R1] and condition flags , just assembling and linking an ARM Linux binary.