From ddf7309f03850526f5a528dc3137d6bf00683e08 Mon Sep 17 00:00:00 2001 From: CleverMouse Date: Thu, 17 Feb 2011 16:15:11 +0000 Subject: [PATCH] Makefile: build atikms with LTO git-svn-id: svn://kolibrios.org@1877 a494cfbc-eb01-0410-851d-a64ba20cac60 --- data/eng/Makefile | 8 +- drivers/ddk/Makefile | 3 +- drivers/video/drm/radeon/Makefile | 2 +- drivers/video/drm/radeon/Makefile.lto | 150 +++++++++++++++++++++++ drivers/video/drm/radeon/radeon_device.c | 7 +- drivers/video/drm/radeon/rdisplay.c | 8 +- 6 files changed, 168 insertions(+), 10 deletions(-) create mode 100644 drivers/video/drm/radeon/Makefile.lto diff --git a/data/eng/Makefile b/data/eng/Makefile index 7c15339c20..7e17beecac 100644 --- a/data/eng/Makefile +++ b/data/eng/Makefile @@ -502,12 +502,12 @@ $(AC97SND_MPG_C_OBJECTS): .obj.ac97snd/%.o: $(AC97DIR)/mpg/%.c $(AC97SND_MPG_H_F # between all Makefiles, so we need locked operations. drivers/atikms.dll: $(REPOSITORY)/drivers/video/drm/radeon/atikms.dll drivers/.dir kpack --nologo $< $@ -$(REPOSITORY)/drivers/video/drm/radeon/atikms.dll: +$(REPOSITORY)/drivers/video/drm/radeon/atikms.dll: $(REPOSITORY)/drivers/video/drm/radeon/Makefile.lto flock $(REPOSITORY)/drivers/video/drm/radeon/.lock \ - $(MAKE) CC=win32-gcc AS=win32-as LD=win32-ld AR=win32-ar FASM=fasm -C $(REPOSITORY)/drivers/video/drm/radeon -$(REPOSITORY)/drivers/ddk/libddk.a: + $(MAKE) CC=win32-gcc45 AS=win32-as LD=win32-ld AR=win32-ar FASM=fasm -C $(REPOSITORY)/drivers/video/drm/radeon -f Makefile.lto +$(REPOSITORY)/drivers/ddk/libddk.a: $(REPOSITORY)/drivers/ddk/Makefile flock $(REPOSITORY)/drivers/ddk/.lock \ - $(MAKE) CC=win32-gcc AS=win32-as LD=win32-ld AR=win32-ar FASM=fasm -C $(REPOSITORY)/drivers/ddk + $(MAKE) CC=win32-gcc45 AS=win32-as LD=win32-ld AR=win32-ar FASM=fasm -C $(REPOSITORY)/drivers/ddk # dependencies $(REPOSITORY)/drivers/video/drm/radeon/atikms.dll: \ $(REPOSITORY)/drivers/video/drm/radeon/atikms.lds \ diff --git a/drivers/ddk/Makefile b/drivers/ddk/Makefile index 580235ca83..86604f6e57 100644 --- a/drivers/ddk/Makefile +++ b/drivers/ddk/Makefile @@ -7,7 +7,8 @@ DRV_INCLUDES = $(DRV_TOPDIR)/include INCLUDES = -I$(DRV_INCLUDES) -I$(DRV_INCLUDES)/linux -I$(DRV_INCLUDES)/linux/asm DEFINES = -DKOLIBRI -D__KERNEL__ -DCONFIG_X86_32 -CFLAGS = -c -Os $(INCLUDES) $(DEFINES) -march=i486 -fomit-frame-pointer -fno-builtin-printf +CFLAGS = -c -Os $(INCLUDES) $(DEFINES) -march=i486 -fomit-frame-pointer -fno-builtin-printf \ +-mno-stack-arg-probe -mpreferred-stack-boundary=2 -mincoming-stack-boundary=2 NAME:= libddk diff --git a/drivers/video/drm/radeon/Makefile b/drivers/video/drm/radeon/Makefile index 302586fa18..12128cfd09 100644 --- a/drivers/video/drm/radeon/Makefile +++ b/drivers/video/drm/radeon/Makefile @@ -90,8 +90,8 @@ NAME_SRC= \ rdisplay_kms.c \ radeon_pm.c \ cmdline.c \ - cursor.S \ fwblob.asm +# cursor.S FW_BINS= \ firmware/R100_cp.bin \ diff --git a/drivers/video/drm/radeon/Makefile.lto b/drivers/video/drm/radeon/Makefile.lto new file mode 100644 index 0000000000..8827f45f1f --- /dev/null +++ b/drivers/video/drm/radeon/Makefile.lto @@ -0,0 +1,150 @@ + +# note that gcc must be at least 4.5! otherwise, use old Makefile +CC = gcc +LD = ld +AS = as +FASM = fasm + +DEFINES = -D__KERNEL__ -DCONFIG_X86_32 + +DRV_TOPDIR = $(CURDIR)/../../.. +DRM_TOPDIR = $(CURDIR)/.. + +DRV_INCLUDES = $(DRV_TOPDIR)/include + +INCLUDES = -I$(DRV_INCLUDES) -I$(DRV_INCLUDES)/drm \ + -I$(DRV_INCLUDES)/linux + +CFLAGS_OPT = -Os -march=i486 -fomit-frame-pointer -fno-builtin-printf -mno-stack-arg-probe -mpreferred-stack-boundary=2 -mincoming-stack-boundary=2 -flto +CFLAGS = -c $(INCLUDES) $(DEFINES) $(CFLAGS_OPT) + +LIBPATH:= $(DRV_TOPDIR)/ddk + +LIBS:= -lddk -lcore + +LDFLAGS = -nostdlib,-shared,-s,-Map,atikms.map,--image-base,0,--file-alignment,512,--section-alignment,4096 + + +NAME:= atikms + +HFILES:= $(DRV_INCLUDES)/linux/types.h \ + $(DRV_INCLUDES)/linux/list.h \ + $(DRV_INCLUDES)/linux/pci.h \ + $(DRV_INCLUDES)/drm/drm.h \ + $(DRV_INCLUDES)/drm/drmP.h \ + $(DRV_INCLUDES)/drm/drm_edid.h \ + $(DRV_INCLUDES)/drm/drm_crtc.h \ + $(DRV_INCLUDES)/drm/drm_mode.h \ + $(DRV_INCLUDES)/drm/drm_mm.h \ + atom.h \ + radeon.h \ + radeon_asic.h + +NAME_SRC= \ + pci.c \ + $(DRM_TOPDIR)/drm_mm.c \ + $(DRM_TOPDIR)/drm_edid.c \ + $(DRM_TOPDIR)/drm_modes.c \ + $(DRM_TOPDIR)/drm_crtc.c \ + $(DRM_TOPDIR)/drm_crtc_helper.c \ + $(DRM_TOPDIR)/drm_fb_helper.c \ + $(DRM_TOPDIR)/drm_dp_i2c_helper.c \ + $(DRM_TOPDIR)/i2c/i2c-core.c \ + $(DRM_TOPDIR)/i2c/i2c-algo-bit.c \ + evergreen.c \ + radeon_device.c \ + radeon_clocks.c \ + radeon_i2c.c \ + atom.c \ + radeon_atombios.c \ + radeon_agp.c \ + atombios_crtc.c \ + atombios_dp.c \ + radeon_encoders.c \ + radeon_connectors.c \ + radeon_bios.c \ + radeon_combios.c \ + radeon_legacy_crtc.c \ + radeon_legacy_encoders.c \ + radeon_legacy_tv.c \ + radeon_display.c \ + radeon_gart.c \ + radeon_ring.c \ + radeon_object_kos.c \ + radeon_gem.c \ + r100.c \ + r200.c \ + r300.c \ + r420.c \ + rv515.c \ + r520.c \ + r600.c \ + r600_audio.c \ + r600_hdmi.c \ + rs400.c \ + rs600.c \ + rs690.c \ + rv770.c \ + radeon_fb.c \ + rdisplay.c \ + rdisplay_kms.c \ + radeon_pm.c \ + cmdline.c \ + fwblob.asm +# cursor.S + +FW_BINS= \ + firmware/R100_cp.bin \ + firmware/R200_cp.bin \ + firmware/R300_cp.bin \ + firmware/R420_cp.bin \ + firmware/R520_cp.bin \ + \ + firmware/RS690_cp.bin \ + firmware/RS600_cp.bin \ + firmware/RS780_me.bin \ + firmware/RS780_pfp.bin \ + \ + firmware/RV610_me.bin \ + firmware/RV620_me.bin \ + firmware/RV630_me.bin \ + firmware/RV635_me.bin \ + firmware/RV670_me.bin \ + firmware/RV710_me.bin \ + firmware/RV730_me.bin \ + firmware/RV770_me.bin \ + \ + firmware/RV610_pfp.bin \ + firmware/RV620_pfp.bin \ + firmware/RV630_pfp.bin \ + firmware/RV635_pfp.bin \ + firmware/RV670_pfp.bin \ + firmware/RV710_pfp.bin \ + firmware/RV730_pfp.bin \ + firmware/RV770_pfp.bin \ + \ + firmware/R600_rlc.bin \ + firmware/R700_rlc.bin + + +SRC_DEP:= + + +NAME_OBJS = $(patsubst %.S, %.o, $(patsubst %.asm, %.o,\ + $(patsubst %.c, %.o, $(NAME_SRC)))) + +all: $(NAME).dll + +$(NAME).dll: $(NAME_OBJS) $(FW_BINS) $(SRC_DEP) $(HFILES) $(LIBPATH)/libcore.a $(LIBPATH)/libddk.a atikms.lds Makefile.lto + $(CC) $(CFLAGS_OPT) -fwhole-program -nostdlib -Wl,-L$(LIBPATH),$(LDFLAGS),-T,atikms.lds -o $@ $(NAME_OBJS) $(LIBS) + + +%.o : %.c $(HFILES) Makefile.lto + $(CC) $(CFLAGS) -o $@ $< + +%.o : %.S $(HFILES) Makefile.lto + $(AS) -o $@ $< + +fwblob.o: fwblob.asm $(FW_BINS) Makefile.lto + $(FASM) $< $@ + diff --git a/drivers/video/drm/radeon/radeon_device.c b/drivers/video/drm/radeon/radeon_device.c index 2210627f15..5bf0ea92b3 100644 --- a/drivers/video/drm/radeon/radeon_device.c +++ b/drivers/video/drm/radeon/radeon_device.c @@ -1013,7 +1013,12 @@ int _stdcall display_handler(ioctl_t *io) static char log[256]; static pci_dev_t device; -u32_t drvEntry(int action, char *cmdline) +u32_t +#if defined(__GNUC__) && __GNUC__ >= 4 +// has sense only if -fwhole-program is used, like Makefile.lto +__attribute__((externally_visible)) +#endif +drvEntry(int action, char *cmdline) { struct radeon_device *rdev = NULL; diff --git a/drivers/video/drm/radeon/rdisplay.c b/drivers/video/drm/radeon/rdisplay.c index 4764b5fc89..3153d7def7 100644 --- a/drivers/video/drm/radeon/rdisplay.c +++ b/drivers/video/drm/radeon/rdisplay.c @@ -15,7 +15,8 @@ display_t *rdisplay; static cursor_t* __stdcall select_cursor(cursor_t *cursor); static void __stdcall move_cursor(cursor_t *cursor, int x, int y); -extern void destroy_cursor(void); +extern void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor); +//extern void destroy_cursor(void); void disable_mouse(void) {}; @@ -66,12 +67,13 @@ int init_cursor(cursor_t *cursor) radeon_bo_kunmap(cursor->robj); - // cursor->header.destroy = destroy_cursor; + cursor->header.destroy = destroy_cursor; return 0; }; -void fini_cursor(cursor_t *cursor) +//void __attribute__((externally_visible)) fini_cursor(cursor_t *cursor) +void __attribute__((regparm(1))) destroy_cursor(cursor_t *cursor) { list_del(&cursor->list); radeon_bo_unpin(cursor->robj);