Schupp Roderich (extern) Com MD PD SWP 2 CM MCH wrote:

>>>>I now have unresolved externals when linking static.exe:
>>>>...
>>>>-out:.\static.exe static.obj : error LNK2001: unresolved 
>>>>external symbol __imp__win32_access static.obj : error 
>>>>LNK2001: unresolved external symbol __imp__win32_stat 
>>>>        
>>>>
>>>This is stuff from perl58.dll which shouldn't be there - static.o 
>>>should only reference standard C library functions. I dunno the 
>>>      
>>>
>>...
>>cl -E ... does the trick.  The win32_* symbols are all 
>>defined in perl's 
>>win32/win32.c (and exported from the perl58.dll), and declared in 
>>win32iop.h.  The pre-processor output (minus the huge chunks 
>>that load 
>>perl58.dll and par.exe) is attached.
>>    
>>
>
>OK, win32iop.h redefines lseek to win32_lseek etc unless 
>WIN32IO_IS_STDIO is defined. The latter is defined when
>PERL_IMPLICIT_SYS is defined. 
>
Ah.  I'd missed that.  That explains it, then:

>Comparing your Config.pm with
>that for ActiveState perl 5.8.6 I see that they have defined
>the latter, but you haven't. Actually PERL_IMPLICIT_SYS gets
>defined in perl-5.8.6/win32/Makefile when USE_IMP_SYS is 
>defined, but I didn't figure out where this can get undefined.
>My guess is that this follows from your decision to build
>your perl without support for ithreads. 
>  
>
Yes - as I said in an earlier message 
(http://www.mail-archive.com/par@perl.org/msg01693.html), I've disabled 
USE_IMP_SYS in the win32/Makefile so that I can enable PERL_MALLOC 
(which is quite a bit faster on Win32).

>That leaves two possible solutions for the original problem 
>with PAR:
>(1) rebuild your perl with the same options as ActiveState does,
>    then rebuild PAR
>  
>
That certainly works, but I don't really want to go there.

>(2) in PAR's myldr/static.c remove the following lines
>
>    #include "EXTERN.h"
>    #include "perl.h"
>
>    (shouldn't be needed anyway, as static.c is supposed 
>    to depend only on standard C functions).
>    You need to replace them with the appropriate list
>    of #include's from the standard C library to cover
>    all functions actually referenced in static.c.
>    (Unfortunately that list is probably build-target specific,
>    so this isn't a general fix.)
>
Commenting out the 2 includes above causes these errors:

mktmpdir.h(35) : error C2079: 'PL_statbuf' uses undefined struct 'stat'
utils.c(60) : warning C4013: 'sprintf' undefined; assuming extern 
returning int
utils.c(61) : warning C4013: 'stat' undefined; assuming extern returning int
utils.c(62) : warning C4013: 'access' undefined; assuming extern 
returning int
sha1.c(38) : error C2061: syntax error : identifier 'U8'
...
sha1.c(157) : fatal error C1189: #error :  Unknown byte order -- you 
need to add code here

So I added:

<sys/types.h>, <sys/stat.h> in mktmpdir.h
<stdio.h>, <sys/types.h>, <sys/stat.h>, <io.h> in utils.c

Fixing sha1.c is trickier because U8 and BYTEORDER are Perl things, so 
can't be fixed without including Perl headers, or duplicating stuff from 
them.  I added:

typedef unsigned char U8;
#define BYTEORDER 0x1234

which is right for my OS.

I then get warnings/errors from mktmpdir.c about S_ISDIR, S_ISLNK, W_OK, 
_mkdir, O_RDONLY, getpid and _rmdir, and from static.c about O_CREAT, 
O_WRONLY, spawnvpe and P_WAIT.

Adding (Perl's!) definitions of S_ISDIR, S_ISLINK and W_OK to mktmpdir.h 
and including <direct.h>, <fcntl.h> and <process.h> sorts out the 
mktmpdir.c issues;  including <fcntl.h> and <process.h> in static.c 
sorts that file out.

I still get a warning from the static.c compilation:

C:\PROGRA~1\MICROS~2\VC98\include\direct.h(132) : warning C4003: not 
enough actual parameters for macro 'mkdir'

but PAR's test suite passes all tests OK, and executables produced by pp 
no longer require perl58.dll!

Thanks for helping me sort this out.  I've attached the complete diff 
(against 0.87) of the changes that I made.  Perhaps these, or similar, 
changes could be incorporated into PAR in the future, although I realise 
(as you mentioned) that there are problems with portability.

Something needs to be done, though, because it's definitely wrong the 
way it stands.

- Steve


------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are 
confidential and intended for the addressee(s) only.  If you have received this 
message in error or there are any problems, please notify the sender 
immediately.  The unauthorized use, disclosure, copying or alteration of this 
message is strictly forbidden.  Note that any views or opinions presented in 
this email are solely those of the author and do not necessarily represent 
those of Radan Computational Ltd.  The recipient(s) of this message should 
check it and any attached files for viruses: Radan Computational will accept no 
liability for any damage caused by any virus transmitted by this email.
diff -ruN PAR-0.87.orig/myldr/mktmpdir.c PAR-0.87/myldr/mktmpdir.c
--- PAR-0.87.orig/myldr/mktmpdir.c      2004-12-11 03:37:56.000000000 +0000
+++ PAR-0.87/myldr/mktmpdir.c   2005-02-16 15:10:51.314101700 +0000
@@ -1,3 +1,7 @@
+#include <direct.h>
+#include <fcntl.h>
+#include <process.h>
+
 #include "ctype.h"
 #include "mktmpdir.h"
 
diff -ruN PAR-0.87.orig/myldr/mktmpdir.h PAR-0.87/myldr/mktmpdir.h
--- PAR-0.87.orig/myldr/mktmpdir.h      2004-12-11 03:37:56.000000000 +0000
+++ PAR-0.87/myldr/mktmpdir.h   2005-02-16 15:11:09.688748900 +0000
@@ -1,14 +1,40 @@
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <errno.h>
 #ifdef WIN32
 #include <windows.h>
 #endif
 
+#ifndef W_OK
+#define W_OK 0x02
+#endif
+
 #ifndef X_OK
 #define X_OK 0x04
 #endif
 
+#ifndef S_ISDIR
+#   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
+#endif
+
+#ifndef S_ISLNK
+#   ifdef _S_ISLNK
+#      define S_ISLNK(m) _S_ISLNK(m)
+#   else
+#      ifdef _S_IFLNK
+#          define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
+#      else
+#          ifdef S_IFLNK
+#              define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
+#          else
+#              define S_ISLNK(m) (0)
+#          endif
+#      endif
+#   endif
+#endif
+
 #ifndef S_ISREG
 #define S_ISREG(x) 1
 #endif
diff -ruN PAR-0.87.orig/myldr/sha1.c PAR-0.87/myldr/sha1.c
--- PAR-0.87.orig/myldr/sha1.c  2004-12-11 03:37:56.000000000 +0000
+++ PAR-0.87/myldr/sha1.c       2005-02-16 15:00:37.031434800 +0000
@@ -29,6 +29,9 @@
 # endif
 #endif
 
+typedef unsigned char U8;
+#define BYTEORDER 0x1234
+
 #define SHA_BLOCKSIZE          64
 #define SHA_DIGESTSIZE         20
 
diff -ruN PAR-0.87.orig/myldr/static.c PAR-0.87/myldr/static.c
--- PAR-0.87.orig/myldr/static.c        2004-12-11 03:37:56.000000000 +0000
+++ PAR-0.87/myldr/static.c     2005-02-16 15:16:02.057342400 +0000
@@ -1,5 +1,5 @@
-#include "EXTERN.h"
-#include "perl.h"
+#include <fcntl.h>
+#include <process.h>
 
 #undef PL_statbuf
 #undef readdir
diff -ruN PAR-0.87.orig/myldr/utils.c PAR-0.87/myldr/utils.c
--- PAR-0.87.orig/myldr/utils.c 2004-12-11 03:37:56.000000000 +0000
+++ PAR-0.87/myldr/utils.c      2005-02-16 14:49:58.281368300 +0000
@@ -15,6 +15,11 @@
  *
  */
 
+#include <io.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
 #include "env.c"
 
 char *par_findprog(char *prog, char *path) {

Reply via email to