From dd5791a2cc47930c4cd28d4903d793ea5e49a2bc Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Mon, 20 Nov 2017 21:56:25 +0000 Subject: [PATCH] Fixes from FreeBSD package (#3765) * Thread: unbreak on BSDs after dbc9bdfe02ae Utilities/Thread.cpp:1920:2: error: unknown type name 'cpu_set_t'; did you mean 'cpusetid_t'? cpu_set_t cs; ^~~~~~~~~ cpusetid_t /usr/include/sys/types.h:84:22: note: 'cpusetid_t' declared here typedef __cpusetid_t cpusetid_t; ^ Utilities/Thread.cpp:1921:2: error: use of undeclared identifier 'CPU_ZERO' CPU_ZERO(&cs); ^ Utilities/Thread.cpp:1922:2: error: use of undeclared identifier 'CPU_SET' CPU_SET(core, &cs); ^ Utilities/Thread.cpp:1923:48: error: unknown type name 'cpu_set_t'; did you mean 'cpusetid_t'? pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cs); ^~~~~~~~~ cpusetid_t * JIT: use MAP_32BIT on Linux and FreeBSD Unless RLIMIT_DATA is low enough FreeBSD by default reserves lower 2Gb for brk(2) style heap, ignoring mmap(2) address hint requested by RPCS3. Passing MAP_32BIT fixes the following crash Assertion failed: ((Type == ELF::R_X86_64_32 && (Value <= UINT32_MAX)) || (Type == ELF::R_X86_64_32S && ((int64_t)Value <= INT32_MAX && (int64_t)Value >= INT32_MIN))), function resolveX86_64Relocation, file /usr/ports/devel/llvm40/work/llvm-4.0.1.src/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp, line 287. * build: unbreak -DVULKAN_PREBUILT with system glslang on Unix rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:4:10: fatal error: '../../../../Vulkan/glslang/SPIRV/GlslangToSpv.h' file not found #include "../../../../Vulkan/glslang/SPIRV/GlslangToSpv.h" ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ rpcs3/CMakeFiles/rpcs3.dir/Emu/RSX/VK/VKCommonDecompiler.cpp.o: In function `vk::compile_glsl_to_spv(std::__1::basic_string, std::__1::allocator >&, glsl::program_domain, std::__1::vector >&)': rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x50e): undefined reference to `glslang::TProgram::TProgram()' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x51d): undefined reference to `glslang::TShader::TShader(EShLanguage)' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x542): undefined reference to `glslang::TShader::setStrings(char const* const*, int)' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x581): undefined reference to `glslang::TShader::parse(TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TShader::Includer&)' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x5d6): undefined reference to `glslang::TProgram::link(EShMessages)' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x5f1): undefined reference to `glslang::GlslangToSpv(glslang::TIntermediate const&, std::__1::vector >&, glslang::SpvOptions*)' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x5ff): undefined reference to `glslang::TShader::getInfoLog()' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x61a): undefined reference to `glslang::TShader::getInfoDebugLog()' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x630): undefined reference to `glslang::TShader::~TShader()' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x63c): undefined reference to `glslang::TProgram::~TProgram()' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x6d2): undefined reference to `glslang::TShader::~TShader()' rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x6de): undefined reference to `glslang::TProgram::~TProgram()' rpcs3/CMakeFiles/rpcs3.dir/Emu/RSX/VK/VKCommonDecompiler.cpp.o: In function `vk::initialize_compiler_context()': rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x6f5): undefined reference to `glslang::InitializeProcess()' rpcs3/CMakeFiles/rpcs3.dir/Emu/RSX/VK/VKCommonDecompiler.cpp.o: In function `vk::finalize_compiler_context()': rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp:(.text+0x856): undefined reference to `glslang::FinalizeProcess()' * build/msvc: add missing glslang include directory after 6bb3f1b4d75c "c:\projects\rpcs3\rpcs3\VKGSRender.vcxproj" (default target) (15) -> (ClCompile target) -> Emu\RSX\VK\VKCommonDecompiler.cpp(4): fatal error C1083: Cannot open include file: 'SPIRV/GlslangToSpv.h': No such file or directory [c:\projects\rpcs3\rpcs3\VKGSRender.vcxproj] --- Utilities/JIT.cpp | 8 ++++++++ Utilities/Thread.cpp | 6 +++++- rpcs3/CMakeLists.txt | 3 +++ rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp | 2 +- rpcs3/VKGSRender.vcxproj | 2 +- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index f9bfd7d390..7e3bd23f5b 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -30,6 +30,8 @@ #ifdef _WIN32 #include +#else +#include #endif #include "JIT.h" @@ -47,6 +49,11 @@ static void* const s_memory = []() -> void* llvm::InitializeNativeTargetAsmPrinter(); LLVMLinkInMCJIT(); +#ifdef MAP_32BIT + auto ptr = ::mmap(nullptr, s_memory_size, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_32BIT, -1, 0); + if (ptr != MAP_FAILED) + return ptr; +#else for (u64 addr = 0x10000000; addr <= 0x80000000 - s_memory_size; addr += 0x1000000) { if (auto ptr = utils::memory_reserve(s_memory_size, (void*)addr)) @@ -54,6 +61,7 @@ static void* const s_memory = []() -> void* return ptr; } } +#endif return utils::memory_reserve(s_memory_size); }(); diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index a6159b1f78..2682ed008b 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -19,6 +19,10 @@ #include #include #endif +#if defined(__DragonFly__) || defined(__FreeBSD__) +#include +#define cpu_set_t cpuset_t +#endif #include #include #include @@ -1922,7 +1926,7 @@ void thread_ctrl::set_ideal_processor_core(int core) thread_affinity_policy_data_t policy = { static_cast(core) }; thread_port_t mach_thread = pthread_mach_thread_np(pthread_self()); thread_policy_set(mach_thread, THREAD_AFFINITY_POLICY, (thread_policy_t)&policy, 1); -#else +#elif defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) cpu_set_t cs; CPU_ZERO(&cs); CPU_SET(core, &cs); diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 6b199e310f..c7096be735 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -236,6 +236,9 @@ if(NOT WIN32 AND USE_VULKAN) if(VULKAN_FOUND) add_definitions(-DHAVE_VULKAN) list(APPEND ADDITIONAL_LIBS ${VULKAN_LIBRARY}) + if(VULKAN_PREBUILT) + list(APPEND ADDITIONAL_LIBS glslang HLSL OGLCompiler SPIRV OSDependent) + endif() else() message("WARNING! USE_VULKAN was enabled, but libvulkan was not found. RPCS3 will be compiled without Vulkan support.") endif() diff --git a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp index 2361d04b70..3510b1acca 100644 --- a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "VKCommonDecompiler.h" #include "restore_new.h" -#include "../../../../Vulkan/glslang/SPIRV/GlslangToSpv.h" +#include "SPIRV/GlslangToSpv.h" #include "define_new_memleakdetect.h" namespace vk diff --git a/rpcs3/VKGSRender.vcxproj b/rpcs3/VKGSRender.vcxproj index 1670e45cf4..939431dfa5 100644 --- a/rpcs3/VKGSRender.vcxproj +++ b/rpcs3/VKGSRender.vcxproj @@ -95,7 +95,7 @@ - ..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories) + ..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;..\Vulkan\glslang;%(AdditionalIncludeDirectories)