All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/vm: allow users to provide additional cflags/ldflags
@ 2023-01-16 22:49 Herton R. Krzesinski
  2023-01-18  0:53 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Herton R. Krzesinski @ 2023-01-16 22:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, vbabka, jforbes, dzickus, scweaver

Right now there is no way to provide additional cflags/ldflags when
building tools/vm binaries. And using eg. make CFLAGS=<options> will
override the CFLAGS being set in the Makefile, making the build fail
since it requires the include of the ../lib dir (for libapi).

This change then allows you to specify:
CFLAGS=<options> LDFLAGS=<options> make V=1 -C tools/vm

And the options will be correctly appended as can be seen from the
make output.

Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
---
 tools/vm/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/vm/Makefile b/tools/vm/Makefile
index 9860622cbb15..6c1da51f4177 100644
--- a/tools/vm/Makefile
+++ b/tools/vm/Makefile
@@ -8,8 +8,8 @@ TARGETS=page-types slabinfo page_owner_sort
 LIB_DIR = ../lib/api
 LIBS = $(LIB_DIR)/libapi.a
 
-CFLAGS = -Wall -Wextra -I../lib/
-LDFLAGS = $(LIBS)
+CFLAGS += -Wall -Wextra -I../lib/
+LDFLAGS += $(LIBS)
 
 all: $(TARGETS)
 
-- 
2.38.1


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

* Re: [PATCH] tools/vm: allow users to provide additional cflags/ldflags
  2023-01-16 22:49 [PATCH] tools/vm: allow users to provide additional cflags/ldflags Herton R. Krzesinski
@ 2023-01-18  0:53 ` Andrew Morton
  2023-01-18 13:47   ` Herton R. Krzesinski
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2023-01-18  0:53 UTC (permalink / raw)
  To: Herton R. Krzesinski; +Cc: linux-kernel, vbabka, jforbes, dzickus, scweaver

On Mon, 16 Jan 2023 19:49:21 -0300 "Herton R. Krzesinski" <herton@redhat.com> wrote:

> Right now there is no way to provide additional cflags/ldflags when
> building tools/vm binaries. And using eg. make CFLAGS=<options> will
> override the CFLAGS being set in the Makefile, making the build fail
> since it requires the include of the ../lib dir (for libapi).
> 
> This change then allows you to specify:
> CFLAGS=<options> LDFLAGS=<options> make V=1 -C tools/vm
> 
> And the options will be correctly appended as can be seen from the
> make output.
> 
> ...
>
> --- a/tools/vm/Makefile
> +++ b/tools/vm/Makefile
> @@ -8,8 +8,8 @@ TARGETS=page-types slabinfo page_owner_sort
>  LIB_DIR = ../lib/api
>  LIBS = $(LIB_DIR)/libapi.a
>  
> -CFLAGS = -Wall -Wextra -I../lib/
> -LDFLAGS = $(LIBS)
> +CFLAGS += -Wall -Wextra -I../lib/
> +LDFLAGS += $(LIBS)
>  

I think EXTRA_CFLAGS is more conventional?

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

* Re: [PATCH] tools/vm: allow users to provide additional cflags/ldflags
  2023-01-18  0:53 ` Andrew Morton
@ 2023-01-18 13:47   ` Herton R. Krzesinski
  2023-01-18 22:10     ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Herton R. Krzesinski @ 2023-01-18 13:47 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, vbabka, jforbes, dzickus, scweaver

On Tue, Jan 17, 2023 at 04:53:26PM -0800, Andrew Morton wrote:
> On Mon, 16 Jan 2023 19:49:21 -0300 "Herton R. Krzesinski" <herton@redhat.com> wrote:
> 
> > Right now there is no way to provide additional cflags/ldflags when
> > building tools/vm binaries. And using eg. make CFLAGS=<options> will
> > override the CFLAGS being set in the Makefile, making the build fail
> > since it requires the include of the ../lib dir (for libapi).
> > 
> > This change then allows you to specify:
> > CFLAGS=<options> LDFLAGS=<options> make V=1 -C tools/vm
> > 
> > And the options will be correctly appended as can be seen from the
> > make output.
> > 
> > ...
> >
> > --- a/tools/vm/Makefile
> > +++ b/tools/vm/Makefile
> > @@ -8,8 +8,8 @@ TARGETS=page-types slabinfo page_owner_sort
> >  LIB_DIR = ../lib/api
> >  LIBS = $(LIB_DIR)/libapi.a
> >  
> > -CFLAGS = -Wall -Wextra -I../lib/
> > -LDFLAGS = $(LIBS)
> > +CFLAGS += -Wall -Wextra -I../lib/
> > +LDFLAGS += $(LIBS)
> >  
> 
> I think EXTRA_CFLAGS is more conventional?
> 

