diff --git a/configure b/configure index 2180bff9da436399c53317dc6b647cf0aa5d8e77..39c65a56eda3d5e24bb39dd733b469d331d5f421 100755 --- a/configure +++ b/configure @@ -3513,6 +3513,26 @@ $as_echo "yes" >&6; } fi fi +# Disable libgcobol on unsupported systems. +# For testing, you can override this with --enable-libgcobol. +if test -d ${srcdir}/libgcobol; then + if test x$enable_libgcobol = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgcobol support" >&5 +$as_echo_n "checking for libgcobol support... " >&6; } + if (srcdir=${srcdir}/libgcobol; \ + . ${srcdir}/configure.tgt; \ + test "$LIBGCOBOL_SUPPORTED" != "yes") + then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + noconfigdirs="$noconfigdirs target-libgcobol" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + fi + fi +fi + # Disable Fortran for some systems. case "${target}" in mmix-*-*) @@ -10214,6 +10234,36 @@ fi stage1_languages=`echo "$stage1_languages" | sed -e "s/^,//" -e "s/,$//"` new_enable_languages=`echo "$new_enable_languages" | sed -e "s/^,//" -e "s/,$//"` +# It's early days for COBOL, and it is known to compile on only some host and +# target systems. We remove COBOL from other builds with a warning. + +cobol_is_okay_host="no" +cobol_is_okay_target="no" + +case "${host}" in + x86_64-*-*) + cobol_is_okay_host="yes" + ;; + aarch64-*-*) + cobol_is_okay_host="yes" + ;; +esac +case "${target}" in + x86_64-*-*) + cobol_is_okay_target="yes" + ;; + aarch64-*-*) + cobol_is_okay_target="yes" + ;; +esac + +if test "$cobol_is_okay_host" = "no" || test "$cobol_is_okay_target" = "no"; then + if echo "${new_enable_languages}" | grep "cobol" >/dev/null 2>&1; then + echo "WARNING: cobol is not available on this host or target" + new_enable_languages=`echo "${new_enable_languages}" | sed s/,cobol//g` + fi +fi + if test "x$missing_languages" != x; then as_fn_error $? " The following requested languages could not be built: ${missing_languages} diff --git a/configure.ac b/configure.ac index 4182de3d65a6c4ff074199914137f569ce0405fd..f521fd410ec0651e220bf706885575af188a8776 100644 --- a/configure.ac +++ b/configure.ac @@ -2543,6 +2543,36 @@ directories, to avoid imposing the performance cost of missing_languages=`echo "$missing_languages" | sed -e "s/^,//" -e "s/,$//"` stage1_languages=`echo "$stage1_languages" | sed -e "s/^,//" -e "s/,$//"` new_enable_languages=`echo "$new_enable_languages" | sed -e "s/^,//" -e "s/,$//"` + +# It's early days for COBOL, and it is known to compile on only some host and +# target systems. We remove COBOL from other builds with a warning. + +cobol_is_okay_host="no" +cobol_is_okay_target="no" + +case "${host}" in + x86_64-*-*) + cobol_is_okay_host="yes" + ;; + aarch64-*-*) + cobol_is_okay_host="yes" + ;; +esac +case "${target}" in + x86_64-*-*) + cobol_is_okay_target="yes" + ;; + aarch64-*-*) + cobol_is_okay_target="yes" + ;; +esac + +if test "$cobol_is_okay_host" = "no" || test "$cobol_is_okay_target" = "no"; then + if echo "${new_enable_languages}" | grep "cobol" >/dev/null 2>&1; then + echo "WARNING: cobol is not available on this host or target" + new_enable_languages=`echo "${new_enable_languages}" | sed s/,cobol//g` + fi +fi if test "x$missing_languages" != x; then AC_MSG_ERROR([ diff --git a/gcc/cobol/ChangeLog b/gcc/cobol/ChangeLog index 95d7777dcdbfeafc9ce721d9ad0c8b6162aba83a..a9f47eb1113299bdb45f363110a1e98f17c58240 100644 --- a/gcc/cobol/ChangeLog +++ b/gcc/cobol/ChangeLog @@ -3,6 +3,11 @@ suppress 32-builds. * Eliminate -Wunused-result warning in libgcobol.cc compilation +2025-02-11 Robert Dubner <rdubner@symas.com> + * libgcobol quietly is not built for -m32 systems in a multi-lib build + * configure.ac allows COBOL only for x86_64 and aarch64 architectures. + Other systems get a warning and the COBOL language is suppressed. + 2025-01-28 Robert Dubner <rdubner@symas.com> * Remove TRACE1 statements from parser_enter_file and parser_leave_file; they are incompatible with COPY statements in the DATA DIVISION. diff --git a/gcc/cobol/gcobc b/gcc/cobol/gcobc index 9afd8fd93fefc380fa7cd9599a0d92eace33679b..74f54a4ef9f18e2d9dc1b522d24bf963d7166ca8 100755 --- a/gcc/cobol/gcobc +++ b/gcc/cobol/gcobc @@ -13,8 +13,8 @@ # # User-defined variables, and their defaults: # -# Variable Default Effect -# echo none If defined, echo the gcobol command +# Variable Default Effect +# echo none If defined, echo the gcobol command # gcobcx none Produce verbose messages # gcobol ./gcobol Name of the gcobol binary # GCOBCUDF PREFIX/share/cobol/udf/ Location of UDFs to be prepended to input @@ -22,7 +22,7 @@ # By default, this script includes all files in $GCOBCUDF. To defeat # that behavior, use GCOBCUDF=none. # -# A list of supported options is produced with "gcobc -HELP". +# A list of supported options is produced with "gcobc -HELP". # ## Maintainer note. In modifying this file, the following may make ## your life easier: @@ -46,20 +46,26 @@ then copydir="-I$COB_COPY_DIR" fi -udf_default="${0%/*}/../share/cobol/udf" +# TODO: this file likely needs to query gcobol for its shared path instead +udf_default="${0%/*}/../share/gcobol/udf" +if [ ! -d "$udfdir" ] +then + # the one above is the installed one from the packages this one was previously used + udf_default="${0%/*}/../share/cobol/udf" +fi udfdir="${GCOBCUDF:-$udf_default}" if [ -d "$udfdir" ] then for F in "$udfdir"/* do - if [ -f $F ] + if [ -f "$F" ] then includes="$includes -include $F " fi done else - if [ "$GCOBCUDF" -a "$GCOBCUDF" != "none" ] + if [ "${GCOBCUDF:-none}" != "none" ] then echo warning: no such directory: "'$GCOBCUDF'" fi @@ -92,16 +98,19 @@ no_warn() { :; } # silence is golden help() { cat<<EOF -$0 recognizes the following GnuCOBOL cobc output mode options: +$0 recognizes the following GnuCOBOL cobc output mode options: -b, -c, -m, -S, -x -$0 recognizes the following GnuCOBOL cobc compilation options: +$0 recognizes the following GnuCOBOL cobc compilation options: -C -d, --debug -E + -g + --coverage -ext -fec=exception-name, -fno-ec=exception-name - -fixed - -F, -free + -fformat + --fixed + -F, --free -fimplicit-init -h, --help -save-temps= @@ -110,10 +119,10 @@ $0 recognizes the following GnuCOBOL cobc compilation options: -std=mf Options that are the same in gcobol and cobc are passed through verbatim. Options that have no analog in gcobol produce a warning message. -To produce this message, use -HELP. +To produce this message, use -HELP. To see the constructed cobc command-line, use -echo. To override the default cobc, set the "cobc" environment variable. -By default, gcobc invokes the gcobol the same directory the gcobc resides. +By default, gcobc invokes the gcobol the same directory the gcobc resides. To override, set the gcobol environment variable. EOF } @@ -137,7 +146,7 @@ do pending_arg= continue fi - + case $opt in -A | -Q) warn "$opt" ;; @@ -147,7 +156,7 @@ do ;; --conf=*) warn "$opt" ;; - -C) error "$opt $incomparable" + -C) error "$opt $incomparable" ;; -d | --debug) opts="$opts -fcobol-exceptions=EC-ALL" warn "$opt implies -fstack-check:" @@ -165,7 +174,7 @@ do -ext) pending_arg=$opt ;; - -ext=*) opts="$opts $(echo $opt | sed 's/-ext=/-copyext ./')" + -ext=*) opts="$opts $(echo "$opt" | sed 's/-ext=/-copyext ./')" ;; # A.3 Compiler options @@ -337,28 +346,39 @@ do -fassign-disk-from=*) warn "$opt" ;; -fvsam-status=*) warn "$opt" ;; -fself-call-recursive=*) warn "$opt" ;; + + # TODO: create a temporary COBOL file with COBOL-WORDS directives + # and force-include it -fnot-reserved=*) warn "$opt" ;; -freserved=*) warn "$opt" ;; -fnot-register=*) warn "$opt" ;; -fregister=*) warn "$opt" ;; - -fixed) opts="$opts -ffixed-form" + -fformat=auto ) ;; # gcobol and gnucobol default + + -fixed | --fixed | -fformat=fixed | -fformat=variable | -fformat=xcard) + # note: variable + xcard are only _more similar_ to fixed than free, + # (with changing right-column to 250/255, which isn't supported in gcobol, yet) + opts="$opts -ffixed-form" ;; - -F | -free) opts="$opts -ffree-form" + + -F | -free | --free | -fformat=free | -fformat=* ) + # note: "all other formats" are only _more similar_ to free than fixed + opts="$opts -ffree-form" ;; - # -g + -h | --help) opts="$opts --help" ;; - + -HELP) help && exit ;; -i | --info) warn "$opt" ;; - + # -I -fimplicit-init) warn "$opt" ;; - -j | -job) warn "$opt" + -j | -job) warn "$opt" ;; -K) ignore_arg "$opt" ;; @@ -371,14 +391,14 @@ do -m) mode="-shared" ;; # -main - # -nomain + # -nomain # -o # -O0, -Ox -O | -O2 | -Os) warn "$opt" ;; -S) mode="$opt" ;; - -save-temps=*) opt="$(echo $opt | sed -E 's/^.+=//')" + -save-temps=*) opt="$(echo "$opt" | sed -E 's/^.+=//')" export GCOBOL_TEMPDIR="$opt" ;; -save-temps) export GCOBOL_TEMPDIR="${PWD:-$(pwd)}" @@ -387,7 +407,7 @@ do -std=mvs) opts="$opts -dialect ibm" ;; - -std=mf) opts="$opts -dialect mf" + -std=mf) opts="$opts -dialect mf" ;; -t | -T | -tlines=* | -P | -P=* | -X | --Xref) warn "$opt (no listing)" @@ -396,16 +416,19 @@ do ;; -v | --verbose) opts="$opts -V" ;; - -V | --version | --dumpversion) opts="$opts --version" + # note: we want -dumpversion to be passed to gcc + -V | --version | -version) opts="$opts --version" ;; - -w) opts="$opts $opt" - ;; + # pass through, strangely -Wall is not supported + -w | -W | -Wextra) opts="$opts $opt" + ;; -Wno-*) no_warn "$opt" ;; + -W*) ignore_arg "$opt" ;; - + -x) mode= ;; @@ -440,4 +463,3 @@ then fi exec $gcobol $mode $opts -