All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN PATCH for-4.17 v6 0/5] Toolstack build system improvement, toward non-recursive makefiles
@ 2023-01-20 19:44 Anthony PERARD
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 1/5] libs: Fix auto-generation of version-script for unstable libs Anthony PERARD
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Anthony PERARD @ 2023-01-20 19:44 UTC (permalink / raw)
  To: xen-devel
  Cc: Anthony PERARD, Wei Liu, Julien Grall, Stefano Stabellini,
	Andrew Cooper, Juergen Gross, George Dunlap, Jan Beulich

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/xen-unstable.git br.toolstack-build-system-v6

Changes in v6:
- For unstable libs, use --default-symver instead of a generated
  version-script.
- Two new patches to deal with $(xenlibs-*,) macros.
- Second patch description reworded.

Changes in v5:
- rebased on staging
- added "tools: Rework linking options for ocaml binding libraries"

Changes in v4:
- several new patches
- some changes to other patches listed in their changelogs

Changes in v3:
- rebased
- several new patches, starting with 13/25 "tools/libs/util: cleanup Makefile"
- introducing macros to deal with linking with in-tree xen libraries
- Add -Werror to CFLAGS for all builds in tools/

Changes in v2:
- one new patch
- other changes described in patch notes

Hi everyone,

I've been looking at reworking the build system we have for the "tools/", and
transforming it to something that suit it better. There are a lot of
dependencies between different sub-directories so it would be nice if GNU make
could actually handle them. This is possible with "non-recursive makefiles".

With non-recursive makefiles, make will have to load/include all the makefiles
and thus will have complete overview of all the dependencies. This will allow
make to build the necessary targets in other directory, and we won't need to
build sub-directories one by one.

To help with this transformation, I've chosen to go with a recent project
called "subdirmk". It help to deal with the fact that all makefiles will share
the same namespace, it is hooked into autoconf, we can easily run `make` from
any subdirectory. Together "autoconf" and "subdirmk" will also help to get
closer to be able to do out-of-tree build of the tools, but I'm mainly looking
to have non-recursive makefile.

Link to the project:
    https://www.chiark.greenend.org.uk/ucgi/~ian/git/subdirmk.git/

But before getting to the main course, I've got quite a few cleanup and some
changes to the makefiles. I start the patch series with patches that remove old
left over stuff, then start reworking makefiles. They are some common changes like
removing the "build" targets in many places as "all" would be the more common
way to spell it and "all" is the default target anyway. They are other changes
related to the conversion to "subdirmk", I start to use the variable $(TARGETS)
in several makefiles, this variable will have a special meaning in subdirmk
which will build those target by default.

As for the conversion to non-recursive makefile, with subdirmk, I have this WIP
branch, it contains some changes that I'm trying out, some notes, and the
conversion, one Makefile per commit. Cleanup are still needed, some makefile
not converted yet, but it's otherwise mostly done.

    https://xenbits.xen.org/git-http/people/aperard/xen-unstable.git br.toolstack-build-system-v1-wip-extra

With that branch, you could tried something like:
    ./configure; cd tools/xl; make
and `xl` should be built as well as all the xen library needed.
Also, things like `make clean` or rebuild should be faster in the all tools/
directory.

Cheers,

Anthony PERARD (5):
  libs: Fix auto-generation of version-script for unstable libs
  libs/light: Rework targets prerequisites
  libs/light: Makefile cleanup
  tools: Introduce macro $(xenlibs-cflags,) and introduce $(USELIBS) in
    subdirs
  tools: Rework $(xenlibs-ldlibs, ) to provide library flags only.

 tools/console/client/Makefile     |  8 ++++--
 tools/console/daemon/Makefile     | 11 ++++----
 tools/helpers/Makefile            | 29 ++++++++-----------
 tools/libs/call/Makefile          |  1 +
 tools/libs/ctrl/Makefile          |  3 --
 tools/libs/devicemodel/Makefile   |  1 +
 tools/libs/evtchn/Makefile        |  1 +
 tools/libs/foreignmemory/Makefile |  1 +
 tools/libs/gnttab/Makefile        |  1 +
 tools/libs/guest/Makefile         |  3 --
 tools/libs/hypfs/Makefile         |  1 +
 tools/libs/light/Makefile         | 47 ++++++++++++++++---------------
 tools/libs/stat/Makefile          |  2 +-
 tools/libs/store/Makefile         |  1 +
 tools/libs/toolcore/Makefile      |  1 +
 tools/libs/toollog/Makefile       |  1 +
 tools/libs/util/Makefile          |  3 --
 tools/libs/vchan/Makefile         |  3 --
 tools/Rules.mk                    | 22 +++++++++------
 tools/libs/libs.mk                | 11 ++++----
 tools/libs/light/libxl_x86_acpi.c |  2 +-
 .gitignore                        |  6 ----
 22 files changed, 75 insertions(+), 84 deletions(-)

-- 
Anthony PERARD



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

* [XEN PATCH for-4.17 v6 1/5] libs: Fix auto-generation of version-script for unstable libs
  2023-01-20 19:44 [XEN PATCH for-4.17 v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
@ 2023-01-20 19:44 ` Anthony PERARD
  2023-02-06 15:52   ` Andrew Cooper
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 2/5] libs/light: Rework targets prerequisites Anthony PERARD
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Anthony PERARD @ 2023-01-20 19:44 UTC (permalink / raw)
  To: xen-devel
  Cc: Anthony PERARD, Andrew Cooper, Andrew Cooper, George Dunlap,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu,
	Juergen Gross

When there isn't a version-script for a shared library (like for
unstable libs), we create one based on the current Xen version. But
that version-script became out-of-date as soon as Xen's version
changes and make as no way to regenerate the version-script on
rebuild.

For unstable libs, we only needs the symver to be different from a
previous release of Xen. There's an option "--default-symver" which
allow to use the soname as symver and as the soname have the Xen
release version, it will be different for every release. With
--default-symver we don't need to generate a version-script.

But we also need to know if there's already an existing version script
, for that we introduce $(version-script) to be used to point to the
path of the existing script. (Guessing if a version script exist for a
stable library with for example $(wildcard) won't work as a file will
exist when building the library without this patch.)

We don't need the version-script unless we are making the shared
library so it is removed from the "all" target.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v6:
    - use --default-symver instead of generating a version-script.
      (option was available in binutils 2.16, according to the doc, so that
      should work.)
    
    v4:
    - new patch
    
    CC: Andrew Cooper <Andrew.Cooper3@citrix.com>

 tools/libs/call/Makefile          |  1 +
 tools/libs/ctrl/Makefile          |  3 ---
 tools/libs/devicemodel/Makefile   |  1 +
 tools/libs/evtchn/Makefile        |  1 +
 tools/libs/foreignmemory/Makefile |  1 +
 tools/libs/gnttab/Makefile        |  1 +
 tools/libs/guest/Makefile         |  3 ---
 tools/libs/hypfs/Makefile         |  1 +
 tools/libs/light/Makefile         |  1 -
 tools/libs/stat/Makefile          |  2 +-
 tools/libs/store/Makefile         |  1 +
 tools/libs/toolcore/Makefile      |  1 +
 tools/libs/toollog/Makefile       |  1 +
 tools/libs/util/Makefile          |  3 ---
 tools/libs/vchan/Makefile         |  3 ---
 tools/libs/libs.mk                | 10 ++++------
 .gitignore                        |  6 ------
 17 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/tools/libs/call/Makefile b/tools/libs/call/Makefile
index 103f5ad360..56a964b517 100644
--- a/tools/libs/call/Makefile
+++ b/tools/libs/call/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 3
+version-script := libxencall.map
 
 include Makefile.common
 
diff --git a/tools/libs/ctrl/Makefile b/tools/libs/ctrl/Makefile
index 93442ab389..094e84b8d8 100644
--- a/tools/libs/ctrl/Makefile
+++ b/tools/libs/ctrl/Makefile
@@ -10,6 +10,3 @@ PKG_CONFIG_NAME := Xencontrol
 NO_HEADERS_CHK := y
 
 include $(XEN_ROOT)/tools/libs/libs.mk
-
-clean::
-	rm -f libxenctrl.map
diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile
index b70dd774e4..20d1d112e7 100644
--- a/tools/libs/devicemodel/Makefile
+++ b/tools/libs/devicemodel/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 4
+version-script := libxendevicemodel.map
 
 include Makefile.common
 
diff --git a/tools/libs/evtchn/Makefile b/tools/libs/evtchn/Makefile
index 3dad3840c6..18cdaab89e 100644
--- a/tools/libs/evtchn/Makefile
+++ b/tools/libs/evtchn/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 2
+version-script := libxenevtchn.map
 
 include Makefile.common
 
diff --git a/tools/libs/foreignmemory/Makefile b/tools/libs/foreignmemory/Makefile
index b70dd774e4..81398e88b1 100644
--- a/tools/libs/foreignmemory/Makefile
+++ b/tools/libs/foreignmemory/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 4
+version-script := libxenforeignmemory.map
 
 include Makefile.common
 
diff --git a/tools/libs/gnttab/Makefile b/tools/libs/gnttab/Makefile
index 3dad3840c6..4528830bdc 100644
--- a/tools/libs/gnttab/Makefile
+++ b/tools/libs/gnttab/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 2
+version-script := libxengnttab.map
 
 include Makefile.common
 
diff --git a/tools/libs/guest/Makefile b/tools/libs/guest/Makefile
index 19d3ff2fdb..93338a9301 100644
--- a/tools/libs/guest/Makefile
+++ b/tools/libs/guest/Makefile
@@ -14,6 +14,3 @@ NO_HEADERS_CHK := y
 include $(XEN_ROOT)/tools/libs/libs.mk
 
 libxenguest.so.$(MAJOR).$(MINOR): LDLIBS += $(ZLIB_LIBS) -lz
-
-clean::
-	rm -f libxenguest.map
diff --git a/tools/libs/hypfs/Makefile b/tools/libs/hypfs/Makefile
index 630e1e6f3e..7fae5c750d 100644
--- a/tools/libs/hypfs/Makefile
+++ b/tools/libs/hypfs/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
 MINOR    = 0
+version-script := libxenhypfs.map
 
 LDLIBS += -lz
 
diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile
index 4fddcc6f51..cd3fa855e1 100644
--- a/tools/libs/light/Makefile
+++ b/tools/libs/light/Makefile
@@ -262,6 +262,5 @@ clean::
 	$(RM) testidl.c.new testidl.c *.api-ok
 	$(RM) $(TEST_PROGS) libxenlight_test.so libxl_test_*.opic
 	$(RM) -r __pycache__
-	$(RM) libxenlight.map
 	$(RM) $(AUTOSRCS) $(AUTOINCS)
 	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean
diff --git a/tools/libs/stat/Makefile b/tools/libs/stat/Makefile
index 7eaf50e91e..ee5c42bf7b 100644
--- a/tools/libs/stat/Makefile
+++ b/tools/libs/stat/Makefile
@@ -134,4 +134,4 @@ uninstall:: uninstall-perl-bindings
 endif
 
 clean::
-	$(RM) libxenstat.map $(BINDINGS) $(BINDINGSRC)
+	$(RM) $(BINDINGS) $(BINDINGSRC)
diff --git a/tools/libs/store/Makefile b/tools/libs/store/Makefile
index 3557a8c76d..daed9d148f 100644
--- a/tools/libs/store/Makefile
+++ b/tools/libs/store/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR = 4
 MINOR = 0
+version-script := libxenstore.map
 
 ifeq ($(CONFIG_Linux),y)
 LDLIBS += -ldl
diff --git a/tools/libs/toolcore/Makefile b/tools/libs/toolcore/Makefile
index 0d92b68b3b..20671dadd0 100644
--- a/tools/libs/toolcore/Makefile
+++ b/tools/libs/toolcore/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR	= 1
 MINOR	= 0
+version-script := libxentoolcore.map
 
 LIBHEADER := xentoolcore.h
 
diff --git a/tools/libs/toollog/Makefile b/tools/libs/toollog/Makefile
index 2361b8cbf1..d612227c85 100644
--- a/tools/libs/toollog/Makefile
+++ b/tools/libs/toollog/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR	= 1
 MINOR	= 0
+version-script := libxentoollog.map
 
 include Makefile.common
 
diff --git a/tools/libs/util/Makefile b/tools/libs/util/Makefile
index 493d2e00be..e016baf888 100644
--- a/tools/libs/util/Makefile
+++ b/tools/libs/util/Makefile
@@ -47,6 +47,3 @@ $(OBJS-y) $(PIC_OBJS): $(AUTOINCS)
 %.c %.h:: %.l
 	@rm -f $*.[ch]
 	$(FLEX) --header-file=$*.h --outfile=$*.c $<
-
-clean::
-	$(RM) libxenutil.map
diff --git a/tools/libs/vchan/Makefile b/tools/libs/vchan/Makefile
index ac2bff66f5..a1ef60ac8e 100644
--- a/tools/libs/vchan/Makefile
+++ b/tools/libs/vchan/Makefile
@@ -11,6 +11,3 @@ OBJS-y += io.o
 NO_HEADERS_CHK := y
 
 include $(XEN_ROOT)/tools/libs/libs.mk
-
-clean::
-	rm -f libxenvchan.map
diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
index 3eb91fc8f3..0e4b5e0bd0 100644
--- a/tools/libs/libs.mk
+++ b/tools/libs/libs.mk
@@ -4,6 +4,7 @@
 #   PKG_CONFIG: name of pkg-config file (xen$(LIBNAME).pc if empty)
 #   MAJOR:   major version of lib (Xen version if empty)
 #   MINOR:   minor version of lib (0 if empty)
+#   version-script: Specify the name of a version script to the linker.
 
 LIBNAME := $(notdir $(CURDIR))
 
@@ -53,7 +54,7 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_INCLUDE)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 
 .PHONY: all
-all: $(TARGETS) $(PKG_CONFIG_LOCAL) libxen$(LIBNAME).map $(LIBHEADERS)
+all: $(TARGETS) $(PKG_CONFIG_LOCAL) $(LIBHEADERS)
 
 ifneq ($(NO_HEADERS_CHK),y)
 all: headers.chk
@@ -71,9 +72,6 @@ headers.lst: FORCE
 	@{ set -e; $(foreach h,$(LIBHEADERS),echo $(h);) } > $@.tmp
 	@$(call move-if-changed,$@.tmp,$@)
 
-libxen$(LIBNAME).map:
-	echo 'VERS_$(MAJOR).$(MINOR) { global: *; };' >$@
-
 lib$(LIB_FILE_NAME).a: $(OBJS-y)
 	$(AR) rc $@ $^
 
@@ -82,8 +80,8 @@ lib$(LIB_FILE_NAME).so: lib$(LIB_FILE_NAME).so.$(MAJOR)
 lib$(LIB_FILE_NAME).so.$(MAJOR): lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR)
 	$(SYMLINK_SHLIB) $< $@
 
-lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxen$(LIBNAME).map
-	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,lib$(LIB_FILE_NAME).so.$(MAJOR) -Wl,--version-script=libxen$(LIBNAME).map $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDLIBS) $(APPEND_LDFLAGS)
+lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS) $(version-script)
+	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,lib$(LIB_FILE_NAME).so.$(MAJOR) -Wl,$(if $(version-script),--version-script=$(version-script),--default-symver) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDLIBS) $(APPEND_LDFLAGS)
 
 # If abi-dumper is available, write out the ABI analysis
 ifneq ($(ABI_DUMPER),)
diff --git a/.gitignore b/.gitignore
index 880ba88c55..d9c906670d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -110,8 +110,6 @@ tools/config.cache
 config/Tools.mk
 config/Stubdom.mk
 config/Docs.mk
-tools/libs/ctrl/libxenctrl.map
-tools/libs/guest/libxenguest.map
 tools/libs/guest/xc_bitops.h
 tools/libs/guest/xc_core.h
 tools/libs/guest/xc_core_arm.h
