2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-27 05:58:04 +03:00

CMakeLists.txt configure Intel C++ Compiler

build.yml: use container linux86buildtools
Minor refactoring
This commit is contained in:
s1lentq 2021-04-07 02:24:40 +07:00
parent 2965e0ea7f
commit ccd36e765b
22 changed files with 330 additions and 171 deletions

View File

@ -72,6 +72,7 @@ jobs:
linux:
name: 'Linux'
runs-on: ubuntu-latest
container: s1lentq/linux86buildtools:latest
steps:
- name: Checkout
@ -79,21 +80,9 @@ jobs:
with:
fetch-depth: 0
- name: Check dependencies
- name: Build using Intel C++ Compiler
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y gcc-multilib g++-multilib
sudo apt-get install -y build-essential
sudo apt-get install -y libc6-dev libc6-dev-i386
sudo apt-get install -y p7zip-full
- name: Build
run: |
mkdir build
cd build
cmake ../
make
rm -rf build && CC=icc CXX=icpc cmake -B build && cmake --build build -j8
- name: Prepare HLSDK
run: |
@ -133,7 +122,8 @@ jobs:
if [[ $? -ne 0 ]]; then
exit 1 # Assertion failed
fi
shell: bash
- name: Deploy artifacts
uses: actions/upload-artifact@v2
id: upload-job

View File

@ -5,6 +5,10 @@ if (WIN32)
message(FATAL_ERROR "CMakeLists.txt Windows platform isn't supported yet. Use msvc/ReHLDS.sln instead it!")
endif()
add_custom_target(appversion DEPENDS
COMMAND "${PROJECT_SOURCE_DIR}/rehlds/version/appversion.sh" "${PROJECT_SOURCE_DIR}"
)
add_subdirectory(rehlds)
add_subdirectory(rehlds/dedicated)
add_subdirectory(rehlds/filesystem)

View File

@ -20,4 +20,6 @@ include_directories(
)
add_library(bzip2 STATIC ${BZIP2_SRCS})
set_target_properties(bzip2 PROPERTIES COMPILE_FLAGS "-m32")
set_target_properties(bzip2 PROPERTIES
COMPILE_FLAGS "-m32"
)

View File

