[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [UNIKRAFT PATCH v3 1/3] build: Enable secondary expansion



Hey Sharan,

thanks a lot for this update. It makes much more sense now. Please see my comments inline.

Thanks,

Simon

On 17.07.20 18:41, Sharan Santhanam wrote:
Enable second expansion of the make variables. The build variables
are expanded on execution of the Make rule.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
  Makefile                     |  3 +++
  support/build/Makefile.rules | 44 ++++++++++++++++++++++----------------------
  2 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/Makefile b/Makefile
index be8fa8c..1f309b7 100644
--- a/Makefile
+++ b/Makefile
@@ -40,6 +40,9 @@ all:
  # Disable built-in rules
  .SUFFIXES:
+# Enable secondary expansion
+.SECONDEXPANSION:
+
  # Save running make version
  RUNNING_MAKE_VERSION := $(MAKE_VERSION)
diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index 8c096fa..7acce87 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -392,17 +392,17 @@ endef
  define buildrule_S_ =
  $(4): $(2) | prepare
        $(call build_cmd_fixdep,AS,$(1),$(4),\
-               $(AS)  $(COMPFLAGS) $(COMPFLAGS-y) \
+               $(AS)  $$(COMPFLAGS) $$(COMPFLAGS-y) \
                       $($(call vprefix_lib,$(1),COMPFLAGS)) $($(call 
vprefix_lib,$(1),COMPFLAGS-y)) \

Also for the focused variables we should enable secondary expansion. That way we get the same behavior for _all_ libraries during the build.

-                      $(ASINCLUDES) $(ASINCLUDES-y) \
+                      $$(ASINCLUDES) $$(ASINCLUDES-y) \
                       $($(call vprefix_lib,$(1),ASINCLUDES)) $($(call 
vprefix_lib,$(1),ASINCLUDES-y)) \

..same here, of course... etc.

                       $($(call vprefix_src,$(1),$(2),$(3),INCLUDES)) $($(call 
vprefix_src,$(1),$(2),$(3),INCLUDES-y)) \
                       $($(call vprefix_glb,$(3),ARCHFLAGS)) $($(call 
vprefix_glb,$(3),ARCHFLAGS-y)) \
-                      $(ASFLAGS) $(ASFLAGS-y) \
+                      $$(ASFLAGS) $$(ASFLAGS-y) \
                       $($(call vprefix_lib,$(1),ASFLAGS)) $($(call 
vprefix_lib,$(1),ASFLAGS-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),FLAGS)) $($(call 
vprefix_src,$(1),$(2),$(3),FLAGS-y)) \
                       $(5) \
-                      $(DBGFLAGS) $(DBGFLAGS-y) \
+                      $$(DBGFLAGS) $$(DBGFLAGS-y) \
                       -D__LIBNAME__=$(1) -D__BASENAME__=$(notdir $(2)) $(if 
$(3),-D__VARIANT__=$(3)) \
                       -c $(2) -o $(4) $(call depflags,$(4))
        )
@@ -419,17 +419,17 @@ buildrule_sx = $(call buildrule_S_,$(1),$(2),$(3),$(4))
  define buildrule_s =
  $(4): $(2) | prepare
        $(call build_cmd,AS,$(1),$(4),\
-               $(AS)  $(COMPFLAGS) $(COMPFLAGS-y) \
+               $(AS)  $$(COMPFLAGS) $$(COMPFLAGS-y) \
                       $($(call vprefix_lib,$(1),COMPFLAGS)) $($(call 
vprefix_lib,$(1),COMPFLAGS-y)) \
-                      $(ASINCLUDES) $(ASINCLUDES-y) \
+                      $$(ASINCLUDES) $$(ASINCLUDES-y) \
                       $($(call vprefix_lib,$(1),ASINCLUDES)) $($(call 
vprefix_lib,$(1),ASINCLUDES-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),INCLUDES)) $($(call 
vprefix_src,$(1),$(2),$(3),INCLUDES-y)) \
                       $($(call vprefix_glb,$(3),ARCHFLAGS)) $($(call 
vprefix_glb,$(3),ARCHFLAGS-y)) \
-                      $(ASFLAGS) $(ASFLAGS-y) \
+                      $$(ASFLAGS) $$(ASFLAGS-y) \
                       $($(call vprefix_lib,$(1),ASFLAGS)) $($(call 
vprefix_lib,$(1),ASFLAGS-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),FLAGS)) $($(call 
vprefix_src,$(1),$(2),$(3),FLAGS-y)) \
                       $(5) \
-                      $(DBGFLAGS) $(DBGFLAGS-y) \
+                      $$(DBGFLAGS) $$(DBGFLAGS-y) \
                       -D__LIBNAME__=$(1) -D__BASENAME__=$(notdir $(2)) $(if 
$(3),-D__VARIANT__=$(3)) \
                       -c $(2) -o $(4)
        )
@@ -444,17 +444,17 @@ endef
  define buildrule_c =
  $(4): $(2) | prepare
        $(call build_cmd_fixdep,CC,$(1),$(4),\
-               $(CC)  $(COMPFLAGS) $(COMPFLAGS-y) \
+               $(CC)  $$(COMPFLAGS) $$(COMPFLAGS-y) \
                       $($(call vprefix_lib,$(1),COMPFLAGS)) $($(call 
vprefix_lib,$(1),COMPFLAGS-y)) \
-                      $(CINCLUDES) $(CINCLUDES-y) \
+                      $$(CINCLUDES) $$(CINCLUDES-y) \
                       $($(call vprefix_lib,$(1),CINCLUDES)) $($(call 
vprefix_lib,$(1),CINCLUDES-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),INCLUDES)) $($(call 
vprefix_src,$(1),$(2),$(3),INCLUDES-y)) \
                       $($(call vprefix_glb,$(3),ARCHFLAGS)) $($(call 
vprefix_glb,$(3),ARCHFLAGS-y)) \
-                      $(CFLAGS) $(CFLAGS-y) \
+                      $$(CFLAGS) $$(CFLAGS-y) \
                       $($(call vprefix_lib,$(1),CFLAGS)) $($(call 
vprefix_lib,$(1),CFLAGS-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),FLAGS)) $($(call 
vprefix_src,$(1),$(2),$(3),FLAGS-y)) \
                       $(5) \
