From b2ecd8f3806f02d1ee0530ffb7f31e600b853bc6 Mon Sep 17 00:00:00 2001 From: "Michael J. Manley" Date: Tue, 8 Jul 2025 22:18:31 -0700 Subject: [PATCH] Forcing Clang unilaterally. Will update docs for build instructions. --- .github/workflows/test-debug-builds.yml | 2 + .github/workflows/test-release-builds.yml | 2 + .../workflows/test-relwithdebinfo-builds.yml | 2 + CHANGELOG.md | 2 + CMakeLists.txt | 37 ++++++++++++++++++- 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-debug-builds.yml b/.github/workflows/test-debug-builds.yml index 1b947885..d4b786bf 100644 --- a/.github/workflows/test-debug-builds.yml +++ b/.github/workflows/test-debug-builds.yml @@ -23,6 +23,8 @@ jobs: libwxgtk3.2-dev libpcap-dev cmake + llvm + clang ninja-build - name: Windows 64bits (MSYS2) os: windows-latest diff --git a/.github/workflows/test-release-builds.yml b/.github/workflows/test-release-builds.yml index 48885742..4fb473ef 100644 --- a/.github/workflows/test-release-builds.yml +++ b/.github/workflows/test-release-builds.yml @@ -23,6 +23,8 @@ jobs: libwxgtk3.2-dev libpcap-dev cmake + llvm + clang ninja-build - name: Windows 64bits (MSYS2) os: windows-latest diff --git a/.github/workflows/test-relwithdebinfo-builds.yml b/.github/workflows/test-relwithdebinfo-builds.yml index 1ffcfb3a..7b085e79 100644 --- a/.github/workflows/test-relwithdebinfo-builds.yml +++ b/.github/workflows/test-relwithdebinfo-builds.yml @@ -23,6 +23,8 @@ jobs: libwxgtk3.2-dev libpcap-dev cmake + llvm + clang ninja-build - name: Windows 64bits (MSYS2) os: windows-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e120b1e..ec671044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Added RAM disk preloaded with RAW/VHD images (*.rdimg;*.rdvhd) - Load up to 2GB disks to temporary disk (doesn't modify the image file) - Mounts as read-only if memory allocation fails (mind the 32bit PCem memory limits) +- 32-bit Windows builds will now be deprecated due to technical issues. v17 will be the last 32-bit PCem. ## Added the following machines to v18 - Hyundai SUPER-16T @@ -33,6 +34,7 @@ ## Developer Changes to v18 - First release to switch from autotools/make to CMake/Ninja - Legacy autotools and mingw makefiles are removed +- Windows and Linux builds now will be built in Clang, and are required to be built with Clang # PCem v17 - New machines added - Amstrad PC5086, Compaq Deskpro, Samsung SPC-6033P, Samsung SPC-6000A, Intel VS440FX, Gigabyte GA-686BX diff --git a/CMakeLists.txt b/CMakeLists.txt index 45d94aa7..49e3f921 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,16 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.20) + +# We are going to force clang on both Linux and Windows builds to be uniform +set(CMAKE_C_COMPILER "clang" CACHE FILEPATH "C compiler") +set(CMAKE_CXX_COMPILER "clang++" CACHE FILEPATH "C++ compiler") project(PCem) +# Dont allow GCC Building anymore, force Clang +if(NOT (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) + message(FATAL_ERROR "Detected compiler is not Clang! Please ensure Clang is in your PATH or specified correctly.") +endif() + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules) @@ -76,6 +85,32 @@ if(USE_EXPERIMENTAL) message(" Printer Support: ${USE_EXPERIMENTAL_PRINTER}") endif() +if(CMAKE_BUILD_TYPE STREQUAL "Release") + option(USE_PGO "Build PCem using PGO Data" OFF) + option(GENERATE_PGO "Build PCem to generate PGO Data for PGO" OFF) + + message("Generate PGO Data: ${GENERATE_PGO}") + message("Use PGO Data: ${USE_PGO}") +endif() + +if(GENERATE_PGO) + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fprofile-generate") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-generate") +endif() + +if(USE_PGO) + if(GENERATE_PGO) + message(FATAL_ERROR "USE_PGO cannot be used with GENERATE_PGO enabled") + endif() + + if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/default.profdata") + message(FATAL_ERROR "Missing default.profdata in output directory. Make sure you run llvm-profdata merge -output=default.profdata *.profraw") + endif() + + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fprofile-use") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-use") +endif() + if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") option(PCEM_RELDEB_AS_RELEASE "Build PCem RelWithDebInfo as Release Mode" OFF) message("Build PCem RelWithDebInfo as Release Mode: ${PCEM_RELDEB_AS_RELEASE}")