homebrew-i386-jos-elf-gcc icon indicating copy to clipboard operation
homebrew-i386-jos-elf-gcc copied to clipboard

Request: Modify to run on M1 Mac

Open mikegil opened this issue 4 years ago • 7 comments

The new Macs using the Apple Silicon M1 chip will not build this package. I see someone has made GCC 10 work via Homebrew now, I wonder if you would be able to patch this similarly. Without it I can't build XV6 which is used by my University as the basis for many of their Systems programming courses. I've tried building XV6 using Clang instead, but it won't build a small enough version of the bootblock to fit in the required space. I'd be happy to help if I can.

mikegil avatar Feb 08 '21 18:02 mikegil

Hi mikegil, unfortunately I don't have a device with M1 chip so it'd be hard for me to provide any support. Is there any known method to build xv6 on M1 chips without homebrew?

liudangyi avatar Feb 08 '21 19:02 liudangyi

Thanks for the response, the problem isn't building xv6 without Homebrew, it's building it without a cross compiler that can target i386. I was trying to use your Homebrew formula to compile i386-jos-elf-gcc locally but that fails to link. I assume some dependency needs to be compiled for the M1 chip first but I have no experience building a cross compiler toolchain so I am not sure what I am looking for in order to try and fix it. I don't know how practical it would be, but if you would be willing to point me in the right direction I am more than happy to see if I can work through it. The error I get from Homebrew is:

Last 15 lines from /Users/mgilbert/Library/Logs/Homebrew/i386-jos-elf-gcc/02.make: checksum-options > cc1-checksum.c.tmp &&
../../gcc/../move-if-change cc1-checksum.c.tmp cc1-checksum.c clang -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -DHAVE_CONFIG_H -o lto1
lto/lto-lang.o lto/lto.o lto/lto-object.o attribs.o main.o libbackend.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a -lmpc -lmpfr -lgmp -L../zlib -lz ../libcpp/libcpp.a -liconv ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a Undefined symbols for architecture arm64: "_host_hooks", referenced from: _toplev_main in libbackend.a(toplev.o) _gt_pch_save in libbackend.a(ggc-common.o) _gt_pch_restore in libbackend.a(ggc-common.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [lto1] Error 1 make[1]: *** Waiting for unfinished jobs.... rm gcc.pod make: *** [all-gcc] Error 2

Apparently it's trying to link in libbackend.a and not finding the appropriate implementation of various functions. I am also assuming it builds libbackend.a somewhere and that this has a dependency on some other library that I would need to find an recompile locally, but I am not sure how I figure out what is needed where. Do you have any guidance for me on where I begin?

Regards,

Michael.

On Feb 8, 2021, at 1:00 PM, Dangyi Liu [email protected] wrote:

Hi mikegil, unfortunately I don't have a device with M1 chip so it'd be hard for me to provide any support. Is there any known method to build xv6 on M1 chips without homebrew?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liudangyi/homebrew-i386-jos-elf-gcc/issues/5#issuecomment-775369135, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGVKLIPHW5VZBITEMAKLUTS6AYE3ANCNFSM4XJPUZXQ.

mikegil avatar Feb 08 '21 19:02 mikegil

@mikegil Hi bro, I meet the same problem. How did u deal with it? Looking forward to your reply

ElliotQi avatar Feb 19 '21 08:02 ElliotQi

I ended up taking this homebrew script and merged it with the recently updated script for gcc from the main homebrew repository (that one points to an ARM64 modified gcc source base and a bigsur patch). The output seemed to "work" and I could then compile xv6, but I still couldn't get QEMU to run it - I couldn't tell wether that's because my attempt at compiling an i386 cross compiler for gcc wasn't working or QEMU won't run i386 code on the ARM64 host yet (I suspect the latter).

On Feb 19, 2021, at 2:15 AM, ElliotQi [email protected] wrote:

@mikegil https://github.com/mikegil Hi bro, I meet the same problem. How did u deal with it? Looking forward to your reply

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/liudangyi/homebrew-i386-jos-elf-gcc/issues/5#issuecomment-781912476, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGVKLNIY74ETZVOE5HYMX3S7YM3DANCNFSM4XJPUZXQ.

mikegil avatar Feb 19 '21 15:02 mikegil

@mikegil Thanks for your reply. Finally, I make the configuration with rosetta2.

ElliotQi avatar Feb 21 '21 03:02 ElliotQi

@mikegil @ElliotQi Can you help me with how you made it work? I tried compiling xv6 on another computer (which I would like not to use) and made it run in the M1 successfully with qemu, but I need a reliable way to compile it locally. Thanks

DanielMilstein avatar Aug 13 '21 16:08 DanielMilstein