diff options
author | Karl Williamson <khw@cpan.org> | 2021-06-20 08:43:36 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2021-06-27 08:21:20 -0700 |
commit | b18c343e06901912cf7f26c526ed2c6acecb68d1 (patch) | |
tree | e043740d0a2721d88a4b11e281f9acb269c76d62 | |
parent | 6004378c556c66e20e5e6558fd7708e43f5c9466 (diff) | |
download | perl-b18c343e06901912cf7f26c526ed2c6acecb68d1.tar.gz |
Update hints/os390.sh
This modernizes this hints file enough that it actually works on a real
live system.
-rw-r--r-- | hints/os390.sh | 208 |
1 files changed, 138 insertions, 70 deletions
diff --git a/hints/os390.sh b/hints/os390.sh index d51003479e..9bee5e2860 100644 --- a/hints/os390.sh +++ b/hints/os390.sh @@ -15,33 +15,90 @@ # as well as the authors of the aix.sh file # -# To get ANSI C, we need to use c89, and ld doesn't exist -# You can override this with Configure -Dcc=gcc -Dld=ld. -case "$cc" in -'') cc='c99' ;; -esac +# It is too late in Configure by the time this is called to change the +# compiler. But xlc or synonyms are the only thing that likely currently will +# work. +# +# But it isn't too late to change 'ld', and the z/OS 390 ld command doesn't +# understand some command line options like -W and -q that the loader needs to +# know about. xlc also acts like a loader and does understand them. case "$ld" in -'') ld='c99' ;; +'') ld='xlc' ;; esac -# -DMAXSIG=39 maximum signal number -# -DOEMVS is used in place of #ifdef __MVS__ in certain places. -# -D_OE_SOCKETS alters system headers. -# -D_XOPEN_SOURCE_EXTENDEDA alters system headers. -# c89 hides most of the useful header stuff, _ALL_SOURCE turns it on again. -# YYDYNAMIC ensures that the OS/390 yacc generated parser is reentrant. +# khw thinks these -W options are obsolete, at least the -Wc, where the 'c' +# indicates it goes to the compiler. It appears that since these were written, +# IBM added the -q series of options to the compiler, which khw thinks should +# be sufficient. -Wl are for the loader, and may be required. +os390_Wc="-Wc" +os390_Wl="-Wl" + # -DEBCDIC should come from Configure and need not be mentioned here. # Prepend your favorites with Configure -Dccflags=your_favorites - def_os390_cflags='-qlanglvl=extended:extc89:extc99 -qlongname -qxplink -qdll -qfloat=ieee -qexportall -qhaltonmsg=3296:4108' - def_os390_cflags="$def_os390_cflags -Wc,XPLINK,dll,EXPORTALL -Wl,XPLINK,dll" - def_os390_defs='-DMAXSIG=39 -DOEMVS -D_OE_SOCKETS -D_XOPEN_SOURCE_EXTENDED -D_ALL_SOURCE -DYYDYNAMIC -D_POSIX_SOURCE=1' + +# This overrides the name the compiler was called with. 'ext' is required for +# "unicode literals" to be enabled +def_os390_cflags='-qlanglvl=extc99'; + +def_os390_cflags="$def_os390_cflags -qlongname"; # khw thinks this is obsolete +def_os390_cflags="$def_os390_cflags -qfloat=ieee"; # khw thinks this is obsolete + +# xplink = eXtended Performance linking: "Uses a z/OS linkage specifically +# designed to increase performance." +def_os390_cflags="$def_os390_cflags -qxplink"; +def_os390_cccdlflags="-qxplink" +def_os390_ldflags="-qxplink" +os390_Wc="$os390_Wc,XPLINK" +os390_Wl="$os390_Wl,XPLINK" + +# Without this, you get "IEW2689W 4C40 DEFINITION SIDE FILE IS NOT DEFINED." +os390_Wl="$os390_Wl,dll" + +# Exports all externally defined functions and variables in the compilation +# unit so that a DLL application can use them." +def_os390_cflags="$def_os390_cflags -qexportall"; +def_os390_cccdlflags="$def_os390_cccdlflags -qexportall" +os390_Wc="$os390_Wc,EXPORTALL" + +# 3296= #include file not found; +# 4108= The use of keyword &1 is non-portable +# We care about this because it +# actually means it didn't do what we expected. e.g., +# INFORMATIONAL CCN4108 ./proto.h:4534 The use of keyword '__attribute__' is non-portable. +def_os390_cflags="$def_os390_cflags -qhaltonmsg=3296:4108" + +# Combinte the -W flags with the rest +def_os390_cflags="$def_os390_cflags $os390_Wc"; +def_os390_cflags="$def_os390_cflags $os390_Wl"; + +def_os390_cccdlflags="$def_os390_cccdlflags $os390_Wc"; +def_os390_cccdlflags="$def_os390_cccdlflags $os390_Wl"; + +def_os390_defs='-DMAXSIG=39'; # maximum signal number; not furnished by IBM +def_os390_defs="$def_os390_defs -DOEMVS"; # is used in place of #ifdef __MVS__ + +# Turn on POSIX compatibility modes +# https://www.ibm.com/support/knowledgecenter/SSLTBW_2.4.0/com.ibm.zos.v2r4.bpxbd00/ftms.htm +def_os390_defs="$def_os390_defs -D_ALL_SOURCE"; + +# defines a BSD-like socket interface for the function prototypes and structures involved +def_os390_defs="$def_os390_defs -D_OE_SOCKETS"; + +# ensure that the OS/390 yacc generated parser is reentrant. +def_os390_defs="$def_os390_defs -DYYDYNAMIC"; + +# LC_MESSAGES only affects the yes/no strings in langinfo; not the things we +# expect it to +def_os390_defs="$def_os390_defs -DNO_LOCALE_MESSAGES" + +# Combine -D with cflags case "$ccflags" in '') ccflags="$def_os390_cflags $def_os390_defs" ;; *) ccflags="$ccflags $def_os390_cflags $def_os390_defs" ;; esac -# Turning on optimization breaks perl. -# You can override this with Configure -Doptimize='-O' or somesuch. +# Turning on optimization causes perl to not even compile from miniperl. You +# can override this with Configure -Doptimize='-O2' or somesuch. case "$optimize" in '') optimize=' ' ;; esac @@ -49,7 +106,7 @@ esac # To link via definition side decks we need the dll option # You can override this with Configure -Ucccdlflags or somesuch. case "$cccdlflags" in -'') cccdlflags='-qxplink -qdll -qexportall -Wc,XPLINK,dll,EXPORTALL -Wl,XPLINK,dll' ;; +'') cccdlflags=$def_os390_cccdlflags;; esac case "$so" in @@ -71,12 +128,13 @@ case "$usenm" in '') usenm='false' ;; esac +case "$ldflags" in +'') ldflags="$def_os390_ldflags $os390_Wl";; +esac + # Setting ldflags='-Wl,EDIT=NO' will get rid of the symbol # information at the end of the executable (=> smaller binaries). # Override this option with -Dldflags='whatever else you wanted'. -case "$ldflags" in -'') ldflags='-qxplink -qdll -Wl,XPLINK,dll' ;; -esac case "$optimize" in *-g*) ;; *) ldflags="$ldflags -Wl,EDIT=NO" @@ -117,13 +175,30 @@ define) ;; esac libperl="libperl.$so" - ccflags="$ccflags -D_SHR_ENVIRON -DPERL_EXTERNAL_GLOB -qexportall -qdll -qxplink" - cccdlflags='-c -qexportall -qxplink -qdll -Wc,XPLINK,dll,EXPORTALL -Wl,XPLINK,dll' + + # Allows char **environ to be accessed from a dynamically loaded + # module such as a DLL + ccflags="$ccflags -D_SHR_ENVIRON" + + cccdlflags="-c $def_os390_cccdlflags" + lddlflags="$def_os390_cccdlflags" + # The following will need to be modified for the installed libperl.x. # The modification to Config.pm is done by the installperl script after the - # build and test. - ccdlflags="-qxplink -qdll -Wl,XPLINK,dll `pwd`/libperl.x" - lddlflags="-qxplink -qdll -Wl,XPLINK,dll `pwd`/libperl.x" + # build and test. These are written to a CBU so that the libperl.x file + # comes after all the dash-options in the flags. Configure takes the + # lddlflags we give it and looks for paths to libraries to append -L options + # to lddlflags. But this causes the file libperl.x to appear in the final + # command line after the -L options. And z/OS doesn't like filenames after + # options. This CBU defers the adding of libperl.x until after any munging + # that Configure does. + cat >config.arch <<' EOCBU' + case "ccdlflags" in + '') ccdlflags="`pwd`/libperl.x" ;; + *) ccdlflags="$ccdlflags `pwd`/libperl.x" ;; + esac + lddlflags="$lddlflags `pwd`/libperl.x" + EOCBU ;; esac @@ -132,7 +207,9 @@ case "$ldlibpthname" in '') ldlibpthname=LIBPATH ;; esac -# The following should always be used +# The following should always be used. Perhaps newer threads will work, but +# when khw tried, other things would have had to be changed to get it to work, +# so left as-is. d_oldpthreads='define' # Header files to include. @@ -146,9 +223,6 @@ esac case "$d_pthread_atfork" in '') d_pthread_atfork='undef' ;; esac -case "$d_pthread_atfork" in -'') d_pthread_atfork='undef' ;; -esac # (from aix.sh) # uname -m output is too specific and not appropriate here @@ -164,14 +238,17 @@ esac # can find the shmat() prototype in <sys/shm.h> and various # 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. +# +# khw believes some of this is obsolete. DOLLARINNAMES allows '$' in variable +# names, for whatever reason +# NOLOC says to use the 1047 code page, and no locale case "$usedl" in define) -echo 'cat >.$$.c; '"$cc"' -D_OE_SOCKETS -D_XOPEN_SOURCE_EXTENDED -D_ALL_SOURCE -D_SHR_ENVIRON -E -Wc,"LANGLVL(DOLLARINNAMES)",NOLOC ${1+"$@"} .$$.c | fgrep -v "??="; rm .$$.c' > cppstdin - ;; +echo 'cat >.$$.c; '"$cc"' -D_OE_SOCKETS -D_ALL_SOURCE -D_SHR_ENVIRON -E -Wc,"LANGLVL(DOLLARINNAMES)",NOLOC ${1+"$@"} .$$.c | fgrep -v "??="; rm .$$.c' > cppstdin + ;; *) -echo 'cat >.$$.c; '"$cc"' -D_OE_SOCKETS -D_XOPEN_SOURCE_EXTENDED -D_ALL_SOURCE -E -Wc,"LANGLVL(DOLLARINNAMES)",NOLOC ${1+"$@"} .$$.c | fgrep -v "??="; rm .$$.c' > cppstdin - ;; +echo 'cat >.$$.c; '"$cc"' -D_OE_SOCKETS -D_ALL_SOURCE -E -Wc,"LANGLVL(DOLLARINNAMES)",NOLOC ${1+"$@"} .$$.c | fgrep -v "??="; rm .$$.c' > cppstdin + ;; esac # @@ -221,47 +298,38 @@ EOWARN fi fi -# Most of the time gcvt() seems to work fine but -# sometimes values like 0.1, 0.2, come out as "10", "20", -# a trivial Perl demonstration snippet is 'print 0.1'. -# The -W 0,float(ieee) seems to be the switch breaking gcvt(). -# sprintf() seems to get things right(er). -gconvert_preference=sprintf - -# Configure gets these wrong for some reason. +# These exist, but there is something wrong with either them, or our reentr.[ch], +# and no one has felt it important enough to investigate/fix. The +# non-reentrant versions seem to work, but will have races in threads. d_gethostbyaddr_r='undef' d_gethostbyname_r='undef' d_gethostent_r='undef' -# The z/OS C compiler supports the attribute keyword, but in a -# limited manner. -# -# Ideally, Configure's tests should test the attributes as they are expected -# to be used in perl, and, ideally, those tests would fail on z/OS. -# Until then, just tell Configure to ignore the attributes. Currently, -# Configure thinks attributes are supported because it does not recognize -# warning messages like this: -# -# INFORMATIONAL CCN4108 ./proto.h:4534 The use of keyword '__attribute__' is non-portable. - -d_attribute_deprecated='undef' -d_attribute_format='undef' -d_attribute_malloc='undef' -d_attribute_nonnull='undef' -d_attribute_noreturn='undef' -d_attribute_pure='undef' -d_attribute_unused='undef' -d_attribute_warn_unused_result='undef' - -# nan() is in libm but doesn't work as expected: nan("") or nan("0") -# returns zero, not a nan: +# nan() used to not work as expected: nan("") or nan("0") returned zero, not a +# nan. This may have been a C89 issue. # http://www-01.ibm.com/support/knowledgecenter/SSLTBW_1.12.0/com.ibm.zos.r12.bpxbd00/nan.htm%23nan?lang=en -# contrast with e.g. -# http://www.cplusplus.com/reference/cmath/nan-function/ -# (C++ but C99 math agrees) -# XXX: Configure scan for proper behavior -d_nan='undef' +#d_nan='undef' # Configure says this exists, but it doesn't work properly. See # <54DCE073.4010100@khwilliamson.com> d_dir_dd_fd='undef' + +############################################################################ +# Thread support +# use Configure -Dusethreads to enable +# This script UU/usethreads.cbu will get 'called-back' by Configure +# after it has prompted the user for whether to use threads. +# setlocale() returns NULL if a thread has been created, so we can't use it +# generally. (It would be possible to have it work for initialization, so that +# the user could specify a locale for the whole program; but deferring doing +# that work until someone wants it) Maybe IBM will support POSIX 2008 at some +# point. There are hooks that make it look like they were working on it. +cat > UU/usethreads.cbu <<'EOCBU' +case "$usethreads" in +$define|true|[yY]*) + echo "Your system's setlocale() is broken under threads; marking it as unavailable" >&4 + d_setlocale="undef" + d_setlocale_accepts_any_locale_name="undef" + d_has_C_UTF8="false" +esac +EOCBU |