@@ -121,7 +119,6 @@ tools/libs/light/_*.[ch]
 tools/libs/light/*.pyc
 tools/libs/light/_libxl.api-for-check
 tools/libs/light/*.api-ok
-tools/libs/light/libxenlight.map
 tools/libs/light/libxl-save-helper
 tools/libs/light/dsdt*
 tools/libs/light/mk_dsdt
@@ -131,13 +128,10 @@ tools/libs/light/testidl.c
 tools/libs/light/test_timedereg
 tools/libs/light/test_fdderegrace
 tools/libs/light/tmp.*
-tools/libs/stat/libxenstat.map
 tools/libs/store/list.h
 tools/libs/store/utils.h
 tools/libs/store/xs_lib.c
 tools/libs/util/libxlu_cfg_y.output
-tools/libs/util/libxenutil.map
-tools/libs/vchan/libxenvchan.map
 tools/debugger/gdb/gdb-6.2.1-linux-i386-xen/*
 tools/debugger/gdb/gdb-6.2.1/*
 tools/debugger/gdb/gdb-6.2.1.tar.bz2
-- 
Anthony PERARD



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

* [XEN PATCH for-4.17 v6 2/5] libs/light: Rework targets prerequisites
  2023-01-20 19:44 [XEN PATCH for-4.17 v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 1/5] libs: Fix auto-generation of version-script for unstable libs Anthony PERARD
@ 2023-01-20 19:44 ` Anthony PERARD
  2023-02-06 18:02   ` Andrew Cooper
  2023-02-08  7:35   ` Juergen Gross
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 3/5] libs/light: Makefile cleanup Anthony PERARD
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Anthony PERARD @ 2023-01-20 19:44 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Juergen Gross

No need for $(AUTOSRCS), GNU make can generate them as needed when
trying to build them as needed when trying to build the object. Also,
those two AUTOSRCS don't need to be a prerequisite of "all". As for
the "clean" target, those two files are already removed via "_*.c".

We don't need $(AUTOINCS) either:
- As for both _libxl_save_msgs*.h headers, we are adding more
  selective dependencies so the headers will still be generated as
  needed.
- "clean" rule already delete the _*.h files, so AUTOINCS aren't needed
  there.

"libxl_internal_json.h" doesn't seems to have ever existed, so the
dependency is removed.

Rework objects prerequisites, to have them dependents on either
"libxl.h" or "libxl_internal.h". "libxl.h" is not normally included
directly in the source code as "libxl_internal.h" is used instead, but
we have "libxl.h" as prerequisite of "libxl_internal.h", so generated
headers will still be generated as needed.

Make doesn't need "libxl.h" to generate "testidl.c", "libxl.h" is only
needed later when building "testidl.o". This avoid the need to
regenerate "testidl.c" when only "libxl.h" changed. Also use automatic
variables $< and $@.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v6:
    - rebased, part of the patch commited as 4ff0811
    - reword commit message
    
    v4:
    - new patch

 tools/libs/light/Makefile | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile
index cd3fa855e1..b28447a2ae 100644
--- a/tools/libs/light/Makefile
+++ b/tools/libs/light/Makefile
@@ -148,9 +148,6 @@ LIBXL_TEST_OBJS += $(foreach t, $(LIBXL_TESTS_INSIDE),libxl_test_$t.opic)
 TEST_PROG_OBJS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t.o) test_common.o
 TEST_PROGS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t)
 
-AUTOINCS = _libxl_save_msgs_callout.h _libxl_save_msgs_helper.h
-AUTOSRCS = _libxl_save_msgs_callout.c _libxl_save_msgs_helper.c
-
 CLIENTS = testidl libxl-save-helper
 
 SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
@@ -178,13 +175,13 @@ libxl_x86_acpi.o libxl_x86_acpi.opic: CFLAGS += -I$(XEN_ROOT)/tools
 $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenguest)
 
 testidl.o: CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenlight)
-testidl.c: libxl_types.idl gentest.py $(XEN_INCLUDE)/libxl.h $(AUTOINCS)
-	$(PYTHON) gentest.py libxl_types.idl testidl.c.new
-	mv testidl.c.new testidl.c
+testidl.c: libxl_types.idl gentest.py
+	$(PYTHON) gentest.py $< $@.new
+	mv -f $@.new $@
 
-all: $(CLIENTS) $(TEST_PROGS) $(AUTOSRCS) $(AUTOINCS)
+all: $(CLIENTS) $(TEST_PROGS)
 
-$(OBJS-y) $(PIC_OBJS) $(SAVE_HELPER_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS): $(AUTOINCS) libxl.api-ok
+$(OBJS-y) $(PIC_OBJS) $(SAVE_HELPER_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS): libxl.api-ok
 
 $(DSDT_FILES-y): acpi
 
@@ -196,7 +193,7 @@ libxl.api-ok: check-libxl-api-rules _libxl.api-for-check
 	$(PERL) $^
 	touch $@
 
-_libxl.api-for-check: $(XEN_INCLUDE)/libxl.h $(AUTOINCS)
+_libxl.api-for-check: $(XEN_INCLUDE)/libxl.h
 	$(CC) $(CPPFLAGS) $(CFLAGS) -c -E $< $(APPEND_CFLAGS) \
 		-DLIBXL_EXTERNAL_CALLERS_ONLY=LIBXL_EXTERNAL_CALLERS_ONLY \
 		>$@.new
@@ -208,14 +205,22 @@ _libxl_save_msgs_helper.h _libxl_save_msgs_callout.h: \
 	$(PERL) -w $< $@ >$@.new
 	$(call move-if-changed,$@.new,$@)
 
+#
+# headers dependencies on generated headers
+#
 $(XEN_INCLUDE)/libxl.h: $(XEN_INCLUDE)/_libxl_types.h
 $(XEN_INCLUDE)/libxl_json.h: $(XEN_INCLUDE)/_libxl_types_json.h
 libxl_internal.h: $(XEN_INCLUDE)/libxl.h $(XEN_INCLUDE)/libxl_json.h
 libxl_internal.h: _libxl_types_internal.h _libxl_types_private.h _libxl_types_internal_private.h
-libxl_internal_json.h: _libxl_types_internal_json.h
+libxl_internal.h: _libxl_save_msgs_callout.h
 
-$(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS) $(SAVE_HELPER_OBJS): $(XEN_INCLUDE)/libxl.h
+#
+# objects dependencies on headers that depends on generated headers
+#
+$(TEST_PROG_OBJS): $(XEN_INCLUDE)/libxl.h
 $(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS): libxl_internal.h
+$(SAVE_HELPER_OBJS): $(XEN_INCLUDE)/libxl.h _libxl_save_msgs_helper.h
+testidl.o: $(XEN_INCLUDE)/libxl.h
 
 # This exploits the 'multi-target pattern rule' trick.
 # gentypes.py should be executed only once to make all the targets.
@@ -262,5 +267,4 @@ clean::
 	$(RM) testidl.c.new testidl.c *.api-ok
 	$(RM) $(TEST_PROGS) libxenlight_test.so libxl_test_*.opic
 	$(RM) -r __pycache__
-	$(RM) $(AUTOSRCS) $(AUTOINCS)
 	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean
-- 
Anthony PERARD



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

* [XEN PATCH for-4.17 v6 3/5] libs/light: Makefile cleanup
  2023-01-20 19:44 [XEN PATCH for-4.17 v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 1/5] libs: Fix auto-generation of version-script for unstable libs Anthony PERARD
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 2/5] libs/light: Rework targets prerequisites Anthony PERARD
@ 2023-01-20 19:44 ` Anthony PERARD
  2023-02-08  7:41   ` Juergen Gross
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 4/5] tools: Introduce macro $(xenlibs-cflags,) and introduce $(USELIBS) in subdirs Anthony PERARD
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Anthony PERARD @ 2023-01-20 19:44 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Juergen Gross

Rework "libacpi.h" include in "libxl_x86_acpi.c" as to be more
selective about the include path and only add "tools/libacpi/". Also
"libxl_dom.c" don't use "libacpi.h" anymore. Use "-iquote" for libacpi
headers.

Get rid of the weird "$(eval stem =" in the middle of a recipe and use
a make automatic variable "$(*F)" instead.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v4:
    - new patch

 tools/libs/light/Makefile         | 16 +++++++---------
 tools/libs/light/libxl_x86_acpi.c |  2 +-
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile
index b28447a2ae..96daeabc47 100644
--- a/tools/libs/light/Makefile
+++ b/tools/libs/light/Makefile
@@ -170,8 +170,7 @@ LDLIBS += $(LDLIBS-y)
 $(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS): CFLAGS += $(CFLAGS_LIBXL) -include $(XEN_ROOT)/tools/config.h
 $(ACPI_OBJS) $(ACPI_PIC_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
 $(TEST_PROG_OBJS) _libxl.api-for-check: CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxentoolcore)
-libxl_dom.o libxl_dom.opic: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
-libxl_x86_acpi.o libxl_x86_acpi.opic: CFLAGS += -I$(XEN_ROOT)/tools
+libxl_x86_acpi.o libxl_x86_acpi.opic: CFLAGS += -iquote $(ACPI_PATH)
 $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenguest)
 
 testidl.o: CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenlight)
@@ -225,13 +224,12 @@ testidl.o: $(XEN_INCLUDE)/libxl.h
 # This exploits the 'multi-target pattern rule' trick.
 # gentypes.py should be executed only once to make all the targets.
 _libxl_type%.h _libxl_type%_json.h _libxl_type%_private.h _libxl_type%.c: libxl_type%.idl gentypes.py idl.py
-	$(eval stem = $(notdir $*))
-	$(PYTHON) gentypes.py libxl_type$(stem).idl __libxl_type$(stem).h __libxl_type$(stem)_private.h \
-		__libxl_type$(stem)_json.h  __libxl_type$(stem).c
-	$(call move-if-changed,__libxl_type$(stem).h,_libxl_type$(stem).h)
-	$(call move-if-changed,__libxl_type$(stem)_private.h,_libxl_type$(stem)_private.h)
-	$(call move-if-changed,__libxl_type$(stem)_json.h,_libxl_type$(stem)_json.h)
-	$(call move-if-changed,__libxl_type$(stem).c,_libxl_type$(stem).c)
+	$(PYTHON) gentypes.py libxl_type$(*F).idl __libxl_type$(*F).h __libxl_type$(*F)_private.h \
+		__libxl_type$(*F)_json.h  __libxl_type$(*F).c
+	$(call move-if-changed,__libxl_type$(*F).h,_libxl_type$(*F).h)
+	$(call move-if-changed,__libxl_type$(*F)_private.h,_libxl_type$(*F)_private.h)
+	$(call move-if-changed,__libxl_type$(*F)_json.h,_libxl_type$(*F)_json.h)
+	$(call move-if-changed,__libxl_type$(*F).c,_libxl_type$(*F).c)
 
 .PRECIOUS: _libxl_type%.h _libxl_type%.c
 
diff --git a/tools/libs/light/libxl_x86_acpi.c b/tools/libs/light/libxl_x86_acpi.c
index 57a6b63790..22eb160659 100644
--- a/tools/libs/light/libxl_x86_acpi.c
+++ b/tools/libs/light/libxl_x86_acpi.c
@@ -16,7 +16,7 @@
 #include "libxl_arch.h"
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/e820.h>
-#include "libacpi/libacpi.h"
+#include "libacpi.h"
 
  /* Number of pages holding ACPI tables */
 #define NUM_ACPI_PAGES 16
-- 
Anthony PERARD



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

* [XEN PATCH for-4.17 v6 4/5] tools: Introduce macro $(xenlibs-cflags,) and introduce $(USELIBS) in subdirs
  2023-01-20 19:44 [XEN PATCH for-4.17 v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
                   ` (2 preceding siblings ...)
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 3/5] libs/light: Makefile cleanup Anthony PERARD
@ 2023-01-20 19:44 ` Anthony PERARD
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 5/5] tools: Rework $(xenlibs-ldlibs, ) to provide library flags only Anthony PERARD
  2023-01-20 19:54 ` [XEN PATCH v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
  5 siblings, 0 replies; 16+ messages in thread
From: Anthony PERARD @ 2023-01-20 19:44 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu

Introduce $(xenlibs-cflags,) to get the CFLAGS needed to build with
the xen library listed as argument. This mainly give the ability to
use the same list of xen libs as we can use with the other macro
$(xenlibs-ldlibs,). Also, we can avoid listing $(CFLAGS_xeninclude)
more than once.

We will use $(USELIBS) to list the xen libraries been used by a
subdirectory or a binary. Since we usually want the CFLAGS, LDFLAGS
and LDLIBS of possibly several xen libs, we don't need to duplicate
the list for each flags. This change to use $(USELIBS) is only done in
console/ and helpers/ for now as those already use the
$(xenlibs-ldlibs,) macro

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v6:
    - new patch

 tools/console/client/Makefile |  7 ++++---
 tools/console/daemon/Makefile | 10 ++++------
 tools/helpers/Makefile        | 26 +++++++++-----------------
 tools/Rules.mk                |  6 ++++++
 4 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/tools/console/client/Makefile b/tools/console/client/Makefile
index 62d89fdeb9..071262c9ae 100644
--- a/tools/console/client/Makefile
+++ b/tools/console/client/Makefile
@@ -1,11 +1,12 @@
 XEN_ROOT=$(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += $(CFLAGS_libxenctrl)
-CFLAGS += $(CFLAGS_libxenstore)
+USELIBS := ctrl store
+
+CFLAGS += $(call xenlibs-cflags,$(USELIBS))
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
-LDLIBS += $(call xenlibs-ldlibs,ctrl store)
+LDLIBS += $(call xenlibs-ldlibs,$(USELIBS))
 LDLIBS += $(SOCKET_LIBS)
 
 OBJS-y := main.o
diff --git a/tools/console/daemon/Makefile b/tools/console/daemon/Makefile
index 9fc3b6711f..e53c874eee 100644
--- a/tools/console/daemon/Makefile
+++ b/tools/console/daemon/Makefile
@@ -1,15 +1,13 @@
 XEN_ROOT=$(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-CFLAGS += $(CFLAGS_libxenctrl)
-CFLAGS += $(CFLAGS_libxenstore)
-CFLAGS += $(CFLAGS_libxenevtchn)
-CFLAGS += $(CFLAGS_libxengnttab)
-CFLAGS += $(CFLAGS_libxenforeignmemory)
+USELIBS := ctrl store evtchn gnttab foreignmemory
+
+CFLAGS += $(call xenlibs-cflags,$(USELIBS))
 CFLAGS-$(CONFIG_ARM) += -DCONFIG_ARM
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
-LDLIBS += $(call xenlibs-ldlibs,ctrl store evtchn gnttab foreignmemory)
+LDLIBS += $(call xenlibs-ldlibs,$(USELIBS))
 LDLIBS += $(SOCKET_LIBS)
 LDLIBS += $(UTIL_LIBS)
 LDLIBS += -lrt
diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile
index 09590eb5b6..0d4df01365 100644
--- a/tools/helpers/Makefile
+++ b/tools/helpers/Makefile
@@ -15,29 +15,21 @@ TARGETS += init-dom0less
 endif
 endif
 
+XEN_INIT_DOM0_USELIBS := ctrl toollog store light
 XEN_INIT_DOM0_OBJS = xen-init-dom0.o init-dom-json.o
-$(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
-$(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxenstore)
-$(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxenlight)
-$(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxenctrl)
-xen-init-dom0: LDLIBS += $(call xenlibs-ldlibs,ctrl toollog store light)
+$(XEN_INIT_DOM0_OBJS): CFLAGS += $(call xenlibs-cflags,$(XEN_INIT_DOM0_USELIBS))
+xen-init-dom0: LDLIBS += $(call xenlibs-ldlibs,$(XEN_INIT_DOM0_USELIBS))
 
+INIT_XENSTORE_DOMAIN_USELIBS := toollog store ctrl guest light
 INIT_XENSTORE_DOMAIN_OBJS = init-xenstore-domain.o init-dom-json.o
-$(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
-$(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenguest)
-$(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenctrl)
-$(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenstore)
-$(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenlight)
+$(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(call xenlibs-cflags,$(INIT_XENSTORE_DOMAIN_USELIBS))
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
-init-xenstore-domain: LDLIBS += $(call xenlibs-ldlibs,toollog store ctrl guest light)
+init-xenstore-domain: LDLIBS += $(call xenlibs-ldlibs,$(INIT_XENSTORE_DOMAIN_USELIBS))
 
+INIT_DOM0LESS_USELIBS := ctrl evtchn toollog store light guest foreignmemory
 INIT_DOM0LESS_OBJS = init-dom0less.o init-dom-json.o
-$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
-$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenstore)
-$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenlight)
-$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenctrl)
-$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenevtchn)
-init-dom0less: LDLIBS += $(call xenlibs-ldlibs,ctrl evtchn toollog store light guest foreignmemory)
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(call xenlibs-cflags,$(INIT_DOM0LESS_USELIBS))
+init-dom0less: LDLIBS += $(call xenlibs-ldlibs,$(INIT_DOM0LESS_USELIBS))
 
 .PHONY: all
 all: $(TARGETS)
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 6e135387bd..d7c1f61cdf 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -88,6 +88,12 @@ define xenlibs-dependencies
         $(USELIBS_$(lib)) $(call xenlibs-dependencies,$(USELIBS_$(lib)))))
 endef
 
+define xenlibs-cflags
+    $(CFLAGS_xeninclude) \
+    $(foreach lib,$(1), \
+	$(filter-out $(CFLAGS_xeninclude),$(CFLAGS_libxen$(lib))))
+endef
+
 # Flags for linking recursive dependencies of Xen libraries in $(1)
 define xenlibs-rpath
     $(addprefix -Wl$(comma)-rpath-link=$(XEN_ROOT)/tools/libs/,$(call xenlibs-dependencies,$(1)))
-- 
Anthony PERARD



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

* [XEN PATCH for-4.17 v6 5/5] tools: Rework $(xenlibs-ldlibs, ) to provide library flags only.
  2023-01-20 19:44 [XEN PATCH for-4.17 v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
                   ` (3 preceding siblings ...)
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 4/5] tools: Introduce macro $(xenlibs-cflags,) and introduce $(USELIBS) in subdirs Anthony PERARD
@ 2023-01-20 19:44 ` Anthony PERARD
  2023-02-08  7:48   ` Juergen Gross
  2023-01-20 19:54 ` [XEN PATCH v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
  5 siblings, 1 reply; 16+ messages in thread
From: Anthony PERARD @ 2023-01-20 19:44 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Juergen Gross

LDLIBS is usually only the library flags (that is the `-l` flags), as
proposed in GNU make manual, while LDFLAGS would be extra flags such
as `-L`.

Rework the make macro $(xenlibs-ldlibs, ) to only provide the library
flags. $(xenlibs-ldflags, ) already only provide the extra flags like
the -rpath-link flags.

Also fix "test_%" recipe in libs/light as "libxenlight.so" in
$(LDLIBS_libxenlight) is been replaced by "-lxenlight". Instead of
just changing the filter, we will start using the $(xenlibs-*,) macro.
For LDFLAGS, we only needs the one for libxenlight, as the one for
toolcore and toollog are already in $(LDFLAGS), they are dependencies
to build libxenlight.so.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v6:
    - new patch

 tools/console/client/Makefile |  1 +
 tools/console/daemon/Makefile |  1 +
 tools/helpers/Makefile        |  3 +++
 tools/libs/light/Makefile     |  2 +-
 tools/Rules.mk                | 16 +++++++---------
 tools/libs/libs.mk            |  1 +
 6 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/tools/console/client/Makefile b/tools/console/client/Makefile
index 071262c9ae..ea7819c03e 100644
--- a/tools/console/client/Makefile
+++ b/tools/console/client/Makefile
@@ -6,6 +6,7 @@ USELIBS := ctrl store
 CFLAGS += $(call xenlibs-cflags,$(USELIBS))
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
+LDFLAGS += $(call xenlibs-ldflags,$(USELIBS))
 LDLIBS += $(call xenlibs-ldlibs,$(USELIBS))
 LDLIBS += $(SOCKET_LIBS)
 
diff --git a/tools/console/daemon/Makefile b/tools/console/daemon/Makefile
index e53c874eee..400611fc2d 100644
--- a/tools/console/daemon/Makefile
+++ b/tools/console/daemon/Makefile
@@ -7,6 +7,7 @@ CFLAGS += $(call xenlibs-cflags,$(USELIBS))
 CFLAGS-$(CONFIG_ARM) += -DCONFIG_ARM
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
+LDFLAGS += $(call xenlibs-ldflags,$(USELIBS))
 LDLIBS += $(call xenlibs-ldlibs,$(USELIBS))
 LDLIBS += $(SOCKET_LIBS)
 LDLIBS += $(UTIL_LIBS)
diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile
index 0d4df01365..5db88dc81b 100644
--- a/tools/helpers/Makefile
+++ b/tools/helpers/Makefile
@@ -18,17 +18,20 @@ endif
 XEN_INIT_DOM0_USELIBS := ctrl toollog store light
 XEN_INIT_DOM0_OBJS = xen-init-dom0.o init-dom-json.o
 $(XEN_INIT_DOM0_OBJS): CFLAGS += $(call xenlibs-cflags,$(XEN_INIT_DOM0_USELIBS))
+xen-init-dom0: LDFLAGS += $(call xenlibs-ldflags,$(XEN_INIT_DOM0_USELIBS))
 xen-init-dom0: LDLIBS += $(call xenlibs-ldlibs,$(XEN_INIT_DOM0_USELIBS))
 
 INIT_XENSTORE_DOMAIN_USELIBS := toollog store ctrl guest light
 INIT_XENSTORE_DOMAIN_OBJS = init-xenstore-domain.o init-dom-json.o
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(call xenlibs-cflags,$(INIT_XENSTORE_DOMAIN_USELIBS))
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
+init-xenstore-domain: LDFLAGS += $(call xenlibs-ldflags,$(INIT_XENSTORE_DOMAIN_USELIBS))
 init-xenstore-domain: LDLIBS += $(call xenlibs-ldlibs,$(INIT_XENSTORE_DOMAIN_USELIBS))
 
 INIT_DOM0LESS_USELIBS := ctrl evtchn toollog store light guest foreignmemory
 INIT_DOM0LESS_OBJS = init-dom0less.o init-dom-json.o
 $(INIT_DOM0LESS_OBJS): CFLAGS += $(call xenlibs-cflags,$(INIT_DOM0LESS_USELIBS))
+init-dom0less: LDFLAGS += $(call xenlibs-ldflags,$(INIT_DOM0LESS_USELIBS))
 init-dom0less: LDLIBS += $(call xenlibs-ldlibs,$(INIT_DOM0LESS_USELIBS))
 
 .PHONY: all
diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile
index 96daeabc47..273f3d0864 100644
--- a/tools/libs/light/Makefile
+++ b/tools/libs/light/Makefile
@@ -244,7 +244,7 @@ libxenlight_test.so: $(PIC_OBJS) $(LIBXL_TEST_OBJS)
 	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS) $(APPEND_LDFLAGS)
 
 test_%: test_%.o test_common.o libxenlight_test.so
-	$(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) $(call xenlibs-ldflags,light) -o $@ $^ $(call xenlibs-ldlibs,toollog toolcore) -lyajl $(APPEND_LDFLAGS)
 
 libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so
 	$(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
diff --git a/tools/Rules.mk b/tools/Rules.mk
index d7c1f61cdf..007a64f2f5 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -105,12 +105,6 @@ define xenlibs-libs
         $(XEN_ROOT)/tools/libs/$(lib)/lib$(FILENAME_$(lib))$(libextension))
 endef
 
-# Flags for linking against all Xen libraries listed in $(1)
-define xenlibs-ldlibs
-    $(call xenlibs-rpath,$(1)) $(call xenlibs-libs,$(1)) \
-    $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
-endef
-
 # Provide needed flags for linking an in-tree Xen library by an external
 # project (or when it is necessary to link with "-lxen$(1)" instead of using
 # the full path to the library).
@@ -119,12 +113,16 @@ define xenlibs-ldflags
     $(foreach lib,$(1),-L$(XEN_ROOT)/tools/libs/$(lib))
 endef
 
+# Flags for linking against all Xen libraries listed in $(1)
+define xenlibs-ldlibs
+    $(foreach lib,$(1),-l$(FILENAME_$(lib)) $(xenlibs-ldlibs-$(lib)))
+endef
+
 # Flags for linking against all Xen libraries listed in $(1) but by making use
 # of -L and -l instead of providing a path to the shared library.
 define xenlibs-ldflags-ldlibs
     $(call xenlibs-ldflags,$(1)) \
-    $(foreach lib,$(1), -l$(FILENAME_$(lib))) \
-    $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
+    $(call xenlibs-ldlibs,$(1))
 endef
 
 define LIB_defs
@@ -132,7 +130,7 @@ define LIB_defs
  XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)
  CFLAGS_libxen$(1) = $$(CFLAGS_xeninclude)
  SHLIB_libxen$(1) = $$(call xenlibs-rpath,$(1)) -Wl,-rpath-link=$$(XEN_libxen$(1))
- LDLIBS_libxen$(1) = $$(call xenlibs-ldlibs,$(1))
+ LDLIBS_libxen$(1) = $$(call xenlibs-ldflags,$(1)) $$(call xenlibs-ldlibs,$(1))
 endef
 
 $(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
index 0e4b5e0bd0..fc6aa7ede9 100644
--- a/tools/libs/libs.mk
+++ b/tools/libs/libs.mk
@@ -17,6 +17,7 @@ CFLAGS   += -Wmissing-prototypes
 CFLAGS   += $(CFLAGS_xeninclude)
 CFLAGS   += $(foreach lib, $(USELIBS_$(LIBNAME)), $(CFLAGS_libxen$(lib)))
 
+LDFLAGS += $(call xenlibs-ldflags,$(USELIBS_$(LIBNAME)))
 LDLIBS += $(call xenlibs-ldlibs,$(USELIBS_$(LIBNAME)))
 
 PIC_OBJS := $(OBJS-y:.o=.opic)
-- 
Anthony PERARD



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

* Re: [XEN PATCH v6 0/5] Toolstack build system improvement, toward non-recursive makefiles
  2023-01-20 19:44 [XEN PATCH for-4.17 v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
                   ` (4 preceding siblings ...)
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 5/5] tools: Rework $(xenlibs-ldlibs, ) to provide library flags only Anthony PERARD
@ 2023-01-20 19:54 ` Anthony PERARD
  5 siblings, 0 replies; 16+ messages in thread
From: Anthony PERARD @ 2023-01-20 19:54 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Julien Grall, Stefano Stabellini, Andrew Cooper,
	Juergen Gross, George Dunlap, Jan Beulich

The "for-4.17" in the subject is a mistake, the series is for staging.

It is just left over from the last time I've sent the series.

Cheers,

-- 
Anthony PERARD


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

* Re: [XEN PATCH for-4.17 v6 1/5] libs: Fix auto-generation of version-script for unstable libs
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 1/5] libs: Fix auto-generation of version-script for unstable libs Anthony PERARD
@ 2023-02-06 15:52   ` Andrew Cooper
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Cooper @ 2023-02-06 15:52 UTC (permalink / raw)
  To: Anthony PERARD, xen-devel
  Cc: George Dunlap, Jan Beulich, Julien Grall, Stefano Stabellini,
	Wei Liu, Juergen Gross

On 20/01/2023 7:44 pm, Anthony PERARD wrote:
> When there isn't a version-script for a shared library (like for
> unstable libs), we create one based on the current Xen version. But
> that version-script became out-of-date as soon as Xen's version
> changes and make as no way to regenerate the version-script on
> rebuild.
>
> For unstable libs, we only needs the symver to be different from a
> previous release of Xen. There's an option "--default-symver" which
> allow to use the soname as symver and as the soname have the Xen
> release version, it will be different for every release. With
> --default-symver we don't need to generate a version-script.
>
> But we also need to know if there's already an existing version script
> , for that we introduce $(version-script) to be used to point to the
> path of the existing script. (Guessing if a version script exist for a
> stable library with for example $(wildcard) won't work as a file will
> exist when building the library without this patch.)
>
> We don't need the version-script unless we are making the shared
> library so it is removed from the "all" target.
>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>


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

* Re: [XEN PATCH for-4.17 v6 2/5] libs/light: Rework targets prerequisites
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 2/5] libs/light: Rework targets prerequisites Anthony PERARD
@ 2023-02-06 18:02   ` Andrew Cooper
  2023-02-07 11:37     ` Anthony PERARD
  2023-02-08  7:35   ` Juergen Gross
  1 sibling, 1 reply; 16+ messages in thread
From: Andrew Cooper @ 2023-02-06 18:02 UTC (permalink / raw)
  To: Anthony PERARD, xen-devel; +Cc: Wei Liu, Juergen Gross

On 20/01/2023 7:44 pm, Anthony PERARD wrote:
> No need for $(AUTOSRCS), GNU make can generate them as needed when
> trying to build them as needed when trying to build the object. Also,
> those two AUTOSRCS don't need to be a prerequisite of "all". As for
> the "clean" target, those two files are already removed via "_*.c".
>
> We don't need $(AUTOINCS) either:
> - As for both _libxl_save_msgs*.h headers, we are adding more
>   selective dependencies so the headers will still be generated as
>   needed.
> - "clean" rule already delete the _*.h files, so AUTOINCS aren't needed
>   there.
>
> "libxl_internal_json.h" doesn't seems to have ever existed, so the
> dependency is removed.
>
> Rework objects prerequisites, to have them dependents on either
> "libxl.h" or "libxl_internal.h". "libxl.h" is not normally included
> directly in the source code as "libxl_internal.h" is used instead, but
> we have "libxl.h" as prerequisite of "libxl_internal.h", so generated
> headers will still be generated as needed.
>
> Make doesn't need "libxl.h" to generate "testidl.c", "libxl.h" is only
> needed later when building "testidl.o". This avoid the need to
> regenerate "testidl.c" when only "libxl.h" changed. Also use automatic
> variables $< and $@.
>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
>
> Notes:
>     v6:
>     - rebased, part of the patch commited as 4ff0811
>     - reword commit message
>     
>     v4:
>     - new patch
>
>  tools/libs/light/Makefile | 28 ++++++++++++++++------------
>  1 file changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile
> index cd3fa855e1..b28447a2ae 100644
> --- a/tools/libs/light/Makefile
> +++ b/tools/libs/light/Makefile
> @@ -148,9 +148,6 @@ LIBXL_TEST_OBJS += $(foreach t, $(LIBXL_TESTS_INSIDE),libxl_test_$t.opic)
>  TEST_PROG_OBJS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t.o) test_common.o
>  TEST_PROGS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t)
>  
> -AUTOINCS = _libxl_save_msgs_callout.h _libxl_save_msgs_helper.h
> -AUTOSRCS = _libxl_save_msgs_callout.c _libxl_save_msgs_helper.c
> -
>  CLIENTS = testidl libxl-save-helper
>  
>  SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
> @@ -178,13 +175,13 @@ libxl_x86_acpi.o libxl_x86_acpi.opic: CFLAGS += -I$(XEN_ROOT)/tools
>  $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenguest)
>  
>  testidl.o: CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenlight)
> -testidl.c: libxl_types.idl gentest.py $(XEN_INCLUDE)/libxl.h $(AUTOINCS)
> -	$(PYTHON) gentest.py libxl_types.idl testidl.c.new
> -	mv testidl.c.new testidl.c
> +testidl.c: libxl_types.idl gentest.py
> +	$(PYTHON) gentest.py $< $@.new
> +	mv -f $@.new $@

Doesn't this want to be a mov-if-changed?

We don't need to force a rebuild if testidl.c hasn't changed, I don't think.

>  
> -all: $(CLIENTS) $(TEST_PROGS) $(AUTOSRCS) $(AUTOINCS)
> +all: $(CLIENTS) $(TEST_PROGS)
>  
> -$(OBJS-y) $(PIC_OBJS) $(SAVE_HELPER_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS): $(AUTOINCS) libxl.api-ok
> +$(OBJS-y) $(PIC_OBJS) $(SAVE_HELPER_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS): libxl.api-ok
>  
>  $(DSDT_FILES-y): acpi
>  
> @@ -196,7 +193,7 @@ libxl.api-ok: check-libxl-api-rules _libxl.api-for-check
>  	$(PERL) $^
>  	touch $@
>  
> -_libxl.api-for-check: $(XEN_INCLUDE)/libxl.h $(AUTOINCS)
> +_libxl.api-for-check: $(XEN_INCLUDE)/libxl.h
>  	$(CC) $(CPPFLAGS) $(CFLAGS) -c -E $< $(APPEND_CFLAGS) \
>  		-DLIBXL_EXTERNAL_CALLERS_ONLY=LIBXL_EXTERNAL_CALLERS_ONLY \
>  		>$@.new
> @@ -208,14 +205,22 @@ _libxl_save_msgs_helper.h _libxl_save_msgs_callout.h: \
>  	$(PERL) -w $< $@ >$@.new
>  	$(call move-if-changed,$@.new,$@)
>  
> +#
> +# headers dependencies on generated headers
> +#
>  $(XEN_INCLUDE)/libxl.h: $(XEN_INCLUDE)/_libxl_types.h
>  $(XEN_INCLUDE)/libxl_json.h: $(XEN_INCLUDE)/_libxl_types_json.h
>  libxl_internal.h: $(XEN_INCLUDE)/libxl.h $(XEN_INCLUDE)/libxl_json.h
>  libxl_internal.h: _libxl_types_internal.h _libxl_types_private.h _libxl_types_internal_private.h
> -libxl_internal_json.h: _libxl_types_internal_json.h
> +libxl_internal.h: _libxl_save_msgs_callout.h
>  
> -$(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS) $(SAVE_HELPER_OBJS): $(XEN_INCLUDE)/libxl.h
> +#
> +# objects dependencies on headers that depends on generated headers
> +#
> +$(TEST_PROG_OBJS): $(XEN_INCLUDE)/libxl.h
>  $(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS): libxl_internal.h
> +$(SAVE_HELPER_OBJS): $(XEN_INCLUDE)/libxl.h _libxl_save_msgs_helper.h
> +testidl.o: $(XEN_INCLUDE)/libxl.h

I know you're just rearranging existing the existing logic, but why
doesn't `#include <libxl.h>` not generate suitable dependences ?

