mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] tools/nolibc: fix build issues when building from tools/
@ 2022-05-28 15:45 Willy Tarreau
  2022-05-28 15:45 ` [PATCH 1/3] tools/nolibc: fix the makefile to also work as "make -C tools ..." Willy Tarreau
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Willy Tarreau @ 2022-05-28 15:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Paul E . McKenney, linux-kernel, Willy Tarreau

Hi,

Linus reported build issues when trying nolibc according to the
documented procedure in "make tools/help":

  https://lore.kernel.org/lkml/CAHk-=wgpAHhPVSqBWb4gYT=CRJzKAZ4inmrL_kcpeNWGkcg3pg@mail.gmail.com/

This series addresses this by setting the ARCH and OUTPUT variables and
adding a few targets to match default expectations. A "help" target also
explains what the existing targets do. This will be particularly useful
once the test suite is merged since it will add new targets.

Thanks,
Willy

---
Willy Tarreau (3):
  tools/nolibc: fix the makefile to also work as "make -C tools ..."
  tools/nolibc: make the default target build the headers
  tools/nolibc: add a help target to list supported targets

 tools/Makefile                |  3 +++
 tools/include/nolibc/Makefile | 37 +++++++++++++++++++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

-- 
2.17.5


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] tools/nolibc: fix the makefile to also work as "make -C tools ..."
  2022-05-28 15:45 [PATCH 0/3] tools/nolibc: fix build issues when building from tools/ Willy Tarreau
@ 2022-05-28 15:45 ` Willy Tarreau
  2022-05-28 15:45 ` [PATCH 2/3] tools/nolibc: make the default target build the headers Willy Tarreau
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Willy Tarreau @ 2022-05-28 15:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Paul E . McKenney, linux-kernel, Willy Tarreau

As reported by Linus, the nolibc's makefile is currently broken when
invoked as per the documented method (make -C tools nolibc_<target>),
because it now relies on the ARCH and OUTPUT variables that are not
set in this case.

This patch addresses this by sourcing subarch.include, and by
presetting OUTPUT to the current directory if not set. This is
sufficient to make the commands work both as a standalone target
and as a tools/ sub-target.

Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 tools/include/nolibc/Makefile | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 7a16d917c185..e8bac6ef3653 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -7,6 +7,22 @@ ifeq ($(srctree),)
 srctree := $(patsubst %/tools/include/,%,$(dir $(CURDIR)))
 endif
 
+# when run as make -C tools/ nolibc_<foo> the arch is not set
+ifeq ($(ARCH),)
+include $(srctree)/scripts/subarch.include
+ARCH = $(SUBARCH)
+endif
+
+# OUTPUT is only set when run from the main makefile, otherwise
+# it defaults to this nolibc directory.
+OUTPUT ?= $(CURDIR)/
+
+ifeq ($(V),1)
+Q=
+else
+Q=@
+endif
+
 nolibc_arch := $(patsubst arm64,aarch64,$(ARCH))
 arch_file := arch-$(nolibc_arch).h
 all_files := ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h string.h \
@@ -36,7 +52,7 @@ headers:
 
 headers_standalone: headers
 	$(Q)$(MAKE) -C $(srctree) headers
-	$(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)/sysroot
+	$(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot
 
 clean:
 	$(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"
-- 
2.17.5


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] tools/nolibc: make the default target build the headers
  2022-05-28 15:45 [PATCH 0/3] tools/nolibc: fix build issues when building from tools/ Willy Tarreau
  2022-05-28 15:45 ` [PATCH 1/3] tools/nolibc: fix the makefile to also work as "make -C tools ..." Willy Tarreau
