From 44a52d79f25f7c3ab6b727fec9916e95612ad231 Mon Sep 17 00:00:00 2001 From: Jacob Wang Date: Sun, 27 Sep 2020 23:49:34 +0800 Subject: [PATCH] use extern in header files when declaring global variables this change has given better compatible with both gcc8 and gcc10 toolchain, should be maintained util upstream fixes A common mistake in C is omitting extern when declaring a global variable in a header file. If the header is included by several files it results in multiple definitions of the same variable. In previous GCC versions this error is ignored. GCC 10 defaults to -fno-common, which means a linker error will now be reported. To fix this, use extern in header files when declaring global variables, and ensure each global is defined in exactly one C file. If tentative definitions of particular variables need to be placed in a common block, __attribute__((__common__)) can be used to force that behavior even in code compiled without -fcommon. As a workaround, legacy C code where all tentative definitions should be placed into a common block can be compiled with -fcommon. int x; // tentative definition - avoid in header files extern int y; // correct declaration in a header file this change has given better compatible with gcc10 toolchain, should be maintained util upstream fixes 'multiple definition ...' warnings Signed-off-by: Jacob Wang Signed-off-by: weitao zhou --- ...ix-build-failure-with-gcc-fno-common.patch | 294 ++++++++++++++++++ satyr.spec | 11 +- 2 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 1001-Fix-build-failure-with-gcc-fno-common.patch diff --git a/1001-Fix-build-failure-with-gcc-fno-common.patch b/1001-Fix-build-failure-with-gcc-fno-common.patch new file mode 100644 index 0000000..a276fce --- /dev/null +++ b/1001-Fix-build-failure-with-gcc-fno-common.patch @@ -0,0 +1,294 @@ +From 0af82291c7c80cc0a1b486882242774211e5d8d4 Mon Sep 17 00:00:00 2001 +From: Michal Fabik +Date: Tue, 28 Jan 2020 08:59:36 +0100 +Subject: [PATCH] Fix build failure with gcc -fno-common + +Definitions of the extern symbols are found in the existing versions of the corresponding .c files. + +Signed-off-by: Michal Fabik +--- + python/py_core_frame.h | 2 +- + python/py_core_stacktrace.h | 2 +- + python/py_core_thread.h | 2 +- + python/py_gdb_frame.h | 2 +- + python/py_gdb_stacktrace.h | 2 +- + python/py_gdb_thread.h | 2 +- + python/py_java_frame.h | 2 +- + python/py_java_stacktrace.h | 2 +- + python/py_java_thread.h | 2 +- + python/py_js_frame.h | 2 +- + python/py_js_stacktrace.h | 2 +- + python/py_koops_frame.h | 2 +- + python/py_koops_stacktrace.h | 2 +- + python/py_operating_system.h | 2 +- + python/py_python_frame.h | 2 +- + python/py_python_stacktrace.h | 2 +- + python/py_report.h | 2 +- + python/py_rpm_package.h | 2 +- + python/py_ruby_frame.h | 2 +- + python/py_ruby_stacktrace.h | 2 +- + 20 files changed, 20 insertions(+), 20 deletions(-) + +diff --git a/python/py_core_frame.h b/python/py_core_frame.h +index dc4a3a2..bc002e6 100644 +--- a/python/py_core_frame.h ++++ b/python/py_core_frame.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_core_frame_type; ++extern PyTypeObject sr_py_core_frame_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_frame. +diff --git a/python/py_core_stacktrace.h b/python/py_core_stacktrace.h +index f458a23..6d91e40 100644 +--- a/python/py_core_stacktrace.h ++++ b/python/py_core_stacktrace.h +@@ -35,7 +35,7 @@ extern "C" { + struct sr_py_core_frame; + struct sr_py_core_thread; + +-PyTypeObject sr_py_core_stacktrace_type; ++extern PyTypeObject sr_py_core_stacktrace_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_multi_thread_stacktrace. +diff --git a/python/py_core_thread.h b/python/py_core_thread.h +index 2890ff1..c400fb0 100644 +--- a/python/py_core_thread.h ++++ b/python/py_core_thread.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_core_thread_type; ++extern PyTypeObject sr_py_core_thread_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_thread. +diff --git a/python/py_gdb_frame.h b/python/py_gdb_frame.h +index a5f6911..64d49b2 100644 +--- a/python/py_gdb_frame.h ++++ b/python/py_gdb_frame.h +@@ -33,7 +33,7 @@ extern "C" { + #include + #include "gdb/frame.h" + +-PyTypeObject sr_py_gdb_frame_type; ++extern PyTypeObject sr_py_gdb_frame_type; + + typedef sr_gdb_frame_address_t sr_py_gdb_frame_address_t; + +diff --git a/python/py_gdb_stacktrace.h b/python/py_gdb_stacktrace.h +index f5a1765..6c977be 100644 +--- a/python/py_gdb_stacktrace.h ++++ b/python/py_gdb_stacktrace.h +@@ -35,7 +35,7 @@ extern "C" { + struct sr_py_gdb_frame; + struct sr_py_gdb_thread; + +-PyTypeObject sr_py_gdb_stacktrace_type; ++extern PyTypeObject sr_py_gdb_stacktrace_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_multi_thread_stacktrace. +diff --git a/python/py_gdb_thread.h b/python/py_gdb_thread.h +index 39d5163..f518fd8 100644 +--- a/python/py_gdb_thread.h ++++ b/python/py_gdb_thread.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_gdb_thread_type; ++extern PyTypeObject sr_py_gdb_thread_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_thread. +diff --git a/python/py_java_frame.h b/python/py_java_frame.h +index 9f30eb5..ce77cd2 100644 +--- a/python/py_java_frame.h ++++ b/python/py_java_frame.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_java_frame_type; ++extern PyTypeObject sr_py_java_frame_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_frame. +diff --git a/python/py_java_stacktrace.h b/python/py_java_stacktrace.h +index 9cbe80a..1ddf412 100644 +--- a/python/py_java_stacktrace.h ++++ b/python/py_java_stacktrace.h +@@ -35,7 +35,7 @@ extern "C" { + struct sr_py_java_frame; + struct sr_py_java_thread; + +-PyTypeObject sr_py_java_stacktrace_type; ++extern PyTypeObject sr_py_java_stacktrace_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_multi_thread_stacktrace. +diff --git a/python/py_java_thread.h b/python/py_java_thread.h +index 0abe8bc..d95438f 100644 +--- a/python/py_java_thread.h ++++ b/python/py_java_thread.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_java_thread_type; ++extern PyTypeObject sr_py_java_thread_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_thread. +diff --git a/python/py_js_frame.h b/python/py_js_frame.h +index 4374f17..8ce154e 100644 +--- a/python/py_js_frame.h ++++ b/python/py_js_frame.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_js_frame_type; ++extern PyTypeObject sr_py_js_frame_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_frame. +diff --git a/python/py_js_stacktrace.h b/python/py_js_stacktrace.h +index 4c24476..14f6c36 100644 +--- a/python/py_js_stacktrace.h ++++ b/python/py_js_stacktrace.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_js_stacktrace_type; ++extern PyTypeObject sr_py_js_stacktrace_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_thread. +diff --git a/python/py_koops_frame.h b/python/py_koops_frame.h +index 81174de..7d658d7 100644 +--- a/python/py_koops_frame.h ++++ b/python/py_koops_frame.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_koops_frame_type; ++extern PyTypeObject sr_py_koops_frame_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_frame. +diff --git a/python/py_koops_stacktrace.h b/python/py_koops_stacktrace.h +index e72ab54..bea12c9 100644 +--- a/python/py_koops_stacktrace.h ++++ b/python/py_koops_stacktrace.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_koops_stacktrace_type; ++extern PyTypeObject sr_py_koops_stacktrace_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_thread. +diff --git a/python/py_operating_system.h b/python/py_operating_system.h +index bcd8e7f..dbfa024 100644 +--- a/python/py_operating_system.h ++++ b/python/py_operating_system.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_operating_system_type; ++extern PyTypeObject sr_py_operating_system_type; + + struct sr_py_operating_system + { +diff --git a/python/py_python_frame.h b/python/py_python_frame.h +index 6b4b63f..6cdde88 100644 +--- a/python/py_python_frame.h ++++ b/python/py_python_frame.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_python_frame_type; ++extern PyTypeObject sr_py_python_frame_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_frame. +diff --git a/python/py_python_stacktrace.h b/python/py_python_stacktrace.h +index a89ad8f..fff51c4 100644 +--- a/python/py_python_stacktrace.h ++++ b/python/py_python_stacktrace.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_python_stacktrace_type; ++extern PyTypeObject sr_py_python_stacktrace_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_thread. +diff --git a/python/py_report.h b/python/py_report.h +index 88ec30f..2c5bb8d 100644 +--- a/python/py_report.h ++++ b/python/py_report.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_report_type; ++extern PyTypeObject sr_py_report_type; + + struct sr_py_report + { +diff --git a/python/py_rpm_package.h b/python/py_rpm_package.h +index 0a00d8d..363acd6 100644 +--- a/python/py_rpm_package.h ++++ b/python/py_rpm_package.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_rpm_package_type; ++extern PyTypeObject sr_py_rpm_package_type; + + struct sr_py_rpm_package + { +diff --git a/python/py_ruby_frame.h b/python/py_ruby_frame.h +index 7f460ff..e7aa568 100644 +--- a/python/py_ruby_frame.h ++++ b/python/py_ruby_frame.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_ruby_frame_type; ++extern PyTypeObject sr_py_ruby_frame_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_frame. +diff --git a/python/py_ruby_stacktrace.h b/python/py_ruby_stacktrace.h +index f4eebce..59d866b 100644 +--- a/python/py_ruby_stacktrace.h ++++ b/python/py_ruby_stacktrace.h +@@ -32,7 +32,7 @@ extern "C" { + #include + #include + +-PyTypeObject sr_py_ruby_stacktrace_type; ++extern PyTypeObject sr_py_ruby_stacktrace_type; + + /* The beginning of this structure has to have the same layout as + * sr_py_base_thread. +-- +2.24.1 + diff --git a/satyr.spec b/satyr.spec index 86d67a1..373a4a1 100644 --- a/satyr.spec +++ b/satyr.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 %{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} %if 0%{?fedora} || 0%{?rhel} > 7 @@ -27,7 +28,7 @@ Name: satyr Version: 0.26 -Release: 2%{?dist} +Release: 2%{anolis_release}%{?dist} Summary: Tools to create anonymous, machine-friendly problem reports License: GPLv2+ URL: https://github.com/abrt/satyr @@ -63,6 +64,11 @@ BuildRequires: git Patch0001: 0001-Anonymize-paths-in-frames.patch Patch0002: 0002-testsuite-Correct-syntax-for-gdb-backtrace-command.patch +# Begin: Anolis customized patches +# Backport from fc32 to fix FTBFS on gcc10 +Patch1001: 1001-Fix-build-failure-with-gcc-fno-common.patch +# End: Anolis customized patches + %description Satyr is a library that can be used to create and process microreports. @@ -179,6 +185,9 @@ make check|| { %endif %changelog +* Wed Dec 01 2021 Weitao Zhou 0.26-2.0.1 +- use extern in header files when declaring global variables for compatible gcc10 build + * Fri Jun 29 2018 Matej Habrnal 0.26-2 - Anonymize paths in frames - Test fix: correct syntax for gdb backtrace command -- Gitee