From d9e1d6a0e6971398a13c959d07cfb5eb8f75dbe1 Mon Sep 17 00:00:00 2001
From: Axel Heider <axel.heider@codasip.com>
Date: Tue, 9 Apr 2024 19:42:02 +0200
Subject: [PATCH] support compiling with clang

Signed-off-by: Axel Heider <axel.heider@codasip.com>
---
 settings.cmake | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/settings.cmake b/settings.cmake
index 54af1d77..eb53c4ab 100644
--- a/settings.cmake
+++ b/settings.cmake
@@ -64,7 +64,14 @@ if(NOT Sel4benchAllowSettingsOverride)
     # This option is controlled by ApplyCommonReleaseVerificationSettings
     mark_as_advanced(CMAKE_BUILD_TYPE)
     if(RELEASE)
-        if(NOT KernelArchRiscV)
+        # Known issues with KernelFWholeProgram ('-fwhole-program'):
+        # - the RISC-V kernel build with gcc currently fails due to a missing
+        #   compiler runtime helper function.
+        # - this option is not supposed by 'clang' at all. Note that we can't
+        #   check CMAKE_C_COMPILER_ID here, because it is empty, as this file
+        #   might get processed before CMake does any compiler evaluation. Thus,
+        #   the only option is checking if TRIPLE is set or not.
+        if((NOT KernelArchRiscV) AND (TRIPLE STREQUAL ""))
             set(KernelFWholeProgram ON CACHE BOOL "" FORCE)
         endif()
     endif()