Query on header test

From: Mukesh Ojha
Date: Thu Jun 10 2021 - 10:13:10 EST


Hi All,

We are facing issue while compiling kernel (5.4) in android (arm64) on ubuntu18 host machine
when header test is performed.
Note: there is no issue observed on ubuntu16.

And it is failing with below issue,

./usr/include/linux/videodev2.h:2323:20: error: field has incomplete type 'struct timespec'
        struct timespec                 timestamp;
                                        ^
./usr/include/linux/videodev2.h:2323:9: note: forward declaration of 'struct timespec'
        struct timespec                 timestamp;
               ^
1 error generated.


where in one of the headers "include/uapi/linux/videodev2.h" is including "sys/time.h"
Inside include/uapi/linux/videodev2.h
#ifndef __KERNEL__
#include <sys/time.h>
#endif

and it is try to search this file in host machine in "usr/include/x86_64-linux-gnu/sys/time.h".
but it is failing with that as looks like ubuntu18  packaged x86_64-linux-gnu time.h is not
compatible while it is compatible with ubuntu16 packaged time.h has no issue.

Defining _GNU_SOURCE is somehow fixing the issue the somehow.
And now i am not sure whether it is maintaining as per the standard of header test or it somehow
violates it.

diff --git a/usr/include/Makefile b/usr/include/Makefile
index bfc7f8e..7b789f7 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -8,7 +8,7 @@
 # We cannot go as far as adding -Wpedantic since it emits too many warnings.
 UAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration

-override c_flags = $(UAPI_CFLAGS) -Wp,-MD,$(depfile) -I$(objtree)/usr/include
+override c_flags = $(UAPI_CFLAGS) -Wp,-MD,$(depfile) -D_GNU_SOURCE -I$(objtree)/usr/include

Thanks,
Mukesh