I was looking and there is no standard under tools/

Some use it, some not. To given an example of what uses CFLAGS:
tools/arch/x86/kcpuid/Makefile:override CFLAGS += -O2 -Wall -I../../../include
tools/arch/x86/intel_sdsi/Makefile:override CFLAGS += -O2 -Wall
tools/iio/Makefile:override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
tools/thermal/tmon/Makefile:override CFLAGS += $(shell $(PKG_CONFIG) --cflags $(STATIC) panelw ncursesw 2> /dev/null || \
tools/gpio/Makefile:override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
tools/pci/Makefile:CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
tools/spi/Makefile:CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
tools/wmi/Makefile:CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include
tools/io_uring/Makefile:CFLAGS += -Wall -Wextra -g -D_GNU_SOURCE
tools/counter/Makefile:override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include

I can however use EXTRA_CFLAGS, not a problem, eg. doing instead:
CFLAGS = -Wall -Wextra -I../lib/ $(EXTRA_CFLAGS)
LDFLAGS = $(LIBS) $(EXTRA_LDFLAGS)

Let me know and I'll resend the patch using EXTRA_* instead.

-- 
[]'s
Herton


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

* Re: [PATCH] tools/vm: allow users to provide additional cflags/ldflags
  2023-01-18 13:47   ` Herton R. Krzesinski
@ 2023-01-18 22:10     ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2023-01-18 22:10 UTC (permalink / raw)
  To: Herton R. Krzesinski; +Cc: linux-kernel, vbabka, jforbes, dzickus, scweaver

On Wed, 18 Jan 2023 10:47:21 -0300 "Herton R. Krzesinski" <herton@redhat.com> wrote:

> On Tue, Jan 17, 2023 at 04:53:26PM -0800, Andrew Morton wrote:
> > On Mon, 16 Jan 2023 19:49:21 -0300 "Herton R. Krzesinski" <herton@redhat.com> wrote:
> > 
> > > Right now there is no way to provide additional cflags/ldflags when
> > > building tools/vm binaries. And using eg. make CFLAGS=<options> will
> > > override the CFLAGS being set in the Makefile, making the build fail
> > > since it requires the include of the ../lib dir (for libapi).
> > > 
> > > This change then allows you to specify:
> > > CFLAGS=<options> LDFLAGS=<options> make V=1 -C tools/vm
> > > 
> > > And the options will be correctly appended as can be seen from the
> > > make output.
> > > 
> > > ...
> > >
> > > --- a/tools/vm/Makefile
> > > +++ b/tools/vm/Makefile
> > > @@ -8,8 +8,8 @@ TARGETS=page-types slabinfo page_owner_sort
> > >  LIB_DIR = ../lib/api
> > >  LIBS = $(LIB_DIR)/libapi.a
> > >  
> > > -CFLAGS = -Wall -Wextra -I../lib/
> > > -LDFLAGS = $(LIBS)
> > > +CFLAGS += -Wall -Wextra -I../lib/
> > > +LDFLAGS += $(LIBS)
> > >  
> > 
> > I think EXTRA_CFLAGS is more conventional?
> > 
> 
> I was looking and there is no standard under tools/
> 
> Some use it, some not. To given an example of what uses CFLAGS:
> tools/arch/x86/kcpuid/Makefile:override CFLAGS += -O2 -Wall -I../../../include
> tools/arch/x86/intel_sdsi/Makefile:override CFLAGS += -O2 -Wall
> tools/iio/Makefile:override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
> tools/thermal/tmon/Makefile:override CFLAGS += $(shell $(PKG_CONFIG) --cflags $(STATIC) panelw ncursesw 2> /dev/null || \
> tools/gpio/Makefile:override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
> tools/pci/Makefile:CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
> tools/spi/Makefile:CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
> tools/wmi/Makefile:CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include
> tools/io_uring/Makefile:CFLAGS += -Wall -Wextra -g -D_GNU_SOURCE
> tools/counter/Makefile:override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
> 
> I can however use EXTRA_CFLAGS, not a problem, eg. doing instead:
> CFLAGS = -Wall -Wextra -I../lib/ $(EXTRA_CFLAGS)
> LDFLAGS = $(LIBS) $(EXTRA_LDFLAGS)
> 
> Let me know and I'll resend the patch using EXTRA_* instead.

Well drat, I was hoping you'd decide ;)

I'll grab it as-is, thanks.

(of course, we could always use both!)

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

end of thread, other threads:[~2023-01-18 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16 22:49 [PATCH] tools/vm: allow users to provide additional cflags/ldflags Herton R. Krzesinski
2023-01-18  0:53 ` Andrew Morton
2023-01-18 13:47   ` Herton R. Krzesinski
2023-01-18 22:10     ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.