develooper Front page | perl.perl5.porters | Postings from January 2001

[PATCH: perl@8506]completion and docs for dynamic loading on OS/390

Thread Previous | Thread Next
Peter Prymmer
January 24, 2001 17:14
[PATCH: perl@8506]completion and docs for dynamic loading on OS/390
Message ID:


The enclosed patch completes dynamic loading for OS/390.  I've tested
this with a `make install` and a successful build of OS390::Stdio v 0.003
in the resultant installation tree.  I found that for a few of the
critical $(CC) and $(LD) command lines in the Makefile I've had to switch
to the "$(CC) -o output_file $other_args" idiom rather than the
"$(CC) $some_args -o output_file $more_args" usage.  Since Configure was
modified a few years ago to follow the former style (allegedly POSIX
required and helpful for some POSIX on non POSIX systems e.g. Wind/U?)
I think this is fairly safe.  I have tested it as OK with GNU make on
OS/390, GNU make on Tru64 and system supplied /bin/make on AIX.  Perhaps
more testing on other platforms would be prudent.

Note the installperl hack to modify lib/ prior to its
installation.  This patch does not attempt to clean up the resultant
lib/Config.pmbak file but it will only occur on OS/390 and leaving it
hanging around in the build tree may prove helpful for debugging customer
complaints about dynaloading :-)

Have fun.

diff -ru perl.8506.orig/hints/ perl.8506/hints/
--- perl.8506.orig/hints/	Tue Jan 23 13:34:29 2001
+++ perl.8506/hints/	Wed Jan 24 15:21:05 2001
@@ -84,23 +84,37 @@
     case "$useshrplib" in
     '') useshrplib='true' ;;
-    case "$dlext" in
-    '') dlext='dll' ;;
-    esac
     case "$dlsrc" in
     '') dlsrc='dl_dllload.xs' ;;
-    so='dll'
-    libperl='libperl.dll'
+    # For performance use 'so' at or beyond v2.8, 'dll' for 2.7 and prior versions
+    case "`uname -v`x`uname -r`" in
+    02x0[89].*|02x1[0-9].*|[0-9][3-9]x*) 
+        so='so'
+        case "$dlext" in
+        '') dlext='so' ;;
+        esac
+        ;;
+    *) 
+        so='dll'
+        case "$dlext" in
+        '') dlext='dll' ;;
+        esac
+        ;;
+    esac
+    libperl="libperl.$so"
     ccflags="$ccflags -D_SHR_ENVIRON -DPERL_EXTERNAL_GLOB -Wc,dll"
     cccdlflags='-c -Wc,dll,EXPORTALL'
     # You might add '-Wl,EDIT=NO' to get rid of the symbol
-    # information at the end of the executable.
-    #
-    # The following will need to be modified for the installed libperl.x
+    # information at the end of the executable (=> smaller binaries).
+    # Do so with -Dldflags='-Wl,EDIT=NO'.
+    case "$ldflags" in
+    '') ldflags='' ;;
+    esac
+    # The following will need to be modified for the installed libperl.x.
+    # The modification to is done by the installperl script after the build and test.
     ccdlflags="-W l,dll `pwd`/libperl.x"
-    ldflags=''
-    lddlflags='-W l,dll'
+    lddlflags="-W l,dll `pwd`/libperl.x"
 # even on static builds using LIBPATH should be OK.
@@ -140,7 +154,14 @@
 # other things.  Unfortunately, cppflags occurs too late to be of 
 # value external to the script.  This may need to be revisited 
 # under a compiler other than c89.
+case "$usedl" in
+echo 'cat >.$$.c; '"$cc"' -D_OE_SOCKETS -D_XOPEN_SOURCE_EXTENDED -D_ALL_SOURCE -D_SHR_ENVIRON -E -Wc,NOLOC ${1+"$@"} .$$.c; rm .$$.c' > cppstdin
+    ;;
 echo 'cat >.$$.c; '"$cc"' -D_OE_SOCKETS -D_XOPEN_SOURCE_EXTENDED -D_ALL_SOURCE -E -Wc,NOLOC ${1+"$@"} .$$.c; rm .$$.c' > cppstdin
+    ;;
 # Note that Makefile.SH employs a bare yacc command to generate 
diff -ru perl.8506.orig/installperl perl.8506/installperl
--- perl.8506.orig/installperl	Wed Jan 24 15:11:23 2001
+++ perl.8506/installperl	Wed Jan 24 15:25:12 2001
@@ -116,7 +116,7 @@
 # print "[$_]\n" for sort keys %archpms;
 my $ver = $Config{version};
-my $release = substr($],0,3);   # Not used presently.
+my $release = substr($],0,3);   # Not used currently.
 my $patchlevel = substr($],3,2);
 die "Patchlevel of perl ($patchlevel)",
     "and patchlevel of ($Config{'PERL_VERSION'}) don't match\n"
@@ -136,6 +136,15 @@
 my $so = $Config{so};
 my $dlext = $Config{dlext};
 my $dlsrc = $Config{dlsrc};
