From ce0bfa11abe3a7ed6847717d8fd0524a08d83e43 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Tue, 16 Mar 2021 23:35:52 +0700 Subject: [PATCH] CMakeLists.txt: Configure for compat oldest libstdc++ CMakeLists.txt: Add -fno-stack-protector ExecuteString: Fix parser build.yml: Add paths-ignore README.md --- .github/workflows/build.yml | 3 +++ rehlds/CMakeLists.txt | 4 ++-- rehlds/HLTV/Console/CMakeLists.txt | 11 +++++++---- rehlds/HLTV/Console/src/System.cpp | 8 ++++---- rehlds/HLTV/Core/CMakeLists.txt | 4 ++-- rehlds/HLTV/DemoPlayer/CMakeLists.txt | 4 ++-- rehlds/HLTV/Director/CMakeLists.txt | 4 ++-- rehlds/HLTV/Proxy/CMakeLists.txt | 4 ++-- rehlds/dedicated/CMakeLists.txt | 11 +++++++---- rehlds/engine/SystemWrapper.cpp | 8 ++++---- rehlds/filesystem/FileSystem_Stdio/CMakeLists.txt | 4 ++-- 11 files changed, 37 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec82c82a3..6120ccdbc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,9 @@ name: C/C++ CI on: push: branches: [master] + paths-ignore: + - '**.md' + pull_request: types: [opened, reopened, synchronize] release: diff --git a/rehlds/CMakeLists.txt b/rehlds/CMakeLists.txt index 16543a94f..f8fdd50b0 100644 --- a/rehlds/CMakeLists.txt +++ b/rehlds/CMakeLists.txt @@ -25,7 +25,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections") if (DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector") endif() if (USE_INTEL_COMPILER) @@ -40,7 +40,7 @@ else() # Produce code optimized for the most common IA32/AMD64/EM64T processors. # As new processors are deployed in the marketplace, the behavior of this option will change. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3\ - -fpermissive\ + -fpermissive -fno-sized-deallocation\ -Wno-unknown-pragmas -Wno-invalid-offsetof\ -Wno-unused-variable -Wno-unused-result -Wno-unused-function -Wno-delete-non-virtual-dtor\ -Wno-write-strings -Wno-format\ diff --git a/rehlds/HLTV/Console/CMakeLists.txt b/rehlds/HLTV/Console/CMakeLists.txt index 2d85a32f8..b6253bbbf 100644 --- a/rehlds/HLTV/Console/CMakeLists.txt +++ b/rehlds/HLTV/Console/CMakeLists.txt @@ -16,15 +16,18 @@ elseif (USE_CLANG_COMPILER) set(CMAKE_CXX_COMPILER "/usr/bin/clang++") endif() +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions") if (DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector") endif() -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie -Wl,--no-export-dynamic") if (USE_INTEL_COMPILER) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp") @@ -38,7 +41,7 @@ else() # Produce code optimized for the most common IA32/AMD64/EM64T processors. # As new processors are deployed in the marketplace, the behavior of this option will change. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\ - -fpermissive\ + -fpermissive -fno-sized-deallocation\ -Wno-unused-result -Wno-unknown-pragmas -Wno-write-strings") endif() @@ -96,5 +99,5 @@ endif() add_executable(hltv ${appversion.sh} ${HLTV_SRCS} ${COMMON_SRCS}) target_link_libraries(hltv dl) -set_target_properties(hltv PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON) +set_target_properties(hltv PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") add_dependencies(hltv appversion) diff --git a/rehlds/HLTV/Console/src/System.cpp b/rehlds/HLTV/Console/src/System.cpp index 982d292b2..e6a543765 100644 --- a/rehlds/HLTV/Console/src/System.cpp +++ b/rehlds/HLTV/Console/src/System.cpp @@ -173,19 +173,19 @@ void System::ExecuteString(const char *commands) unsigned int i; for (i = 0; i < ARRAYSIZE(singleCmd); i++) { - char c = *pszSource++; - - *pszDest++ = c; + const char c = *pszSource++; if (c == '"') { bInQuote = !bInQuote; } - else if (c == ';' && !bInQuote) + else if ((c == ';' && !bInQuote) || !c) { // End of command and not in a quoted string break; } + + *pszDest++ = c; } if (i >= ARRAYSIZE(singleCmd)) diff --git a/rehlds/HLTV/Core/CMakeLists.txt b/rehlds/HLTV/Core/CMakeLists.txt index 032b6738a..e96908610 100644 --- a/rehlds/HLTV/Core/CMakeLists.txt +++ b/rehlds/HLTV/Core/CMakeLists.txt @@ -21,7 +21,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions") if (DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector") endif() if (USE_INTEL_COMPILER) @@ -36,7 +36,7 @@ else() # Produce code optimized for the most common IA32/AMD64/EM64T processors. # As new processors are deployed in the marketplace, the behavior of this option will change. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\ - -fpermissive\ + -fpermissive -fno-sized-deallocation\ -Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable\ -Wno-sign-compare -Wno-write-strings -Wno-strict-aliasing") diff --git a/rehlds/HLTV/DemoPlayer/CMakeLists.txt b/rehlds/HLTV/DemoPlayer/CMakeLists.txt index 17d85c3cd..819e50fbd 100644 --- a/rehlds/HLTV/DemoPlayer/CMakeLists.txt +++ b/rehlds/HLTV/DemoPlayer/CMakeLists.txt @@ -21,7 +21,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions") if (DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector") endif() if (USE_INTEL_COMPILER) @@ -36,7 +36,7 @@ else() # Produce code optimized for the most common IA32/AMD64/EM64T processors. # As new processors are deployed in the marketplace, the behavior of this option will change. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\ - -fpermissive\ + -fpermissive -fno-sized-deallocation\ -Wno-unused-result -Wno-unknown-pragmas\ -Wno-sign-compare -Wno-write-strings -Wno-strict-aliasing") endif() diff --git a/rehlds/HLTV/Director/CMakeLists.txt b/rehlds/HLTV/Director/CMakeLists.txt index 7667adb6f..bb6a81cb1 100644 --- a/rehlds/HLTV/Director/CMakeLists.txt +++ b/rehlds/HLTV/Director/CMakeLists.txt @@ -21,7 +21,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions") if (DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector") endif() if (USE_INTEL_COMPILER) @@ -36,7 +36,7 @@ else() # Produce code optimized for the most common IA32/AMD64/EM64T processors. # As new processors are deployed in the marketplace, the behavior of this option will change. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\ - -fpermissive\ + -fpermissive -fno-sized-deallocation\ -Wno-unused-result -Wno-unknown-pragmas\ -Wno-write-strings -Wno-strict-aliasing") endif() diff --git a/rehlds/HLTV/Proxy/CMakeLists.txt b/rehlds/HLTV/Proxy/CMakeLists.txt index 3365aeec4..47317feb9 100644 --- a/rehlds/HLTV/Proxy/CMakeLists.txt +++ b/rehlds/HLTV/Proxy/CMakeLists.txt @@ -21,7 +21,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions") if (DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector") endif() if (USE_INTEL_COMPILER) @@ -36,7 +36,7 @@ else() # Produce code optimized for the most common IA32/AMD64/EM64T processors. # As new processors are deployed in the marketplace, the behavior of this option will change. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\ - -fpermissive\ + -fpermissive -fno-sized-deallocation\ -Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable\ -Wno-write-strings -Wno-strict-aliasing") diff --git a/rehlds/dedicated/CMakeLists.txt b/rehlds/dedicated/CMakeLists.txt index 0f53ac5ea..808159c05 100644 --- a/rehlds/dedicated/CMakeLists.txt +++ b/rehlds/dedicated/CMakeLists.txt @@ -16,15 +16,18 @@ elseif (USE_CLANG_COMPILER) set(CMAKE_CXX_COMPILER "/usr/bin/clang++") endif() +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions") if (DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector") endif() -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie") +set(CMAKE_EXE_LINKER_FLAGS "-no-pie -Wl,--no-export-dynamic") if (USE_INTEL_COMPILER) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp") @@ -38,7 +41,7 @@ else() # Produce code optimized for the most common IA32/AMD64/EM64T processors. # As new processors are deployed in the marketplace, the behavior of this option will change. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3 -flto\ - -fpermissive\ + -fpermissive -fno-sized-deallocation\ -Wno-unused-result") endif() @@ -92,4 +95,4 @@ add_definitions( add_executable(hlds ${DEDICATED_SRCS} ${COMMON_SRCS}) target_link_libraries(hlds dl) -set_target_properties(hlds PROPERTIES OUTPUT_NAME hlds_linux PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON) +set_target_properties(hlds PROPERTIES OUTPUT_NAME hlds_linux PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") diff --git a/rehlds/engine/SystemWrapper.cpp b/rehlds/engine/SystemWrapper.cpp index ba3ca9c9b..5b059b70c 100644 --- a/rehlds/engine/SystemWrapper.cpp +++ b/rehlds/engine/SystemWrapper.cpp @@ -572,19 +572,19 @@ void SystemWrapper::ExecuteString(const char *commands) unsigned int i; for (i = 0; i < ARRAYSIZE(singleCmd); i++) { - char c = *pszSource++; - - *pszDest++ = c; + const char c = *pszSource++; if (c == '"') { bInQuote = !bInQuote; } - else if (c == ';' && !bInQuote) + else if ((c == ';' && !bInQuote) || !c) { // End of command and not in a quoted string break; } + + *pszDest++ = c; } if (i >= ARRAYSIZE(singleCmd)) diff --git a/rehlds/filesystem/FileSystem_Stdio/CMakeLists.txt b/rehlds/filesystem/FileSystem_Stdio/CMakeLists.txt index 9e22885e8..ab6c8bc64 100644 --- a/rehlds/filesystem/FileSystem_Stdio/CMakeLists.txt +++ b/rehlds/filesystem/FileSystem_Stdio/CMakeLists.txt @@ -28,7 +28,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions") if (DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector") endif() if (USE_INTEL_COMPILER) @@ -38,7 +38,7 @@ else() # Produce code optimized for the most common IA32/AMD64/EM64T processors. # As new processors are deployed in the marketplace, the behavior of this option will change. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic -msse3\ - -fpermissive\ + -fpermissive -fno-sized-deallocation\ -Wno-unknown-pragmas -Wno-unused-result -Wno-unused-variable -Wno-unused-function\ -Wno-write-strings -Wno-sign-compare")