@ -1,23 +1,33 @@
#----------------------------------------
# 1. Preparing build:
# rm -rf build
# mkdir build && cd build
#
# 2. Select compiler and build it
# - Compile with Clang:
# CC="clang" CXX="clang++" cmake ..
# make
#
# - Compile with Intel C++ Compiler:
# CC="icc" CXX="icpc" cmake ..
# make
#
# - Compile with GCC Compiler:
# cmake ..
# make
#----------------------------------------
cmake_minimum_required(VERSION 3.1)
project(engine CXX)
option(DEBUG "Build with debug information." OFF)
option(USE_INTEL_COMPILER "Use the Intel compiler." OFF)
option(USE_CLANG_COMPILER "Use the Clang compiler." OFF)
option(USE_STATIC_LIBSTDC "Enables static linking libstdc++." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
if (USE_INTEL_COMPILER)
set(CMAKE_C_COMPILER "/opt/intel/bin/icc")
set(CMAKE_CXX_COMPILER "/opt/intel/bin/icpc")
elseif (USE_CLANG_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-rtti -fno-plt -fno-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-rtti -fno-exceptions")
# Remove noxref code and data
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
@ -28,8 +38,16 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()
if (USE_INTEL_COMPILER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
# Check Intel C++ compiler
if ($ENV{CXX} MATCHES "icpc")
# -fp-model=precise
# ICC uses -fp-model fast=1 by default for more aggressive optimizations on floating-point calculations
# https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/floating-point-options/fp-model-fp.html#fp-model-fp_GUID-99936BBA-1508-4E9F-AC09-FA98613CE2F5
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-fp-model=precise\
-fasm-blocks\
-Qoption,cpp,--treat_func_as_string_literal_cpp")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel -no-intel-extensions")
if (NOT DEBUG)
@ -39,28 +57,33 @@ if (USE_INTEL_COMPILER)
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\
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mtune=generic -msse3\
-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\
-Wno-sign-compare -Wno-strict-aliasing -Wno-ignored-attributes")
if (NOT USE_CLANG_COMPILER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
# Check if not Clang compiler
if (NOT $ENV{CXX} MATCHES "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-plt -Wno-unused-but-set-variable")
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation -Wno-format-truncation -Wno-class-memaccess")
endif()
endif()
endif()
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection=none")
endif()
if (NOT DEBUG AND USE_STATIC_LIBSTDC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-gc-sections -Wl,--version-script=\"${PROJECT_SOURCE_DIR}/../version_script.lds\"")
if (NOT DEBUG)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-Wl,-gc-sections -Wl,--version-script=\"${PROJECT_SOURCE_DIR}/../version_script.lds\"")
endif()
if (USE_STATIC_LIBSTDC)
@ -86,25 +109,83 @@ set(PROJECT_PUBLIC_DIR
"${PROJECT_SOURCE_DIR}/public/rehlds"
)
file(GLOB ENGINE_SRCS
"engine/*.cpp"
"rehlds/*.cpp"
"version/*.cpp"
set(ENGINE_SRCS
engine/sv_main.cpp
engine/sv_user.cpp
engine/sv_phys.cpp
engine/sv_move.cpp
engine/sv_pmove.cpp
engine/sv_log.cpp
engine/sv_remoteaccess.cpp
engine/sv_steam3.cpp
engine/sv_upld.cpp
engine/sys_dll.cpp
engine/sys_dll2.cpp
engine/sys_engine.cpp
engine/sys_linuxwind.cpp
engine/SystemWrapper.cpp
engine/host.cpp
engine/host_cmd.cpp
engine/net_chan.cpp
engine/net_ws.cpp
engine/pmove.cpp
engine/pmovetst.cpp
engine/pr_cmds.cpp
engine/pr_edict.cpp
engine/wad.cpp
engine/model.cpp
engine/world.cpp
engine/zone.cpp
engine/cmd.cpp
engine/cmodel.cpp
engine/com_custom.cpp
engine/common.cpp
engine/crc.cpp
engine/cvar.cpp
engine/decals.cpp
engine/delta.cpp
engine/delta_jit.cpp
engine/ed_strpool.cpp
engine/filesystem.cpp
engine/filesystem_internal.cpp
engine/hashpak.cpp
engine/info.cpp
engine/ipratelimit.cpp
engine/l_studio.cpp
engine/textures.cpp
engine/tmessage.cpp
engine/traceinit.cpp
engine/unicode_strtools.cpp
engine/buildnum.cpp
engine/mathlib.cpp
engine/mathlib_sse.cpp
engine/md5.cpp
engine/mem.cpp
engine/module.cpp
engine/r_studio.cpp
engine/vid_null.cpp
engine/cl_null.cpp
engine/snd_null.cpp
engine/sse_mathfun.cpp
engine/public_amalgamation.cpp
rehlds/flight_recorder.cpp
rehlds/FlightRecorderImpl.cpp
rehlds/hookchains_impl.cpp
rehlds/main.cpp
rehlds/platform.cpp
rehlds/public_amalgamation.cpp
rehlds/rehlds_api_impl.cpp
rehlds/rehlds_interfaces_impl.cpp
rehlds/rehlds_security.cpp
)
list(REMOVE_ITEM ENGINE_SRCS EXCLUDE
"${PROJECT_SOURCE_DIR}/rehlds/precompiled.cpp"
"${PROJECT_SOURCE_DIR}/rehlds/RehldsRuntimeConfig.cpp"
"${PROJECT_SOURCE_DIR}/rehlds/structSizeCheck.cpp"
)
file(GLOB COMMON_SRCS
set(COMMON_SRCS
"common/BaseSystemModule.cpp"
"common/ObjectList.cpp"
"common/TokenLine.cpp"
)
file(GLOB PUBLIC_SRCS
set(PUBLIC_SRCS
"public/tier0/dbg.cpp"
"public/registry.cpp"
"public/steamid.cpp"
@ -140,18 +221,27 @@ add_definitions(
-D_vsnwprintf=vswprintf
)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN/.' -L${PROJECT_SOURCE_DIR}/lib/linux32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-Wl,-rpath,'$ORIGIN/.' \
-L${PROJECT_SOURCE_DIR}/lib/linux32")
if (NOT TARGET bzip2)
add_subdirectory(../dep/bzip2 lib)
endif()
if (NOT TARGET appversion)
add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/version/appversion.sh" "${PROJECT_SOURCE_DIR}")
add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/version/appversion.sh" "${PROJECT_SOURCE_DIR}/..")
endif()
add_library(engine SHARED ${appversion.sh} ${ENGINE_SRCS} ${COMMON_SRCS} ${PUBLIC_SRCS})
set_property(TARGET engine PROPERTY LIBRARY_OUTPUT_NAME engine_i486)
set_target_properties(engine PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE OFF)
target_link_libraries(engine dl rt m aelf32 bzip2 steam_api)
add_dependencies(engine appversion)
set_target_properties(engine PROPERTIES
LIBRARY_OUTPUT_NAME engine_i486
PREFIX ""
COMPILE_FLAGS "-m32"
LINK_FLAGS "-m32"
POSITION_INDEPENDENT_CODE OFF
)
target_link_libraries(engine dl rt m aelf32 bzip2 steam_api)

View File

@ -2,20 +2,10 @@ cmake_minimum_required(VERSION 3.1)
project(hltv CXX)
option(DEBUG "Build with debug information." OFF)
option(USE_INTEL_COMPILER "Use the Intel compiler." OFF)
option(USE_CLANG_COMPILER "Use the Clang compiler." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (USE_INTEL_COMPILER)
set(CMAKE_C_COMPILER "/opt/intel/bin/icc")
set(CMAKE_CXX_COMPILER "/opt/intel/bin/icpc")
elseif (USE_CLANG_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
@ -29,7 +19,8 @@ endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie -Wl,--no-export-dynamic")
if (USE_INTEL_COMPILER)
# Check Intel C++ compiler
if ($ENV{CXX} MATCHES "icpc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-intel -no-intel-extensions")
@ -40,15 +31,18 @@ if (USE_INTEL_COMPILER)
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\
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mtune=generic -msse3 -flto\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result -Wno-unknown-pragmas -Wno-write-strings")
if (NOT USE_CLANG_COMPILER AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
# Check if not Clang compiler AND GCC >= 8.3
if (NOT $ENV{CXX} MATCHES "clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation -Wno-format-truncation")
endif()
endif()
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection=none")
endif()
@ -103,10 +97,17 @@ add_definitions(
)
if (NOT TARGET appversion)
add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/../../version/appversion.sh" "${PROJECT_SOURCE_DIR}/../..")
add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/../../version/appversion.sh" "${PROJECT_SOURCE_DIR}/../../..")
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")
add_dependencies(hltv appversion)
target_link_libraries(hltv dl)
set_target_properties(hltv PROPERTIES
LIBRARY_OUTPUT_NAME hltv
PREFIX ""
COMPILE_FLAGS "-m32"
LINK_FLAGS "-m32"
POSITION_INDEPENDENT_CODE OFF
)

View File

@ -1,3 +1,4 @@
#include "precompiled.h"
#include "interface.cpp"
#include "stdc++compat.cpp"

View File

@ -2,19 +2,10 @@ cmake_minimum_required(VERSION 3.1)
project(core CXX)
option(DEBUG "Build with debug information." OFF)
option(USE_INTEL_COMPILER "Use the Intel compiler." OFF)
option(USE_CLANG_COMPILER "Use the Clang compiler." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (USE_INTEL_COMPILER)
set(CMAKE_C_COMPILER "/opt/intel/bin/icc")
set(CMAKE_CXX_COMPILER "/opt/intel/bin/icpc")
elseif (USE_CLANG_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
@ -24,7 +15,8 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()
if (USE_INTEL_COMPILER)
# Check Intel C++ compiler
if ($ENV{CXX} MATCHES "icpc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel -no-intel-extensions")
@ -40,15 +32,18 @@ else()
-Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable\
-Wno-sign-compare -Wno-write-strings -Wno-strict-aliasing")
if (USE_CLANG_COMPILER)
# Check Clang compiler
if ($ENV{CXX} MATCHES "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
else()
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation -Wno-format-truncation")
endif()
endif()
endif()
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection=none")
endif()
@ -127,4 +122,10 @@ endif()
add_library(core SHARED ${CORE_SRCS} ${COMMON_SRCS})
target_link_libraries(core dl bzip2)
set_target_properties(core PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON)
set_target_properties(core PROPERTIES
LIBRARY_OUTPUT_NAME core
PREFIX ""
COMPILE_FLAGS "-m32"
LINK_FLAGS "-m32"
POSITION_INDEPENDENT_CODE OFF
)

View File

@ -1,3 +1,4 @@
#include "precompiled.h"
#include "interface.cpp"
#include "stdc++compat.cpp"

View File

@ -2,19 +2,10 @@ cmake_minimum_required(VERSION 3.1)
project(demoplayer CXX)
option(DEBUG "Build with debug information." OFF)
option(USE_INTEL_COMPILER "Use the Intel compiler." OFF)
option(USE_CLANG_COMPILER "Use the Clang compiler." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (USE_INTEL_COMPILER)
set(CMAKE_C_COMPILER "/opt/intel/bin/icc")
set(CMAKE_CXX_COMPILER "/opt/intel/bin/icpc")
elseif (USE_CLANG_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
@ -24,7 +15,8 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()
if (USE_INTEL_COMPILER)
# Check Intel C++ compiler
if ($ENV{CXX} MATCHES "icpc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel -no-intel-extensions")
@ -35,12 +27,14 @@ if (USE_INTEL_COMPILER)
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\
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mtune=generic -msse3 -flto\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result -Wno-unknown-pragmas\
-Wno-sign-compare -Wno-write-strings -Wno-strict-aliasing")
endif()
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection=none")
endif()
@ -98,4 +92,10 @@ add_definitions(
add_library(demoplayer SHARED ${DEMOPLAYER_SRCS} ${COMMON_SRCS})
target_link_libraries(demoplayer dl)
set_target_properties(demoplayer PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON)
set_target_properties(demoplayer PROPERTIES
LIBRARY_OUTPUT_NAME demoplayer
PREFIX ""
COMPILE_FLAGS "-m32"
LINK_FLAGS "-m32"
POSITION_INDEPENDENT_CODE OFF
)

View File

@ -1,3 +1,4 @@
#include "precompiled.h"
#include "interface.cpp"
#include "stdc++compat.cpp"

View File

@ -2,19 +2,10 @@ cmake_minimum_required(VERSION 3.1)
project(director CXX)
option(DEBUG "Build with debug information." OFF)
option(USE_INTEL_COMPILER "Use the Intel compiler." OFF)
option(USE_CLANG_COMPILER "Use the Clang compiler." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (USE_INTEL_COMPILER)
set(CMAKE_C_COMPILER "/opt/intel/bin/icc")
set(CMAKE_CXX_COMPILER "/opt/intel/bin/icpc")
elseif (USE_CLANG_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
@ -24,7 +15,8 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()
if (USE_INTEL_COMPILER)
# Check Intel C++ compiler
if ($ENV{CXX} MATCHES "icpc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel -no-intel-extensions")
@ -35,12 +27,14 @@ if (USE_INTEL_COMPILER)
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\
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mtune=generic -msse3 -flto\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result -Wno-unknown-pragmas\
-Wno-write-strings -Wno-strict-aliasing")
endif()
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection=none")
endif()
@ -98,8 +92,16 @@ add_definitions(
-D_snprintf=snprintf
)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN/.' -L${PROJECT_SOURCE_DIR}/../../lib/linux32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-Wl,-rpath,'$ORIGIN/.' \
-L${PROJECT_SOURCE_DIR}/../../lib/linux32")
add_library(director SHARED ${DIRECTOR_SRCS} ${COMMON_SRCS})
target_link_libraries(director dl m)
set_target_properties(director PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON)
set_target_properties(director PROPERTIES
LIBRARY_OUTPUT_NAME director
PREFIX ""
COMPILE_FLAGS "-m32"
LINK_FLAGS "-m32"
POSITION_INDEPENDENT_CODE OFF
)

View File

@ -1,3 +1,4 @@
#include "precompiled.h"
#include "interface.cpp"
#include "stdc++compat.cpp"

View File

@ -2,21 +2,12 @@ cmake_minimum_required(VERSION 3.1)
project(proxy CXX)
option(DEBUG "Build with debug information." OFF)
option(USE_INTEL_COMPILER "Use the Intel compiler." OFF)
option(USE_CLANG_COMPILER "Use the Clang compiler." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
if (USE_INTEL_COMPILER)
set(CMAKE_C_COMPILER "/opt/intel/bin/icc")
set(CMAKE_CXX_COMPILER "/opt/intel/bin/icpc")
elseif (USE_CLANG_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-plt -fno-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
if (DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O3 -ggdb")
@ -24,7 +15,8 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()
if (USE_INTEL_COMPILER)
# Check Intel C++ compiler
if ($ENV{CXX} MATCHES "icpc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel -no-intel-extensions")
@ -35,20 +27,26 @@ if (USE_INTEL_COMPILER)
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\
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mtune=generic -msse3 -flto\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result -Wno-unknown-pragmas -Wno-unused-variable\
-Wno-write-strings -Wno-strict-aliasing")
if (USE_CLANG_COMPILER)
# Check Clang compiler
if ($ENV{CXX} MATCHES "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-plt")
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation -Wno-format-truncation")
endif()
endif()
endif()
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection=none")
endif()
@ -124,7 +122,9 @@ add_definitions(
-D_snprintf=snprintf
)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN/.' -L${PROJECT_SOURCE_DIR}/../../lib/linux32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} \
-Wl,-rpath,'$ORIGIN/.' \
-L${PROJECT_SOURCE_DIR}/../../lib/linux32")
if (NOT TARGET bzip2)
add_subdirectory(../../../dep/bzip2 lib)
@ -132,4 +132,9 @@ endif()
add_library(proxy SHARED ${PROXY_SRCS} ${COMMON_SRCS})
target_link_libraries(proxy dl m bzip2 steam_api)
set_target_properties(proxy PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON)
set_target_properties(proxy PROPERTIES
PREFIX ""
COMPILE_FLAGS "-m32"
LINK_FLAGS "-m32"
POSITION_INDEPENDENT_CODE OFF
)

View File

@ -1,3 +1,4 @@
#include "precompiled.h"
#include "interface.cpp"
#include "stdc++compat.cpp"

View File

@ -1,15 +1,23 @@
#include <stdio.h>
#include <stdlib.h>
#if !defined(_WIN32) && !defined(BUILD_STATIC_LIBSTDC) // if build with static libstdc++ then ignore
void NORETURN Sys_Error(const char *error, ...);
// This file adds the necessary compatibility tricks to avoid symbols with
// version GLIBCXX_3.4.16 and bigger, keeping binary compatibility with libstdc++ 4.6.1.
namespace std
{
#if __cpp_exceptions
logic_error::logic_error(const char *__arg) : exception(), _M_msg(__arg) {}
out_of_range::out_of_range(const char *__arg) : logic_error(__arg) {}
out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT {}
#endif // #if __cpp_exceptions
// We shouldn't be throwing exceptions at all, but it sadly turns out we call STL (inline) functions that do.
void __throw_out_of_range_fmt(const char *fmt, ...)
{
#if __cpp_exceptions
va_list ap;
char buf[1024]; // That should be big enough.
@ -18,16 +26,43 @@ namespace std
buf[sizeof(buf) - 1] = '\0';
va_end(ap);
Sys_Error(buf);
throw std::out_of_range(buf);
#else
abort();
#endif
}
}; // namespace std
// Technically, this symbol is not in GLIBCXX_3.4.20, but in CXXABI_1.3.8,
// but that's equivalent, version-wise. Those calls are added by the compiler
// Was added in GCC 4.9
// Technically, this symbol is not in GLIBCXX_3.4.20, but in CXXABI_1.3.8, but that's equivalent, version-wise.
// Those calls are added by the compiler
// itself on `new Class[n]` calls.
extern "C"
void __cxa_throw_bad_array_new_length()
{
Sys_Error("Bad array new length.");
#if __cpp_exceptions
throw std::bad_array_new_length();
#else
abort();
#endif
}
#if defined(__INTEL_COMPILER) && __cplusplus >= 201402L
// This operator delete sized deallocations was added in c++14
// and required at least not less than CXXABI_1.3.9
// we should to keep CXXABI_1.3.8 for binary compatibility with oldest libstdc++.
// GCC and Clang allow to compile C++14 code with -fno-sized-deallocation to disable the new feature, but ICC isn't allow
// so that our C++14 library code would never call that version of operator delete,
// for ICC compiler we must override those operators for static linking to the library.
void operator delete[](void *ptr, std::size_t size) noexcept
{
::operator delete(ptr);
}
void operator delete(void *ptr, std::size_t size) noexcept
{
::operator delete(ptr);
}
#endif
#endif // !defined(_WIN32)

View File

@ -2,20 +2,10 @@ cmake_minimum_required(VERSION 3.1)
project(hlds CXX)
option(DEBUG "Build with debug information." OFF)
option(USE_INTEL_COMPILER "Use the Intel compiler." OFF)
option(USE_CLANG_COMPILER "Use the Clang compiler." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (USE_INTEL_COMPILER)
set(CMAKE_C_COMPILER "/opt/intel/bin/icc")
set(CMAKE_CXX_COMPILER "/opt/intel/bin/icpc")
elseif (USE_CLANG_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
@ -29,7 +19,8 @@ endif()
set(CMAKE_EXE_LINKER_FLAGS "-no-pie -Wl,--no-export-dynamic")
if (USE_INTEL_COMPILER)
# Check Intel C++ compiler
if ($ENV{CXX} MATCHES "icpc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-intel -no-intel-extensions")
@ -40,15 +31,18 @@ if (USE_INTEL_COMPILER)
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\
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mtune=generic -msse3\
-fpermissive -fno-sized-deallocation\
-Wno-unused-result")
if (NOT USE_CLANG_COMPILER AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
# Check if not Clang compiler AND GCC >= 8.3
if (NOT $ENV{CXX} MATCHES "clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation -Wno-format-truncation")
endif()
endif()
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection=none")
endif()
@ -102,6 +96,18 @@ add_definitions(
-D_vsnprintf=vsnprintf
)
if (NOT TARGET appversion)
add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/../../version/appversion.sh" "${PROJECT_SOURCE_DIR}/../..")
endif()
add_executable(hlds ${DEDICATED_SRCS} ${COMMON_SRCS})
add_dependencies(hlds appversion)
target_link_libraries(hlds dl)
set_target_properties(hlds PROPERTIES OUTPUT_NAME hlds_linux PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
set_target_properties(hlds PROPERTIES
OUTPUT_NAME hlds_linux
PREFIX ""
COMPILE_FLAGS "-m32"
LINK_FLAGS "-m32"
POSITION_INDEPENDENT_CODE OFF
)

View File

@ -1,3 +1,4 @@
#include "precompiled.h"
#include "interface.cpp"
#include "stdc++compat.cpp"

View File

@ -2,26 +2,10 @@ cmake_minimum_required(VERSION 3.1)
project(filesystem_stdio CXX)
option(DEBUG "Build with debug information." OFF)
option(USE_INTEL_COMPILER "Use the Intel compiler." OFF)
option(USE_CLANG_COMPILER "Use the Clang compiler." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(WRAP_FUNCS_LIST
"scandir" "opendir" "freopen" "fopen" "fopen64" "open" "open64" "creat"
"access" "stat" "lstat" "__xstat" "__lxstat" "__xstat64" "__lxstat64"
"chmod" "chown" "lchown" "unlink" "symlink" "link" "mknod" "mount"
"mkfifo" "rename" "utime" "utimes" "mkdir" "rmdir"
)
if (USE_INTEL_COMPILER)
set(CMAKE_C_COMPILER "/opt/intel/bin/icc")
set(CMAKE_CXX_COMPILER "/opt/intel/bin/icpc")
elseif (USE_CLANG_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
endif()
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions")
@ -31,26 +15,38 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O3 -fno-stack-protector")
endif()
if (USE_INTEL_COMPILER)
# Check Intel C++ compiler
if ($ENV{CXX} MATCHES "icpc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qoption,cpp,--treat_func_as_string_literal_cpp")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel -no-intel-extensions")
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\
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mtune=generic -msse3\
-fpermissive -fno-sized-deallocation\
-Wno-unknown-pragmas -Wno-unused-result -Wno-unused-variable -Wno-unused-function\
-Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-result -Wno-unused-function\
-Wno-write-strings -Wno-sign-compare")
if (NOT USE_CLANG_COMPILER AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
# Check if not Clang compiler AND GCC >= 8.3
if (NOT $ENV{CXX} MATCHES "clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-truncation -Wno-class-memaccess")
endif()
endif()
# NOTE: Don't use IPO or LTO with '--wrap' may make this feature ineffective
set(WRAP_FUNCS_LIST
"scandir" "opendir" "freopen" "fopen" "fopen64" "open" "open64" "creat"
"access" "stat" "lstat" "__xstat" "__lxstat" "__xstat64" "__lxstat64"
"chmod" "chown" "lchown" "unlink" "symlink" "link" "mknod" "mount"
"mkfifo" "rename" "utime" "utimes" "mkdir" "rmdir"
)
foreach(f ${WRAP_FUNCS_LIST})
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-wrap,${f}")
endforeach()
# GCC >= 8.3
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcf-protection=none")
endif()
@ -94,5 +90,13 @@ add_definitions(
)
add_library(filesystem_stdio SHARED ${FILESYSTEM_STDIO_SRCS})
set_target_properties(filesystem_stdio PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON)
set_target_properties(filesystem_stdio PROPERTIES
LIBRARY_OUTPUT_NAME filesystem_stdio
PREFIX ""
COMPILE_FLAGS "-m32"
LINK_FLAGS "-m32"
POSITION_INDEPENDENT_CODE OFF
)
target_link_libraries(filesystem_stdio dl)

View File

@ -769,9 +769,9 @@ extern "C" {
return __wrap_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
}
int __wrap_access(const char *pathname, int mode)
WRAP(access, int, const char *pathname, int mode)
{
return __real_access(CWrap(pathname, false), mode);
return CALL(access)(CWrap(pathname, false), mode);
}
WRAP(stat, int, const char *path, struct stat *buf)

View File

@ -5,3 +5,4 @@
#include "tier0/dbg.cpp"
#include "tier0/characterset.cpp"
#include "stdc++compat.cpp"

View File

@ -3,9 +3,9 @@
init()
{
SOURCE_DIR=$@
GIT_DIR=$SOURCE_DIR/..
VERSION_FILE=$GIT_DIR/gradle.properties
APPVERSION_FILE=$SOURCE_DIR/version/appversion.h
GIT_DIR=$SOURCE_DIR
VERSION_FILE=$SOURCE_DIR/gradle.properties
APPVERSION_FILE=$SOURCE_DIR/rehlds/version/appversion.h
if test -z "`git --version`"; then
echo "Please install git client"

View File

@ -14,7 +14,15 @@ main()
do
:
version=$(readelf -sV $f | sed -n 's/.*@'$k'_//p' | sort -u -V | tail -1 | cut -d ' ' -f 1)
if [[ ! -z "$version" ]]; then
# version no present - skipped
if [[ -z "$version" ]]; then
version="UND"
# version is private - skipped
elif [ "$version" = "PRIVATE" ]; then
version="PRV"
# ensure numeric
elif [[ $version =~ ^[0-9]+$ ]]; then
check_version_greater $version ${threshold_version[$k]}
if [[ $? -eq 1 ]]; then
echo -e "\033[0;31mAssertion failed:\033[0m Binary \033[0;32m${f}\033[0m has ${k}_\033[0;33m$version\033[0m greater than max version ${k}_\033[0;33m${threshold_version[$k]}\033[0m"
@ -23,7 +31,11 @@ main()
fi
done
echo -e "[\033[0;32mOK\033[0m] ${k}_\033[0;33m${threshold_version[$k]}\033[0m"
if [[ "$version" = "PRV" || "$version" = "UND" ]]; then
echo -e "[\033[0;90mSKIP\033[0m] \033[0;33m${version}\033[0m < ${k}_\033[0;33m${threshold_version[$k]}\033[0m"
else
echo -e "[\033[0;32mOK\033[0m] \033[0;33m${version}\033[0m < ${k}_\033[0;33m${threshold_version[$k]}\033[0m"
fi
done
}