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

Re: [Minios-devel] [UNIKRAFT PATCH v3 5/8] build/Makefile.rules: Add support for linker scripts requiring the pre-processor '*.lds.S'



looks good to me. Just one thing. The header is too long, I will change
it to "build/Makefile.rules: support '*.lds.S' - reprocessed linker scripts"

Reviewed-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>


Simon Kuenzer <simon.kuenzer@xxxxxxxxx> writes:

> Introduce support for linker scripts that have to be pre-processed. Such a 
> linker
> script source file has to have the file extension *.lds.S. One would define 
> the
> linker script generation in the platforms' `Linker.uk` file. For this purpose,
> two new Makefile functions are introduced:
>  src2lds - Converts a path of a linker script source to
>            a path to its processed linker script within the build directory
>  buildrule_lds - Generates a Make target that builds a linker script (*.lds) 
> from
>            a linker script source (*.lds.S). A switch case is installed to
>            buildrule.
>
> Usage example in a /plat/kvm/Linker.uk
>
>  KVM_LDSCRIPT_SRC := $(CONFIG_UK_BASE)/plat/kvm/x86/link64.lds.S
>  KVM_LDSCRIPT     := $(call src2lds,libkvmplat,$(KVM_LDSCRIPT_SRC))
>
>  # Install a build rule for our linker script,
>  #  we can call buildrule directly
>  $(eval $(call buildrule,libkvmplat,$(MY_LDSCRIPT_SRC),$(MY_LDSCRIPT)))
>
>    [...]
>
>  # One can refer to the processed linker script with $(KVM_LDSCRIPT)
>
> Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> ---
>  support/build/Makefile.rules | 55 
> +++++++++++++++++++++++++++++++++-----------
>  1 file changed, 41 insertions(+), 14 deletions(-)
>
> diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
> index a5f5f7d..7b80ea6 100644
> --- a/support/build/Makefile.rules
> +++ b/support/build/Makefile.rules
> @@ -70,14 +70,24 @@ $(addprefix $(call sub_build_dir,$(1))/,$(addsuffix 
> .o,$(basename $(notdir $(2))
>  )
>  endef
>  
> -# converts a list of object file paths to paths pointing to their 
> corresponding dependency file
> -# obj2dep $objects
> -obj2dep = $(patsubst %.o,%.d,$(1))
> +# converts a list of output file (object files or linker scripts) paths
> +# to paths pointing to their corresponding dependency file
> +# out2dep $objects
> +out2dep = $(patsubst %.o,%.d,$(patsubst %.lds,%.lds.d,$(1)))
>  
>  # converts a list of sources (.S, .c, .cc, .cpp) to paths pointing to their 
> corresponding dependency file
>  # src2dep $libname,$source(s),$variant(optional)
> -src2dep = $(call obj2dep,$(call src2obj,$(1),$(2),$(3)))
> +src2dep = $(call out2dep,$(call src2obj,$(1),$(2),$(3)))
>  
> +# converts paths of linker script sources (*.lds.S) to paths of corresponding
> +# processed linker scripts (*.lds) within the library's build directory
> +# src2lds $libname,$ldS(s),$variant(optional)
> +define src2lds =
> +$(if $(3),\
> +$(addprefix $(call sub_build_dir,$(1))/,$(addsuffix .$(3).lds,$(basename 
> $(basename $(notdir $(2)))))),\
> +$(addprefix $(call sub_build_dir,$(1))/,$(addsuffix .lds,$(basename 
> $(basename $(notdir $(2))))))\
> +)
> +endef
>  
>  
> ################################################################################
>  #
> @@ -210,7 +220,7 @@ depflags = -Wp$(comma)-MD$(comma)$(call tmp_depfile,$(3))
>  define build_cmd_fixdep =
>       $(call build_cmd,$1,$2,$3,$4)
>       $Q $(UK_FIXDEP) $(call tmp_depfile,$3) $3 '$(call strip,$4)' \
> -             $(BUILD_DIR)    > $(call obj2dep,$3) && \
> +             $(BUILD_DIR)    > $(call out2dep,$3) && \
>               rm -f $(call tmp_depfile,$3)
>  endef
>  
> @@ -329,10 +339,10 @@ $(3): $(2) | prepare
>       )
>  
>  UK_SRCS-y += $(2)
> -UK_DEPS-y += $(call obj2dep,$(3))
> +UK_DEPS-y += $(call out2dep,$(3))
>  UK_OBJS-y += $(3)
>  $(eval $(call vprefix_lib,$(1),OBJS-y) += $(3))
> -$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> obj2dep,$(3)))
> +$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> out2dep,$(3)))
>  endef
>  
>  define buildrule_s =
> @@ -347,10 +357,10 @@ $(3): $(2) | prepare
>       )
>  
>  UK_SRCS-y += $(2)
> -UK_DEPS-y += $(call obj2dep,$(3))
> +UK_DEPS-y += $(call out2dep,$(3))
>  UK_OBJS-y += $(3)
>  $(eval $(call vprefix_lib,$(1),OBJS-y) += $(3))
> -$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> obj2dep,$(3)))
> +$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> out2dep,$(3)))
>  endef
>  
>  define buildrule_c =
> @@ -365,10 +375,10 @@ $(3): $(2) | prepare
>  )
>  
>  UK_SRCS-y += $(2)
> -UK_DEPS-y += $(call obj2dep,$(3))
> +UK_DEPS-y += $(call out2dep,$(3))
>  UK_OBJS-y += $(3)
>  $(eval $(call vprefix_lib,$(1),OBJS-y) += $(3))
> -$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> obj2dep,$(3)))
> +$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> out2dep,$(3)))
>  endef
>  
>  define buildrule_cc =
> @@ -383,10 +393,26 @@ $(3): $(2) | prepare
>       )
>  
>  UK_SRCS-y += $(2)
> -UK_DEPS-y += $(call obj2dep,$(3))
> +UK_DEPS-y += $(call out2dep,$(3))
>  UK_OBJS-y += $(3)
>  $(eval $(call vprefix_lib,$(1),OBJS-y) += $(3))
> -$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> obj2dep,$(3)))
> +$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> out2dep,$(3)))
> +endef
> +
> +define buildrule_lds =
> +$(3): $(2) | prepare
> +     $(call build_cmd_fixdep,LDS,$(1),$(3),\
> +             $(AS)  -E -P -x assembler-with-cpp $(ASINCLUDES) 
> $(ASINCLUDES-y) \
> +                    $($(call vprefix_lib,$(1),ASINCLUDES)) $($(call 
> vprefix_lib,$(1),ASINCLUDES-y)) \
> +                    $(ASFLAGS) $(ASFLAGS-y) \
> +                    $($(call vprefix_lib,$(1),ASFLAGS)) $($(call 
> vprefix_lib,$(1),ASFLAGS-y)) \
> +                    $(4) \
> +                    $(2) -o $(3) $(depflags)
> +     )
> +
> +UK_SRCS-y += $(2)
> +UK_DEPS-y += $(call out2dep,$(3))
> +$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> out2dep,$(3)))
>  endef
>  
>  # wrapper for buildrule_*,
> @@ -394,13 +420,14 @@ endef
>  #
>  # buildrule $libname,$source,$target,$extraflags(optional)
>  define buildrule =
> +$(if $(filter %.lds.S,$(2)),$(call buildrule_lds,$(1),$(2),$(3),$(4)),\
>  $(if $(filter %.S,  $(2)),$(call buildrule_S ,$(1),$(2),$(3),$(4)),\
>  $(if $(filter %.s,  $(2)),$(call buildrule_s ,$(1),$(2),$(3),$(4)),\
>  $(if $(filter %.c,  $(2)),$(call buildrule_c ,$(1),$(2),$(3),$(4)),\
>  $(if $(filter %.cc, $(2)),$(call buildrule_cc,$(1),$(2),$(3),$(4)),\
>  $(if $(filter %.cpp,$(2)),$(call buildrule_cc,$(1),$(2),$(3),$(4)),\
>  $(error $(3): missing build rule for source type $(suffix $(2))) \
> -)))))
> +))))))
>  endef
>  
>  
> -- 
> 2.7.4
>

-- 
Yuri Volchkov
Software Specialist

NEC Europe Ltd
Kurfürsten-Anlage 36
D-69115 Heidelberg

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

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