We’re almost done with the implementation for integrating M88k into clang. The last step is to add the new clang files that we have added into their corresponding CMakeLists.txt file, which allows us to build the clang project with our M88k target implementation:
- First, add the Targets/M88k.cpp line to clang/lib/Basic/CMakeLists.txt.
- Next, add Targets/M88k.cpp to clang/lib/CodeGen/CMakeLists.txt.
- Finally, add ToolChains/Arch/M88k.cpp to clang/lib/Driver/CMakeLists.txt.
There we have it! That concludes our toolchain implementation for the toolchain support for the M88k target, which subsequently means we’ve completed the integration into clang for M88k!
The last step we need to do is build clang with the M88k target. The following commands will build the clang and LLVM project. For clang, be aware of the M88k target. Here, the -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=M88k CMake option must be added, as in the previous section:
$ cmake -G Ninja ../llvm-project/llvm -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=M88k -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=”clang;llvm”
$ ninja
We should now have a version of clang that recognizes the M88k target! We can confirm this by checking the list of targets that clang supports, through the –print-targets option:
$ clang –print-targets | grep M88k
m88k – M88k
In this section, we delved into the technical details of integrating a new backend target into clang and having it recognized. In the next section, we’ll explore the concept of cross-compiling, where we detail the procedure of targeting a different CPU architecture from the current host.