cobol, driver, libgcobol: Add support for libgcobol.spec.

Ads support for using a library spec file (e.g. to include the
target requirements for non-standard libraries - or even libm
which we can now configure at the target side).

gcc/cobol/ChangeLog:

	* gcobolspec.cc (SPEC_FILE): New.
	(lang_specific_driver): Make the 'need libgcobol' flag global
	so that the prelink callback can use it. Libm use is now handled
	via the library spec.
	(lang_specific_pre_link): Include libgcobol.spec where needed.

libgcobol/ChangeLog:

	* Makefile.am: Add libgcobol.spec and dependency.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Add libgcobol.spec handling.
	* libgcobol.spec.in: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
This commit is contained in:
Iain Sandoe 2025-03-15 22:47:47 +00:00
parent b90364ee1c
commit 63f7285e76
6 changed files with 77 additions and 48 deletions

View file

@ -57,10 +57,6 @@ along with GCC; see the file COPYING3. If not see
int lang_specific_extra_outfiles = 0;
#ifndef MATH_LIBRARY
#define MATH_LIBRARY "m"
#endif
#ifndef DL_LIBRARY
#define DL_LIBRARY "dl"
#endif
@ -73,12 +69,16 @@ int lang_specific_extra_outfiles = 0;
#define COBOL_LIBRARY "gcobol"
#endif
#define SPEC_FILE "libgcobol.spec"
/* The original argument list and related info is copied here. */
static const struct cl_decoded_option *original_options;
/* The new argument list will be built here. */
static std::vector<cl_decoded_option>new_opt;
static bool need_libgcobol = true;
// #define NOISY 1
static void
@ -195,8 +195,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
// These flags indicate whether we need various libraries
bool need_libgcobol = true;
bool need_libmath = (MATH_LIBRARY[0] != '\0');
bool need_libdl = (DL_LIBRARY[0] != '\0');
bool need_libstdc = (STDCPP_LIBRARY[0] != '\0');
// bool need_libquadmath = (QUADMATH_LIBRARY[0] != '\0');
@ -304,7 +302,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
// With this option, no libraries need be loaded
saw_OPT_c = true;
need_libgcobol = false;
need_libmath = false;
need_libdl = false;
need_libstdc = false;
// need_libquadmath = false;
@ -331,7 +328,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
case OPT_E:
// With these options, no libraries need be loaded
need_libgcobol = false;
need_libmath = false;
need_libdl = false;
need_libstdc = false;
// need_libquadmath = false;
@ -345,11 +341,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
case OPT_l:
n_infiles += 1;
if(strcmp(decoded_options[i].arg, MATH_LIBRARY) == 0)
{
need_libmath = false;
}
else if(strcmp(decoded_options[i].arg, DL_LIBRARY) == 0)
if(strcmp(decoded_options[i].arg, DL_LIBRARY) == 0)
{
need_libdl = false;
}
@ -455,7 +447,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
if( n_infiles == 0 )
{
need_libgcobol = false;
need_libmath = false;
need_libdl = false;
need_libstdc = false;
// need_libquadmath = false;
@ -588,11 +579,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
{
add_arg_lib(COBOL_LIBRARY, static_libgcobol);
}
if( need_libmath)
{
add_arg_lib(MATH_LIBRARY, static_in_general);
}
if( need_libdl )
if( need_libdl )
{
add_arg_lib(DL_LIBRARY, static_in_general);
}
@ -654,14 +641,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
*in_decoded_options = new_options;
}
/*
* Called before linking.
* Returns 0 on success and -1 on failure.
* Unused.
*/
/* Called before linking. Returns 0 on success and -1 on failure. */
int
lang_specific_pre_link( void )
{
return 0;
}
lang_specific_pre_link (void)
{
if (need_libgcobol)
do_spec ("%:include(libgcobol.spec)");
return 0;
}

View file

@ -28,6 +28,7 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
# Skip the whole process if we are not building libgcobol.
if BUILD_LIBGCOBOL
toolexeclib_LTLIBRARIES = libgcobol.la
toolexeclib_DATA = libgcobol.spec
##
## 2.2.12 Automatic Dependency Tracking
@ -64,5 +65,6 @@ version_arg = -version-info $(LIBGCOBOL_VERSION)
libgcobol_la_LDFLAGS = $(LTLDFLAGS) $(LTLIBICONV) \
$(extra_ldflags_libgcobol) $(LIBS) \
$(version_arg)
libgcobol_la_DEPENDENCIES = libgcobol.spec
endif BUILD_LIBGCOBOL

View file

