MentOS
MentOS copied to clipboard
Cannot build MentOS on macOS M2
The doc says to build MentOS on macOS, these packages are needed:
- i386-elf-binutils
- i386-elf-gcc
I already did, and can built xv6. But when building MentOS, running make fails because it invokes Apple's compiler, not i386-elf-gcc
[ 1%] Building C object libc/CMakeFiles/libc.dir/src/err.c.o
cc: error: unsupported argument 'i686' to option '-march='
make[2]: *** [libc/CMakeFiles/libc.dir/src/err.c.o] Error 1
make[1]: *** [libc/CMakeFiles/libc.dir/all] Error 2
make: *** [all] Error 2
OK, how to modify the CMake config/Makefile/etc so it's i386-elf-gcc which is should be called instead?
My cmake knowledge is very rusty. Apologies. I tried this:
$ cmake .. -D CMAKE_C_COMPILER=i386-elf-gcc
-- The C compiler identification is GNU 14.1.0
-- The ASM compiler identification is GNU
-- Found assembler: /opt/homebrew/bin/i386-elf-gcc
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - no
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/homebrew/bin/i386-elf-gcc
-- Check for working C compiler: /opt/homebrew/bin/i386-elf-gcc - broken
CMake Error at /opt/homebrew/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler
"/opt/homebrew/bin/i386-elf-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/Users/andretampubolon/Lab/OSDev/MentOS/mentos-git/build/CMakeFiles/CMakeScratch/TryCompile-T1F4hq'
Run Build Command(s): /opt/homebrew/bin/cmake -E env VERBOSE=1 /opt/homebrew/bin/gmake -f Makefile cmTC_4e7c6/fast
/opt/homebrew/bin/gmake -f CMakeFiles/cmTC_4e7c6.dir/build.make CMakeFiles/cmTC_4e7c6.dir/build
gmake[1]: Entering directory '/Users/andretampubolon/Lab/OSDev/MentOS/mentos-git/build/CMakeFiles/CMakeScratch/TryCompile-T1F4hq'
Building C object CMakeFiles/cmTC_4e7c6.dir/testCCompiler.c.o
/opt/homebrew/bin/i386-elf-gcc -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -o CMakeFiles/cmTC_4e7c6.dir/testCCompiler.c.o -c /Users/andretampubolon/Lab/OSDev/MentOS/mentos-git/build/CMakeFiles/CMakeScratch/TryCompile-T1F4hq/testCCompiler.c
i386-elf-gcc: error: unrecognized command-line option '-arch'
gmake[1]: *** [CMakeFiles/cmTC_4e7c6.dir/build.make:81: CMakeFiles/cmTC_4e7c6.dir/testCCompiler.c.o] Error 1
gmake[1]: Leaving directory '/Users/andretampubolon/Lab/OSDev/MentOS/mentos-git/build/CMakeFiles/CMakeScratch/TryCompile-T1F4hq'
gmake: *** [Makefile:134: cmTC_4e7c6/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:9 (project)
-- Configuring incomplete, errors occurred!