+if ($^O eq 'os390') {
+    my $pwd;
+    chomp($pwd=`pwd`);
+    my $archlibexp = $Config{archlibexp};
+    my $usedl = $Config{usedl};
+    if ($usedl eq 'define') {
+        `./$^X -pibak -e 's{$pwd\/libperl.x}{$archlibexp/CORE/libperl.x}' lib/`;
+    }
 my $d_dosuid = $Config{d_dosuid};
 my $binexp = $Config{binexp};
diff -ru perl.8506.orig/Makefile.SH perl.8506/Makefile.SH
--- perl.8506.orig/Makefile.SH	Tue Jan 23 13:34:06 2001
+++ perl.8506/Makefile.SH	Wed Jan 24 14:56:09 2001
@@ -78,6 +78,7 @@
 		linklibperl="-L `pwd | sed 's/\/UU$//'` -Wl,+s -Wl,+b$archlibexp/CORE -lperl"
+            shrpldflags='-W l,dll'
@@ -419,7 +420,7 @@
 	case "$useshrplib" in
 		$spitshell >>Makefile <<'!NO!SUBS!'
-	$(LD) $(SHRPLDFLAGS) -o $@ perl$(OBJ_EXT) $(obj)
+	$(LD) -o $@ $(SHRPLDFLAGS) perl$(OBJ_EXT) $(obj)
 		case "$osname" in
@@ -484,16 +485,16 @@
 	$spitshell >>Makefile <<'!NO!SUBS!'
 perl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
-	$(SHRPENV) $(LDLIBPTH) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
+	$(SHRPENV) $(LDLIBPTH) $(CC) -o perl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
 pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
-	$(SHRPENV) $(LDLIBPTH) purify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
+	$(SHRPENV) $(LDLIBPTH) purify $(CC) -o pureperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
 purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
-	$(SHRPENV) $(LDLIBPTH) purecov $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
+	$(SHRPENV) $(LDLIBPTH) purecov $(CC) -o purecovperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
 quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
-	$(SHRPENV) $(LDLIBPTH) quantify $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
+	$(SHRPENV) $(LDLIBPTH) quantify $(CC) -o quantperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
 # This version, if specified in Configure, does ONLY those scripts which need
 # set-id emulation.  Suidperl must be setuid root.  It contains the "taint"
@@ -501,7 +502,7 @@
 # has been invoked correctly.
 suidperl: $& sperl$(OBJ_EXT) perlmain$(OBJ_EXT) $(LIBPERL) $(DYNALOADER) $(static_ext) ext.libs $(PERLEXPORT)
-	$(SHRPENV) $(LDLIBPTH) $(CC) $(CLDFLAGS) $(CCDLFLAGS) -o suidperl perlmain$(OBJ_EXT) sperl$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
+	$(SHRPENV) $(LDLIBPTH) $(CC) -o suidperl $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) sperl$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
diff -ru perl.8506.orig/README.os390 perl.8506/README.os390
--- perl.8506.orig/README.os390	Wed Jan 24 15:54:03 2001
+++ perl.8506/README.os390	Wed Jan 24 17:00:12 2001
@@ -58,6 +58,9 @@
 (as well as Perl and Apache) in the red-piece/book "Open Source Software 
 for OS/390 UNIX", SG24-5944-00 from IBM.
+You might also want to have GNU groff for OS/390 installed before
+running the `make install` step for Perl.
 There is a syntax error in the /usr/include/sys/socket.h header file
 that IBM supplies with USS V2R7, V2R8, and possibly V2R9.  The problem with
 the header file is that near the definition of the SO_REUSEPORT constant
@@ -143,10 +146,13 @@
 =item *
-This port doesn't support dynamic loading.  Although OS/390 has support 
-for DLLs via dllload(), there are some differences that cause problems 
-for Perl.  (We need a volunteer to write a ext/DynaLoader/dl_dllload.xs 
+This port will support dynamic loading, but it is not selected by
+default.  If you would like to experiment with dynamic loading then
+be sure to specify -Dusedl in the arguments to the Configure script.
+See the comments in hints/ for more information on dynamic loading.
+If you build with dynamic loading then you will need to add the
+$archlibexp/CORE directory to your LIBPATH environment variable in order
+for perl to work.  See the file for the value of $archlibexp.
 =item *
@@ -260,6 +266,12 @@
+=head2 installation anomalies
+The installman script will try to run on OS/390.  There will be fewer errors
+if you have a roff utility installed.  You can obtain GNU groff from the 
+Redbook SG24-5944-00 ftp site.
 =head2 Usage Hints
 When using perl on OS/390 please keep in mind that the EBCDIC and ASCII
@@ -321,8 +333,10 @@
     make test
     make install
-You can also build xs based extensions to Perl for OS/390 but will need 
-to follow the instructions in ExtUtils::MakeMaker for building 
+If you built perl with dynamic loading capability then that would also
+be the way to build xs based extensions.  However, if you built perl with
+the default static linking you can still build xs based extensions for OS/390 
+but you will need to follow the instructions in ExtUtils::MakeMaker for building 
 statically linked perl binaries.  In the simplest configurations building
 a static perl + xs extension boils down to:
@@ -337,12 +351,21 @@
 than the system's /bin/make program, whether for plain modules or for
 xs based extensions.
+If the make process encounters trouble with either compilation or
+linking then try setting the _C89_CCMODE to 1.  Assuming sh is your
+login shell then run:
+    export _C89_CCMODE=1
+If tcsh is your login shell then use the setenv command.
 =head1 AUTHORS
 David Fiander and Peter Prymmer with thanks to Dennis Longnecker
 and William Raffloer for valuable reports, LPAR and PTF feedback.
 Thanks to Mike MacIsaac and Egon Terwedow for SG24-5944-00.
 Thanks to Ignasi Roca for pointing out the floating point problems.
+Thanks to John Goodyear for dynamic loading help.
 =head1 SEE ALSO
@@ -386,6 +409,8 @@
 Updated 12 November 2000 for the 5.7.1 release of Perl.
 Updated 15 January 2001 for the 5.7.1 release of Perl.
+Updated 24 January 2001 to mention dynamic loading.
End of Patch.

Peter Prymmer

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About