From 3319beda5a19e0542b6b9aa5b21ab98f8c456088 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Mon, 18 Aug 2025 18:03:03 +0300 Subject: [PATCH 1/5] build: Set some compiler flags only when this is the top-level project --- CMakeLists.txt | 53 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f692e08..ad62f9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,43 +42,54 @@ endif () # These are shared by bddisasm and bdshemu. if (MSVC OR "${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC") - set(BDDISASM_COMMON_COMPILE_OPTIONS /W4 /WX) + if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) + set(BDDISASM_COMMON_COMPILE_OPTIONS /W4 /WX) + endif () else () set(BDDISASM_COMMON_COMPILE_OPTIONS "$<$:-U_FORTIFY_SOURCE>" "$<$:-D_FORTIFY_SOURCE=2>" - -Wall -Wno-unknown-pragmas - -Wextra - -Wshadow - -Wformat-security - -Wstrict-overflow=2 - -Wstrict-prototypes - -Wwrite-strings - -Wshadow - -Winit-self -Wno-unused-function -Wno-multichar -Wno-incompatible-pointer-types -Wnull-dereference - -Werror=format-security - -Werror=implicit-function-declaration -pipe -fwrapv -fno-strict-aliasing -fstack-protector-strong - -fno-omit-frame-pointer - -ffunction-sections - -fdata-sections - -g3 - -gdwarf-4 - -grecord-gcc-switches - -march=native) + ) + + if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) + list(APPEND BDDISASM_COMMON_COMPILE_OPTIONS + -Wall + -Wextra + -Wshadow + -Wformat-security + -Wstrict-overflow=2 + -Wstrict-prototypes + -Wwrite-strings + -Winit-self + -Werror=format-security + -Werror=implicit-function-declaration + -fno-omit-frame-pointer + -g3 + -gdwarf-4 + -grecord-gcc-switches + -march=native + ) + endif () if (CMAKE_C_COMPILER_ID STREQUAL "GNU") list(APPEND BDDISASM_COMMON_COMPILE_OPTIONS - -Wduplicated-cond - -Wno-discarded-qualifiers) + -Wno-discarded-qualifiers + ) + + if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) + list(APPEND BDDISASM_COMMON_COMPILE_OPTIONS + -Wduplicated-cond + ) + endif () endif () endif () From bfe6311140c1b2cfc2af63f8e68b18990eb9e38c Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Mon, 18 Aug 2025 18:04:27 +0300 Subject: [PATCH 2/5] build: Silence `Wgnu-anonymous-struct` and `Wnested-anon-types` --- inc/bdx86_core.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/inc/bdx86_core.h b/inc/bdx86_core.h index 167784c..7f442ef 100644 --- a/inc/bdx86_core.h +++ b/inc/bdx86_core.h @@ -13,6 +13,11 @@ #include "bdx86_constants.h" #include "bdx86_cpuidflags.h" +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu-anonymous-struct" +#pragma clang diagnostic ignored "-Wnested-anon-types" +#endif #ifdef _MSC_VER #pragma warning(push) @@ -1955,4 +1960,8 @@ NdInitContext( #pragma warning(pop) #endif +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + #endif // BDX86_CORE_H From 3d6b8beb0bf731c3e5317819fd0d270b94b25210 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Mon, 18 Aug 2025 18:05:03 +0300 Subject: [PATCH 3/5] build: Silence `Wlanguage-extension-token` --- inc/bddisasm_types.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inc/bddisasm_types.h b/inc/bddisasm_types.h index 7916561..dd68893 100644 --- a/inc/bddisasm_types.h +++ b/inc/bddisasm_types.h @@ -5,6 +5,10 @@ #ifndef BDDISASM_TYPES_H #define BDDISASM_TYPES_H +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wlanguage-extension-token" +#endif #if defined(_MSC_VER) || defined(__ICC) || defined(__INTEL_COMPILER) @@ -104,4 +108,8 @@ typedef ND_UINT8 ND_BOOL; #define ND_TRUE (1) #define ND_FALSE (0) +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + #endif // BDDISASM_TYPES_H From a161ef08c6e36cee0257c97709b215a2fa46bd51 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Mon, 18 Aug 2025 18:14:30 +0300 Subject: [PATCH 4/5] Update ci.yml --- .github/workflows/ci.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9fafb9..e3c21b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -158,6 +158,25 @@ jobs: ninja cd - + Windows-clang-build: + + runs-on: winodws-latest + + permissions: read-all + steps: + - uses: actions/checkout@v4 + - name: Install Clang + uses: egor-tensin/setup-clang@ef434b41eb33a70396fb336b1bae39c76d740c3d # v1.4 + - uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # master + - name: Build libs + run: | + mkdir build + cd build + cmake .. -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + # disasmtool can not be built with clang on Windows at the moment. + ninja bddisasm bdshemu + cd - + Macos-build: runs-on: macos-latest From 29bee6bdf1b7ee81f8ac2a35b75dfd28029a2752 Mon Sep 17 00:00:00 2001 From: Anichitei Ionel-Cristinel <49393881+ianichitei@users.noreply.github.com> Date: Mon, 18 Aug 2025 18:25:00 +0300 Subject: [PATCH 5/5] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3c21b5..83ad1a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,7 +160,7 @@ jobs: Windows-clang-build: - runs-on: winodws-latest + runs-on: windows-latest permissions: read-all steps: