From 9e0e31132a2ae11675af9762bcabff4dd0010c9f Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 30 Jul 2025 20:59:28 +0200 Subject: [PATCH] [icc] fix intel c++ compiler errors (#146) Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/146 Co-authored-by: lizzie Co-committed-by: lizzie --- docs/build/Linux.md | 31 ++-- src/CMakeLists.txt | 146 +++++++++--------- src/audio_core/sink/sink_stream.cpp | 4 +- .../resources/npad/npad_vibration.cpp | 4 +- src/input_common/drivers/sdl_driver.cpp | 14 +- src/input_common/input_engine.cpp | 4 +- .../spirv/emit_spirv_floating_point.cpp | 6 +- .../frontend/maxwell/decode.cpp | 10 +- .../frontend/maxwell/opcodes.cpp | 20 +-- 9 files changed, 125 insertions(+), 114 deletions(-) diff --git a/docs/build/Linux.md b/docs/build/Linux.md index 4aad874ac2..8ec4a91086 100644 --- a/docs/build/Linux.md +++ b/docs/build/Linux.md @@ -33,13 +33,12 @@ Dependencies are listed here as commands that can be copied/pasted. Of course, t - Proper wayland support requires `qt6-wayland` - GCC 11 or later is required. - Ubuntu / Linux Mint / Debian: - - `sudo apt-get install autoconf cmake g++-11 gcc-11 git glslang-tools libasound2 libboost-context-dev libglu1-mesa-dev libhidapi-dev libpulse-dev libtool libudev-dev libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxext-dev libxkbcommon-x11-0 mesa-common-dev nasm ninja-build qtbase6-dev qtbase6-private-dev qtwebengine6-dev qtmultimedia6-dev libmbedtls-dev catch2 libfmt-dev liblz4-dev nlohmann-json3-dev libzstd-dev libssl-dev libavfilter-dev libavcodec-dev libswscale-dev` + - `sudo apt-get install autoconf cmake g++ gcc git glslang-tools libasound2 libboost-context-dev libglu1-mesa-dev libhidapi-dev libpulse-dev libtool libudev-dev libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxext-dev libxkbcommon-x11-0 mesa-common-dev nasm ninja-build qtbase6-dev libmbedtls-dev catch2 libfmt-dev liblz4-dev nlohmann-json3-dev libzstd-dev libssl-dev libavfilter-dev libavcodec-dev libswscale-dev pkg-config zlib1g-dev` - Ubuntu 22.04, Linux Mint 20, or Debian 12 or later is required. - - Users need to manually specify building with QT Web Engine enabled. This is done using the parameter `-DYUZU_USE_QT_WEB_ENGINE=ON` when running CMake. - - Users need to manually specify building with GCC 11. This can be done by adding the parameters `-DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11` when running CMake. i.e. + - Users need to manually specify building with QT Web Engine enabled. This is done using the parameter `-DYUZU_USE_QT_WEB_ENGINE=ON` when running CMake. - Users need to manually disable building SDL2 from externals if they intend to use the version provided by their system by adding the parameters `-DYUZU_USE_EXTERNAL_SDL2=OFF` -``` +```sh git submodule update --init --recursive cmake .. -GNinja -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 ``` @@ -57,10 +56,10 @@ cmake .. -GNinja -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 **Master:** - ```bash - git clone --recursive https://git.eden-emu.dev/eden-emu/eden - cd eden - ``` +```bash +git clone --recursive https://git.eden-emu.dev/eden-emu/eden +cd eden +``` The `--recursive` option automatically clones the required Git submodules. @@ -124,12 +123,12 @@ After building, an AppImage can be packaged via `.ci/linux/package.sh`. This scr After building, the binaries `eden` and `eden-cmd` (depending on your build options) will end up in `build/bin/`. - ```bash - # SDL - cd build/bin/ - ./eden-cmd +```bash +# SDL +cd build/bin/ +./eden-cmd - # Qt - cd build/bin/ - ./eden - ``` +# Qt +cd build/bin/ +./eden +``` diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4308534f12..647db3ca76 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,5 @@ +# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2018 yuzu Emulator Project # SPDX-License-Identifier: GPL-2.0-or-later @@ -88,26 +90,26 @@ if (MSVC) /wd4702 # unreachable code (when used with LTO) ) -if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS) - # when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format - # Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21 - add_compile_options(/Z7) - # Avoid D9025 warning - string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") -else() - add_compile_options(/Zi) -endif() + if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS) + # when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format + # Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21 + add_compile_options(/Z7) + # Avoid D9025 warning + string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + else() + add_compile_options(/Zi) + endif() -if (ARCHITECTURE_x86_64) - add_compile_options(/QIntel-jcc-erratum) -endif() + if (ARCHITECTURE_x86_64) + add_compile_options(/QIntel-jcc-erratum) + endif() -# /GS- - No stack buffer overflow checks -add_compile_options("$<$:/GS->") + # /GS- - No stack buffer overflow checks + add_compile_options("$<$:/GS->") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE) -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE) + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) else() add_compile_options( -fwrapv @@ -124,63 +126,63 @@ else() -Wno-missing-field-initializers ) -if (CMAKE_CXX_COMPILER_ID MATCHES Clang) # Clang or AppleClang - add_compile_options( - -Wno-braced-scalar-init - -Wno-unused-private-field - -Wno-nullability-completeness - -Werror=shadow-uncaptured-local - -Werror=implicit-fallthrough - -Werror=type-limits - ) -endif() - -if (ARCHITECTURE_x86_64) - add_compile_options("-mcx16") -endif() - -if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) - add_compile_options("-stdlib=libc++") -endif() - -# GCC bugs -if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # These diagnostics would be great if they worked, but are just completely broken - # and produce bogus errors on external libraries like fmt. - add_compile_options( - -Wno-array-bounds - -Wno-stringop-overread - -Wno-stringop-overflow - ) -endif() - -# Set file offset size to 64 bits. -# -# On modern Unixes, this is typically already the case. The lone exception is -# glibc, which may default to 32 bits. glibc allows this to be configured -# by setting _FILE_OFFSET_BITS. -if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW) - add_definitions(-D_FILE_OFFSET_BITS=64) -endif() - -if (MINGW) - add_definitions(-DMINGW_HAS_SECURE_API) - add_compile_options("-msse4.1") - - if (MINGW_STATIC_BUILD) - add_definitions(-DQT_STATICPLUGIN) - add_compile_options("-static") + if (CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES IntelLLVM) # Clang or AppleClang + add_compile_options( + -Wno-braced-scalar-init + -Wno-unused-private-field + -Wno-nullability-completeness + -Werror=shadow-uncaptured-local + -Werror=implicit-fallthrough + -Werror=type-limits + ) endif() -endif() -if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW) - # GNU ar: Create thin archive files. - # Requires binutils-2.19 or later. - set(CMAKE_C_ARCHIVE_CREATE " qcTP ") - set(CMAKE_C_ARCHIVE_APPEND " qTP ") - set(CMAKE_CXX_ARCHIVE_CREATE " qcTP ") - set(CMAKE_CXX_ARCHIVE_APPEND " qTP ") -endif() + if (ARCHITECTURE_x86_64) + add_compile_options("-mcx16") + endif() + + if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) + add_compile_options("-stdlib=libc++") + endif() + + # GCC bugs + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # These diagnostics would be great if they worked, but are just completely broken + # and produce bogus errors on external libraries like fmt. + add_compile_options( + -Wno-array-bounds + -Wno-stringop-overread + -Wno-stringop-overflow + ) + endif() + + # Set file offset size to 64 bits. + # + # On modern Unixes, this is typically already the case. The lone exception is + # glibc, which may default to 32 bits. glibc allows this to be configured + # by setting _FILE_OFFSET_BITS. + if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW) + add_definitions(-D_FILE_OFFSET_BITS=64) + endif() + + if (MINGW) + add_definitions(-DMINGW_HAS_SECURE_API) + add_compile_options("-msse4.1") + + if (MINGW_STATIC_BUILD) + add_definitions(-DQT_STATICPLUGIN) + add_compile_options("-static") + endif() + endif() + + if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW) + # GNU ar: Create thin archive files. + # Requires binutils-2.19 or later. + set(CMAKE_C_ARCHIVE_CREATE " qcTP ") + set(CMAKE_C_ARCHIVE_APPEND " qTP ") + set(CMAKE_CXX_ARCHIVE_CREATE " qcTP ") + set(CMAKE_CXX_ARCHIVE_APPEND " qTP ") + endif() endif() add_subdirectory(common) diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 0a98eb31e2..c0078e6ddc 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -44,7 +46,7 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::span samples) { // Center = 0.596 // LFE = 0.354 // Back = 0.707 - static constexpr std::array down_mix_coeff{1.0, 0.596f, 0.354f, 0.707f}; + static constexpr std::array down_mix_coeff{1.0f, 0.596f, 0.354f, 0.707f}; for (u32 read_index = 0, write_index = 0; read_index < samples.size(); read_index += system_channels, write_index += device_channels) { diff --git a/src/hid_core/resources/npad/npad_vibration.cpp b/src/hid_core/resources/npad/npad_vibration.cpp index 4c103889a6..f70876360f 100644 --- a/src/hid_core/resources/npad/npad_vibration.cpp +++ b/src/hid_core/resources/npad/npad_vibration.cpp @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later @@ -69,7 +71,7 @@ Result NpadVibration::GetVibrationMasterVolume(f32& out_volume) const { Result NpadVibration::BeginPermitVibrationSession(u64 aruid) { std::scoped_lock lock{mutex}; session_aruid = aruid; - volume = 1.0; + volume = 1.0f; return ResultSuccess; } diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index ef898527ec..51169c6f2b 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2018 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -110,12 +112,12 @@ public: bool RumblePlay(const Common::Input::VibrationStatus vibration) { constexpr u32 rumble_max_duration_ms = 2000; - constexpr f32 low_start_sensitivity_limit = 140.0; - constexpr f32 low_width_sensitivity_limit = 400.0; - constexpr f32 high_start_sensitivity_limit = 200.0; - constexpr f32 high_width_sensitivity_limit = 700.0; + constexpr f32 low_start_sensitivity_limit = 140.0f; + constexpr f32 low_width_sensitivity_limit = 400.0f; + constexpr f32 high_start_sensitivity_limit = 200.0f; + constexpr f32 high_width_sensitivity_limit = 700.0f; // Try to provide some feeling of the frequency by reducing the amplitude depending on it. - f32 low_frequency_scale = 1.0; + f32 low_frequency_scale = 1.0f; if (vibration.low_frequency > low_start_sensitivity_limit) { low_frequency_scale = std::max(1.0f - (vibration.low_frequency - low_start_sensitivity_limit) / @@ -124,7 +126,7 @@ public: } f32 low_amplitude = vibration.low_amplitude * low_frequency_scale; - f32 high_frequency_scale = 1.0; + f32 high_frequency_scale = 1.0f; if (vibration.high_frequency > high_start_sensitivity_limit) { high_frequency_scale = std::max(1.0f - (vibration.high_frequency - high_start_sensitivity_limit) / diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index e4c5b5b3c7..1e24b588e3 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -249,7 +251,7 @@ void InputEngine::ResetButtonState() { void InputEngine::ResetAnalogState() { for (const auto& controller : controller_list) { for (const auto& axis : controller.second.axes) { - SetAxis(controller.first, axis.first, 0.0); + SetAxis(controller.first, axis.first, 0.0f); } } } diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp index c740c96fb3..d921913b4a 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -165,8 +167,8 @@ Id EmitFPSaturate16(EmitContext& ctx, Id value) { } Id EmitFPSaturate32(EmitContext& ctx, Id value) { - const Id zero{ctx.Const(f32{0.0})}; - const Id one{ctx.Const(f32{1.0})}; + const Id zero{ctx.Const(f32{0.0f})}; + const Id one{ctx.Const(f32{1.0f})}; return Clamp(ctx, ctx.F32[1], value, zero, one); } diff --git a/src/shader_recompiler/frontend/maxwell/decode.cpp b/src/shader_recompiler/frontend/maxwell/decode.cpp index 774f65bc59..47111a0501 100644 --- a/src/shader_recompiler/frontend/maxwell/decode.cpp +++ b/src/shader_recompiler/frontend/maxwell/decode.cpp @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -51,7 +53,8 @@ struct InstEncoding { MaskValue mask_value; Opcode opcode; }; -constexpr std::array UNORDERED_ENCODINGS{ +constexpr auto SortedEncodings() { + std::array encodings{ #define INST(name, cute, encode) \ InstEncoding{ \ .mask_value{MaskValueFromEncoding(encode)}, \ @@ -59,10 +62,7 @@ constexpr std::array UNORDERED_ENCODINGS{ }, #include "maxwell.inc" #undef INST -}; - -constexpr auto SortedEncodings() { - std::array encodings{UNORDERED_ENCODINGS}; + }; std::ranges::sort(encodings, [](const InstEncoding& lhs, const InstEncoding& rhs) { return std::popcount(lhs.mask_value.mask) > std::popcount(rhs.mask_value.mask); }); diff --git a/src/shader_recompiler/frontend/maxwell/opcodes.cpp b/src/shader_recompiler/frontend/maxwell/opcodes.cpp index 2d5c4d79e6..82a4b01114 100644 --- a/src/shader_recompiler/frontend/maxwell/opcodes.cpp +++ b/src/shader_recompiler/frontend/maxwell/opcodes.cpp @@ -1,25 +1,25 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include "shader_recompiler/exception.h" #include "shader_recompiler/frontend/maxwell/opcodes.h" namespace Shader::Maxwell { -namespace { -constexpr std::array NAME_TABLE{ + +const char* NameOf(Opcode opcode) { + constexpr const char* NAME_TABLE[] = { #define INST(name, cute, encode) cute, #include "maxwell.inc" #undef INST -}; -} // Anonymous namespace - -const char* NameOf(Opcode opcode) { - if (static_cast(opcode) >= NAME_TABLE.size()) { - throw InvalidArgument("Invalid opcode with raw value {}", static_cast(opcode)); - } - return NAME_TABLE[static_cast(opcode)]; + }; + if (size_t(opcode) >= sizeof(NAME_TABLE) / sizeof(NAME_TABLE[0])) + throw InvalidArgument("Invalid opcode with raw value {}", int(opcode)); + return NAME_TABLE[size_t(opcode)]; } } // namespace Shader::Maxwell