ia64/xen-unstable

changeset 11878:307e5ed9657e

Clean up linker flag definitions.

1. GNU ld does not understand -m{32,64}. It must be cooked for it by
the GCC driver program.
2. Where GNU ld is directly called we must use -melf_{i386,x86_64}.
3. We cannot avoid calling GNU ld directly in some cases (e.g., when
specifying GNU-specific linker scripts) as on some host
architectures the GCC driver is configured to call the host
linker.
4. We cannot add -melf_{i386,x86_64} to LDFLAGS as the option is
not recognised by GCC.

Hence we define new LDFLAGS_DIRECT, to be added to the command line
only when invoking GNU ld directly.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Oct 18 16:56:27 2006 +0100 (2006-10-18)
parents 05bf8693c735
children 3409c35a0b0e
files config/x86_32.mk config/x86_64.mk tools/firmware/hvmloader/Makefile tools/firmware/vmxassist/Makefile xen/Rules.mk xen/arch/x86/Rules.mk
line diff
     1.1 --- a/config/x86_32.mk	Wed Oct 18 16:08:58 2006 +0100
     1.2 +++ b/config/x86_32.mk	Wed Oct 18 16:56:27 2006 +0100
     1.3 @@ -7,5 +7,7 @@ CONFIG_XCUTILS := y
     1.4  CONFIG_IOEMU := y
     1.5  
     1.6  CFLAGS += -m32 -march=i686
     1.7 -LDFLAGS += -m32
     1.8  LIBDIR := lib
     1.9 +
    1.10 +# Use only if calling $(LD) directly.
    1.11 +LDFLAGS_DIRECT += -melf_i386
     2.1 --- a/config/x86_64.mk	Wed Oct 18 16:08:58 2006 +0100
     2.2 +++ b/config/x86_64.mk	Wed Oct 18 16:56:27 2006 +0100
     2.3 @@ -7,5 +7,7 @@ CONFIG_XCUTILS := y
     2.4  CONFIG_IOEMU := y
     2.5  
     2.6  CFLAGS += -m64
     2.7 -LDFLAGS += -m64
     2.8  LIBDIR = $(LIB64DIR)
     2.9 +
    2.10 +# Use only if calling $(LD) directly.
    2.11 +LDFLAGS_DIRECT += -melf_x86_64
     3.1 --- a/tools/firmware/hvmloader/Makefile	Wed Oct 18 16:08:58 2006 +0100
     3.2 +++ b/tools/firmware/hvmloader/Makefile	Wed Oct 18 16:56:27 2006 +0100
     3.3 @@ -38,7 +38,7 @@ CFLAGS  += $(call test-gcc-flag,$(CC),-f
     3.4  
     3.5  OBJCOPY  = objcopy
     3.6  CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
     3.7 -LDFLAGS  = -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
     3.8 +LDFLAGS  = -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
     3.9  
    3.10  SRCS = hvmloader.c acpi_madt.c mp_tables.c util.c smbios.c
    3.11  OBJS = $(patsubst %.c,%.o,$(SRCS))
    3.12 @@ -48,7 +48,7 @@ all: hvmloader
    3.13  
    3.14  hvmloader: roms.h $(SRCS)
    3.15  	$(CC) $(CFLAGS) -c $(SRCS)
    3.16 -	$(CC) $(LDFLAGS) -o hvmloader.tmp $(OBJS)
    3.17 +	$(CC) $(CFLAGS) $(LDFLAGS) -o hvmloader.tmp $(OBJS)
    3.18  	$(OBJCOPY) hvmloader.tmp hvmloader
    3.19  	rm -f hvmloader.tmp
    3.20  
     4.1 --- a/tools/firmware/vmxassist/Makefile	Wed Oct 18 16:08:58 2006 +0100
     4.2 +++ b/tools/firmware/vmxassist/Makefile	Wed Oct 18 16:56:27 2006 +0100
     4.3 @@ -39,7 +39,6 @@ CFLAGS  += $(call test-gcc-flag,$(CC),-f
     4.4  CPP      = cpp -P
     4.5  OBJCOPY  = objcopy -p -O binary -R .note -R .comment -R .bss -S --gap-fill=0
     4.6  CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
     4.7 -LDFLAGS  = -m elf_i386
     4.8  
     4.9  OBJECTS = head.o trap.o vm86.o setup.o util.o
    4.10  
    4.11 @@ -48,7 +47,7 @@ all: vmxassist.bin
    4.12  
    4.13  vmxassist.bin: vmxassist.ld $(OBJECTS)
    4.14  	$(CPP) $(DEFINES) vmxassist.ld > vmxassist.tmp
    4.15 -	$(LD) -o vmxassist $(LDFLAGS) -nostdlib --fatal-warnings -N -T vmxassist.tmp $(OBJECTS)
    4.16 +	$(LD) -o vmxassist $(LDFLAGS_DIRECT) -nostdlib --fatal-warnings -N -T vmxassist.tmp $(OBJECTS)
    4.17  	nm -n vmxassist > vmxassist.sym
    4.18  	$(OBJCOPY) vmxassist vmxassist.tmp
    4.19  	dd if=vmxassist.tmp of=vmxassist.bin ibs=512 conv=sync
     5.1 --- a/xen/Rules.mk	Wed Oct 18 16:08:58 2006 +0100
     5.2 +++ b/xen/Rules.mk	Wed Oct 18 16:56:27 2006 +0100
     5.3 @@ -71,6 +71,9 @@ CFLAGS   := $(strip $(CFLAGS) $(CFLAGS-y
     5.4  AFLAGS   := $(strip $(AFLAGS) $(AFLAGS-y))
     5.5  AFLAGS   += $(patsubst -std=gnu%,,$(CFLAGS))
     5.6  
     5.7 +# LDFLAGS are only passed directly to $(LD)
     5.8 +LDFLAGS  += $(LDFLAGS_DIRECT)
     5.9 +
    5.10  include Makefile
    5.11  
    5.12  # Ensure each subdirectory has exactly one trailing slash.
     6.1 --- a/xen/arch/x86/Rules.mk	Wed Oct 18 16:08:58 2006 +0100
     6.2 +++ b/xen/arch/x86/Rules.mk	Wed Oct 18 16:56:27 2006 +0100
     6.3 @@ -34,7 +34,6 @@ CFLAGS  += -DCONFIG_X86_SUPERVISOR_MODE_
     6.4  endif
     6.5  
     6.6  ifeq ($(XEN_TARGET_ARCH),x86_32)
     6.7 -LDFLAGS += -m elf_i386
     6.8  x86_32 := y
     6.9  x86_64 := n
    6.10  endif
    6.11 @@ -45,7 +44,6 @@ CFLAGS  += -fno-asynchronous-unwind-tabl
    6.12  # -fvisibility=hidden reduces -fpic cost, if it's available
    6.13  CFLAGS  += $(shell $(CC) -v --help 2>&1 | grep " -fvisibility=" | \
    6.14               grep -q hidden && echo "-DGCC_HAS_VISIBILITY_ATTRIBUTE")
    6.15 -LDFLAGS += -m elf_x86_64
    6.16  x86_32 := n
    6.17  x86_64 := y
    6.18  endif