public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] locarchive.c nested macros
@ 2002-04-30  8:32 Jakub Jelinek
  2002-05-01  9:48 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2002-04-30  8:32 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

I have only 256MB of RAM on my workstation and compiling
locarchive.c takes lots of memory at least with gcc 2.96-RH
(230MB before I killed it), with gcc 3.1 it is slightly better (~ 100MB)
but anyway building glibc with -j3 is problematic then.
The thing is that stpcpy is extremely huge macro (we need to do something
for gcc 3.2, so that stpcpy is properly optimized by the compiler and
we don't have to do all this), and nesting it 5 times means the resulting
preprocessed source is ~6MB and the early compiler passes are fed lots of
data till most of it is optimized away. After following patch, locarchive.i
is ~ 730KB and compiling it eats way less memory.
At least with gcc-3.1, the generated code is identical.

2002-04-30  Jakub Jelinek  <jakub@redhat.com>

	* locale/programs/locarchive.c (add_locales_to_archive): Don't nest
	too many stpcpy macros.

--- libc/locale/programs/locarchive.c.jj	Thu Apr 18 09:55:47 2002
+++ libc/locale/programs/locarchive.c	Tue Apr 30 17:34:05 2002
@@ -711,11 +711,8 @@ add_locales_to_archive (nlist, list, rep
 			     directory and it therefore must contain a
 			     regular file with the same name except a
 			     "SYS_" prefix.  */
-			  strcpy (stpcpy (stpcpy (stpcpy (stpcpy (fullname,
-								  fname),
-							  "/"),
-						  d->d_name),
-					  "/SYS_"),
+			  char *t = stpcpy (stpcpy (fullname, fname), "/");
+			  strcpy (stpcpy (stpcpy (t, d->d_name), "/SYS_"),
 				  d->d_name);
 
 			  if (stat64 (fullname, &st) == -1)
@@ -765,11 +762,10 @@ add_locales_to_archive (nlist, list, rep
 
 	    if (S_ISDIR (st.st_mode))
 	      {
+		char *t;
 		close (fd);
-		strcpy (stpcpy (stpcpy (stpcpy (stpcpy (fullname, fname),
-						"/"),
-					locnames[cnt]),
-				"/SYS_"),
+		t = stpcpy (stpcpy (fullname, fname), "/");
+		strcpy (stpcpy (stpcpy (t, locnames[cnt]), "/SYS_"),
 			locnames[cnt]);
 
 		fd = open64 (fullname, O_RDONLY);

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] locarchive.c nested macros
  2002-04-30  8:32 [PATCH] locarchive.c nested macros Jakub Jelinek
@ 2002-05-01  9:48 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2002-05-01  9:48 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

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

On Tue, 2002-04-30 at 08:31, Jakub Jelinek wrote:

> I have only 256MB of RAM on my workstation and compiling
> locarchive.c takes lots of memory at least with gcc 2.96-RH
> (230MB before I killed it), with gcc 3.1 it is slightly better (~ 100MB)
> but anyway building glibc with -j3 is problematic then.

I'd have preferred to leave this to remind the gcc people of finally
adding __builtin_stpcpy but since it'd fixed only in new compilers I've
applied it.  Thanks,

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-05-01 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-30  8:32 [PATCH] locarchive.c nested macros Jakub Jelinek
2002-05-01  9:48 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).