Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpupower: avoid multiple definition with gcc -fno-common

Building cpupower with -fno-common in CFLAGS results in errors due to
multiple definitions of the 'cpu_count' and 'start_time' variables.

./utils/idle_monitor/snb_idle.o:./utils/idle_monitor/cpupower-monitor.h:28:
multiple definition of `cpu_count';
./utils/idle_monitor/nhm_idle.o:./utils/idle_monitor/cpupower-monitor.h:28:
first defined here
...
./utils/idle_monitor/cpuidle_sysfs.o:./utils/idle_monitor/cpuidle_sysfs.c:22:
multiple definition of `start_time';
./utils/idle_monitor/amd_fam14h_idle.o:./utils/idle_monitor/amd_fam14h_idle.c:85:
first defined here

The -fno-common option will be enabled by default in GCC 10.

Bug: https://bugs.gentoo.org/707462
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Mike Gilbert and committed by
Shuah Khan
2de7fb60 bb6d3fb3

+5 -3
+1 -1
tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
··· 82 82 static struct pci_dev *amd_fam14h_pci_dev; 83 83 static int nbp1_entered; 84 84 85 - struct timespec start_time; 85 + static struct timespec start_time; 86 86 static unsigned long long timediff; 87 87 88 88 #ifdef DEBUG
+1 -1
tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
··· 19 19 20 20 static unsigned long long **previous_count; 21 21 static unsigned long long **current_count; 22 - struct timespec start_time; 22 + static struct timespec start_time; 23 23 static unsigned long long timediff; 24 24 25 25 static int cpuidle_get_count_percent(unsigned int id, double *percent,
+2
tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
··· 27 27 0 28 28 }; 29 29 30 + int cpu_count; 31 + 30 32 static struct cpuidle_monitor *monitors[MONITORS_MAX]; 31 33 static unsigned int avail_monitors; 32 34
+1 -1
tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
··· 25 25 #endif 26 26 #define CSTATE_DESC_LEN 60 27 27 28 - int cpu_count; 28 + extern int cpu_count; 29 29 30 30 /* Hard to define the right names ...: */ 31 31 enum power_range_e {