~Andrew


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

* Re: [XEN PATCH for-4.17 v6 2/5] libs/light: Rework targets prerequisites
  2023-02-06 18:02   ` Andrew Cooper
@ 2023-02-07 11:37     ` Anthony PERARD
  0 siblings, 0 replies; 16+ messages in thread
From: Anthony PERARD @ 2023-02-07 11:37 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel, Wei Liu, Juergen Gross

On Mon, Feb 06, 2023 at 06:02:51PM +0000, Andrew Cooper wrote:
> On 20/01/2023 7:44 pm, Anthony PERARD wrote:
> > diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile
> > index cd3fa855e1..b28447a2ae 100644
> > --- a/tools/libs/light/Makefile
> > +++ b/tools/libs/light/Makefile
> > @@ -178,13 +175,13 @@ libxl_x86_acpi.o libxl_x86_acpi.opic: CFLAGS += -I$(XEN_ROOT)/tools
> >  $(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenguest)
> >  
> >  testidl.o: CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenlight)
> > -testidl.c: libxl_types.idl gentest.py $(XEN_INCLUDE)/libxl.h $(AUTOINCS)
> > -	$(PYTHON) gentest.py libxl_types.idl testidl.c.new
> > -	mv testidl.c.new testidl.c
> > +testidl.c: libxl_types.idl gentest.py
> > +	$(PYTHON) gentest.py $< $@.new
> > +	mv -f $@.new $@
> 
> Doesn't this want to be a mov-if-changed?
> 
> We don't need to force a rebuild if testidl.c hasn't changed, I don't think.

I don't like move-if-changed, as when the prerequisites happens to be
newer than the target, the rules keeps been executed on incremental
builds.

Also in this case, only two targets depends on this one, "testidl.o" and
"testidl", so move-if-changed would not be very useful.

> > @@ -208,14 +205,22 @@ _libxl_save_msgs_helper.h _libxl_save_msgs_callout.h: \
> >  	$(PERL) -w $< $@ >$@.new
> >  	$(call move-if-changed,$@.new,$@)
> >  
> > +#
> > +# headers dependencies on generated headers
> > +#
> >  $(XEN_INCLUDE)/libxl.h: $(XEN_INCLUDE)/_libxl_types.h
> >  $(XEN_INCLUDE)/libxl_json.h: $(XEN_INCLUDE)/_libxl_types_json.h
> >  libxl_internal.h: $(XEN_INCLUDE)/libxl.h $(XEN_INCLUDE)/libxl_json.h
> >  libxl_internal.h: _libxl_types_internal.h _libxl_types_private.h _libxl_types_internal_private.h
> > -libxl_internal_json.h: _libxl_types_internal_json.h
> > +libxl_internal.h: _libxl_save_msgs_callout.h
> >  
> > -$(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS) $(SAVE_HELPER_OBJS): $(XEN_INCLUDE)/libxl.h
> > +#
> > +# objects dependencies on headers that depends on generated headers
> > +#
> > +$(TEST_PROG_OBJS): $(XEN_INCLUDE)/libxl.h
> >  $(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS): libxl_internal.h
> > +$(SAVE_HELPER_OBJS): $(XEN_INCLUDE)/libxl.h _libxl_save_msgs_helper.h
> > +testidl.o: $(XEN_INCLUDE)/libxl.h
> 
> I know you're just rearranging existing the existing logic, but why
> doesn't `#include <libxl.h>` not generate suitable dependences ?

Make doesn't know how to read *.c files ;-). But more importantly, we
don't have any logic to generate dependencies ahead of building the
object, so make doesn't know about it.

Thanks,

-- 
Anthony PERARD


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

* Re: [XEN PATCH for-4.17 v6 2/5] libs/light: Rework targets prerequisites
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 2/5] libs/light: Rework targets prerequisites Anthony PERARD
  2023-02-06 18:02   ` Andrew Cooper
@ 2023-02-08  7:35   ` Juergen Gross
  1 sibling, 0 replies; 16+ messages in thread
From: Juergen Gross @ 2023-02-08  7:35 UTC (permalink / raw)
  To: Anthony PERARD, xen-devel; +Cc: Wei Liu


[-- Attachment #1.1.1: Type: text/plain, Size: 1411 bytes --]

On 20.01.23 20:44, Anthony PERARD wrote:
> No need for $(AUTOSRCS), GNU make can generate them as needed when
> trying to build them as needed when trying to build the object. Also,
> those two AUTOSRCS don't need to be a prerequisite of "all". As for
> the "clean" target, those two files are already removed via "_*.c".
> 
> We don't need $(AUTOINCS) either:
> - As for both _libxl_save_msgs*.h headers, we are adding more
>    selective dependencies so the headers will still be generated as
>    needed.
> - "clean" rule already delete the _*.h files, so AUTOINCS aren't needed
>    there.
> 
> "libxl_internal_json.h" doesn't seems to have ever existed, so the
> dependency is removed.
> 
> Rework objects prerequisites, to have them dependents on either
> "libxl.h" or "libxl_internal.h". "libxl.h" is not normally included
> directly in the source code as "libxl_internal.h" is used instead, but
> we have "libxl.h" as prerequisite of "libxl_internal.h", so generated
> headers will still be generated as needed.
> 
> Make doesn't need "libxl.h" to generate "testidl.c", "libxl.h" is only
> needed later when building "testidl.o". This avoid the need to
> regenerate "testidl.c" when only "libxl.h" changed. Also use automatic
> variables $< and $@.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

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

* Re: [XEN PATCH for-4.17 v6 3/5] libs/light: Makefile cleanup
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 3/5] libs/light: Makefile cleanup Anthony PERARD
@ 2023-02-08  7:41   ` Juergen Gross
  0 siblings, 0 replies; 16+ messages in thread
From: Juergen Gross @ 2023-02-08  7:41 UTC (permalink / raw)
  To: Anthony PERARD, xen-devel; +Cc: Wei Liu


[-- Attachment #1.1.1: Type: text/plain, Size: 518 bytes --]

On 20.01.23 20:44, Anthony PERARD wrote:
> Rework "libacpi.h" include in "libxl_x86_acpi.c" as to be more
> selective about the include path and only add "tools/libacpi/". Also
> "libxl_dom.c" don't use "libacpi.h" anymore. Use "-iquote" for libacpi
> headers.
> 
> Get rid of the weird "$(eval stem =" in the middle of a recipe and use
> a make automatic variable "$(*F)" instead.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

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

* Re: [XEN PATCH for-4.17 v6 5/5] tools: Rework $(xenlibs-ldlibs, ) to provide library flags only.
  2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 5/5] tools: Rework $(xenlibs-ldlibs, ) to provide library flags only Anthony PERARD
@ 2023-02-08  7:48   ` Juergen Gross
  2023-02-08 15:10     ` Anthony PERARD
  0 siblings, 1 reply; 16+ messages in thread
From: Juergen Gross @ 2023-02-08  7:48 UTC (permalink / raw)
  To: Anthony PERARD, xen-devel; +Cc: Wei Liu


[-- Attachment #1.1.1: Type: text/plain, Size: 959 bytes --]

On 20.01.23 20:44, Anthony PERARD wrote:
> LDLIBS is usually only the library flags (that is the `-l` flags), as
> proposed in GNU make manual, while LDFLAGS would be extra flags such
> as `-L`.
> 
> Rework the make macro $(xenlibs-ldlibs, ) to only provide the library
> flags. $(xenlibs-ldflags, ) already only provide the extra flags like
> the -rpath-link flags.
> 
> Also fix "test_%" recipe in libs/light as "libxenlight.so" in
> $(LDLIBS_libxenlight) is been replaced by "-lxenlight". Instead of
> just changing the filter, we will start using the $(xenlibs-*,) macro.
> For LDFLAGS, we only needs the one for libxenlight, as the one for

nit: s/needs/need/

> toolcore and toollog are already in $(LDFLAGS), they are dependencies
> to build libxenlight.so.

I don't like this very much. toolcore and toollog are used directly by
the test_% programs, so I don't think we should rely on libxenlight
depending on them.


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

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

* Re: [XEN PATCH for-4.17 v6 5/5] tools: Rework $(xenlibs-ldlibs, ) to provide library flags only.
  2023-02-08  7:48   ` Juergen Gross
@ 2023-02-08 15:10     ` Anthony PERARD
  2023-02-08 15:20       ` Juergen Gross
  0 siblings, 1 reply; 16+ messages in thread
From: Anthony PERARD @ 2023-02-08 15:10 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, Wei Liu

On Wed, Feb 08, 2023 at 08:48:33AM +0100, Juergen Gross wrote:
> On 20.01.23 20:44, Anthony PERARD wrote:
> > LDLIBS is usually only the library flags (that is the `-l` flags), as
> > proposed in GNU make manual, while LDFLAGS would be extra flags such
> > as `-L`.
> > 
> > Rework the make macro $(xenlibs-ldlibs, ) to only provide the library
> > flags. $(xenlibs-ldflags, ) already only provide the extra flags like
> > the -rpath-link flags.
> > 
> > Also fix "test_%" recipe in libs/light as "libxenlight.so" in
> > $(LDLIBS_libxenlight) is been replaced by "-lxenlight". Instead of
> > just changing the filter, we will start using the $(xenlibs-*,) macro.
> > For LDFLAGS, we only needs the one for libxenlight, as the one for
> 
> nit: s/needs/need/
> 
> > toolcore and toollog are already in $(LDFLAGS), they are dependencies
> > to build libxenlight.so.
> 
> I don't like this very much. toolcore and toollog are used directly by
> the test_% programs, so I don't think we should rely on libxenlight
> depending on them.

Ok, I can add them back, it isn't much of an issue to have duplicated
flags on the command line.

Cheers,

-- 
Anthony PERARD


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

* Re: [XEN PATCH for-4.17 v6 5/5] tools: Rework $(xenlibs-ldlibs, ) to provide library flags only.
  2023-02-08 15:10     ` Anthony PERARD
@ 2023-02-08 15:20       ` Juergen Gross
  2023-02-08 16:59         ` [XEN PATCH v6.1 " Anthony PERARD
  0 siblings, 1 reply; 16+ messages in thread
From: Juergen Gross @ 2023-02-08 15:20 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Wei Liu


[-- Attachment #1.1.1: Type: text/plain, Size: 1302 bytes --]

On 08.02.23 16:10, Anthony PERARD wrote:
> On Wed, Feb 08, 2023 at 08:48:33AM +0100, Juergen Gross wrote:
>> On 20.01.23 20:44, Anthony PERARD wrote:
>>> LDLIBS is usually only the library flags (that is the `-l` flags), as
>>> proposed in GNU make manual, while LDFLAGS would be extra flags such
>>> as `-L`.
>>>
>>> Rework the make macro $(xenlibs-ldlibs, ) to only provide the library
>>> flags. $(xenlibs-ldflags, ) already only provide the extra flags like
>>> the -rpath-link flags.
>>>
>>> Also fix "test_%" recipe in libs/light as "libxenlight.so" in
>>> $(LDLIBS_libxenlight) is been replaced by "-lxenlight". Instead of
>>> just changing the filter, we will start using the $(xenlibs-*,) macro.
>>> For LDFLAGS, we only needs the one for libxenlight, as the one for
>>
>> nit: s/needs/need/
>>
>>> toolcore and toollog are already in $(LDFLAGS), they are dependencies
>>> to build libxenlight.so.
>>
>> I don't like this very much. toolcore and toollog are used directly by
>> the test_% programs, so I don't think we should rely on libxenlight
>> depending on them.
> 
> Ok, I can add them back, it isn't much of an issue to have duplicated
> flags on the command line.

In that case you can add my

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

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

* [XEN PATCH v6.1 5/5] tools: Rework $(xenlibs-ldlibs, ) to provide library flags only.
  2023-02-08 15:20       ` Juergen Gross
@ 2023-02-08 16:59         ` Anthony PERARD
  0 siblings, 0 replies; 16+ messages in thread
From: Anthony PERARD @ 2023-02-08 16:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Juergen Gross, Wei Liu

LDLIBS is usually only the library flags (that is the `-l` flags), as
proposed in GNU make manual, while LDFLAGS would be extra flags such
as `-L`.

Rework the make macro $(xenlibs-ldlibs, ) to only provide the library
flags. $(xenlibs-ldflags, ) already only provide the extra flags like
the -rpath-link flags.

Also fix "test_%" recipe in libs/light as "libxenlight.so" in
$(LDLIBS_libxenlight) is been replaced by "-lxenlight". Instead of
just changing the filter, we will start using the $(xenlibs-*,) macro.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
---

Notes:
    v6.1:
    - For test_% recipe, add toolcore and toollog to the $(xenlibs-ldflags,)
      macro, to not have to reli on the flags been already present in
      $(LDFLAGS).
    
    v6:
    - new patch

 tools/Rules.mk                | 16 +++++++---------
 tools/console/client/Makefile |  1 +
 tools/console/daemon/Makefile |  1 +
 tools/helpers/Makefile        |  3 +++
 tools/libs/libs.mk            |  1 +
 tools/libs/light/Makefile     |  2 +-
 6 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/tools/Rules.mk b/tools/Rules.mk
index d7c1f61cdf..007a64f2f5 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -105,12 +105,6 @@ define xenlibs-libs
         $(XEN_ROOT)/tools/libs/$(lib)/lib$(FILENAME_$(lib))$(libextension))
 endef
 
-# Flags for linking against all Xen libraries listed in $(1)
-define xenlibs-ldlibs
-    $(call xenlibs-rpath,$(1)) $(call xenlibs-libs,$(1)) \
-    $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
-endef
-
 # Provide needed flags for linking an in-tree Xen library by an external
 # project (or when it is necessary to link with "-lxen$(1)" instead of using
 # the full path to the library).
@@ -119,12 +113,16 @@ define xenlibs-ldflags
     $(foreach lib,$(1),-L$(XEN_ROOT)/tools/libs/$(lib))
 endef
 
+# Flags for linking against all Xen libraries listed in $(1)
+define xenlibs-ldlibs
+    $(foreach lib,$(1),-l$(FILENAME_$(lib)) $(xenlibs-ldlibs-$(lib)))
+endef
+
 # Flags for linking against all Xen libraries listed in $(1) but by making use
 # of -L and -l instead of providing a path to the shared library.
 define xenlibs-ldflags-ldlibs
     $(call xenlibs-ldflags,$(1)) \
-    $(foreach lib,$(1), -l$(FILENAME_$(lib))) \
-    $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
+    $(call xenlibs-ldlibs,$(1))
 endef
 
 define LIB_defs
@@ -132,7 +130,7 @@ define LIB_defs
  XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)
  CFLAGS_libxen$(1) = $$(CFLAGS_xeninclude)
  SHLIB_libxen$(1) = $$(call xenlibs-rpath,$(1)) -Wl,-rpath-link=$$(XEN_libxen$(1))
- LDLIBS_libxen$(1) = $$(call xenlibs-ldlibs,$(1))
+ LDLIBS_libxen$(1) = $$(call xenlibs-ldflags,$(1)) $$(call xenlibs-ldlibs,$(1))
 endef
 
 $(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
diff --git a/tools/console/client/Makefile b/tools/console/client/Makefile
index 071262c9ae..ea7819c03e 100644
--- a/tools/console/client/Makefile
+++ b/tools/console/client/Makefile
@@ -6,6 +6,7 @@ USELIBS := ctrl store
 CFLAGS += $(call xenlibs-cflags,$(USELIBS))
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
+LDFLAGS += $(call xenlibs-ldflags,$(USELIBS))
 LDLIBS += $(call xenlibs-ldlibs,$(USELIBS))
 LDLIBS += $(SOCKET_LIBS)
 
diff --git a/tools/console/daemon/Makefile b/tools/console/daemon/Makefile
index e53c874eee..400611fc2d 100644
--- a/tools/console/daemon/Makefile
+++ b/tools/console/daemon/Makefile
@@ -7,6 +7,7 @@ CFLAGS += $(call xenlibs-cflags,$(USELIBS))
 CFLAGS-$(CONFIG_ARM) += -DCONFIG_ARM
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
+LDFLAGS += $(call xenlibs-ldflags,$(USELIBS))
 LDLIBS += $(call xenlibs-ldlibs,$(USELIBS))
 LDLIBS += $(SOCKET_LIBS)
 LDLIBS += $(UTIL_LIBS)
diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile
index 0d4df01365..5db88dc81b 100644
--- a/tools/helpers/Makefile
+++ b/tools/helpers/Makefile
@@ -18,17 +18,20 @@ endif
 XEN_INIT_DOM0_USELIBS := ctrl toollog store light
 XEN_INIT_DOM0_OBJS = xen-init-dom0.o init-dom-json.o
 $(XEN_INIT_DOM0_OBJS): CFLAGS += $(call xenlibs-cflags,$(XEN_INIT_DOM0_USELIBS))
+xen-init-dom0: LDFLAGS += $(call xenlibs-ldflags,$(XEN_INIT_DOM0_USELIBS))
 xen-init-dom0: LDLIBS += $(call xenlibs-ldlibs,$(XEN_INIT_DOM0_USELIBS))
 
 INIT_XENSTORE_DOMAIN_USELIBS := toollog store ctrl guest light
 INIT_XENSTORE_DOMAIN_OBJS = init-xenstore-domain.o init-dom-json.o
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(call xenlibs-cflags,$(INIT_XENSTORE_DOMAIN_USELIBS))
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
+init-xenstore-domain: LDFLAGS += $(call xenlibs-ldflags,$(INIT_XENSTORE_DOMAIN_USELIBS))
 init-xenstore-domain: LDLIBS += $(call xenlibs-ldlibs,$(INIT_XENSTORE_DOMAIN_USELIBS))
 
 INIT_DOM0LESS_USELIBS := ctrl evtchn toollog store light guest foreignmemory
 INIT_DOM0LESS_OBJS = init-dom0less.o init-dom-json.o
 $(INIT_DOM0LESS_OBJS): CFLAGS += $(call xenlibs-cflags,$(INIT_DOM0LESS_USELIBS))
+init-dom0less: LDFLAGS += $(call xenlibs-ldflags,$(INIT_DOM0LESS_USELIBS))
 init-dom0less: LDLIBS += $(call xenlibs-ldlibs,$(INIT_DOM0LESS_USELIBS))
 
 .PHONY: all
diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
index 0e4b5e0bd0..fc6aa7ede9 100644
--- a/tools/libs/libs.mk
+++ b/tools/libs/libs.mk
@@ -17,6 +17,7 @@ CFLAGS   += -Wmissing-prototypes
 CFLAGS   += $(CFLAGS_xeninclude)
 CFLAGS   += $(foreach lib, $(USELIBS_$(LIBNAME)), $(CFLAGS_libxen$(lib)))
 
+LDFLAGS += $(call xenlibs-ldflags,$(USELIBS_$(LIBNAME)))
 LDLIBS += $(call xenlibs-ldlibs,$(USELIBS_$(LIBNAME)))
 
 PIC_OBJS := $(OBJS-y:.o=.opic)
diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile
index 96daeabc47..04ea2a82c0 100644
--- a/tools/libs/light/Makefile
+++ b/tools/libs/light/Makefile
@@ -244,7 +244,7 @@ libxenlight_test.so: $(PIC_OBJS) $(LIBXL_TEST_OBJS)
 	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS) $(APPEND_LDFLAGS)
 
 test_%: test_%.o test_common.o libxenlight_test.so
-	$(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) $(call xenlibs-ldflags,toollog toolcore light) -o $@ $^ $(call xenlibs-ldlibs,toollog toolcore) -lyajl $(APPEND_LDFLAGS)
 
 libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so
 	$(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
-- 
Anthony PERARD



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

end of thread, other threads:[~2023-02-08 17:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20 19:44 [XEN PATCH for-4.17 v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD
2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 1/5] libs: Fix auto-generation of version-script for unstable libs Anthony PERARD
2023-02-06 15:52   ` Andrew Cooper
2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 2/5] libs/light: Rework targets prerequisites Anthony PERARD
2023-02-06 18:02   ` Andrew Cooper
2023-02-07 11:37     ` Anthony PERARD
2023-02-08  7:35   ` Juergen Gross
2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 3/5] libs/light: Makefile cleanup Anthony PERARD
2023-02-08  7:41   ` Juergen Gross
2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 4/5] tools: Introduce macro $(xenlibs-cflags,) and introduce $(USELIBS) in subdirs Anthony PERARD
2023-01-20 19:44 ` [XEN PATCH for-4.17 v6 5/5] tools: Rework $(xenlibs-ldlibs, ) to provide library flags only Anthony PERARD
2023-02-08  7:48   ` Juergen Gross
2023-02-08 15:10     ` Anthony PERARD
2023-02-08 15:20       ` Juergen Gross
2023-02-08 16:59         ` [XEN PATCH v6.1 " Anthony PERARD
2023-01-20 19:54 ` [XEN PATCH v6 0/5] Toolstack build system improvement, toward non-recursive makefiles Anthony PERARD

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.