Compiling lftp on Solaris with Sun Studio

Yann Rouillard <[email protected]> Sun, 20 Aug 2006 01:25:45 +0200
Newsgroups gmane.network.lftp.devel
Message-ID <[email protected]>
Hi,

I maintain the lftp package for the blastwave project ( 
http://www.blastwave.org/ ) and I had some issues with lftp 3.5.4 under 
Solaris with Sun CC.

I attached the patchs I applied to be able to solve the problems:

- I had a problem with the bool type, there seems to be an error in the
stdbool_.h file when the compiler does support bool, moreover the 
included stdbool.h is not in the default include path so it triggers an 
error on Solaris 5.8 where this file doesn't exist.

I applied patch sun_cc_bool_compilation_fix.patch to solve this problem.

- I had a segfault when I did a  'ls' with the sftp protocol, it turns 
out the MakeRef macro didn't work as expected
Makeref(session->MakeDirList(v)) was transformed by CC in
(_MakeRef((session->MakeDirList(v))),(session->MakeDirList(v))) which 
created 2 SFtpDirList instead of one, both sharing the same session value.

I applied patch MakeRef_macro.patch which change the MakeRef calls to 
avoid this, is there a way to direclty change the macro so this 
behaviour doesn't happen ?

Would you consider merging this patches ?

Cheers,

Yann
MakeRef_macro.patch (text/x-patch, 1.5 KB)
diff --speed-large-files --minimal -Nru lftp-3.5.4.orig/src/FileCopy.cc lftp-3.5.4/src/FileCopy.cc
--- lftp-3.5.4.orig/src/FileCopy.cc	2006-07-25 04:38:31.000000000 -0400
+++ lftp-3.5.4/src/FileCopy.cc	2006-08-19 09:01:42.438310000 -0400
@@ -408,8 +408,10 @@
    max_buf=0x10000;
    cont=false;
    error_text=0;
-   rate        =MakeRef(new Speedometer("xfer:rate-period"));
-   rate_for_eta=MakeRef(new Speedometer("xfer:eta-period"));
+   rate        =new Speedometer("xfer:rate-period");
+   rate        =MakeRef(rate);
+   rate_for_eta=new Speedometer("xfer:eta-period");
+   rate_for_eta=MakeRef(rate_for_eta);
    put_buf=0;
    put_eof_pos=0;
    bytes_count=0;
@@ -798,8 +800,10 @@
 	    fxp_eof:
 	       // FIXME: set date for real.
 	       date_set=true;
-	       if(!verify)
-		  verify=MakeRef(new FileVerificator(session,file));
+	       if(!verify) {
+		  verify=new FileVerificator(session,file);
+		  verify=MakeRef(verify);
+	       }
 	       return MOVED;
 	    }
 	    else if(res==FA::IN_PROGRESS)
@@ -1395,8 +1399,10 @@
 	    }
 	    if(stream && delete_stream && !stream->Done())
 	       return m;
-	    if(!verify)
-	       verify=MakeRef(new FileVerificator(stream));
+	    if(!verify) {
+	       verify=new FileVerificator(stream);
+	       verify=MakeRef(verify);
+	    }
 	    return MOVED;
 	 }
 	 if(seek_pos==0)
@@ -1731,7 +1737,8 @@
    : FileCopyPeer(GET)
 {
    session=s;
-   dl=MakeRef(session->MakeDirList(v));
+   dl=session->MakeDirList(v);
+   dl=MakeRef(dl);
    if(dl==0)
       eof=true;
    can_seek=false;
sun_cc_bool_compilation_fix.patch (text/x-patch, 2.1 KB)
diff --speed-large-files --minimal -Nru lftp-3.5.4.orig/lib/argmatch.c lftp-3.5.4/lib/argmatch.c
--- lftp-3.5.4.orig/lib/argmatch.c	2006-07-24 03:54:53.000000000 -0400
+++ lftp-3.5.4/lib/argmatch.c	2006-08-19 14:08:45.545751000 -0400
@@ -27,7 +27,11 @@
 /* Specification.  */
 #include "argmatch.h"
 
-#include <stdbool.h>
+#ifdef HAVE_STDBOOL_H
+# include <stdbool.h>
+#else
+# include "../lib/stdbool.h"
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --speed-large-files --minimal -Nru lftp-3.5.4.orig/lib/human.h lftp-3.5.4/lib/human.h
--- lftp-3.5.4.orig/lib/human.h	2006-07-24 03:54:53.000000000 -0400
+++ lftp-3.5.4/lib/human.h	2006-08-19 14:09:22.415324000 -0400
@@ -23,7 +23,11 @@
 # define HUMAN_H_ 1
 
 # include <limits.h>
-# include <stdbool.h>
+# ifdef HAVE_STDBOOL_H
+#  include <stdbool.h>
+# else
+#  include "../lib/stdbool.h"
+# endif
 
 # if HAVE_STDINT_H
 #  include <stdint.h>
diff --speed-large-files --minimal -Nru lftp-3.5.4.orig/lib/quotearg.c lftp-3.5.4/lib/quotearg.c
--- lftp-3.5.4.orig/lib/quotearg.c	2006-07-24 03:54:53.000000000 -0400
+++ lftp-3.5.4/lib/quotearg.c	2006-08-19 14:08:45.545777000 -0400
@@ -30,7 +30,11 @@
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
-#include <stdbool.h>
+#ifdef HAVE_STDBOOL_H
+# include <stdbool.h>
+#else
+# include "../lib/stdbool.h"
+#endif
 #include <stdlib.h>
 #include <string.h>
 
diff --speed-large-files --minimal -Nru lftp-3.5.4.orig/lib/stdbool_.h lftp-3.5.4/lib/stdbool_.h
--- lftp-3.5.4.orig/lib/stdbool_.h	2006-07-24 03:54:53.000000000 -0400
+++ lftp-3.5.4/lib/stdbool_.h	2006-08-19 14:08:45.545792000 -0400
@@ -74,7 +74,7 @@
   /* A compiler known to have 'bool'.  */
   /* If the compiler already has both 'bool' and '_Bool', we can assume they
      are the same types.  */
-# if !@HAVE__BOOL@
+# if @HAVE__BOOL@
 typedef bool _Bool;
 # endif
 #else
@@ -100,7 +100,7 @@
 enum { false = 0, true = 1 };
 # else
    /* With this compiler, trust the _Bool type if the compiler has it.  */
-#  if !@HAVE__BOOL@
+#  if @HAVE__BOOL@
 typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
 #  endif
 # endif