From: Michal Marek <mmarek@suse.cz>
To: Stephen Rothwell <sfr@canb.auug.org.au>, Sam Ravnborg <sam@ravnborg.org>
Cc: kbuild <linux-kbuild@vger.kernel.org>,
Thierry Reding <thierry.reding@gmail.com>,
David Herrmann <dh.herrmann@googlemail.com>,
Jiri Kosina <jkosina@suse.cz>
Subject: Re: [PATCH v2 0/6] kbuild: use target compiler for user binaries in samples/
Date: Thu, 21 Aug 2014 15:46:35 +0200 [thread overview]
Message-ID: <20140821134635.GA25607@sepie.suse.cz> (raw)
In-Reply-To: <53C7EA2A.6050301@suse.cz>
On Thu, Jul 17, 2014 at 05:22:18PM +0200, Michal Marek wrote:
> On 2014-07-14 02:33, Stephen Rothwell wrote:
> > Hi Sam,
> >
> > On Mon, 14 Jul 2014 10:29:36 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >>
> >> On Sun, 13 Jul 2014 20:36:37 +0200 Sam Ravnborg <sam@ravnborg.org> wrote:
> >>>
> >>> NOTE: This will likely break the build if the toolchain used do
> >>> not include a libc. Let's see how much noise this creates.
> >>
> >> Then I will drop them from linux-next. Until someone supplies lots of
> >> cross compilers with libc support, the samples can not (must not) be
> >> built by default.
> >
> > Just to be clear: for my current build infrastructure, this means
> > powerpc and x86_64 hosted cross compilers.
>
> So we basically can have zero, one or both of
> A) target toolchain with libc support
> B) host toolchain with recent enough kernel headers
>
> Just can idea - in case we have B, but not A, would it make sense to
> build $(uapiprogs-y) with the host compiler, but without the
> -Iusr/include flag?
Actually, we can build with the host compiler against the exported
headers, these just need to be exported for the right architecture.
How about the following patch (applies on top of 1/6 of
this series)? It creates a usr/host/include tree with headers for the
host architecture and builds the uapiprogs with the host compiler. This
should build in all scenarios that work today. The only downside is that
when cross-compiling, the sample binaries continue to be somewhat
impractical. But it is not _that_ difficult to build them by hand,
provided one has a complete cross-compiling setup.
Michal
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 6b691d3b..6466704 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -233,8 +233,3 @@ KBUILD_VMLINUX_MAIN
All object files for the main part of vmlinux.
KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN together specify
all the object files used to link vmlinux.
-
-UAPICFLAGS
---------------------------------------------------
-Arch specific flags used when building sample binaries.
-This is usually the machine size (32 versus 64 bit).
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 2c6d53b..163d5dd 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -746,7 +746,7 @@ Kbuild support building sample modules and sample binaries.
To build sample modules the existing infrastructure is used, but
to build sample binaries kbuild adds dedicated suppport.
-The sample binaries are build for the same host and bit-size as the kernel.
+The sample binaries are build for the architecture of the build host.
The samples may demonstrate facilities not yet available
in the installed libc therefore they are build so they include
diff --git a/Makefile b/Makefile
index 9f654a4..66073f2 100644
--- a/Makefile
+++ b/Makefile
@@ -968,11 +968,13 @@ prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
archprepare: archheaders archscripts prepare1 scripts_basic
-# To build userspace samples the uapi headers needs to be exported
+# To build userspace samples the uapi headers need to be exported for
+# the host architecture
prepare0: archprepare FORCE
$(Q)$(MAKE) $(build)=.
ifdef CONFIG_SAMPLES
- $(Q)$(MAKE) KBUILD_SRC= headers_install
+ $(MAKE) KBUILD_SRC= ARCH=$(SUBARCH) \
+ INSTALL_HDR_PATH=usr/host headers_install
endif
# All the preparing..
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 4b32933..874e6d6 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -18,7 +18,6 @@ LD_BFD := elf32-s390
LDFLAGS := -m elf_s390
KBUILD_CFLAGS += -m31
KBUILD_AFLAGS += -m31
-UAPICFLAGS += -m31
UTS_MACHINE := s390
STACK_SIZE := 8192
CHECKFLAGS += -D__s390__ -msize-long
@@ -29,7 +28,6 @@ KBUILD_AFLAGS_MODULE += -fPIC
KBUILD_CFLAGS_MODULE += -fPIC
KBUILD_CFLAGS += -m64
KBUILD_AFLAGS += -m64
-UAPICFLAGS += -m64
UTS_MACHINE := s390x
STACK_SIZE := 16384
CHECKFLAGS += -D__s390__ -D__s390x__
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index fc0dcf1..eaee146 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -26,7 +26,6 @@ UTS_MACHINE := sparc
KBUILD_CFLAGS += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
KBUILD_AFLAGS += -m32 -Wa,-Av8
-UAPICFLAGS += -m32
else
#####
@@ -43,7 +42,6 @@ KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare
KBUILD_CFLAGS += -Wa,--undeclared-regs
KBUILD_CFLAGS += $(call cc-option,-mtune=ultrasparc3)
KBUILD_AFLAGS += -m64 -mcpu=ultrasparc -Wa,--undeclared-regs
-UAPICFLAGS += -m64
ifeq ($(CONFIG_MCOUNT),y)
KBUILD_CFLAGS += -pg
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index add7271..c1aa368 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -47,7 +47,6 @@ ifeq ($(CONFIG_X86_32),y)
biarch := $(call cc-option,-m32)
KBUILD_AFLAGS += $(biarch)
KBUILD_CFLAGS += $(biarch)
- UAPICFLAGS += $(biarch)
KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
@@ -80,7 +79,6 @@ else
biarch := -m64
KBUILD_AFLAGS += -m64
KBUILD_CFLAGS += -m64
- UAPICFLAGS += -m64
# Don't autogenerate traditional x87, MMX or SSE instructions
KBUILD_CFLAGS += -mno-mmx -mno-sse
diff --git a/scripts/Makefile.uapiprogs b/scripts/Makefile.uapiprogs
index 63c09d0..c88a0cc 100644
--- a/scripts/Makefile.uapiprogs
+++ b/scripts/Makefile.uapiprogs
@@ -29,8 +29,7 @@ uapi-cmulti := $(addprefix $(obj)/,$(uapi-cmulti))
uapi-cobjs := $(addprefix $(obj)/,$(uapi-cobjs))
# Options to uapicc.
-uapic_flags = -Wp,-MD,$(depfile) -isystem $(INSTALL_HDR_PATH)/include \
- $(UAPICFLAGS) -Wall
+uapic_flags = -Wp,-MD,$(depfile) -isystem usr/host/include $(HOSTCFLAGS)
#####
# Compile uapi programs on the build host
@@ -38,21 +37,21 @@ uapic_flags = -Wp,-MD,$(depfile) -isystem $(INSTALL_HDR_PATH)/include \
# Create executable from a single .c file
# uapi-csingle -> executable
quiet_cmd_uapi-csingle = UAPICC $@
- cmd_uapi-csingle = $(CC) $(uapic_flags) -o $@ $<
+ cmd_uapi-csingle = $(HOSTCC) $(uapic_flags) -o $@ $<
$(uapi-csingle): $(obj)/%: $(src)/%.c FORCE
$(call if_changed_dep,uapi-csingle)
# Create .o file from a single .c file
# uapi-cobjs -> .o
quiet_cmd_uapi-cobjs = UAPICC $@
- cmd_uapi-cobjs = $(CC) $(uapic_flags) -c -o $@ $<
+ cmd_uapi-cobjs = $(HOSTCC) $(uapic_flags) -c -o $@ $<
$(uapi-cobjs): $(obj)/%.o: $(src)/%.c FORCE
$(call if_changed_dep,uapi-cobjs)
# Link an executable based on list of .o files
# uapi-cmulti -> executable
quiet_cmd_uapi-cmulti = UAPILD $@
- cmd_uapi-cmulti = $(CC) -o $@ \
+ cmd_uapi-cmulti = $(HOSTCC) -o $@ \
$(addprefix $(obj)/,$($(@F)-y))
$(uapi-cmulti): $(obj)/%: $(uapi-cobjs) FORCE
$(call if_changed,uapi-cmulti)
prev parent reply other threads:[~2014-08-21 13:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-13 18:36 [PATCH v2 0/6] kbuild: use target compiler for user binaries in samples/ Sam Ravnborg
2014-07-13 18:42 ` [PATCH 1/6] kbuild: add support for building userspace api programs Sam Ravnborg
2014-07-13 18:42 ` [PATCH 2/6] samples: refactor Makefile Sam Ravnborg
2014-07-13 19:25 ` Randy Dunlap
2014-07-13 19:52 ` Sam Ravnborg
2014-07-13 20:13 ` Randy Dunlap
2014-07-14 0:26 ` Stephen Rothwell
2014-07-13 18:42 ` [PATCH 3/6] samples: use uapiprogs support for seccomp Sam Ravnborg
2014-07-16 9:43 ` Masahiro Yamada
2014-07-16 10:31 ` Sam Ravnborg
2014-07-17 3:40 ` Masahiro Yamada
2014-07-13 18:42 ` [PATCH 4/6] samples: use uapiprogs support for hidraw Sam Ravnborg
2014-07-13 18:42 ` [PATCH 5/6] samples: fix warnings in uhid-example Sam Ravnborg
2014-07-13 18:42 ` [PATCH 6/6] samples: use uapiprogs support for uhid Sam Ravnborg
2014-07-13 19:23 ` [PATCH 1/6] kbuild: add support for building userspace api programs Randy Dunlap
2014-07-13 19:53 ` Sam Ravnborg
2014-07-14 0:29 ` [PATCH v2 0/6] kbuild: use target compiler for user binaries in samples/ Stephen Rothwell
2014-07-14 0:33 ` Stephen Rothwell
2014-07-17 15:22 ` Michal Marek
2014-08-21 13:46 ` Michal Marek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140821134635.GA25607@sepie.suse.cz \
--to=mmarek@suse.cz \
--cc=dh.herrmann@googlemail.com \
--cc=jkosina@suse.cz \
--cc=linux-kbuild@vger.kernel.org \
--cc=sam@ravnborg.org \
--cc=sfr@canb.auug.org.au \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox