From 4eeb05215915c26a19a09ee59a6e736b297dd8c1 Mon Sep 17 00:00:00 2001 From: Jacob Wang Date: Mon, 28 Sep 2020 20:34: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 --- 1001-v4l-utils-1.18.0-gcc10.patch | 46 +++++++++++++++++++++++++++++++ v4l-utils.spec | 10 ++++++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 1001-v4l-utils-1.18.0-gcc10.patch diff --git a/1001-v4l-utils-1.18.0-gcc10.patch b/1001-v4l-utils-1.18.0-gcc10.patch new file mode 100644 index 0000000..b6fb8de --- /dev/null +++ b/1001-v4l-utils-1.18.0-gcc10.patch @@ -0,0 +1,46 @@ +diff -Nuar v4l-utils-1.14.2.orig/lib/include/libdvbv5/desc_t2_delivery.h v4l-utils-1.14.2/lib/include/libdvbv5/desc_t2_delivery.h +--- v4l-utils-1.14.2.orig/lib/include/libdvbv5/desc_t2_delivery.h 2017-12-27 21:50:55.000000000 +0800 ++++ v4l-utils-1.14.2/lib/include/libdvbv5/desc_t2_delivery.h 2020-09-28 20:39:48.187770901 +0800 +@@ -215,7 +215,7 @@ + * @brief converts from internal representation to string the SISO_MISO + * field of dvb_desc_t2_delivery:SISO_MISO field. + */ +-const char *siso_miso[4]; ++extern const char *siso_miso[4]; + + #ifdef __cplusplus + } +diff -Nuar v4l-utils-1.14.2.orig/lib/libdvbv5/dvb-v5.h v4l-utils-1.14.2/lib/libdvbv5/dvb-v5.h +--- v4l-utils-1.14.2.orig/lib/libdvbv5/dvb-v5.h 2017-12-27 21:50:55.000000000 +0800 ++++ v4l-utils-1.14.2/lib/libdvbv5/dvb-v5.h 2020-09-28 20:40:47.656171183 +0800 +@@ -14,17 +14,17 @@ + char *name; + }; + extern struct fe_status_name fe_status_name[8]; +-const char *fe_code_rate_name[14]; +-const char *fe_modulation_name[15]; +-const char *fe_transmission_mode_name[10]; +-const unsigned fe_bandwidth_name[8]; +-const char *fe_guard_interval_name[12]; +-const char *fe_hierarchy_name[6]; +-const char *fe_voltage_name[4]; +-const char *fe_tone_name[3]; +-const char *fe_inversion_name[4]; +-const char *fe_pilot_name[4]; +-const char *fe_rolloff_name[5]; +-const char *dvb_v5_name[71]; +-const char *delivery_system_name[20]; ++extern const char *fe_code_rate_name[14]; ++extern const char *fe_modulation_name[15]; ++extern const char *fe_transmission_mode_name[10]; ++extern const unsigned fe_bandwidth_name[8]; ++extern const char *fe_guard_interval_name[12]; ++extern const char *fe_hierarchy_name[6]; ++extern const char *fe_voltage_name[4]; ++extern const char *fe_tone_name[3]; ++extern const char *fe_inversion_name[4]; ++extern const char *fe_pilot_name[4]; ++extern const char *fe_rolloff_name[5]; ++extern const char *dvb_v5_name[71]; ++extern const char *delivery_system_name[20]; + #endif diff --git a/v4l-utils.spec b/v4l-utils.spec index b213049..48cc9f1 100644 --- a/v4l-utils.spec +++ b/v4l-utils.spec @@ -1,6 +1,7 @@ +%define anolis_release .0.1 Name: v4l-utils Version: 1.14.2 -Release: 3%{?dist} +Release: 3%{anolis_release}%{?dist} Summary: Utilities for video4linux and DVB devices # libdvbv5, dvbv5 utils, ir-keytable and v4l2-sysfs-path are GPLv2 only License: GPLv2+ and GPLv2 @@ -9,6 +10,10 @@ URL: http://www.linuxtv.org/downloads/v4l-utils/ Source0: http://linuxtv.org/downloads/v4l-utils/v4l-utils-%{version}.tar.bz2 Patch0: v4l-utils-sysmacros.patch +# Begin: Anolis customized patches +Patch1001: 1001-v4l-utils-1.18.0-gcc10.patch +# End: Anolis customized patches + BuildRequires: alsa-lib-devel BuildRequires: desktop-file-utils BuildRequires: doxygen @@ -191,6 +196,9 @@ desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/qv4l2.desktop %changelog +* Wed Dec 01 2021 Weitao Zhou 1.14.2-3.0.1 +- use extern in header files when declaring global variables for compatible gcc10 build + * Sun Apr 29 2018 Peter Robinson 1.14.2-2 - Add sys/sysmacros.h include fix patch -- Gitee