Re: [PATCH] uapi: Make generic uapi headers compile standalone.

From: Randy Dunlap
Date: Thu Jun 07 2018 - 20:07:14 EST


On 06/06/2018 04:16 PM, Jayant Chowdhary wrote:
> In order for static analysis tools to analyze each of the uapi headers,
> we need to enable them to compile stand-alone. Some uapi headers were
> missing dependencies which would not make them compile stand-alone in
> user-land. This patch adds those dependencies.

Hi,

Thanks for getting started on this. I see that the kbuild robot and I were
still not able to do successful builds even after this patch is applied.
We were building different targets though. robot was doing kernel builds
and I was doing a large "all-uapi" build.

I started on my all-uapi work about 1 week ago but haven't posted anything yet,
but it's posted (attached) below. It's not yet up to kernel quality yet (for a
Makefile), and I have made very little progress toward a successful userspace build.

If anyone is interested, just put these 3 files in <kernel_tree>/tools/build
and then run:

make ARCH=$some_arch O=build_dir headers_check
so that the headers will be cleaned up and installed in build_dir/usr/.

Then run 'make -f all-uapi.mk'
and the userspace program with all header files found in build_dir/usr/include
will be built -- i.e., attempted (not successfully).

(note: chmod +x hdr-fix-lines.pl)


--
~Randy
# all-uapi.mk
# currently resides in tools/build/
#
# before running 'make -f all-uapi.mk',
# run (from top of kernel tree): make ARCH=arch O=dir headers_check
# so that the uapi headers will be installed.

srctree=../..
CC=gcc

all: all-uapi.h all-uapi.o

all-uapi.h: all-uapi.mk hdr-fix-lines.pl
rm -f all-uapi.h
touch all-uapi.h
# find $(srctree)/xx64/usr/include/uapi -type f | grep -v \\.orig |
find $(srctree)/xx64/usr/include -type f | grep -v \\.orig | \
./hdr-fix-lines.pl >>all-uapi.h

all-uapi.o: all-uapi.h
$(CC) -I../../xx64/usr/include all-uapi.c -o all-uapi.o
// SPDX GPL 2.0
// This userspace source file pulls in all #include <uapi/*> header files
// to see what kinds of problems happen.

#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>

#include <linux/posix_types.h>
#include <asm-generic/ipcbuf.h>

#include "all-uapi.h"

int main(int argc, char *argv[])
{
}

Attachment: hdr-fix-lines.pl
Description: Perl program