maojie / pintos_mac

Stanford Pintos Operating System on Mac
Other
34 stars 20 forks source link

Install i386-elf-gcc using homebrew and use QEMU for simulator #2

Open jinmel opened 10 years ago

jinmel commented 10 years ago

Homebrew often conflicts with MacPorts, and it is a pain for homebrew users to install MacPorts just for this project. Homebrew is better maintained by active open source community

Instead of installing i386-elf-gcc using macports, I wrote formulas for gcc cross compiler to work with homebrew

Simulator was changed to QEMU since bochs is outdated and QEMU has faster performance(except for alarm clock tests)

I deleted other README contents of your original README because it's all on Pintos Documentation homepage

maojie commented 10 years ago

Hi jinmel,

Thanks for your patch! Could you please add your name and email into the README file? I'll take a look at you changes tomorrow.

Thanks & Best regards Jeremy

jinmel commented 10 years ago

I added my contact :)

Cheers

corydolphin commented 10 years ago

Hi @jinmel I am trying to follow along and use your update, but I cannot seem to get the project to compile. I may be missing something obvious, here is what I did:

  1. Clone your branch
  2. Change CC from clang to i386-elf-gcc
  3. run make in the utils folder.

When I do so, I receive the following error message:

i386-elf-gcc -Wall -W   -c -o squish-pty.o squish-pty.c
squish-pty.c:2:19: fatal error: errno.h: No such file or directory
 #include <errno.h>
                   ^
compilation terminated.
make: *** [squish-pty.o] Error 1

Any idea of how to fix the issue?

jinmel commented 10 years ago

@wcdolphin

Sorry for late response. Those i386-elf-gcc from the homebrew tap does not include the library shared object files so squish-pty.c may fail. I successfully did this project without using squish-pty.

leon-g-xu commented 10 years ago

Hi @jinmel, I was trying to build in the userprog directory for project2. But I am getting errors: tests/lib.o: In function vmsg': /Users/guodongxu/Projects/pintos-mac/userprog/build/../../tests/lib.c:21: undefined reference tosnprintf' /Users/guodongxu/Projects/pintos-mac/userprog/build/../../tests/lib.c:22: undefined reference to vsnprintf' /Users/guodongxu/Projects/pintos-mac/userprog/build/../../tests/lib.c:23: undefined reference tostrlcpy' ...

Have you run into this issue when you are building userprog?

Thanks Leon

jinmel commented 10 years ago

Yes this happens because homebrew doesn't build the libc library for i386 architecture. The hotfix for this issue is to install a complete .dmg and make changes to makefile according to the gcc binary name. I am still working on this issue. If you are successful building all the libraries for i386 please contribute to https://github.com/sevki/homebrew-gcc_cross_compilers

ouceduxzk commented 9 years ago

Hi, on Yosemite , brew fails to install i386-elf-gcc. checking for gcc... /usr/local/bin/gcc-4.2 checking for C compiler default output file name... configure: error: in /private/tmp/i386-elf-binutils-RMvF46/binutils-2.23/build': configure: error: C compiler cannot create executables Seeconfig.log' for more details. couldn't understand kern.osversion `14.0.0'

DanielGibbsNZ commented 9 years ago

I had the same issue as @ouceduxzk on Yosemite and managed to work around it by using a different fork of homebrew-gcc_cross_compilers. This fork also requires gcc49 from homebrew/versions.

brew untap jinmel/homebrew-gcc_cross_compilers
brew tap altkatz/homebrew-gcc_cross_compilers
brew install homebrew/versions/gcc49
brew unlink gcc
brew link gcc49
brew install i386-elf-gcc i386-elf-binutils
brew unlink binutils
brew link i386-elf-binutils

The linking and unlinking may be optional, it depends on what you had installed before. The whole process took ages for me, but that may just be my machine being slow.

The first project (threads) compiled fine, but the other ones failed with a bunch of undefined references as mentioned above.

DanielGibbsNZ commented 9 years ago

I've fixed the "undefined reference" errors (@guodongx, @jinmel) in https://github.com/jinmel/pintos_mac/pull/1, meaning that all the projects now build successfully on OS X Yosemite.

thientran1707 commented 8 years ago

@DanielGibbsNZ thanks a lot, I am trying to do the OS 140 assignments in Mac. Thanks a lot for your work

beckha commented 8 years ago

when I run brew install i386-elf-gcc, I found this error. Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: libgold.a(workqueue-threads.o) has no symbols ranlib libgold.a Any idea of how to fix the issue? Thanks