@ -35,6 +35,7 @@
# Written de novo for libgcobol.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
@ -141,7 +142,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_FILES = libgcobol.spec
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
@ -170,7 +171,8 @@ am__uninstall_files_from_dir = { \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \
"$(DESTDIR)$(toolexeclibdir)"
LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
libgcobol_la_LIBADD =
@BUILD_LIBGCOBOL_TRUE@am_libgcobol_la_OBJECTS = charmaps.lo \
@ -223,6 +225,7 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
DATA = $(toolexeclib_DATA)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)config.h.in
# Read a list of newline-separated strings from the standard input,
@ -312,6 +315,7 @@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SPEC_LIBGCOBOL_DEPS = @SPEC_LIBGCOBOL_DEPS@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@ -386,6 +390,7 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
# Skip the whole process if we are not building libgcobol.
@BUILD_LIBGCOBOL_TRUE@toolexeclib_LTLIBRARIES = libgcobol.la
@BUILD_LIBGCOBOL_TRUE@toolexeclib_DATA = libgcobol.spec
@BUILD_LIBGCOBOL_TRUE@libgcobol_la_SOURCES = \
@BUILD_LIBGCOBOL_TRUE@ charmaps.cc \
@BUILD_LIBGCOBOL_TRUE@ constants.cc \
@ -409,6 +414,7 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
@BUILD_LIBGCOBOL_TRUE@ $(extra_ldflags_libgcobol) $(LIBS) \
@BUILD_LIBGCOBOL_TRUE@ $(version_arg)
@BUILD_LIBGCOBOL_TRUE@libgcobol_la_DEPENDENCIES = libgcobol.spec
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@ -462,6 +468,8 @@ $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
distclean-hdr:
-rm -f config.h stamp-h1
libgcobol.spec: $(top_builddir)/config.status $(srcdir)/libgcobol.spec.in
cd $(top_builddir) && $(SHELL) ./config.status $@
install-toolexeclibLTLIBRARIES: $(toolexeclib_LTLIBRARIES)
@$(NORMAL_INSTALL)
@ -545,6 +553,27 @@ clean-libtool:
distclean-libtool:
-rm -f libtool config.lt
install-toolexeclibDATA: $(toolexeclib_DATA)
@$(NORMAL_INSTALL)
@list='$(toolexeclib_DATA)'; test -n "$(toolexeclibdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(toolexeclibdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibdir)" || exit $$?; \
done
uninstall-toolexeclibDATA:
@$(NORMAL_UNINSTALL)
@list='$(toolexeclib_DATA)'; test -n "$(toolexeclibdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(toolexeclibdir)'; $(am__uninstall_files_from_dir)
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
@ -606,9 +635,9 @@ distclean-tags:
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) config.h
all-am: Makefile $(LTLIBRARIES) $(DATA) config.h
installdirs:
for dir in "$(DESTDIR)$(toolexeclibdir)"; do \
for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@ -671,7 +700,8 @@ install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-toolexeclibLTLIBRARIES
install-exec-am: install-toolexeclibDATA \
install-toolexeclibLTLIBRARIES
install-html: install-html-am
@ -713,7 +743,8 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-toolexeclibLTLIBRARIES
uninstall-am: uninstall-toolexeclibDATA \
uninstall-toolexeclibLTLIBRARIES
.MAKE: all install-am install-strip
@ -726,12 +757,13 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip \
install-ps install-ps-am install-strip install-toolexeclibDATA \
install-toolexeclibLTLIBRARIES installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am uninstall-toolexeclibLTLIBRARIES
uninstall-am uninstall-toolexeclibDATA \
uninstall-toolexeclibLTLIBRARIES
.PRECIOUS: Makefile

12
libgcobol/configure vendored
View file

@ -630,11 +630,11 @@ ac_includes_default="\
#endif"
ac_func_list=
ac_unique_file="Makefile.am"
ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
SPEC_LIBGCOBOL_DEPS
get_gcc_base_ver
extra_ldflags_libgcobol
LIBGCOBOL_VERSION
@ -16992,14 +16992,13 @@ fi
# Add dependencies for libgcobol.spec file
#SPEC_LIBGCOBOL_DEPS="$LIBS"
#AC_SUBST(SPEC_LIBGCOBOL_DEPS)
# Add dependencies for libgcobol.spec file, this might be excessive - since
# the spec file might not use all of them.
SPEC_LIBGCOBOL_DEPS="$LIBS"
ac_config_files="$ac_config_files Makefile"
ac_config_files="$ac_config_files Makefile libgcobol.spec"
####AC_CONFIG_FILES(libgcobol.spec)
{ $as_echo "$as_me:${as_lineno-$LINENO}: libgcobol has been configured." >&5
$as_echo "$as_me: libgcobol has been configured." >&6;}
@ -18124,6 +18123,7 @@ do
"depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"libgcobol.spec") CONFIG_FILES="$CONFIG_FILES libgcobol.spec" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac

View file

@ -203,13 +203,15 @@ fi
# Determine what GCC version number to use in filesystem paths.
GCC_BASE_VER
# Add dependencies for libgcobol.spec file
#SPEC_LIBGCOBOL_DEPS="$LIBS"
#AC_SUBST(SPEC_LIBGCOBOL_DEPS)
# Add dependencies for libgcobol.spec file, this might be excessive - since
# the spec file might not use all of them.
SPEC_LIBGCOBOL_DEPS="$LIBS"
AC_SUBST(SPEC_LIBGCOBOL_DEPS)
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_FILES([Makefile])
####AC_CONFIG_FILES(libgcobol.spec)
AC_CONFIG_FILES([
Makefile
libgcobol.spec
])
AC_MSG_NOTICE([libgcobol has been configured.])

View file

@ -0,0 +1,8 @@
#
# This spec file is read by gcobol when linking.
# It is used to specify the libraries we need to link in, in the right
# order.
#
%rename lib liborig
*lib: @LIBM@ %(liborig)