-                      $(DBGFLAGS) $(DBGFLAGS-y) \
+                      $$(DBGFLAGS) $$(DBGFLAGS-y) \
                       -D__LIBNAME__=$(1) -D__BASENAME__=$(notdir $(2)) $(if 
$(3),-D__VARIANT__=$(3)) \
                       -c $(2) -o $(4) $(call depflags,$(4))
  )
@@ -469,16 +469,16 @@ endef
  define buildrule_cxx =
  $(4): $(2) | prepare
        $(call build_cmd_fixdep,CXX,$(1),$(4),\
-               $(CXX) $(COMPFLAGS) $(COMPFLAGS-y) \
+               $(CXX) $$(COMPFLAGS) $$(COMPFLAGS-y) \
                       $(CXXINCLUDES) $(CXXINCLUDES-y) \
                       $($(call vprefix_lib,$(1),CXXINCLUDES)) $($(call 
vprefix_lib,$(1),CXXINCLUDES-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),INCLUDES)) $($(call 
vprefix_src,$(1),$(2),$(3),INCLUDES-y)) \
                       $($(call vprefix_glb,$(3),ARCHFLAGS)) $($(call 
vprefix_glb,$(3),ARCHFLAGS-y)) \
-                      $(CXXFLAGS) $(CXXFLAGS-y) \
+                      $$(CXXFLAGS) $$(CXXFLAGS-y) \
                       $($(call vprefix_lib,$(1),CXXFLAGS)) $($(call 
vprefix_lib,$(1),CXXFLAGS-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),FLAGS)) $($(call 
vprefix_src,$(1),$(2),$(3),FLAGS-y)) \
                       $(5) \
-                      $(DBGFLAGS) $(DBGFLAGS-y) \
+                      $$(DBGFLAGS) $$(DBGFLAGS-y) \
                       -D__LIBNAME__=$(1) -D__BASENAME__=$(notdir $(2)) $(if 
$(3),-D__VARIANT__=$(3)) \
                       -c $(2) -o $(4) $(call depflags,$(4))
        )
@@ -501,16 +501,16 @@ buildrule_c$(plus)$(plus) = $(call 
buildrule_cxx,$(1),$(2),$(3),$(4))
  define buildrule_go =
  $(4): $(2) | prepare
        $(call build_cmd,GOC,$(1),$(4),\
-               $(GOC) $(COMPFLAGS) $(COMPFLAGS-y) \
-                      $(GOCINCLUDES) $(GOCINCLUDES-y) \
+               $(GOC) $$(COMPFLAGS) $$(COMPFLAGS-y) \
+                      $$(GOCINCLUDES) $$(GOCINCLUDES-y) \
                       $($(call vprefix_lib,$(1),GOCINCLUDES)) $($(call 
vprefix_lib,$(1),GOCINCLUDES-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),INCLUDES)) $($(call 
vprefix_src,$(1),$(2),$(3),INCLUDES-y)) \
                       $($(call vprefix_glb,$(3),ARCHFLAGS)) $($(call 
vprefix_glb,$(3),ARCHFLAGS-y)) \
-                      $(GOCFLAGS) $(GOCFLAGS-y) \
+                      $$(GOCFLAGS) $$(GOCFLAGS-y) \
                       $($(call vprefix_lib,$(1),GOCFLAGS)) $($(call 
vprefix_lib,$(1),GOCFLAGS-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),FLAGS)) $($(call 
vprefix_src,$(1),$(2),$(3),FLAGS-y)) \
                       $(5) \
-                      $(DBGFLAGS) $(DBGFLAGS-y) \
+                      $$(DBGFLAGS) $$(DBGFLAGS-y) \
                       -D__LIBNAME__=$(1) -D__BASENAME__=$(notdir $(2)) $(if 
$(3),-D__VARIANT__=$(3)) \
                       -c $(2) -o $(4) $(call depflags,$(4))
        )
@@ -534,11 +534,11 @@ define buildrule_S_lds =
  $(4): $(2) | prepare
        $(call build_cmd_fixdep,LDS,$(1),$(4),\
                $(AS)  -E -P -x assembler-with-cpp $(COMPFLAGS) $(COMPFLAGS-y) \
-                      $(ASINCLUDES) $(ASINCLUDES-y) \
+                      $$(ASINCLUDES) $$(ASINCLUDES-y) \
                       $($(call vprefix_lib,$(1),ASINCLUDES)) $($(call 
vprefix_lib,$(1),ASINCLUDES-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),INCLUDES)) $($(call 
vprefix_src,$(1),$(2),$(3),INCLUDES-y)) \
-                      $(ARCHFLAGS) $(ARCHFLAGS-y) \
-                      $(ASFLAGS) $(ASFLAGS-y) \
+                      $$(ARCHFLAGS) $$(ARCHFLAGS-y) \
+                      $$(ASFLAGS) $$(ASFLAGS-y) \
                       $($(call vprefix_lib,$(1),ASFLAGS)) $($(call 
vprefix_lib,$(1),ASFLAGS-y)) \
                       $($(call vprefix_src,$(1),$(2),$(3),FLAGS)) $($(call 
vprefix_src,$(1),$(2),$(3),FLAGS-y)) \
                       $(5) \




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.