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

Re: [Minios-devel] [UNIKRAFT PATCH v3 1/2] build: Use GCC replacements for `ld`, `ar`, and `nm`



Hello,


On 05/16/2018 02:56 PM, Simon Kuenzer wrote:
Instead of using `ld`, `ar`, and `nm`,
use GCC's replacements.
This opens further optimizations options that
could be used later for building images (e.g., LTO).

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
  Makefile              |  6 +++---
  Makefile.uk           |  8 ++++----
  plat/kvm/Linker.uk    |  8 ++++----
  plat/linuxu/Linker.uk |  2 +-
  plat/xen/Linker.uk    | 16 ++++++++--------
  5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/Makefile b/Makefile
index b177bff..974b183 100644
--- a/Makefile
+++ b/Makefile
@@ -387,13 +387,13 @@ CROSS_COMPILE := $(CROSS_COMPILE:"%"=%)
  include $(UK_BASE)/arch/$(UK_ARCH)/Compiler.uk
# Make variables (CC, etc...)
-LD             := $(CROSS_COMPILE)ld
+LD             := $(CROSS_COMPILE)gcc
  CC            := $(CROSS_COMPILE)gcc
  CPP           := $(CC)
  CXX           := $(CPP)
  AS            := $(CC)
-AR             := $(CROSS_COMPILE)ar
-NM             := $(CROSS_COMPILE)nm
+AR             := $(CROSS_COMPILE)gcc-ar
+NM             := $(CROSS_COMPILE)gcc-nm
  READELF               := $(CROSS_COMPILE)readelf
  STRIP         := $(CROSS_COMPILE)strip
  OBJCOPY               := $(CROSS_COMPILE)objcopy
diff --git a/Makefile.uk b/Makefile.uk
index 5855b40..c540ada 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -20,8 +20,8 @@ CXXINCLUDES += -nostdinc -nostdlib -I$(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.
-LIBLDFLAGS  += --omagic -r
-LDFLAGS            += --omagic
+LIBLDFLAGS  += -nostdinc -nostdlib -Wl,--omagic -Wl,-r
+LDFLAGS     += -nostdinc -nostdlib -Wl,--omagic -Wl,--build-id=none
CFLAGS-$(OPTIMIZE_NONE) += -O0 -fno-optimize-sibling-calls -fno-tree-vectorize
  CXXFLAGS-$(OPTIMIZE_NONE)          += -O0 -fno-optimize-sibling-calls 
-fno-tree-vectorize
@@ -32,12 +32,12 @@ CXXFLAGS-$(OPTIMIZE_SIZE)          += -Os
CFLAGS-$(OPTIMIZE_DEADELIM) += -fdata-sections -ffunction-sections
  CXXFLAGS-$(OPTIMIZE_DEADELIM)      += -fdata-sections -ffunction-sections
-LDFLAGS-$(OPTIMIZE_DEADELIM)       += --gc-sections
+LDFLAGS-$(OPTIMIZE_DEADELIM)       += -Wl,--gc-sections
ifneq ($(DEBUG_SYMBOLS),y)
  CFLAGS                             += -g0
  CXXFLAGS                           += -g0
-LDFLAGS-y                         += --strip-debug
+LDFLAGS-y                         += -Wl,--strip-debug
  else
  CFLAGS-$(DEBUG_SYMBOLS_LVL1)       += -g1
  CXXFLAGS-$(DEBUG_SYMBOLS_LVL1)     += -g1
diff --git a/plat/kvm/Linker.uk b/plat/kvm/Linker.uk
index 7957b7a..a91a786 100644
--- a/plat/kvm/Linker.uk
+++ b/plat/kvm/Linker.uk
@@ -1,6 +1,6 @@
  ifeq (x86_64,$(UK_ARCH))
-KVM_LDSCRIPT  := $(UK_BASE)/plat/kvm/x86/link64.ld
-KVM_LDFLAGS-y += -m elf_x86_64
+KVM_LDSCRIPT  := -Wl,-T,$(UK_BASE)/plat/kvm/x86/link64.ld
+KVM_LDFLAGS-y += -Wl,-m,elf_x86_64
  endif
##
@@ -10,12 +10,12 @@ KVM_IMAGE := $(BUILD_DIR)/$(UK_NAME)_kvm-$(UK_ARCH)
$(KVM_IMAGE): $(KVM_LINK) $(KVM_LINK-y) $(UK_LINK) $(UK_LINK-y)
        $(call build_cmd,LD,,$@.ld.o,\
-              $(LD) $(LIBLDFLAGS) $(LIBLDFLAGS-y) $(KVM_LDFLAGS) 
$(KVM_LDFLAGS-y) $^ -o $@.ld.o)
+              $(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) $(KVM_LDFLAGS) 
$(KVM_LDFLAGS-y) $^ -o $@.ld.o)
        $(call build_cmd,OBJCOPY,,$@.o,\
               $(OBJCOPY) -w -G kvmos_* -G _libkvmplat_entry $@.ld.o $@.o)
  ifeq (x86_64,$(UK_ARCH))
        $(call build_cmd,LD,,$@,\
-              $(LD) $(LDFLAGS) $(LDFLAGS-y) $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) -T 
$(KVM_LDSCRIPT) $@.o -o $@)
+              $(LD) $(LDFLAGS) $(LDFLAGS-y) $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) 
$(KVM_LDSCRIPT) $@.o -o $@)
  ifeq ($(OPTIMIZE_DBGFILE),y)
        $(call build_cmd,OBJCOPY,,$@.dbg,\
               $(OBJCOPY) --only-keep-debug $@ $@.dbg)
