ccsm metrics enabling on edk2 - shijunjing/edk2 GitHub Wiki

C Code Source Metrics (CCSM) enabling on edk2

https://github.com/bright-tools/ccsm

Build CCSM on LLVM 10.0

  • Clone the ccsm LLVM 10.0 branch code:
c:\steven\Metrics>git clone https://github.com/shijunjing/ccsm.git ccsm-fork --recursive
c:\steven\Metrics\ccsm-fork>git checkout LLVM_10.0
  • Clone LLVM and checkout branch llvmorg-10.0.0. This branch has three fix patches to pass build with LLVM 10.0
c:\steven\LLVM\llvm-project>git checkout llvmorg-10.0.0
  • Add ccsm-fork into the clang build binaries
c:\steven\LLVM\llvm-project>git diff
diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
+set(CCSM_DIR C:/steven/Metrics/ccsm-fork)
+add_subdirectory(${CCSM_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/ccsm)
  • Configure the VS2017 build with "RelWithDebInfo" build type
c:\steven\LLVM\llvm-project\_build_debug>cmake ..\llvm -G "Visual Studio 15 2017" -A x64 -DCMAKE_VERBOSE_MAKEFILE=ON  -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLLVM_ENABLE_ASSERTIONS=ON -Thost=x64 -DLLVM_ENABLE_PROJECTS="clang;lld"  -DCMAKE_INSTALL_PREFIX=C:\steven\LLVM\llvm-project\_install_debug -DLLVM_TARGETS_TO_BUILD="X86"

click the C:\steven\LLVM\llvm-project_build_debug\LLVM.sln to launch the VS2017 and set the solution configuration to "RelWithDebInfo". Right click the Solution 'LLVM' to build whole solution.

Build edk2 OVMF with new built LLVM/CLANG 10.0 and run it on Qemu

C:\steven\edk2>edksetup.bat ForceRebuild
C:\steven\edk2>set CLANG_BIN=c:\steven\LLVM\llvm-project\_build_debug\RelWithDebInfo\bin\
C:\steven\edk2>build -p OvmfPkg/OvmfPkgIa32X64.dsc -t CLANGPDB -a IA32 -a X64 -b DEBUG -DDEBUG_ON_SERIAL_PORT
C:\steven\edk2>"c:\Program Files\qemu\qemu-system-x86_64.exe" -m 4096 -bios Build/Ovmf3264/DEBUG_CLANGPDB/FV/OVMF.fd -global e1000.romfile=""  -machine q35 -serial mon:stdio