public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Make gcc -align options .config-settable
@ 2004-10-01 19:26 Denis Vlasenko
  2004-10-01 22:17 ` Andrew Morton
  2004-10-04 18:38 ` Bill Davidsen
  0 siblings, 2 replies; 13+ messages in thread
From: Denis Vlasenko @ 2004-10-01 19:26 UTC (permalink / raw)
  To: Andrew Morton, Sam Ravnborg; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 195 bytes --]

Resend.

With all alignment options set to 1 (minimum alignment),
I've got 5% smaller vmlinux compared to one built with
default code alignment.

Rediffed against 2.6.9-rc3.
Please apply.
--
vda

[-- Attachment #2: align269r3.patch --]
[-- Type: text/x-diff, Size: 2812 bytes --]

diff -urp linux-2.6.9-rc3.src/Makefile linux-2.6.9-rc3_align.src/Makefile
--- linux-2.6.9-rc3.src/Makefile	Fri Oct  1 21:29:57 2004
+++ linux-2.6.9-rc3_align.src/Makefile	Fri Oct  1 21:45:20 2004
@@ -334,6 +334,8 @@ LDFLAGS_MODULE  = -r
 CFLAGS_KERNEL	=
 AFLAGS_KERNEL	=
 
+GCC_VERSION	= $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
+
 NOSTDINC_FLAGS  = -nostdinc -iwithprefix include
 
 # Use LINUXINCLUDE when you must reference the include/ directory.
@@ -484,6 +486,22 @@ ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 CFLAGS		+= -Os
 else
 CFLAGS		+= -O2
+endif
+
+GCC3		= $(shell if [ $(GCC_VERSION) -ge 0300 ] ; then echo "1"; else echo "0"; fi ;)
+ifeq ($(GCC3),1)
+ifneq ($(CONFIG_CC_ALIGN_FUNCTIONS),0)
+CFLAGS		+= -falign-functions=$(CONFIG_CC_ALIGN_FUNCTIONS)
+endif
+ifneq ($(CONFIG_CC_ALIGN_LABELS),0)
+CFLAGS		+= -falign-labels=$(CONFIG_CC_ALIGN_LABELS)
+endif
+ifneq ($(CONFIG_CC_ALIGN_LOOPS),0)
+CFLAGS		+= -falign-loops=$(CONFIG_CC_ALIGN_LOOPS)
+endif
+ifneq ($(CONFIG_CC_ALIGN_JUMPS),0)
+CFLAGS		+= -falign-jumps=$(CONFIG_CC_ALIGN_JUMPS)
+endif
 endif
 
 ifndef CONFIG_FRAME_POINTER
diff -urp linux-2.6.9-rc3.src/init/Kconfig linux-2.6.9-rc3_align.src/init/Kconfig
--- linux-2.6.9-rc3.src/init/Kconfig	Fri Oct  1 21:30:19 2004
+++ linux-2.6.9-rc3_align.src/init/Kconfig	Fri Oct  1 21:45:20 2004
@@ -303,6 +303,43 @@ config SHMEM
 	  option replaces shmem and tmpfs with the much simpler ramfs code,
 	  which may be appropriate on small systems without swap.
 
+config CC_ALIGN_FUNCTIONS
+	int "Function alignment"
+	default 0
+	help
+	  Align the start of functions to the next power-of-two greater than n,
+	  skipping up to n bytes.  For instance, 32 aligns functions
+	  to the next 32-byte boundary, but 24 would align to the next
+	  32-byte boundary only if this can be done by skipping 23 bytes or less.
+	  Zero means use compiler's default.
+
+config CC_ALIGN_LABELS
+	int "Label alignment"
+	default 0
+	help
+	  Align all branch targets to a power-of-two boundary, skipping
+	  up to n bytes like ALIGN_FUNCTIONS.  This option can easily
+	  make code slower, because it must insert dummy operations for
+	  when the branch target is reached in the usual flow of the code.
+	  Zero means use compiler's default.
+
+config CC_ALIGN_LOOPS
+	int "Loop alignment"
+	default 0
+	help
+	  Align loops to a power-of-two boundary, skipping up to n bytes.
+	  Zero means use compiler's default.
+
+config CC_ALIGN_JUMPS
+	int "Jump alignment"
+	default 0
+	help
+	  Align branch targets to a power-of-two boundary, for branch
+	  targets where the targets can only be reached by jumping,
+	  skipping up to n bytes like ALIGN_FUNCTIONS.  In this case,
+	  no dummy operations need be executed.
+	  Zero means use compiler's default.
+
 endmenu		# General setup
 
 config TINY_SHMEM

^ permalink raw reply	[flat|nested] 13+ messages in thread
[parent not found: <2KBq9-2S1-15@gated-at.bofh.it>]

end of thread, other threads:[~2004-10-16 22:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-01 19:26 [PATCH] Make gcc -align options .config-settable Denis Vlasenko
2004-10-01 22:17 ` Andrew Morton
2004-10-04 22:04   ` Sam Ravnborg
2004-10-08  5:03   ` Keith Owens
2004-10-17  0:38   ` Sam Ravnborg
2004-10-04 18:38 ` Bill Davidsen
     [not found] <2KBq9-2S1-15@gated-at.bofh.it>
2004-10-08 12:20 ` Andi Kleen
2004-10-08 17:10   ` Denis Vlasenko
2004-10-08 14:30     ` Grzegorz Kulewski
2004-10-08 20:42       ` Denis Vlasenko
2004-10-08 21:30         ` Grzegorz Kulewski
2004-10-08 15:42     ` Andi Kleen
2004-10-08 20:46       ` Denis Vlasenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox