Skip to content

Commit 7f6a164

Browse files
committed
Prepare for experiments with gcc-12
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
1 parent 61b4e99 commit 7f6a164

10 files changed

Lines changed: 71 additions & 30 deletions

File tree

cmake/init-compilation-flags.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if(APPLE)
3636
add_definitions(-D_XOPEN_SOURCE)
3737
else()
3838
# Since Ubuntu 22.04 lto is enabled by default; breaks some builds
39-
add_link_options(-fno-lto)
39+
#add_link_options(-fno-lto)
4040
endif()
4141

4242

@@ -73,7 +73,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL ${DEFAULT_BUILD_TYPE})
7373
list(APPEND COMPILE_LTO_OPTIONS -ffat-lto-objects)
7474
endif()
7575
if(COMPILER_GCC)
76-
list(APPEND COMPILE_LTO_OPTIONS -fuse-linker-plugin -Wl,-flto)
76+
list(APPEND COMPILE_LTO_OPTIONS -Wl,-flto)
7777
endif()
7878
add_compile_options(${COMPILE_LTO_OPTIONS})
7979
add_link_options(${LINK_LTO_OPTIONS})

cmake/utils.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ endfunction()
6969

7070
function(allow_deprecated_declarations)
7171
foreach(src_file ${ARGN})
72-
set_source_files_properties(${src_file} PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
72+
set_property(SOURCE ${src_file} APPEND PROPERTY COMPILE_OPTIONS -Wno-deprecated-declarations)
73+
endforeach()
74+
endfunction()
75+
76+
function(allow_stringop_overflow)
77+
foreach(src_file ${ARGN})
78+
set_property(SOURCE ${src_file} APPEND PROPERTY COMPILE_OPTIONS -Wno-stringop-overflow)
7379
endforeach()
7480
endfunction()
7581

compiler/compiler-settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void CompilerSettings::init() {
340340
std::string cxx_default_flags = ss.str();
341341

342342
cxx_toolchain_option.value_ = !cxx_toolchain_dir.value_.empty() ? ("-B" + cxx_toolchain_dir.value_) : "";
343-
incremental_linker_flags.value_ = dynamic_incremental_linkage.get() ? "-shared" : "-r -nostdlib";
343+
incremental_linker_flags.value_ = dynamic_incremental_linkage.get() ? "-shared" : "-r -nostdlib -gdwarf64 -gdwarf-5 -mcmodel=large -flto -Wl,-flto -flinker-output=rel";
344344

345345
remove_extra_spaces(extra_ld_flags.value_);
346346

compiler/compiler.cmake

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,36 @@ prepend(KPHP_COMPILER_SOURCES ${KPHP_COMPILER_DIR}/
225225
utils/string-utils.cpp)
226226

227227
# Suppress YAML-cpp-related warnings
228-
if(COMPILER_CLANG)
229-
allow_deprecated_declarations(${KPHP_COMPILER_DIR}/data/composer-json-data.cpp)
230-
allow_deprecated_declarations(${KPHP_COMPILER_DIR}/data/modulite-data.cpp)
228+
if(COMPILER_CLANG OR (COMPILER_GCC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0")))
229+
allow_deprecated_declarations(
230+
${KPHP_COMPILER_DIR}/data/composer-json-data.cpp
231+
${KPHP_COMPILER_DIR}/data/modulite-data.cpp
232+
)
233+
endif()
234+
235+
if(COMPILER_GCC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0"))
236+
allow_stringop_overflow(
237+
${KPHP_COMPILER_DIR}/code-gen/vertex-compiler.cpp
238+
${KPHP_COMPILER_DIR}/data/class-data.cpp
239+
${KPHP_COMPILER_DIR}/data/kphp-json-tags.cpp
240+
${KPHP_COMPILER_DIR}/data/generics-mixins.cpp
241+
${KPHP_COMPILER_DIR}/data/kphp-tracing-tags.cpp
242+
${KPHP_COMPILER_DIR}/data/modulite-data.cpp
243+
${KPHP_COMPILER_DIR}/code-gen/files/tracing-autogen.cpp
244+
${KPHP_COMPILER_DIR}/pipes/analyze-performance.cpp
245+
${KPHP_COMPILER_DIR}/pipes/check-access-modifiers.cpp
246+
${KPHP_COMPILER_DIR}/pipes/check-classes.cpp
247+
${KPHP_COMPILER_DIR}/pipes/check-tl-classes.cpp
248+
${KPHP_COMPILER_DIR}/pipes/code-gen.cpp
249+
${KPHP_COMPILER_DIR}/pipes/filter-only-actually-used.cpp
250+
${KPHP_COMPILER_DIR}/pipes/final-check.cpp
251+
${KPHP_COMPILER_DIR}/pipes/parse-and-apply-phpdoc.cpp
252+
${KPHP_COMPILER_DIR}/pipes/sort-and-inherit-classes.cpp
253+
${KPHP_COMPILER_DIR}/pipes/register-kphp-configuration.cpp
254+
${KPHP_COMPILER_DIR}/phpdoc.cpp
255+
${KPHP_COMPILER_DIR}/gentree.cpp
256+
${KPHP_COMPILER_DIR}/make/make.cpp
257+
)
231258
endif()
232259

233260
if(APPLE)

compiler/ffi/c_parser/parsing_driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <charconv>
1313
#include <unordered_set>
14+
#include <vector>
1415

1516
using namespace ffi;
1617

@@ -113,7 +114,7 @@ FFIType *ParsingDriver::function_to_var(FFIType *function) {
113114
function->kind = FFITypeKind::Var;
114115
FFIType *function_ptr_type = alloc.new_type(FFITypeKind::FunctionPointer);
115116
function_ptr_type->members = std::move(function->members);
116-
function->members = {function_ptr_type};
117+
function->members = std::vector<FFIType*>{function_ptr_type};
117118
return function;
118119
}
119120

runtime-common/core/core-types/definition/array.inl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,27 @@ bool array<T>::is_int_key(const typename array<T>::key_type& key) {
103103
return key.is_int();
104104
}
105105

106-
static uint8_t empty_array_raw_mem[2 * sizeof(array_inner_control)];
107-
108106
template<>
109107
inline typename array<Unknown>::array_inner* array<Unknown>::array_inner::empty_array() {
110108
// need this hack because gcc10 and newer complains about
111-
// "array subscript is outside array bounds of array<Unknown>::array_inner
112-
new (&empty_array_raw_mem) array_inner_control{
113-
true,
114-
ExtraRefCnt::for_global_const,
115-
-1,
116-
{0, 0},
117-
0,
118-
2,
119-
};
120-
return reinterpret_cast<array<Unknown>::array_inner*>(&empty_array_raw_mem);
109+
// "array subscript is outside array bounds of array<Unknown>::array_inner"
110+
static array_inner_control empty_array[2]{{
111+
true,
112+
ExtraRefCnt::for_global_const,
113+
-1,
114+
{0, 0},
115+
0,
116+
2,
117+
},
118+
{
119+
true,
120+
ExtraRefCnt::for_global_const,
121+
-1,
122+
{0, 0},
123+
0,
124+
2,
125+
}};
126+
return static_cast<array<Unknown>::array_inner*>(&empty_array[0]);
121127
}
122128

123129
template<class T>

runtime/runtime.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ set_source_files_properties(
142142
)
143143

144144
# Suppress YAML-cpp-related warnings
145-
if(COMPILER_CLANG)
145+
if(COMPILER_CLANG OR (COMPILER_GCC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0")))
146146
allow_deprecated_declarations(${BASE_DIR}/runtime/interface.cpp)
147147
endif()
148148

server/server.cmake

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ prepend(KPHP_SERVER_SOURCES ${BASE_DIR}/server/
3131
signal-handlers.cpp)
3232

3333
# Suppress YAML-cpp-related warnings
34-
if(COMPILER_CLANG)
35-
allow_deprecated_declarations(${BASE_DIR}/server/json-logger.cpp)
36-
allow_deprecated_declarations(${BASE_DIR}/server/lease-config-parser.cpp)
37-
allow_deprecated_declarations(${BASE_DIR}/server/php-engine.cpp)
38-
allow_deprecated_declarations(${BASE_DIR}/server/php-master.cpp)
39-
allow_deprecated_declarations(${BASE_DIR}/server/server-config.cpp)
34+
if(COMPILER_CLANG OR (COMPILER_GCC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0")))
35+
allow_deprecated_declarations(
36+
${BASE_DIR}/server/json-logger.cpp
37+
${BASE_DIR}/server/lease-config-parser.cpp
38+
${BASE_DIR}/server/php-engine.cpp
39+
${BASE_DIR}/server/php-master.cpp
40+
${BASE_DIR}/server/server-config.cpp
41+
)
4042
endif()
4143

4244
prepend(KPHP_JOB_WORKERS_SOURCES ${BASE_DIR}/server/job-workers/

tests/cpp/server/server-tests.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ prepend(SERVER_TESTS_SOURCES ${BASE_DIR}/tests/cpp/server/
77
workers-control-test.cpp)
88

99
# Suppress YAML-cpp-related warnings
10-
if(COMPILER_CLANG)
10+
if(COMPILER_CLANG OR (COMPILER_GCC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0")))
1111
allow_deprecated_declarations(${BASE_DIR}/tests/cpp/server/server-config-test.cpp)
1212
endif()
1313

vkext/vkext-rpc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,8 @@ void update_precise_now() {
154154
}
155155
}
156156

157-
static rpc_connection dummy_rpc_connection{};
158-
159157
rpc_connection *rpc_connection_get(int fd) {
158+
static rpc_connection dummy_rpc_connection{};
160159
dummy_rpc_connection.fd = fd;
161160
rpc_connection **T = tree_lookup_value_connection(rpc_connection_tree, reinterpret_cast<rpc_connection *>(&dummy_rpc_connection));
162161
return T ? *T : 0;

0 commit comments

Comments
 (0)