From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30845 invoked by alias); 30 Apr 2002 15:32:02 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 30788 invoked from network); 30 Apr 2002 15:31:56 -0000 Received: from unknown (HELO sunsite.mff.cuni.cz) (195.113.19.66) by sources.redhat.com with SMTP; 30 Apr 2002 15:31:56 -0000 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.11.6/8.11.6) id g3UFVfB02350; Tue, 30 Apr 2002 17:31:41 +0200 Date: Tue, 30 Apr 2002 08:32:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] locarchive.c nested macros Message-ID: <20020430173141.T32482@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-SW-Source: 2002-04/txt/msg00078.txt.bz2 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 * 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