Breaking news! Vibe coding achieved the utterly impressive feat! Macintosh System 7 Ported To X86 With LLM Help. The original System7 ran on Motorola 68K. The author claimed that they ported the OS to x86 in 3 days, with a fully functional Finder and GUI, and no access to the original source code. The project files can be found on GitHub.
It is understood that the port ran under QEMU to simplify dealing with real hardware, which has to do many things like ACPI power management. But as you may have surmised from the title, this is not the only "shortcut" that has been taken.
ISO contains just the kernel?
To start, let's take a look at how to run the project from the instructions provided:
# Build the kernel make # Create bootable ISO make iso # Clean build artifacts make clean # Run in QEMU qemu-system-i386 -cdrom system71.iso -serial stdio -display sdl -vga std -m 256M
So let's take a look at the Makefile to see how the ISO was built.
ISO_DIR = iso KERNEL = kernel.elf ISO = system71.iso GRUB = grub-mkrescue # ISO target iso: $(ISO) $(ISO): $(KERNEL) @echo "Creating bootable ISO..." @cp $(KERNEL) $(ISO_DIR)/boot/ @echo 'menuentry "System 7.1 Portable" {' > $(ISO_DIR)/boot/grub/grub.cfg @echo ' multiboot2 /boot/$(KERNEL)' >> $(ISO_DIR)/boot/grub/grub.cfg @echo ' boot' >> $(ISO_DIR)/boot/grub/grub.cfg @echo '}' >> $(ISO_DIR)/boot/grub/grub.cfg @$(GRUB) -o $(ISO) $(ISO_DIR)
The ISO is made using grub-mkrescue. The kernel is linked using the multiboot2 specification, which means grub would have switched the x86 CPU into 32-bit protected mode with a flat address space.
But it is a little surprising that the ISO comprised of just the kernel.elf and grub.cfg, devoid of all other assets such as fonts, icons, application binaries. There is no filesystem because everything is compiled into the kernel.
Indeed, you can find the hard coded icons and the hard coded font bitmap. The FontResources is really some code to download fonts from the Internet using curl, but this is not compiled into the kernel, and this is not the code used to generate the hard coded font bitmap either. This is probably just dead code.
If there is no filesystem, then it is a wonder why the project contains HFS filesystem code?
Dead Code Galore
There is a huge amount of dead code in the repo, all generated AI slop. This is an impressive catalog: AppleEventManager, ControlManager, ControlPanels, DeskManager, DeviceManager, DialogManager, EventManager, FS (HFS), FileMgr, Finder, FontManager, FontResources, GestaltManager, ListManager, MemoryMgr, MenuManager, PatternMgr, Platform, ProcessMgr, QuickDraw, ResourceMgr, Resources, ScrapManager, SoundManager, TextEdit, WindowManager.
I have spot checked a few: The FS code has mentions of btree and catalog, but it is an in-memory filesystem (no actual disk volume support). The QuickDraw code does not contain any shape drawing code, i.e. the code purporting to draw the line or oval does not actually render the pixels. There is no implementation of the Bresenham's algorithm.
Only a handful of these managers are referenced in main.c, and even so, only the initialization function is called. There is no evidence that main.c actually uses any of the managers in any substantial way. For example, even though it includes the QuickDraw header, most of the drawing routine is in main.c itself.
What's in a main?
So what does the main.c actually do?
- Writing to the serial console using outb.
- The serial port input is used to simulate GUI interaction, e.g. 'm' activates the menu, 'a' activates the Apple menu.
- Draws console text in VGA mode.
- Multiboot2 handover.
- Drawing of text, apple logo, window, rectangle, and icon.
- Fake initialization of managers.
- There is some mouse handling using hard-coded coordinates to map cursor to UI elements. But this is commented out.
In summary, we just get a very thin veneer of what is minimally required to draw some UI in QEMU and using serial port to interact with it.
Conclusion
This is perhaps not the most flattering case study of using LLM to vibe code. AI faithfully created a bunch of dead code, but what was actually working is a small amount of code that is minimally required to create the appearance of a working operating system.
This whole thing reminds me of Theranos. Its CEO, Elizabeth Holmes, charmed her investors into believing that she invented a miracle medical diagnostics machine that purported to be able to run a bunch of tests using only a single drop of blood. In the few demos they did, they actually drew vials of blood using the normal process and ran the regular lab tests behind the scenes. The machine never worked.
It took Theranos (timeline) from rising to fame in 2015 to fraud indictment in 2018. ChatGPT was first publicly released in 2022. How many more years will people discover that AI is fraud? Probably never, unless somehow AI starts to put people's lives in danger, but not out of malice, just incompetence.
No comments:
Post a Comment