MSBuild: Support building with clang-cl

This commit is contained in:
Stenzek 2023-08-21 22:38:55 +10:00
parent bf15d13eb7
commit 76b5b8ad06
15 changed files with 862 additions and 34 deletions

View File

@ -2,6 +2,10 @@
#include <stdint.h> #include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h>
#endif
inline static uint32_t bit_length(uint32_t n) { inline static uint32_t bit_length(uint32_t n) {
const uint32_t n_minus_1 = n - 1; const uint32_t n_minus_1 = n - 1;

View File

@ -28,6 +28,9 @@
// see Include/shared/winapifamily.h in the Windows Kit // see Include/shared/winapifamily.h in the Windows Kit
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API))) #if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
#ifndef WINAPI_FAMILY_ONE_PARTITION
#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition)
#endif
#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP) #if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
#define IOWIN32_USING_WINRT_API 1 #define IOWIN32_USING_WINRT_API 1
#endif #endif

View File

@ -19,7 +19,9 @@
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;_CRT_INTERNAL_NONSTDC_NAMES;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_HAS_EXCEPTIONS=0;_CRT_INTERNAL_NONSTDC_NAMES;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalOptions>/Zc:__cplusplus /Zo /utf-8 %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions Condition="!$(Configuration.Contains(Clang))">/Zc:__cplusplus /Zo /utf-8 %(AdditionalOptions)</AdditionalOptions>
<!-- Force ThinLTO for Release builds, MSVC doesn't seem to do it otherwise. -->
<AdditionalOptions Condition="$(Configuration.Contains(Clang)) And $(Configuration.Contains(ReleaseLTCG))"> -flto=thin %(AdditionalOptions)</AdditionalOptions>
<ExceptionHandling>false</ExceptionHandling> <ExceptionHandling>false</ExceptionHandling>
</ClCompile> </ClCompile>
<Link> <Link>

View File

@ -49,6 +49,54 @@
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="DebugFast-Clang|ARM64">
<Configuration>DebugFast-Clang</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="DebugFast-Clang|Win32">
<Configuration>DebugFast-Clang</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="DebugFast-Clang|x64">
<Configuration>DebugFast-Clang</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug-Clang|ARM64">
<Configuration>Debug-Clang</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug-Clang|Win32">
<Configuration>Debug-Clang</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug-Clang|x64">
<Configuration>Debug-Clang</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseLTCG-Clang|ARM64">
<Configuration>ReleaseLTCG-Clang</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseLTCG-Clang|Win32">
<Configuration>ReleaseLTCG-Clang</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseLTCG-Clang|x64">
<Configuration>ReleaseLTCG-Clang</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release-Clang|ARM64">
<Configuration>Release-Clang</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release-Clang|Win32">
<Configuration>Release-Clang</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release-Clang|x64">
<Configuration>Release-Clang</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<CharacterSet>NotSet</CharacterSet> <CharacterSet>NotSet</CharacterSet> <!-- TODO: Change to Unicode -->
<PlatformToolset>v143</PlatformToolset> <PlatformToolset Condition="!$(Configuration.Contains(Clang))">v143</PlatformToolset>
<PlatformToolset Condition="$(Configuration.Contains(Clang))">ClangCL</PlatformToolset>
<SpectreMitigation>false</SpectreMitigation> <SpectreMitigation>false</SpectreMitigation>
</PropertyGroup> </PropertyGroup>

View File

@ -989,15 +989,7 @@ void RA_Shutdown()
// Call shutdown on toolchain // Call shutdown on toolchain
if (_RA_Shutdown != nullptr) if (_RA_Shutdown != nullptr)
{ {
#ifdef __cplusplus _RA_Shutdown();
try {
#endif
_RA_Shutdown();
#ifdef __cplusplus
}
catch (std::runtime_error&) {
}
#endif
} }
// Clear func ptrs // Clear func ptrs

View File

@ -129,9 +129,9 @@ extern "C" {
*/ */
#ifndef XXH_DISPATCH_AVX2 #ifndef XXH_DISPATCH_AVX2
# if (defined(__GNUC__) && (__GNUC__ > 4)) /* GCC 5.0+ */ \ # if (defined(__GNUC__) && (__GNUC__ > 4)) /* GCC 5.0+ */ \
|| (defined(_MSC_VER) && _MSC_VER >= 1900) /* VS 2015+ */ \ || (defined(_MSC_VER) && _MSC_VER >= 1900 && !defined(__clang__)) /* VS 2015+ */ \
|| (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180030501) /* VS 2013 Update 2 */ \ || (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180030501 && !defined(__clang__)) /* VS 2013 Update 2 */ \
|| XXH_HAS_INCLUDE(<avx2intrin.h>) /* GCC/Clang internal header */ || (XXH_HAS_INCLUDE(<avx2intrin.h>) && !defined(_MSC_VER)) /* GCC/Clang internal header */
# define XXH_DISPATCH_AVX2 1 /* enable dispatch towards AVX2 */ # define XXH_DISPATCH_AVX2 1 /* enable dispatch towards AVX2 */
# else # else
# define XXH_DISPATCH_AVX2 0 # define XXH_DISPATCH_AVX2 0
@ -154,8 +154,8 @@ extern "C" {
#ifndef XXH_DISPATCH_AVX512 #ifndef XXH_DISPATCH_AVX512
# if (defined(__GNUC__) \ # if (defined(__GNUC__) \
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))) /* GCC 4.9+ */ \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))) /* GCC 4.9+ */ \
|| (defined(_MSC_VER) && _MSC_VER >= 1910) /* VS 2017+ */ \ || (defined(_MSC_VER) && _MSC_VER >= 1910 && !defined(__clang__)) /* VS 2017+ */ \
|| XXH_HAS_INCLUDE(<avx512fintrin.h>) /* GCC/Clang internal header */ || (XXH_HAS_INCLUDE(<avx512fintrin.h>) && !defined(_MSC_VER)) /* GCC/Clang internal header */
# define XXH_DISPATCH_AVX512 1 /* enable dispatch towards AVX512 */ # define XXH_DISPATCH_AVX512 1 /* enable dispatch towards AVX512 */
# else # else
# define XXH_DISPATCH_AVX512 0 # define XXH_DISPATCH_AVX512 0

File diff suppressed because it is too large Load Diff

View File

@ -129,8 +129,8 @@ static LONG NTAPI ExceptionHandler(PEXCEPTION_POINTERS exi)
{ {
char line[1024]; char line[1024];
DWORD written; DWORD written;
std::snprintf(line, countof(line), "Exception 0x%08X at 0x%p\n", exi->ExceptionRecord->ExceptionCode, std::snprintf(line, countof(line), "Exception 0x%08X at 0x%p\n",
exi->ExceptionRecord->ExceptionAddress); static_cast<unsigned>(exi->ExceptionRecord->ExceptionCode), exi->ExceptionRecord->ExceptionAddress);
WriteFile(hFile, line, static_cast<DWORD>(std::strlen(line)), &written, nullptr); WriteFile(hFile, line, static_cast<DWORD>(std::strlen(line)), &written, nullptr);
} }
@ -207,9 +207,13 @@ bool Install()
return false; return false;
} }
void SetWriteDirectory(const std::string_view& dump_directory) {} void SetWriteDirectory(const std::string_view& dump_directory)
{
}
void Uninstall() {} void Uninstall()
{
}
} // namespace CrashHandler } // namespace CrashHandler

View File

@ -424,7 +424,7 @@ public:
LPSTR m_szSymPath; LPSTR m_szSymPath;
#pragma pack(push, 8) #pragma pack(push, 8)
typedef struct IMAGEHLP_MODULE64_V3 struct IMAGEHLP_MODULE64_V3
{ {
DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64)
DWORD64 BaseOfImage; // base load address of module DWORD64 BaseOfImage; // base load address of module
@ -453,7 +453,7 @@ public:
BOOL Publics; // contains public symbols BOOL Publics; // contains public symbols
}; };
typedef struct IMAGEHLP_MODULE64_V2 struct IMAGEHLP_MODULE64_V2
{ {
DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64)
DWORD64 BaseOfImage; // base load address of module DWORD64 BaseOfImage; // base load address of module
@ -805,6 +805,8 @@ private:
case 8: //SymVirtual: case 8: //SymVirtual:
szSymType = "Virtual"; szSymType = "Virtual";
break; break;
default:
break;
} }
} }
LPCSTR pdbName = Module.LoadedImageName; LPCSTR pdbName = Module.LoadedImageName;

View File

