Skip to content
Permalink
Browse files
kbuild: decouple build from userspace headers
First, userspace headers can be under incompatible license.

Second, kernel doesn't require userspace to operate and should not
require anything from userspace to be built other than compiler.
We would use -ffreestanding too if not builtin function shenanigans.

To decouple:

* ship minimal stdarg.h as <linux/stdarg.h>,
	1 type, 4 macros

GPL 2 version of <stdarg.h> can be extracted from
http://archive.debian.org/debian/pool/main/g/gcc-4.2/gcc-4.2_4.2.4.orig.tar.gz

* delete "-isystem" from command line arguments,
	this is what enables header leakage

* fixup/delete include directives where necessary.

Link: https://lkml.kernel.org/r/YO8ioz4sHwcUAkdt@localhost.localdomain
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Alexey Dobriyan authored and hnaz committed Jul 16, 2021
1 parent 1a131dd commit c1af5351189e92e8d4c666f636b51c0bfe262a27
Show file tree
Hide file tree
Showing 62 changed files with 44 additions and 77 deletions.
@@ -972,7 +972,7 @@ KBUILD_CFLAGS += -falign-functions=64
endif

# arch Makefile may override CC so keep this after arch Makefile is included
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
NOSTDINC_FLAGS += -nostdinc

# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement
@@ -5,8 +5,6 @@
* Copyright (C) 1996-2000 Russell King - Converted to ARM.
* Original Copyright (C) 1995 Linus Torvalds
*/
#include <stdarg.h>

#include <linux/export.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
@@ -10,8 +10,6 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include <stdarg.h>
#include <linux/smp.h>
#include <linux/io.h>
#include <linux/ioport.h>
@@ -6,9 +6,6 @@
* Copyright (C) 1996-2000 Russell King - Converted to ARM.
* Copyright (C) 2012 ARM Ltd.
*/

#include <stdarg.h>

#include <linux/compat.h>
#include <linux/efi.h>
#include <linux/elf.h>
@@ -14,8 +14,6 @@
*/

#define __KERNEL_SYSCALLS__
#include <stdarg.h>

#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
@@ -51,7 +51,7 @@
* prumpf 991016
*/

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/delay.h>
#include <linux/init.h>
@@ -17,9 +17,6 @@
* Copyright (C) 2001-2014 Helge Deller <deller@gmx.de>
* Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org>
*/

#include <stdarg.h>

#include <linux/elf.h>
#include <linux/errno.h>
#include <linux/kernel.h>
@@ -11,7 +11,6 @@

#undef DEBUG

#include <stdarg.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/init.h>
@@ -14,7 +14,7 @@
/* we cannot use FORTIFY as it brings in new symbols */
#define __NO_FORTIFY

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/init.h>
@@ -7,7 +7,7 @@
* Copyright (C) 2001 IBM.
*/

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/spinlock.h>
@@ -5,7 +5,7 @@
* c 2001 PPC 64 Team, IBM Corp
*/

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/console.h>
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/kernel.h>
#include <linux/stdarg.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <asm/stacktrace.h>
@@ -8,7 +9,6 @@
#include <asm/setup.h>
#include <asm/sclp.h>
#include <asm/uv.h>
#include <stdarg.h>
#include "boot.h"

const char hex_asc[] = "0123456789abcdef";
@@ -8,9 +8,6 @@
/*
* This file handles the architecture-dependent parts of process handling..
*/

#include <stdarg.h>

#include <linux/elfcore.h>
#include <linux/errno.h>
#include <linux/module.h>
@@ -9,9 +9,6 @@
/*
* This file handles the architecture-dependent parts of process handling..
*/

#include <stdarg.h>

#include <linux/errno.h>
#include <linux/export.h>
#include <linux/sched.h>
@@ -7,7 +7,6 @@
#define __IRQ_USER_H__

#include <sysdep/ptrace.h>
#include <stdbool.h>

enum um_irq_type {
IRQ_READ,
@@ -8,7 +8,6 @@
#ifndef __OS_H__
#define __OS_H__

#include <stdarg.h>
#include <irq_user.h>
#include <longjmp.h>
#include <mm_id.h>
@@ -67,7 +67,7 @@ int signals_enabled;
#ifdef UML_CONFIG_UML_TIME_TRAVEL_SUPPORT
static int signals_blocked;
#else
#define signals_blocked false
#define signals_blocked 0
#endif
static unsigned int signals_pending;
static unsigned int signals_active = 0;
@@ -3,6 +3,7 @@
* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
*/

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -18,7 +18,7 @@

#ifndef __ASSEMBLY__

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/types.h>
#include <linux/edd.h>
#include <asm/setup.h>
@@ -15,8 +15,6 @@

#define AEGIS_BLOCK_SIZE 16

#include <stddef.h>

extern int aegis128_have_aes_insn;

void *memcpy(void *dest, const void *src, size_t n);
@@ -8,7 +8,6 @@

#define pr_fmt(fmt) "xen-blkback: " fmt

#include <stdarg.h>
#include <linux/module.h>
#include <linux/kthread.h>
#include <xen/events.h>
@@ -7,7 +7,7 @@
* Copyright 2011 Intel Corporation; author Matt Fleming
*/

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/ctype.h>
#include <linux/efi.h>
@@ -10,7 +10,7 @@
* Oh, it's a waste of space, but oh-so-yummy for debugging.
*/

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/compiler.h>
#include <linux/ctype.h>
@@ -28,9 +28,9 @@
*/

#include <linux/delay.h>
#include <linux/stdarg.h>

#include "dm_services.h"
#include <stdarg.h>

#include "dc.h"
#include "dc_dmub_srv.h"
@@ -39,7 +39,6 @@
#include <linux/types.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <stdarg.h>

#include "atomfirmware.h"

@@ -25,7 +25,7 @@

#define DEBUG /* for pr_debug() */

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/io.h>
#include <linux/moduleparam.h>
@@ -25,7 +25,6 @@
#include <linux/pm_runtime.h>
#include <linux/kthread.h>
#include <linux/devcoredump.h>
#include <stdarg.h>
#include "msm_kms.h"

#define MSM_DISP_SNAPSHOT_MAX_BLKS 10
@@ -379,7 +379,7 @@ static char *pnames[] =
/*2f */ "Useruserdata"
};