@ 2022-05-28 15:45 ` Willy Tarreau
  2022-05-28 15:45 ` [PATCH 3/3] tools/nolibc: add a help target to list supported targets Willy Tarreau
  2022-05-31 15:23 ` [PATCH 0/3] tools/nolibc: fix build issues when building from tools/ Paul E. McKenney
  3 siblings, 0 replies; 5+ messages in thread
From: Willy Tarreau @ 2022-05-28 15:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Paul E . McKenney, linux-kernel, Willy Tarreau

The help in "make -C tools" enumerates nolibc as a valid target so we
must at least make it do something. Let's make it do the equivalent
of "make headers" in that it will prepare a sysroot with the arch's
headers, but will not install the kernel's headers. This is the
minimum some tools will need when built with a full-blown toolchain
anyway.

Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 tools/Makefile                | 3 +++
 tools/include/nolibc/Makefile | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/Makefile b/tools/Makefile
index c074e42fd92f..e497875fc7e3 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -78,6 +78,9 @@ bpf/%: FORCE
 libapi: FORCE
 	$(call descend,lib/api)
 
+nolibc: FORCE
+	$(call descend,include/nolibc)
+
 nolibc_%: FORCE
 	$(call descend,include/nolibc,$(patsubst nolibc_%,%,$@))
 
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index e8bac6ef3653..9768819abd55 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -29,7 +29,7 @@ all_files := ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h string.h \
              sys.h time.h types.h unistd.h
 
 # install all headers needed to support a bare-metal compiler
-all:
+all: headers
 
 # Note: when ARCH is "x86" we concatenate both x86_64 and i386
 headers:
-- 
2.17.5


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] tools/nolibc: add a help target to list supported targets
  2022-05-28 15:45 [PATCH 0/3] tools/nolibc: fix build issues when building from tools/ Willy Tarreau
  2022-05-28 15:45 ` [PATCH 1/3] tools/nolibc: fix the makefile to also work as "make -C tools ..." Willy Tarreau
  2022-05-28 15:45 ` [PATCH 2/3] tools/nolibc: make the default target build the headers Willy Tarreau
@ 2022-05-28 15:45 ` Willy Tarreau
  2022-05-31 15:23 ` [PATCH 0/3] tools/nolibc: fix build issues when building from tools/ Paul E. McKenney
  3 siblings, 0 replies; 5+ messages in thread
From: Willy Tarreau @ 2022-05-28 15:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Paul E . McKenney, linux-kernel, Willy Tarreau

The "help" target simply presents the list of supported targets
and the current set of variables being used to build the sysroot.

Since the help in tools/ suggests to use "install", which is
supported by most tools while such a target is not really relevant
here, an "install" target was also added, redirecting to "help".

Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 tools/include/nolibc/Makefile | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 9768819abd55..cfd06764b5ae 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -31,6 +31,23 @@ all_files := ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h string.h \
 # install all headers needed to support a bare-metal compiler
 all: headers
 
+install: help
+
+help:
+	@echo "Supported targets under nolibc:"
+	@echo "  all                 call \"headers\""
+	@echo "  clean               clean the sysroot"
+	@echo "  headers             prepare a sysroot in tools/include/nolibc/sysroot"
+	@echo "  headers_standalone  like \"headers\", and also install kernel headers"
+	@echo "  help                this help"
+	@echo ""
+	@echo "These targets may also be called from tools as \"make nolibc_<target>\"."
+	@echo ""
+	@echo "Currently using the following variables:"
+	@echo "  ARCH    = $(ARCH)"
+	@echo "  OUTPUT  = $(OUTPUT)"
+	@echo ""
+
 # Note: when ARCH is "x86" we concatenate both x86_64 and i386
 headers:
 	$(Q)mkdir -p $(OUTPUT)sysroot
-- 
2.17.5


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] tools/nolibc: fix build issues when building from tools/
  2022-05-28 15:45 [PATCH 0/3] tools/nolibc: fix build issues when building from tools/ Willy Tarreau
                   ` (2 preceding siblings ...)
  2022-05-28 15:45 ` [PATCH 3/3] tools/nolibc: add a help target to list supported targets Willy Tarreau
@ 2022-05-31 15:23 ` Paul E. McKenney
  3 siblings, 0 replies; 5+ messages in thread
From: Paul E. McKenney @ 2022-05-31 15:23 UTC (permalink / raw)
  To: Willy Tarreau; +Cc: Linus Torvalds, linux-kernel

On Sat, May 28, 2022 at 05:45:43PM +0200, Willy Tarreau wrote:
> Hi,
> 
> Linus reported build issues when trying nolibc according to the
> documented procedure in "make tools/help":
> 
>   https://lore.kernel.org/lkml/CAHk-=wgpAHhPVSqBWb4gYT=CRJzKAZ4inmrL_kcpeNWGkcg3pg@mail.gmail.com/
> 
> This series addresses this by setting the ARCH and OUTPUT variables and
> adding a few targets to match default expectations. A "help" target also
> explains what the existing targets do. This will be particularly useful
> once the test suite is merged since it will add new targets.
> 
> Thanks,
> Willy

Queued for testing and review, thank you!

							Thanx, Paul

> ---
> Willy Tarreau (3):
>   tools/nolibc: fix the makefile to also work as "make -C tools ..."
>   tools/nolibc: make the default target build the headers
>   tools/nolibc: add a help target to list supported targets
> 
>  tools/Makefile                |  3 +++
>  tools/include/nolibc/Makefile | 37 +++++++++++++++++++++++++++++++++--
>  2 files changed, 38 insertions(+), 2 deletions(-)
> 
> -- 
> 2.17.5
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-31 15:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-28 15:45 [PATCH 0/3] tools/nolibc: fix build issues when building from tools/ Willy Tarreau
2022-05-28 15:45 ` [PATCH 1/3] tools/nolibc: fix the makefile to also work as "make -C tools ..." Willy Tarreau
2022-05-28 15:45 ` [PATCH 2/3] tools/nolibc: make the default target build the headers Willy Tarreau
2022-05-28 15:45 ` [PATCH 3/3] tools/nolibc: add a help target to list supported targets Willy Tarreau
2022-05-31 15:23 ` [PATCH 0/3] tools/nolibc: fix build issues when building from tools/ Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®