Skip to content

Commit 6271bad

Browse files
committed
new implementation
1 parent 9f44812 commit 6271bad

File tree

9 files changed

+457
-110
lines changed

9 files changed

+457
-110
lines changed

CMakeLists.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,14 @@ endif()
7070
# FIXME: this reports an unused architecture if only vms are built.
7171
# We may not be able to avoid this for now without doing a huge rewrite
7272
# of this file.
73-
if (NOT (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP))
74-
message(NOTICE "You can safely ignore the following reported architecture, it is not used.")
75-
endif()
76-
include(DaemonPlatform)
77-
7873
# FIXME: this reports an unused compiler if only vms are built.
7974
# We cannot avoid this for now without doing a huge rewrite of this files
8075
# since we also set useless flags using informations provided by this.
8176
if (NOT (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP))
77+
message(NOTICE "You can safely ignore the following reported architecture, it is not used.")
8278
message(NOTICE "You can safely ignore the following reported compilers, they are unused.")
8379
endif()
84-
include(DaemonCompiler)
80+
include(DaemonPlatform)
8581

8682
if (Daemon_OUT)
8783
set(CMAKE_CURRENT_BINARY_DIR ${Daemon_OUT})
@@ -438,9 +434,11 @@ function(ADD_PRECOMPILED_HEADER Target)
438434
set(Header ${COMMON_DIR}/Common.h)
439435

