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

[patches] PATCH: make building with -Os possible



If you try building EGLIBC with -Os instead of -O2, it fails because it's missing some __extern_inline definitions in io/sys/stat.h. The attached patch fixes this problem -- it's kind of ugly, but it works.

Size savings when compiling with -Os versus -O2 varies by target. Here are the numbers I got. The first number is the total size of the stripped sysroot tree in kB, the second one the size of libc.so.6.

powerpc-none-linux-gnu
-O2	40432	1388226
-Os	36284	1225481
        89.7%	88.3%

i686-none-linux-gnu
-O2	32236	1275856
-Os	29152	1066487
	90.4%	83.6%

arm-none-linux-gnueabi
-O2     34284	1168380
-Os	32344	1090296
	94.3%	93.3%

mips-none-linux-gnu
-O2	37476 	1461949
-Os	34808	1376726
	92.9%	94.2%

Tested without regression on powerpc-none-linux-gnu, as well as built on the other targets. OK to commit?

-Sandra

2007-11-29  Sandra Loosemore  <sandra@xxxxxxxxxxxxxxxx>

	Allow building EGLIBC with -Os.

	* include/features.h (__USE_EXTERN_INLINES_IN_LIBC):  New.
	* io/sys/stat.h: Use it instead of __USE_EXTERN_INLINES.




Index: include/features.h
===================================================================
*** include/features.h	(revision 4330)
--- include/features.h	(working copy)
***************
*** 345,350 ****
--- 345,358 ----
  # define __USE_EXTERN_INLINES	1
  #endif
  
+ /* There are some functions that must be declared 'extern inline' even with
+    -Os when building LIBC, or they'll end up undefined.  */
+ #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
+     && (defined _LIBC || !defined __OPTIMIZE_SIZE__) && !defined __NO_INLINE__ \
+     && defined __extern_inline
+ # define __USE_EXTERN_INLINES_IN_LIBC	1
+ #endif
+ 
  
  /* This is here only because every header file already includes this one.
     Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
Index: io/sys/stat.h
===================================================================
*** io/sys/stat.h	(revision 4330)
--- io/sys/stat.h	(working copy)
*************** extern int __xmknodat (int __ver, int __
*** 444,450 ****
  		       __mode_t __mode, __dev_t *__dev)
       __THROW __nonnull ((3, 5));
  
! #if defined __GNUC__ && __GNUC__ >= 2 && defined __USE_EXTERN_INLINES
  /* Inlined versions of the real stat and mknod functions.  */
  
  __extern_inline int
--- 444,450 ----
  		       __mode_t __mode, __dev_t *__dev)
       __THROW __nonnull ((3, 5));
  
! #if defined __GNUC__ && __GNUC__ >= 2 && defined __USE_EXTERN_INLINES_IN_LIBC
  /* Inlined versions of the real stat and mknod functions.  */
  
  __extern_inline int