Cmake config problems with Apple ii port of LLVM MOS

50 views Asked by At

I am running into issues trying to build this fork of the LLVM-MOS project. My goal is to compile a C program and load into onto an Apple ][

The Readme says:

1. When you first clone the repository, or change any of the CMake files, execute $ cmake -D CMAKE_C_COMPILER="/path/to/mos-common-clang" -S src -B build in the root of the repository, where /path/to/mos-common-clang is the path to mos-common-clang in your LLVM-MOS SDK installation.

When I run that:

% cmake -D CMAKE_C_COMPILER="$(where mos-common-clang | head -n 1)" -S src -B build
-- The C compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang
-- Check for working C compiler: /Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang - broken
CMake Error at /opt/homebrew/Cellar/cmake/3.28.3/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/Users/garrettbodley/Code/apple-ii-port-work/build/CMakeFiles/CMakeScratch/TryCompile-LJQLYD'
    
    Run Build Command(s): /opt/homebrew/Cellar/cmake/3.28.3/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_c9898/fast
    /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_c9898.dir/build.make CMakeFiles/cmTC_c9898.dir/build
    Building C object CMakeFiles/cmTC_c9898.dir/testCCompiler.c.o
    /Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang   -arch arm64 -o CMakeFiles/cmTC_c9898.dir/testCCompiler.c.o -c /Users/garrettbodley/Code/apple-ii-port-work/build/CMakeFiles/CMakeScratch/TryCompile-LJQLYD/testCCompiler.c
    mos-common-clang: error: unsupported option '-arch' for target 'mos-common'
    make[1]: *** [CMakeFiles/cmTC_c9898.dir/testCCompiler.c.o] Error 1
    make: *** [cmTC_c9898/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:5 (project)

-- Configuring incomplete, errors occurred!

It is very unclear to me why CMake is automatically using -arch arm64 flags?

I can make the error go away with:

cmake -DCMAKE_ASM_COMPILER="/Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang" -DCMAKE_C_COMPILER_FORCED=TRUE -D CMAKE_C_COMPILER="/Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang" -S src -B build

I do not entirely understand what these flags are doing...

% cmake -DCMAKE_ASM_COMPILER="/Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang" -DCMAKE_C_COMPILER_FORCED=TRUE -D CMAKE_C_COMPILER="/Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang" -S src -B build                  
-- The C compiler identification is unknown
-- Configuring done (0.4s)
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_ASM_COMPILER= /Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang

-- The C compiler identification is AppleClang 14.0.0.14000029
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /Users/garrettbodley/Code/llvm-mos/bin/mos-common-clang
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/garrettbodley/Code/apple-ii-port-work/build

The Readme then says to run make -C build from the root dir

% make -C build
[ 10%] Linking C executable breakout.bin
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [example/breakout-appleiie-bare/breakout.bin] Error 1
make[1]: *** [example/breakout-appleiie-bare/CMakeFiles/apple-iie-bare-example-breakout.dir/all] Error 2
make: *** [all] Error 2

What is crt0.o? Why is the linker failing to find this? How do I get to a place where I can use this llvm-apple-ii compiler in the Makefile of my own project?


(Apple //e, Apple ii e, Apple ][ e, Apple 2 e)

^ in case other people google for this ^

0

There are 0 answers