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

Re: [Minios-devel] [UNIKRAFT PATCH] Add build rules for go files



Hi Charalampos,

I have one minor comment, but I'm going to fix it on upstreaming. Other
than that:

Reviewed-by: Costin Lupu <costin.lupu@xxxxxxxxx>

On 8/22/19 4:01 PM, Charalampos Mainas wrote:
> Adds a build rule for go files.
> 
> Signed-off by: Charalampos Mainas <charalampos.mainas@xxxxxxxxx>
> 
> ---
>  Makefile                     |  7 +++++++
>  Makefile.uk                  | 17 +++++++++++++++++
>  support/build/Makefile.rules | 21 ++++++++++++++++++++-
>  3 files changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 406ec59e..c37f3810 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -224,6 +224,10 @@ CXXFLAGS :=
>  CXXFLAGS-y :=
>  CXXINCLUDES :=
>  CXXINCLUDES-y :=
> +GOCFLAGS :=
> +GOCFLAGS-y :=
> +GOCINCLUDES :=
> +GOCINCLUDES-y :=
>  LDFLAGS :=
>  LDFLAGS-y :=
>  IMAGE_LDFLAGS :=
> @@ -442,6 +446,7 @@ LD                := $(CONFIG_CROSS_COMPILE)gcc
>  CC           := $(CONFIG_CROSS_COMPILE)gcc
>  CPP          := $(CC)
>  CXX          := $(CPP)
> +GOC          := gccgo-7

We do actually need to be able to run ARM applications written in Go as
well. Therefore we should set GOC value to
'$(CONFIG_CROSS_COMPILE)gccgo-7'. And in the future we'll have to get
rid of the version number so that we can use any avaiable version.