@ -336,7 +336,7 @@ void Timer::NanoSleep(std::uint64_t ns)
if (SetWaitableTimer(timer, &due_time, 0, nullptr, nullptr, FALSE)) if (SetWaitableTimer(timer, &due_time, 0, nullptr, nullptr, FALSE))
WaitForSingleObject(timer, INFINITE); WaitForSingleObject(timer, INFINITE);
else else
std::fprintf(stderr, "SetWaitableTimer() failed: %08X\n", GetLastError()); std::fprintf(stderr, "SetWaitableTimer() failed: %08X\n", static_cast<unsigned>(GetLastError()));
} }
else else
{ {

View File

@ -1495,11 +1495,12 @@ void FullscreenUI::DrawInputBindingWindow()
if (ImGui::BeginPopupModal(title, nullptr, if (ImGui::BeginPopupModal(title, nullptr,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoInputs)) ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoInputs))
{ {
ImGui::TextWrapped( ImGui::TextWrapped("%s", SmallString::FromFmt(FSUI_FSTR("Setting {} binding {}."), s_input_binding_section,
SmallString::FromFmt(FSUI_FSTR("Setting {} binding {}."), s_input_binding_section, s_input_binding_display_name)); s_input_binding_display_name)
.GetCharArray());
ImGui::TextUnformatted(FSUI_CSTR("Push a controller button or axis now.")); ImGui::TextUnformatted(FSUI_CSTR("Push a controller button or axis now."));
ImGui::NewLine(); ImGui::NewLine();
ImGui::Text(FSUI_CSTR("Timing out in %.0f seconds..."), time_remaining); ImGui::TextUnformatted(SmallString::FromFmt(FSUI_FSTR("Timing out in {:.0f} seconds..."), time_remaining));
ImGui::EndPopup(); ImGui::EndPopup();
} }
@ -6234,16 +6235,18 @@ void FullscreenUI::DrawCoverDownloaderWindow()
if (ImGui::BeginPopupModal("Download Covers", &is_open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize)) if (ImGui::BeginPopupModal("Download Covers", &is_open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize))
{ {
ImGui::TextWrapped( ImGui::TextWrapped(
"%s",
FSUI_CSTR("DuckStation can automatically download covers for games which do not currently have a cover set. We " FSUI_CSTR("DuckStation can automatically download covers for games which do not currently have a cover set. We "
"do not host any cover images, the user must provide their own source for images.")); "do not host any cover images, the user must provide their own source for images."));
ImGui::NewLine(); ImGui::NewLine();
ImGui::TextWrapped(FSUI_CSTR("In the form below, specify the URLs to download covers from, with one template URL " ImGui::TextWrapped("%s",
FSUI_CSTR("In the form below, specify the URLs to download covers from, with one template URL "
"per line. The following variables are available:")); "per line. The following variables are available:"));
ImGui::NewLine(); ImGui::NewLine();
ImGui::TextWrapped(FSUI_CSTR("${title}: Title of the game.\n${filetitle}: Name component of the game's " ImGui::TextWrapped("%s", FSUI_CSTR("${title}: Title of the game.\n${filetitle}: Name component of the game's "
"filename.\n${serial}: Serial of the game.")); "filename.\n${serial}: Serial of the game."));
ImGui::NewLine(); ImGui::NewLine();
ImGui::TextWrapped(FSUI_CSTR("Example: https://www.example-not-a-real-domain.com/covers/${serial}.jpg")); ImGui::TextWrapped("%s", FSUI_CSTR("Example: https://www.example-not-a-real-domain.com/covers/${serial}.jpg"));
ImGui::NewLine(); ImGui::NewLine();
BeginMenuButtons(); BeginMenuButtons();

View File

@ -135,7 +135,7 @@ void ControllerLEDSettingsDialog::linkButton(ColorPickerButton* button, u32 play
SDLInputSource::ParseRGBForPlayerId(m_dialog->getStringValue("SDLExtra", key.c_str(), ""), player_id); SDLInputSource::ParseRGBForPlayerId(m_dialog->getStringValue("SDLExtra", key.c_str(), ""), player_id);
button->setColor(current_value); button->setColor(current_value);
connect(button, &ColorPickerButton::colorChanged, this, [this, player_id, key = std::move(key)](u32 new_rgb) { connect(button, &ColorPickerButton::colorChanged, this, [this, key = std::move(key)](u32 new_rgb) {
m_dialog->setStringValue("SDLExtra", key.c_str(), fmt::format("{:06X}", new_rgb).c_str()); m_dialog->setStringValue("SDLExtra", key.c_str(), fmt::format("{:06X}", new_rgb).c_str());
}); });
#endif #endif

View File

@ -368,9 +368,16 @@
<AdditionalDependencies>$(QtEntryPointLib);%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>$(QtEntryPointLib);%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
<ClCompile> <ClCompile>
<PreprocessorDefinitions>QT_NO_EXCEPTIONS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4127;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4127;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="$(Configuration.Contains(Clang))">
<ClCompile>
<!-- Throws warning : known but unsupported action 'shared' for '#pragma section' - ignored [-Wignored-pragmas] -->
<AdditionalOptions Condition="$(Configuration.Contains(Clang))">-Wno-ignored-pragmas %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<Import Project="..\..\dep\msvc\vsprops\Targets.props" /> <Import Project="..\..\dep\msvc\vsprops\Targets.props" />
<Import Project="..\..\dep\msvc\vsprops\QtCompile.targets" /> <Import Project="..\..\dep\msvc\vsprops\QtCompile.targets" />
</Project> </Project>

View File

@ -84,7 +84,7 @@ public:
void UnmapIndexBuffer(u32 used_index_count) override; void UnmapIndexBuffer(u32 used_index_count) override;
void PushUniformBuffer(const void* data, u32 data_size) override; void PushUniformBuffer(const void* data, u32 data_size) override;
void* MapUniformBuffer(u32 size) override; void* MapUniformBuffer(u32 size) override;
void UnmapUniformBuffer(u32 size); void UnmapUniformBuffer(u32 size) override;
void SetFramebuffer(GPUFramebuffer* fb) override; void SetFramebuffer(GPUFramebuffer* fb) override;
void SetPipeline(GPUPipeline* pipeline) override; void SetPipeline(GPUPipeline* pipeline) override;
void SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler* sampler) override; void SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler* sampler) override;