lkml.org 
[lkml]   [2020]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 056/155] cpupower: avoid multiple definition with gcc -fno-common
    Date
    From: Mike Gilbert <floppym@gentoo.org>

    [ Upstream commit 2de7fb60a4740135e03cf55c1982e393ccb87b6b ]

    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>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c | 2 +-
    tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c | 2 +-
    tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c | 2 ++
    tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h | 2 +-
    4 files changed, 5 insertions(+), 3 deletions(-)

    diff --git a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
    index 3f893b99b337c..555cb338a71a4 100644
    --- a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
    +++ b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
    @@ -82,7 +82,7 @@ static struct pci_access *pci_acc;
    static struct pci_dev *amd_fam14h_pci_dev;
    static int nbp1_entered;

    -struct timespec start_time;
    +static struct timespec start_time;
    static unsigned long long timediff;

    #ifdef DEBUG
    diff --git a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
    index f634aeb65c5f6..7fb4f7a291ad5 100644
    --- a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
    +++ b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
    @@ -19,7 +19,7 @@ struct cpuidle_monitor cpuidle_sysfs_monitor;

    static unsigned long long **previous_count;
    static unsigned long long **current_count;
    -struct timespec start_time;
    +static struct timespec start_time;
    static unsigned long long timediff;

    static int cpuidle_get_count_percent(unsigned int id, double *percent,
    diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
    index d3c3e6e7aa26c..3d54fd4336261 100644
    --- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
    +++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
    @@ -27,6 +27,8 @@ struct cpuidle_monitor *all_monitors[] = {
    0
    };

    +int cpu_count;
    +
    static struct cpuidle_monitor *monitors[MONITORS_MAX];
    static unsigned int avail_monitors;

    diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
    index a2d901d3bfaf9..eafef38f1982e 100644
    --- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
    +++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
    @@ -25,7 +25,7 @@
    #endif
    #define CSTATE_DESC_LEN 60

    -int cpu_count;
    +extern int cpu_count;

    /* Hard to define the right names ...: */
    enum power_range_e {
    --
    2.20.1


    \
     
     \ /
      Last update: 2020-03-31 11:14    [W:4.123 / U:0.088 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site