#include <stdarg.h>
#include <linux/stdarg.h>

/*-------------------------------------------------------*/
static _cdebbuf *bufprint(_cdebbuf *cdb, char *fmt, ...)
@@ -2,7 +2,6 @@
/*
* Driver for the ADB controller in the Mac I/O (Hydra) chip.
*/
#include <stdarg.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/kernel.h>
@@ -9,7 +9,7 @@
*
* Copyright (C) 1996 Paul Mackerras.
*/
#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/kernel.h>
@@ -23,8 +23,6 @@
* Apple's "ADB Analyzer" bus sniffer is invaluable:
* ftp://ftp.apple.com/developer/Tool_Chest/Devices_-_Hardware/Apple_Desktop_Bus/
*/

#include <stdarg.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/kernel.h>
@@ -18,7 +18,7 @@
* a sleep or a freq. switch
*
*/
#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/mutex.h>
#include <linux/types.h>
#include <linux/errno.h>
@@ -79,7 +79,6 @@

#undef HERMES_DEBUG
#ifdef HERMES_DEBUG
#include <stdarg.h>

#define DEBUG(lvl, stuff...) if ((lvl) <= HERMES_DEBUG) DMSG(stuff)

@@ -7,7 +7,6 @@
#define IOSM_IPC_IMEM_H

#include <linux/skbuff.h>
#include <stdbool.h>

#include "iosm_ipc_mmio.h"
#include "iosm_ipc_pcie.h"
@@ -5,7 +5,6 @@
#define ASPEED_PINMUX_H

#include <linux/regmap.h>
#include <stdbool.h>

/*
* The ASPEED SoCs provide typically more than 200 pins for GPIO and other
@@ -10,7 +10,6 @@
/***************************************************************************
* OS specific includes
*/
#include <stdarg.h>
#include <linux/module.h>
#include <linux/debugfs.h>
#include <linux/firmware.h>
@@ -16,8 +16,6 @@
#ifndef __ISP_LOCAL_H_INCLUDED__
#define __ISP_LOCAL_H_INCLUDED__

#include <stdbool.h>

#include "isp_global.h"

#include <isp2400_support.h>
@@ -16,7 +16,7 @@
#ifndef __PRINT_SUPPORT_H_INCLUDED__
#define __PRINT_SUPPORT_H_INCLUDED__

#include <stdarg.h>
#include <linux/stdarg.h>

extern int (*sh_css_printf)(const char *fmt, va_list args);
/* depends on host supplied print function in ia_css_init() */
@@ -17,7 +17,7 @@
#define __IA_CSS_ENV_H

#include <type_support.h>
#include <stdarg.h> /* va_list */
#include <linux/stdarg.h> /* va_list */
#include "ia_css_types.h"
#include "ia_css_acc_types.h"

@@ -19,7 +19,7 @@
/*! \file */

#include <type_support.h>
#include <stdarg.h>
#include <linux/stdarg.h>
#include "ia_css_types.h"
#include "ia_css_binary.h"
#include "ia_css_frame_public.h"
@@ -20,7 +20,7 @@
#include <math_support.h>
#include <type_support.h>
#include <platform_support.h>
#include <stdarg.h>
#include <linux/stdarg.h>

#if !defined(ISP2401)
#include "input_formatter.h"
@@ -33,8 +33,6 @@

#define pr_fmt(fmt) "xen-pvscsi: " fmt

#include <stdarg.h>

#include <linux/module.h>
#include <linux/utsname.h>
#include <linux/interrupt.h>
@@ -14,7 +14,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#ifdef __KERNEL__

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/string.h>
#include <linux/spinlock.h>
#include <linux/kernel.h>
@@ -8,7 +8,7 @@
#include <linux/string.h>
#include <linux/buffer_head.h>

#include <stdarg.h>
#include <linux/stdarg.h>

static char error_buf[1024];
static char fmt_buf[1024];

0 comments on commit c1af535

Please sign in to comment.