简体   繁体   中英

Android kernel build error: core_ctl.c - dereferencing pointer to incomplete type

This kernel builds fine with the ARM GCC toolchain.. for some reason, the aarch64 toolchain throws this error.

kernel/sched/core_ctl.c: In function 'cpufreq_gov_cb':
kernel/sched/core_ctl.c:1086:25: error: dereferencing pointer to incomplete type
   core_ctl_set_busy(info->cpu, info->load);
                         ^
kernel/sched/core_ctl.c:1086:36: error: dereferencing pointer to incomplete type
   core_ctl_set_busy(info->cpu, info->load);
                                    ^
scripts/Makefile.build:257: recipe for target 'kernel/sched/core_ctl.o' failed

Here's the struct at the very beginning of the file where "cpu" is defined (can't find load in the c file):

#include <linux/init.h>
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <linux/cpufreq.h>
#include <linux/timer.h>
#include <linux/kthread.h>
#include <linux/sched.h>
#include <linux/sched/rt.h>
#include <linux/mutex.h>

#include <trace/events/sched.h>

#define MAX_CPUS_PER_GROUP 4

struct cpu_data {
    /* Per CPU data. */
    bool    inited;
    bool    online;
    bool    rejected;
    bool    is_busy;
    bool    not_preferred;
    unsigned int busy;
    unsigned int cpu;
    struct list_head sib;
    unsigned int first_cpu;
    struct list_head pending_sib;

    /* Per cluster data set only on first CPU */
    unsigned int min_cpus;
    unsigned int max_cpus;
    unsigned int offline_delay_ms;
    unsigned int busy_up_thres[MAX_CPUS_PER_GROUP];
    unsigned int busy_down_thres[MAX_CPUS_PER_GROUP];
    unsigned int online_cpus;
    unsigned int avail_cpus;
    unsigned int num_cpus;
    unsigned int need_cpus;
    unsigned int task_thres;
    s64 need_ts;
    struct list_head lru;
    bool pending;
    spinlock_t pending_lock;
    bool is_big_cluster;
    int nrrun;
    bool nrrun_changed;
    struct timer_list timer;
    struct task_struct *hotplug_thread;
    struct kobject kobj;
    struct list_head pending_lru;
    bool disabled;
};

What could make the compiler report incomplete type? I'm not too familiar with pointers and structures in C yet.. can't figure it out.

It seems that the header file for struct cpufreq_govinfo is missing when the kernel/sched/core_ctl.c is compiled on your machine.

struct cpufreq_govinfo {
 unsigned int cpu;
 unsigned int load;
 unsigned int sampling_rate_us;
};

On my machine(ARM:CortexA7), the GCC compiler does not throw compile error since the following head file is properly included.

  kernel/include/linux/cpufreq.h

In addition, the following patch will enable you to have preprocessed file after building Linux Kernel.

diff --git a/Makefile b/Makefile
index b03ca98..f52240c 100644
--- a/Makefile
+++ b/Makefile
@@ -406,6 +406,7 @@ KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                   -fno-strict-aliasing -fno-common \
                   -Werror-implicit-function-declaration \
                   -Wno-format-security \
+                  -save-temps=obj \
                   -std=gnu89

If you take a look at the preprocessed file .tmp_core_ctl.i, you would be able to see all of the header files for compiling core_ctl.c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM