Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Feb 2007 16:49:24 -0500
From:      Mikhail Teterin <mi+kde@aldan.algebra.com>
To:        "Michael Johnson" <ahze@ahze.net>
Cc:        gnome@freebsd.org, Mikhail Teterin <mi+mx@aldan.algebra.com>
Subject:   Re: improving firefox port
Message-ID:  <200702261649.25138@aldan>
In-Reply-To: <b2203fed0611100511pe742dc1qaafa088898fe816c@mail.gmail.com>
References:  <200611091924.56887.mi%2Bmx@aldan.algebra.com> <b2203fed0611100511pe742dc1qaafa088898fe816c@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--Boundary-00=_lX14FjNCjr++2Z9
Content-Type: text/plain;
  charset="koi8-u"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Friday 10 November 2006 08:11, Michael Johnson wrote:
= On 11/9/06, Mikhail Teterin <mi+mx@aldan.algebra.com> wrote:
= > Hello!
= >
= > The following changes to firefox/Makefile and mozilla/Makefile.common,
= > along with attached additional patch (firefox/files/patch-sysbz2) allow:
= >
= >         1) use of the base system's -lbz2 instead of compiling Mozilla's
= >	       own;
= 
= I'm not 100% sure if this is still true (I'll try later today) but
= excluding mozilla/modules/zlib will break Sunbird. I'm
= all for using system -lbz2/zlib though.

This remains a problem. Both ports I just checked -- firefox and sunbird -- 
continue to build their own bzip2, which is wasteful at best and dangerous at 
worst, since they may be using system's /lib/libbz2.so after compiling 
against their own set of headers.

The attached patches fix this for both firefox and sunbird. Patching 
mozilla/Makefile.common will reveal, what other Mozilla-software 
(thunderbird?) suffer from the same problem, so that it too can be fixed. The 
fixes themselves are trivial (see patches).

Now, the base libz was bumped to version 1.2.3 in FreeBSD-6.x some time last 
September. This means, the first hunk of www/firefox/patch-configure is no 
longer required there. However, on 5.x it is still required and should be 
present for all other mozilla-derived ports (such as sunbird).

= >         2) build and run the vendor's self-checks (yes, I'm still at
= >	       it :-)
= 
= I like this, but do you think we should add this to ALL_TARGET instead
= of adding a check: target and manually run make check?

My position on this has not changed -- the tests should run always, IMO. It 
is, however, trivial to paint this shed one way or the other, once the rest 
is done (tests run cleanly), so suit yourself :-)

I'm also including a separate patch for mozilla's libreg -- it removes a 
bargeload of warnings and makes firefox less likely to crash, when faced with 
a file, that's longer than 4Gb. I tried submitting it to mozilla.org, but the 
patched file is already a horrible ifdef-spaghetti, and is supposed to be 
split into platform-specific modules at some point. I build my firefox with 
this patch included, but nobody else has to :-)

Please, give it a whirl at your build farm -- as I mentioned, some other 
things may need bz2/libz patching... Yours,

	-mi

--Boundary-00=_lX14FjNCjr++2Z9
Content-Type: text/x-diff;
  charset="koi8-u";
  name="patch-libreg"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="patch-libreg"

--- modules/libreg/src/vr_stubs.h	Tue Jul 22 16:16:02 2003
+++ modules/libreg/src/vr_stubs.h	Sat Aug  6 04:25:58 2005
@@ -85,8 +85,8 @@
 #define USE_STDIO_MODES
 
-#define XP_FileSeek(file,offset,whence) fseek((file), (offset), (whence))
+#define XP_FileSeek(file,offset,whence) fseeko((file), (offset), (whence))
 #define XP_FileRead(dest,count,file)    fread((dest), 1, (count), (file))
 #define XP_FileWrite(src,count,file)    fwrite((src), 1, (count), (file))