diff --git a/plat/linuxu/Linker.uk b/plat/linuxu/Linker.uk
index 16a5b15..d50401f 100644
--- a/plat/linuxu/Linker.uk
+++ b/plat/linuxu/Linker.uk
@@ -1,4 +1,4 @@
-LINUXU_LDFLAGS-y += -e_liblinuxuplat_start
+LINUXU_LDFLAGS-y += -Wl,-e,_liblinuxuplat_start
##
  ## Link image
diff --git a/plat/xen/Linker.uk b/plat/xen/Linker.uk
index c0851c3..3890196 100644
--- a/plat/xen/Linker.uk
+++ b/plat/xen/Linker.uk
@@ -1,16 +1,16 @@
  ifeq (x86_64,$(UK_ARCH))
-XEN_LDSCRIPT  := $(UK_BASE)/plat/xen/x86/link64.ld
-XEN_LDFLAGS-y += -m elf_x86_64
+XEN_LDSCRIPT  := -Wl,-T,$(UK_BASE)/plat/xen/x86/link64.ld
+XEN_LDFLAGS-y += -Wl,-m,elf_x86_64
  endif
  ifeq (x86_32,$(UK_ARCH))
-XEN_LDSCRIPT  := $(UK_BASE)/plat/xen/x86/link32.ld
-XEN_LDFLAGS-y += -m elf_x86_32
+XEN_LDSCRIPT  := -Wl,-T,$(UK_BASE)/plat/xen/x86/link32.ld
+XEN_LDFLAGS-y += -Wl,-m,elf_x86_32
  endif
  ifeq (arm_64,$(UK_ARCH))
-XEN_LDSCRIPT  := $(UK_BASE)/plat/xen/arm/link64.ld
+XEN_LDSCRIPT  := -Wl,-T,$(UK_BASE)/plat/xen/arm/link64.ld
  endif
  ifeq (arm,$(UK_ARCH))
-XEN_LDSCRIPT  := $(UK_BASE)/plat/xen/arm/link32.ld
+XEN_LDSCRIPT  := -Wl,-T,$(UK_BASE)/plat/xen/arm/link32.ld
  endif
##
@@ -25,7 +25,7 @@ $(XEN_IMAGE): $(XEN_LINK) $(XEN_LINK-y) $(UK_LINK) 
$(UK_LINK-y)
               $(OBJCOPY) -w -G xenos_* -G _libxenplat_start $@.ld.o $@.o)
  ifeq (arm,$(UK_ARCH))
        $(call build_cmd,LD,,$@.elf,\
-              $(LD) $(LDFLAGS) $(LDFLAGS-y) $(XEN_LDFLAGS) $(XEN_LDFLAGS-y) -T 
$(XEN_LDSCRIPT) $@.o -o $@.elf)
+              $(LD) $(LDFLAGS) $(LDFLAGS-y) $(XEN_LDFLAGS) $(XEN_LDFLAGS-y) 
$(XEN_LDSCRIPT) $@.o -o $@.elf)
  ifeq ($(OPTIMIZE_DBGFILE),y)
        $(call build_cmd,OBJCOPY,,$@.dbg,\
               $(OBJCOPY) --only-keep-debug $@.elf $@.dbg)
@@ -44,7 +44,7 @@ endif
               $(GZIP) -f -9 -c $@ >$@.gz)
  else
        $(call build_cmd,LD,,$@,\
-              $(LD) $(LDFLAGS) $(LDFLAGS-y) $(XEN_LDFLAGS) $(XEN_LDFLAGS-y) -T 
$(XEN_LDSCRIPT) $@.o -o $@)
+              $(LD) $(LDFLAGS) $(LDFLAGS-y) $(XEN_LDFLAGS) $(XEN_LDFLAGS-y) 
$(XEN_LDSCRIPT) $@.o -o $@)
  ifeq ($(OPTIMIZE_DBGFILE),y)
        $(call build_cmd,OBJCOPY,,$@.dbg,\
               $(OBJCOPY) --only-keep-debug $@ $@.dbg)
The changes look fine.

Thanks & Regards
S Sharan

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