>  AS           := $(CC)
>  AR           := $(CONFIG_CROSS_COMPILE)gcc-ar
>  NM           := $(CONFIG_CROSS_COMPILE)gcc-nm
> @@ -473,6 +478,7 @@ CC_VER_MINOR   := $(word 2,$(subst ., ,$(CC_VERSION)))
>  ASFLAGS              += -DCC_VERSION=$(CC_VERSION)
>  CFLAGS               += -DCC_VERSION=$(CC_VERSION)
>  CXXFLAGS     += -DCC_VERSION=$(CC_VERSION)
> +GOCFLAGS     += -DCC_VERSION=$(CC_VERSION)
>  
>  # ensure $(BUILD_DIR)/kconfig, $(BUILD_DIR)/include and 
> $(BUILD_DIR)/include/uk exists
>  $(call mk_sub_build_dir,kconfig)
> @@ -482,6 +488,7 @@ $(call mk_sub_build_dir,include/uk)
>  ASINCLUDES            += -I$(UK_GENERATED_INCLUDES)
>  CINCLUDES             += -I$(UK_GENERATED_INCLUDES)
>  CXXINCLUDES           += -I$(UK_GENERATED_INCLUDES)
> +GOCINCLUDES           += -I$(UK_GENERATED_INCLUDES)
>  
>  
> ################################################################################
>  # Build rules
> diff --git a/Makefile.uk b/Makefile.uk
> index 2047daef..cb716758 100644
> --- a/Makefile.uk
> +++ b/Makefile.uk
> @@ -17,6 +17,11 @@ CXXFLAGS    += -fno-stack-protector 
> -fno-omit-frame-pointer -fno-tree-sra
>  CXXFLAGS    += -Wall -Wextra
>  CXXINCLUDES += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
>  
> +GOCFLAGS    += -U __linux__ -U __FreeBSD__ -U __sun__
> +GOCFLAGS    += -fno-stack-protector -fno-omit-frame-pointer -fno-tree-sra
> +GOCFLAGS    += -fno-split-stack -Wall -Wextra 
> +GOCINCLUDES += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
> +
>  # Set the text and data sections to be readable and writable. Also,
>  # do not page-align the data segment. If the output format supports
>  # Unix style magic numbers, mark the output as OMAGIC.
> @@ -25,29 +30,38 @@ LDFLAGS     += -nostdinc -nostdlib -Wl,--omagic 
> -Wl,--build-id=none
>  
>  CFLAGS-$(CONFIG_OPTIMIZE_NONE)            += -O0 -fno-optimize-sibling-calls 
> -fno-tree-vectorize
>  CXXFLAGS-$(CONFIG_OPTIMIZE_NONE)          += -O0 -fno-optimize-sibling-calls 
> -fno-tree-vectorize
> +GOCFLAGS-$(CONFIG_OPTIMIZE_NONE)          += -O0 -fno-optimize-sibling-calls 
> -fno-tree-vectorize
>  CFLAGS-$(CONFIG_OPTIMIZE_PERF)            += -O2
>  CXXFLAGS-$(CONFIG_OPTIMIZE_PERF)          += -O2
> +GOCFLAGS-$(CONFIG_OPTIMIZE_PERF)          += -O2
>  CFLAGS-$(CONFIG_OPTIMIZE_SIZE)            += -Os
>  CXXFLAGS-$(CONFIG_OPTIMIZE_SIZE)          += -Os
> +GOCFLAGS-$(CONFIG_OPTIMIZE_SIZE)          += -Os
>  
>  CFLAGS-$(CONFIG_OPTIMIZE_DEADELIM)        += -fdata-sections 
> -ffunction-sections
>  CXXFLAGS-$(CONFIG_OPTIMIZE_DEADELIM)      += -fdata-sections 
> -ffunction-sections
> +GOCFLAGS-$(CONFIG_OPTIMIZE_DEADELIM)      += -fdata-sections 
> -ffunction-sections
>  LDFLAGS-$(CONFIG_OPTIMIZE_DEADELIM)       += -Wl,--gc-sections
>  
>  # LTO requires the compiler flags to be handed over also for linking
>  CFLAGS-$(CONFIG_OPTIMIZE_LTO)             += -flto
>  CXXFLAGS-$(CONFIG_OPTIMIZE_LTO)           += -flto
> +GOCFLAGS-$(CONFIG_OPTIMIZE_LTO)           += -flto
>  LIBLDFLAGS-$(CONFIG_OPTIMIZE_LTO)         += $(CFLAGS) $(CFLAGS-y)
>  LDFLAGS-$(CONFIG_OPTIMIZE_LTO)            += $(CFLAGS) $(CFLAGS-y)
>  
>  CFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0)       += -g0
>  CXXFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0)     += -g0
> +GOCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0)     += -g0
>  CFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL1)       += -g1
>  CXXFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL1)     += -g1
> +GOCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0)     += -g1
>  CFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL2)       += -g2
>  CXXFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL2)     += -g2
> +GOCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0)     += -g2
>  CFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL3)       += -g3
>  CXXFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL3)     += -g3
> +GOCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0)     += -g3
>  
>  ASFLAGS  += -D __Unikraft__ -DUK_CODENAME="$(UK_CODENAME)"
>  ASFLAGS  += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION)
> @@ -58,6 +72,9 @@ CFLAGS   += -DUK_FULLVERSION=$(UK_FULLVERSION)
>  CXXFLAGS += -D __Unikraft__ -DUK_CODENAME="$(UK_CODENAME)"
>  CXXFLAGS += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION)
>  CXXFLAGS += -DUK_FULLVERSION=$(UK_FULLVERSION)
> +GOCFLAGS += -D __Unikraft__ -DUK_CODENAME="$(UK_CODENAME)"
> +GOCFLAGS += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION)
> +GOCFLAGS += -DUK_FULLVERSION=$(UK_FULLVERSION)
>  M4FLAGS  += -D __Unikraft__ -DUK_CODENAME="$(UK_CODENAME)"
>  M4FLAGS  += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION)
>  
> diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
> index 2a1d20a6..2564ff60 100644
> --- a/support/build/Makefile.rules
> +++ b/support/build/Makefile.rules
> @@ -416,6 +416,24 @@ $(eval $(call vprefix_lib,$(1),OBJS-y) += $(3))
>  $(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
> out2dep,$(3)))
>  endef
>  
> +define buildrule_go =
> +$(3): $(2) | prepare
> +     $(call build_cmd,GOC,$(1),$(3),\
> +             $(GOC) $(GOCINCLUDES) $(GOCINCLUDES-y) \
> +                     $($(call vprefix_lib,$(1),GOCINCLUDES)) $($(call 
> vprefix_lib,$(1),GOCINCLUDES-y)) \
> +                     $(GOCFLAGS) $(GOCFLAGS-y) \
> +                     $($(call vprefix_lib,$(1),GOCFLAGS)) $($(call 
> vprefix_lib,$(1),GOCFLAGS-y)) \
> +                     $(4) -D__LIBNAME__=$(1) -D__BASENAME__=$(notdir $(2)) \
> +                     -c $(2) -o $(3) $(depflags)
> +     )
> +
> +UK_SRCS-y += $(2)
> +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 
> out2dep,$(3)))
> +endef
> +
>  define add_lds_to_plat =
>  $(eval $(call uc,$(2))_LD_SCRIPT-y += $(1))
>  endef
> @@ -483,8 +501,9 @@ $(if $(filter %.cpp,  $(2)),$(call buildrule_cc 
> ,$(1),$(2),$(3),$(4)),\
>  $(if $(filter %.CPP,  $(2)),$(call buildrule_cc ,$(1),$(2),$(3),$(4)),\
>  $(if $(filter %.c++,  $(2)),$(call buildrule_cc ,$(1),$(2),$(3),$(4)),\
>  $(if $(filter %.C,    $(2)),$(call buildrule_cc ,$(1),$(2),$(3),$(4)),\
> +$(if $(filter %.go,   $(2)),$(call buildrule_go ,$(1),$(2),$(3),$(4)),\
>  $(error $(3): missing build rule for source type $(suffix $(2))) \
> -)))))))))))))
> +))))))))))))))
>  endef
>  
>  
> 

_______________________________________________
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®.