440436
# Compiler-specific PCH support
441-
if (DAEMON_COMPILER_IS_GNUCXX OR DAEMON_COMPILER_IS_CLANGCXX OR NACL)
437+
if (DAEMON_CXX_COMPILER_GCC_COMPATIBILITY OR DAEMON_CXX_COMPILER_Clang_COMPATIBILITY)
438+
# There is a bug in CMake: if we set CMAKE_CXX_COMPILER to "zig;c++",
439+
# only "zig" is returned when using the ${CMAKE_CXX_COMPILER} variable.
442440
add_custom_command(OUTPUT "${OBJ_DIR}/${Target}.h.gch"
443-
COMMAND ${PNACLPYTHON_PREFIX2} ${CMAKE_CXX_COMPILER} ${CUSTOM_CXX_COMPILER_SUBCOMMAND}
441+
COMMAND ${PNACLPYTHON_PREFIX2} ${CMAKE_CXX_COMPILER} ${DAEMON_CXX_COMPILER_SUBCOMMAND}
444442
${Defs} ${Flags} -x c++-header ${Header} -o "${OBJ_DIR}/${Target}.h.gch"
445443
DEPENDS ${Header}
446444
IMPLICIT_DEPENDS CXX ${Header}
@@ -450,7 +448,7 @@ function(ADD_PRECOMPILED_HEADER Target)
450448
add_dependencies(${Target} ${Target}-pch)
451449

452450
# PNaCl clang doesn't support -include-pch properly
453-
if (DAEMON_COMPILER_IS_CLANGCXX AND NOT NACL)
451+
if (NOT DAEMON_CXX_COMPILER_NAME STREQUAL "PNaCl")
454452
set_property(TARGET ${Target} APPEND PROPERTY COMPILE_OPTIONS "-include-pch;${OBJ_DIR}/${Target}.h.gch")
455453
else()
456454
set_property(TARGET ${Target} APPEND PROPERTY COMPILE_OPTIONS "-include;${OBJ_DIR}/${Target}.h;-Winvalid-pch")

cmake/DaemonCompiler.cmake

Lines changed: 0 additions & 95 deletions
This file was deleted.

cmake/DaemonFlags.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ else()
199199

200200
if (ARCH STREQUAL "amd64")
201201
# K8 or EM64T minimum: AMD Athlon 64 ClawHammer, Intel Xeon Nocona, Intel Pentium 4 model F (Prescott revision EO), VIA Nano.
202-
if ("${DAEMON_CXX_COMPILER_ID}" STREQUAL "Intel")
202+
if ("${DAEMON_CXX_COMPILER_NAME}" STREQUAL "ICC")
203203
set(GCC_GENERIC_ARCH "pentium4")
204-
elseif ("${DAEMON_CXX_COMPILER_ID}" STREQUAL "Zig")
204+
elseif ("${DAEMON_CXX_COMPILER_NAME}" STREQUAL "Zig")
205205
set(GCC_GENERIC_ARCH "x86_64")
206206
else()
207207
set(GCC_GENERIC_ARCH "x86-64")
@@ -227,7 +227,7 @@ else()
227227
option(USE_CPU_GENERIC_ARCHITECTURE "Enforce generic -march and -mtune compiler options" ON)
228228
if (USE_CPU_GENERIC_ARCHITECTURE)
229229
set_c_cxx_flag("-march=${GCC_GENERIC_ARCH}")
230-
if ("${DAEMON_CXX_COMPILER_ID}" STREQUAL "Zig")
230+
if ("${DAEMON_CXX_COMPILER_NAME}" STREQUAL "Zig")
231231
set_c_cxx_flag("-mtune=${GCC_GENERIC_ARCH}")
232232
else()
233233
set_c_cxx_flag("-mtune=generic")

cmake/DaemonGame.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626

2727
include_directories(${MOUNT_DIR} ${LIB_DIR} ${LIB_DIR}/zlib)
28-
include(DaemonPlatform)
29-
include(DaemonNacl)
3028

3129
# Do not report unused native compiler if native vms are not built.
3230
# If only NACL vms are built, this will be reported in chainloaded build.
3331
if (BUILD_GAME_NATIVE_DLL OR BUILD_GAME_NATIVE_EXE OR NACL)
34-
include(DaemonCompiler)
32+
include(DaemonPlatform)
33+
include(DaemonNacl)
3534
include(DaemonFlags)
3635
endif()
3736

cmake/DaemonPlatform.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ else()
3939
endif()
4040

4141
include("${DAEMON_DIR}/tools/DaemonArchitecture/DaemonArchitecture.cmake")
42+
include("${DAEMON_DIR}/tools/DaemonCompiler/DaemonCompiler.cmake")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! /usr/bin/env bash
2+
3+
# test script
4+
5+
"${1}" DaemonCompiler.cpp -o /dev/null 2>&1 \
6+
| grep '###REPORT###' \
7+
| sed -e 's/.*(###REPORT###(//;s/)###REPORT###(/=/;s/)###REPORT###).*//'
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#define STRING(s) #s
2+
#define XSTRING(s) STRING(s)
3+
4+
#define REPORT(key, value) \
5+
"(###REPORT###(DAEMON_COMPILER_" key ")###REPORT###(" value ")###REPORT###)"
6+
#define REPORT_VERSION_3(name, major, minor, patch) \
7+
REPORT(name "_VERSION", XSTRING(major) "." XSTRING(minor) "." XSTRING(patch))
8+
#define REPORT_VERSION_2(name, major, minor) \
9+
REPORT(name "_VERSION", XSTRING(major) "." XSTRING(minor))
10+
#define REPORT_VERSION_1(name, major) \
11+
REPORT(name "_VERSION", XSTRING(major))
12+
#define REPORT_VERSION_STRING(name, value) \
13+
REPORT(name "_VERSION_STRING", value)
14+
#define REPORT_COMPATIBILITY(name) \
15+
REPORT(name "_COMPATIBILITY", "ON")
16+
#define REPORT_NAME(name) \
17+
REPORT("NAME", name)
18+
19+
// GCC
20+
21+
#if defined(__GNUC__)
22+
#pragma message(REPORT_COMPATIBILITY("GCC"))
23+
#endif
24+
25+
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
26+
#pragma message(REPORT_VERSION_3("GCC", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__))
27+
#endif
28+
29+
// Clang
30+
31+
#if defined(__clang__)
32+
#pragma message(REPORT_COMPATIBILITY("Clang"))
33+
#endif
34+
35+
#if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
36+
#pragma message(REPORT_VERSION_3("Clang", __clang_major__, __clang_minor__, __clang_patchlevel__))
37+
#endif
38+
39+
#if defined(__clang_version__)
40+
#pragma message(REPORT_VERSION_STRING("Clang", __clang_version__))
41+
#endif
42+
43+
// ICC
44+
45+
#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE)
46+
#pragma message(REPORT_VERSION_2("ICC", __INTEL_COMPILER, __INTEL_COMPILER_UPDATE))
47+
#elif defined(_ICC)
48+
#pragma message(REPORT_VERSION_1("ICC", __ICC))
49+
#endif
50+
51+
// ICX
52+
53+
#if defined(__INTEL_CLANG_COMPILER)
54+
// This would require extra parsing since it's the form 20240000 for 2024.0.0
55+
#pragma message(REPORT_VERSION_1("ICX", __INTEL_CLANG_COMPILER))
56+
#elif defined(__INTEL_LLVM_COMPILER)
57+
// This would require extra parsing since it's the form 20240000 for 2024.0.0
58+
#pragma message(REPORT_VERSION_1("ICX", __INTEL_LLVM_COMPILER))
59+
#endif
60+
61+
// ArmClang
62+
63+
#if defined(__armclang_major__) && defined(__armclang_minor__)
64+
#pragma message(REPORT_VERSION_2("ArmClang", __armclang_major__, __armclang_minor__)
65+
#endif
66+
67+
#if defined(__armclang_version__)
68+
#pragma message(REPORT_VERSION_STRING("ArmClang", __armclang_version__))
69+
#endif
70+
71+
// Generic
72+
73+
#if defined(__VERSION__)
74+
#pragma message(REPORT_VERSION_STRING("generic", __VERSION__))
75+
#endif
76+
77+
// Selection
78+
79+
// There is no Zig specific define.
80+
81+
// There is no AOCC specific define, we should parse other defines:
82+
// #define __VERSION__ "AMD Clang 14.0.6 (CLANG: AOCC_4.0.0-Build#434 2022_10_28)"
83+
// #define __clang_version__ "14.0.6 (CLANG: AOCC_4.0.0-Build#434 2022_10_28)"
84+
85+
#if defined(__INTEL_COMPILER) || defined(__ICC)
86+
#pragma message(REPORT_NAME("ICC")) // Intel
87+
#elif defined(__INTEL_CLANG_COMPILER) || defined(__INTEL_LLVM_COMPILER)
88+
#pragma message(REPORT_NAME("ICX")) // IntelLLVM
89+
#elif defined(__wasi__)
90+
#pragma message(REPORT_NAME("WASI"))
91+
#elif defined(__saigo__)
92+
#pragma message(REPORT_NAME("Saigo"))
93+
#elif defined(__pnacl__)
94+
#pragma message(REPORT_NAME("PNaCl"))
95+
#elif defined(__MINGW64__) || defined(__MINGW32__)
96+
#pragma message(REPORT_NAME("MingGW"))
97+
#elif defined(__armclang_major__) || defined(__armclang_version__)
98+
#pragma message(REPORT_NAME("ArmClang"))
99+
#elif defined(__clang__)
100+
#pragma message(REPORT_NAME("Clang"))
101+
#elif defined(__GNUC__)
102+
#pragma message(REPORT_NAME("GCC")) // GNU
103+
#else
104+
#pragma message(REPORT_NAME("Unknown"))
105+
#endif
106+
107+
// Make the compilation succeeds if architecture is supported.
108+
int main(int argc, char** argv) {
109+
return 0;
110+
}

0 commit comments

Comments
 (0)