-#define XP_FileTell(file)               ftell(file)
+#define XP_FileTell(file)               ftello(file)
 #define XP_FileFlush(file)              fflush(file)
 #define XP_FileClose(file)              fclose(file)
--- modules/libreg/src/reg.c	Mon May 17 04:48:53 2004
+++ modules/libreg/src/reg.c	Sat Aug  6 04:27:10 2005
@@ -423,9 +423,9 @@
 static REGERR nr_OpenFile(const char *path, FILEHANDLE *fh);
 static REGERR nr_CloseFile(FILEHANDLE *fh); /* Note: fh is a pointer */
-static REGERR nr_ReadFile(FILEHANDLE fh, REGOFF offset, int32 len, void *buffer);
-static REGERR nr_WriteFile(FILEHANDLE fh, REGOFF offset, int32 len, void *buffer);
-static REGERR nr_LockRange(FILEHANDLE fh, REGOFF offset, int32 len);
-static REGERR nr_UnlockRange(FILEHANDLE fh, REGOFF offset, int32 len);
-static int32  nr_GetFileLength(FILEHANDLE fh);
+static REGERR nr_ReadFile(FILEHANDLE fh, REGOFF offset, size_t len, void *buffer);
+static REGERR nr_WriteFile(FILEHANDLE fh, REGOFF offset, size_t len, const void *buffer);
+static REGERR nr_LockRange(FILEHANDLE fh, REGOFF offset, size_t len);
+static REGERR nr_UnlockRange(FILEHANDLE fh, REGOFF offset, size_t len);
+static off_t   nr_GetFileLength(FILEHANDLE fh);
 /* -------------------------------------------------------------------- */
 
@@ -523,5 +523,5 @@
 
 
-static REGERR nr_ReadFile(FILEHANDLE fh, REGOFF offset, int32 len, void *buffer)
+static REGERR nr_ReadFile(FILEHANDLE fh, REGOFF offset, size_t len, void *buffer)
 {
 #if VERIFY_READ
@@ -531,5 +531,5 @@
 #endif
 
-    int32 readlen;
+    size_t readlen;
     REGERR err = REGERR_OK;
 
@@ -548,4 +548,5 @@
         readlen = XP_FileRead(buffer, len, fh );
         /* PR_READ() returns an unreliable length, check EOF separately */
+#if !defined(USE_STDIO_MODES) /* USE_STDIO_MODES means XP_FileRead = fread */
         if (readlen < 0) {
 #if !defined(STANDALONE_REGISTRY) || (!defined(XP_MAC) && !defined(XP_MACOSX))
@@ -560,5 +561,7 @@
                 err = REGERR_BADREAD;
         }
-        else if (readlen < len) {
+        else
+#endif /* USE_STDIO_MODES */
+	  if (readlen < len) {
 #if VERIFY_READ
             /* PR_READ() says we hit EOF but return length is unreliable. */
@@ -587,5 +590,5 @@
 
 
-static REGERR nr_WriteFile(FILEHANDLE fh, REGOFF offset, int32 len, void *buffer)
+static REGERR nr_WriteFile(FILEHANDLE fh, REGOFF offset, size_t len, const void *buffer)
 {
 
@@ -601,5 +604,5 @@
         return REGERR_FAIL;
 
-    if ((int32)XP_FileWrite(buffer, len, fh) != len)
+    if (XP_FileWrite(buffer, len, fh) != len)
     {
         /* disk full or some other catastrophic error */
@@ -613,5 +616,5 @@
 
 
-static REGERR nr_LockRange(FILEHANDLE fh, REGOFF offset, int32 len)
+static REGERR nr_LockRange(FILEHANDLE fh, REGOFF offset, size_t len)
 {
     /* TODO: Implement XP lock function with built-in retry. */
@@ -623,5 +626,5 @@
 
 
-static REGERR nr_UnlockRange(FILEHANDLE fh, REGOFF offset, int32 len)
+static REGERR nr_UnlockRange(FILEHANDLE fh, REGOFF offset, size_t len)
 {
     /* TODO: Implement XP unlock function with built-in retry. */
@@ -634,8 +637,8 @@
 
 #if SELF_REPAIR
-static int32 nr_GetFileLength(FILEHANDLE fh)
+static off_t nr_GetFileLength(FILEHANDLE fh)
 {
-    int32 length;
-    int32 curpos;
+    off_t length;
+    off_t curpos;
 
     curpos = XP_FileTell(fh);
@@ -730,17 +733,17 @@
 
 static REGERR nr_ReadDesc(REGFILE *reg, REGOFF offset, REGDESC *desc);      /* reads a desc */
-static REGERR nr_ReadName(REGFILE *reg, REGDESC *desc, uint32 buflen, char *buf);
-static REGERR nr_ReadData(REGFILE *reg, REGDESC *desc, uint32 buflen, char *buf);
+static REGERR nr_ReadName(REGFILE *reg, REGDESC *desc, size_t buflen, char *buf);
+static REGERR nr_ReadData(REGFILE *reg, REGDESC *desc, size_t buflen, char *buf);
 
 static REGERR nr_WriteDesc(REGFILE *reg, REGDESC *desc);                    /* writes a desc */
-static REGERR nr_WriteString(REGFILE *reg, char *string, REGDESC *desc);    /* writes a string */
-static REGERR nr_WriteData(REGFILE *reg, char *string, uint32 len, REGDESC *desc);  /* writes a string */
+static REGERR nr_WriteString(REGFILE *reg, const char *string, REGDESC *desc);    /* writes a string */
+static REGERR nr_WriteData(REGFILE *reg, const char *string, size_t len, REGDESC *desc);  /* writes a string */
 
 static REGERR nr_AppendDesc(REGFILE *reg, REGDESC *desc, REGOFF *result);   /* adds a desc */
-static REGERR nr_AppendName(REGFILE *reg, char *name, REGDESC *desc);       /* adds a name */
-static REGERR nr_AppendString(REGFILE *reg, char *string, REGDESC *desc);   /* adds a string */
-static REGERR nr_AppendData(REGFILE *reg, char *string, uint32 len, REGDESC *desc); /* adds a string */
+static REGERR nr_AppendName(REGFILE *reg, const char *name, REGDESC *desc);       /* adds a name */
+static REGERR nr_AppendString(REGFILE *reg, const char *string, REGDESC *desc);   /* adds a string */
+static REGERR nr_AppendData(REGFILE *reg, const char *string, size_t len, REGDESC *desc); /* adds a string */
 
-static XP_Bool nr_IsValidUTF8(char *string);    /* checks if a string is UTF-8 encoded */
+static XP_Bool nr_IsValidUTF8(const char *string);    /* checks if a string is UTF-8 encoded */
 /* -------------------------------------------------------------------- */
 
@@ -751,5 +754,5 @@
 
     int err;
-    long filelength;
+    off_t filelength;
     char hdrBuf[sizeof(REGHDR)];
 
@@ -968,5 +971,5 @@
 
 
-static REGERR nr_ReadName(REGFILE *reg, REGDESC *desc, uint32 buflen, char *buf)
+static REGERR nr_ReadName(REGFILE *reg, REGDESC *desc, size_t buflen, char *buf)
 {
 
@@ -992,5 +995,5 @@
 
 
-static REGERR nr_ReadData(REGFILE *reg, REGDESC *desc, uint32 buflen, char *buf)
+static REGERR nr_ReadData(REGFILE *reg, REGDESC *desc, size_t buflen, char *buf)
 {
 
@@ -1104,9 +1107,9 @@
 
 
-static REGERR nr_AppendName(REGFILE *reg, char *name, REGDESC *desc)
+static REGERR nr_AppendName(REGFILE *reg, const char *name, REGDESC *desc)
 {
     REGERR err;
     int len;
-    char *p;
+    const char *p;
 
     XP_ASSERT(reg);
@@ -1154,5 +1157,5 @@
 
 
-static REGERR nr_WriteString(REGFILE *reg, char *string, REGDESC *desc)
+static REGERR nr_WriteString(REGFILE *reg, const char *string, REGDESC *desc)
 {
     uint32 len;
@@ -1171,5 +1174,5 @@
 
 
-static REGERR nr_WriteData(REGFILE *reg, char *string, uint32 len, REGDESC *desc)
+static REGERR nr_WriteData(REGFILE *reg, const char *string, size_t len, REGDESC *desc)
 {
     REGERR err;
@@ -1206,5 +1209,5 @@
 
 
-static REGERR nr_AppendString(REGFILE *reg, char *string, REGDESC *desc)
+static REGERR nr_AppendString(REGFILE *reg, const char *string, REGDESC *desc)
 {
     uint32 len;
@@ -1223,5 +1226,5 @@
 
 
-static REGERR nr_AppendData(REGFILE *reg, char *string, uint32 len, REGDESC *desc)
+static REGERR nr_AppendData(REGFILE *reg, const char *string, size_t len, REGDESC *desc)
 {
     REGERR err;
@@ -1259,8 +1262,8 @@
 }   /* nr_AppendData */
 
-static XP_Bool nr_IsValidUTF8(char *string)
+static XP_Bool nr_IsValidUTF8(const char *string)
 {
     int follow = 0;
-    char *c;
+    const char *c;
     unsigned char ch;
 
@@ -1520,9 +1523,9 @@
 
 static REGERR nr_CreateSubKey(REGFILE *reg, REGOFF parent, REGDESC *pDesc,
-                              char *name);
+                              const char *name);
 static REGERR nr_CreateEntryString(REGFILE *reg, REGDESC *pParent, 
-    char *name, char *value);
-static REGERR nr_CreateEntry(REGFILE *reg, REGDESC *pParent, char *name,
-    uint16 type, char *buffer, uint32 length);
+    const char *name, const char *value);
+static REGERR nr_CreateEntry(REGFILE *reg, REGDESC *pParent, const char *name,
+    uint16 type, const char *value, size_t length);
 /* -------------------------------------------------------------------- */
 
@@ -1675,5 +1678,5 @@
                               REGOFF parent,
                               REGDESC *pDesc,
-                              char *name)
+                              const char *name)
 {
     /* nr_CreateSubKey does NO error checking--callers *MUST*
@@ -1721,5 +1724,5 @@
 
 
-static REGERR nr_CreateEntryString(REGFILE *reg, REGDESC *pParent, char *name, char *value)
+static REGERR nr_CreateEntryString(REGFILE *reg, REGDESC *pParent, const char *name, const char *value)
 {
     REGDESC desc;
@@ -1758,6 +1761,6 @@
 
 
-static REGERR nr_CreateEntry(REGFILE *reg, REGDESC *pParent, char *name,
-    uint16 type, char *value, uint32 length)
+static REGERR nr_CreateEntry(REGFILE *reg, REGDESC *pParent, const char *name,
+    uint16 type, const char *value, size_t length)
 {
     REGDESC desc;
@@ -1804,6 +1807,6 @@
 static REGERR  nr_InitStdRkeys( REGFILE *reg );
 static XP_Bool nr_ProtectedNode( REGFILE *reg, REGOFF key );
-static REGERR  nr_RegAddKey( REGFILE *reg, RKEY key, char *path, RKEY *newKey, XP_Bool raw );
-static REGERR  nr_RegDeleteKey( REGFILE *reg, RKEY key, char *path, XP_Bool raw );
+static REGERR  nr_RegAddKey( REGFILE *reg, RKEY key, const char *path, RKEY *newKey, XP_Bool raw );
+static REGERR  nr_RegDeleteKey( REGFILE *reg, RKEY key, const char *path, XP_Bool raw );
 static REGERR  nr_RegOpen( const char *filename, HREG *hReg );
 static REGERR  nr_RegClose( HREG hReg );
@@ -1953,5 +1956,5 @@
 
 
-static REGERR nr_RegAddKey( REGFILE *reg, RKEY key, char *path, RKEY *newKey, XP_Bool raw )
+static REGERR nr_RegAddKey( REGFILE *reg, RKEY key, const char *path, RKEY *newKey, XP_Bool raw )
 {
     REGERR      err;
@@ -1960,5 +1963,5 @@
     REGOFF      parent;
     char        namebuf[MAXREGNAMELEN];
-    char        *p;
+    const char *p;
 
     XP_ASSERT( regStartCount > 0 );
@@ -2029,5 +2032,5 @@
 
 
-static REGERR nr_RegDeleteKey( REGFILE *reg, RKEY key, char *path, XP_Bool raw )
+static REGERR nr_RegDeleteKey( REGFILE *reg, RKEY key, const char *path, XP_Bool raw )
 {
     REGERR      err;

--Boundary-00=_lX14FjNCjr++2Z9
Content-Type: text/x-diff; charset="koi8-u"; name="mozilla-bzip2-libz.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="mozilla-bzip2-libz.diff"

Index: www/mozilla/Makefile.common
===================================================================
RCS file: /home/pcvs/ports/www/mozilla/Makefile.common,v
retrieving revision 1.23
diff -U2 -r1.23 Makefile.common
--- www/mozilla/Makefile.common	4 Feb 2007 22:37:34 -0000	1.23
+++ www/mozilla/Makefile.common	26 Feb 2007 21:47:11 -0000
@@ -102,4 +102,6 @@
 			--exclude MANIFEST			\
 			--exclude mozilla/modules/libimg/png	\
+			--exclude mozilla/modules/libbz2	\
+			--exclude mozilla/modules/zlib		\
 			--exclude mozilla/jpeg			\
 			--exclude mozilla/dbm			\
@@ -140,5 +142,4 @@
 # Standard options from README
 MOZ_OPTIONS+=	--enable-crypto 	\
-		--disable-tests 	\
 		--enable-default-toolkit=gtk2 \
 		--enable-xft		\
Index: www/firefox/Makefile
===================================================================
RCS file: /home/pcvs/ports/www/firefox/Makefile,v
retrieving revision 1.173
diff -U2 -r1.173 Makefile
--- www/firefox/Makefile	24 Feb 2007 22:08:27 -0000	1.173
+++ www/firefox/Makefile	26 Feb 2007 21:47:11 -0000
@@ -24,5 +24,5 @@
 
 WANT_GNOME=	yes
-ALL_TARGET=	default
+ALL_TARGET=	default check
 CONFIGURE_ENV=	LOCALBASE=${LOCALBASE}
 EXTRA_CFLAGS=	-O2
Index: www/firefox/files/patch-sysbz2
===================================================================
RCS file: www/firefox/files/patch-sysbz2
diff -N www/firefox/files/patch-sysbz2
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ www/firefox/files/patch-sysbz2	26 Feb 2007 21:47:11 -0000
@@ -0,0 +1,14 @@
+--- toolkit/mozapps/update/src/updater/Makefile.in	Wed Sep 14 10:09:18 2005
++++ toolkit/mozapps/update/src/updater/Makefile.in	Wed Jan 25 19:00:11 2006
+@@ -53,9 +53,9 @@
+ PROGRAM = updater$(BIN_SUFFIX)
+ 
+-REQUIRES = libmar libbz2
++REQUIRES = libmar
++OS_LIBS += -lbz2
+ 
+ LIBS += \
+ 	$(DIST)/lib/$(LIB_PREFIX)mar.$(LIB_SUFFIX) \
+-	$(DIST)/lib/$(LIB_PREFIX)bz2.$(LIB_SUFFIX) \
+ 	$(NULL)
+ 
Index: www/firefox/files/patch-sysnss
===================================================================
RCS file: /home/pcvs/ports/www/firefox/files/patch-sysnss,v
retrieving revision 1.4
diff -U2 -r1.4 patch-sysnss
--- www/firefox/files/patch-sysnss	10 Nov 2006 07:03:50 -0000	1.4
+++ www/firefox/files/patch-sysnss	26 Feb 2007 21:47:11 -0000
@@ -1,5 +1,5 @@
 --- Makefile.in	Tue Sep 14 16:59:40 2004
 +++ Makefile.in	Tue Aug  2 08:26:55 2005
-@@ -102,6 +102,4 @@
+@@ -92,6 +92,4 @@
  # tier 1 -  3rd party individual libraries
  #
@@ -8,5 +8,11 @@
  ifndef MOZ_NATIVE_JPEG
  tier_1_dirs	+= jpeg
---- security/manager/Makefile.in.orig	Tue Mar 28 14:36:54 2006
+@@ -108,5 +106,4 @@
+ 
+ ifdef MOZ_UPDATER
+-tier_1_dirs += modules/libbz2
+ tier_1_dirs += modules/libmar
+ endif
+--- security/manager/Makefile.in	Tue Mar 28 14:36:54 2006
 +++ security/manager/Makefile.in	Tue Mar 28 14:40:29 2006
 @@ -54,22 +54,13 @@
Index: deskutils/sunbird/files/patch-sysbz2
===================================================================
RCS file: deskutils/sunbird/files/patch-sysbz2
diff -N deskutils/sunbird/files/patch-sysbz2
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ deskutils/sunbird/files/patch-sysbz2	26 Feb 2007 21:47:11 -0000
@@ -0,0 +1,22 @@
+--- toolkit/toolkit-tiers.mk	Wed Sep 27 16:17:55 2006
++++ toolkit/toolkit-tiers.mk	Mon Feb 26 15:43:28 2007
+@@ -69,5 +69,4 @@
+ 
+ ifdef MOZ_UPDATER
+-tier_external_dirs += modules/libbz2
+ tier_external_dirs += modules/libmar
+ endif
+--- toolkit/mozapps/update/src/updater/Makefile.in	Mon Aug 14 13:28:28 2006
++++ toolkit/mozapps/update/src/updater/Makefile.in	Mon Feb 26 16:20:14 2007
+@@ -53,9 +53,9 @@
+ PROGRAM = updater$(BIN_SUFFIX)
+ 
+-REQUIRES = libmar libbz2
++REQUIRES = libmar
++OS_LIBS += -lbz2
+ 
+ LIBS += \
+ 	$(DEPTH)/modules/libmar/src/$(LIB_PREFIX)mar.$(LIB_SUFFIX) \
+-	$(DEPTH)/modules/libbz2/src/$(LIB_PREFIX)bz2.$(LIB_SUFFIX) \
+ 	$(NULL)
+ 
Index: deskutils/sunbird/files/patch-syslibz
===================================================================
RCS file: deskutils/sunbird/files/patch-syslibz
diff -N deskutils/sunbird/files/patch-syslibz
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ deskutils/sunbird/files/patch-syslibz	26 Feb 2007 21:47:11 -0000
@@ -0,0 +1,9 @@
+--- configure	Wed Sep 27 17:10:32 2006
++++ configure	Mon Feb 26 16:46:15 2007
+@@ -1073,5 +1073,5 @@
+ MOZJPEG=62
+ MOZPNG=10207
+-MOZZLIB=1.2.3
++MOZZLIB=1.2.2
+ NSPR_VERSION=4
+ NSS_VERSION=3

--Boundary-00=_lX14FjNCjr++2Z9--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702261649.25138>