Hi!
The following patch adds new configure options similar to ObjC/Algol68
--with-bdw-gc{,-lib,-include}= configure options where one can override
the default of -I /usr/include/libxml2 and -lxml2 for finding libxml2
headers and library. Similarly to the bdw-gc options, the override can
be for all multilibs or just specific to each multilib.
Bootstrapped/regtested on x86_64-linux and i686-linux without any of the
new options on the configure line, and tested also with
../configure --enable-languages=c,c++,cobol --with-target-libxml2=/tmp/libxml2 \
--disable-bootstrap --disable-libsanitizer --disable-libgomp
Ok for trunk?
2026-02-14 Jakub Jelinek <[email protected]>
PR cobol/122839
* configure.ac (--with-target-libxml2, --with-target-libxml2-include,
--with-target-libxml2-lib): New configure options, use those to find
libxml2.
(LIBXML2_CPPFLAGS, LIBXML2_LIBS): New AC_SUBSTs.
* Makefile.am (AM_CPPFLAGS): Add $(LIBXML2_CPPFLAGS) rather than
-I /usr/include/libxml2.
(libgcobol_la_LDFLAGS): Add $(LIBXML2_LIBS).
* configure: Regenerate.
* config.h.in: Regenerate.
* Makefile.in: Regenerate.
* doc/install.texi (COBOL-Specific Options): New.
--- libgcobol/configure.ac.jj 2025-11-29 17:28:45.753139094 +0100
+++ libgcobol/configure.ac 2026-02-13 12:52:26.475053320 +0100
@@ -233,14 +233,102 @@ libgcobol_have_cacosf128=no
AC_SEARCH_LIBS([cacosf128], [c m], libgcobol_have_cacosf128=yes)
# These are libxml2.
-AC_CHECK_LIB(xml2, xmlSAXUserParseMemory,
- [LIBS="-lxml2 $LIBS"
- AC_DEFINE(HAVE_SAX_XML_PARSER, 1,
- [Define to 1 if you have the `xmlSAXUserParseMemory' function.])])
-AC_CHECK_LIB(xml2, xmlParseChunk,
- [LIBS="-lxml2 $LIBS"
- AC_DEFINE(HAVE_SAX_XML_PARSER, 1,
- [Define to 1 if you have the `xmlParseChunk' function.])])
+AC_ARG_WITH([target-libxml2],
+[AS_HELP_STRING([--with-target-libxml2=PATHLIST],
+ [specify prefix directory for installed libxml2 package.
+ Equivalent to --with-target-libxml2-include=PATH/include
+ plus --with-target-libxml2-lib=PATH/lib])])
+AC_ARG_WITH([target-libxml2-include],
+[AS_HELP_STRING([--with-target-libxml2-include=PATHLIST],
+ [specify directories for installed libxml2 include files])])
+AC_ARG_WITH([target-libxml2-lib],
+[AS_HELP_STRING([--with-target-libxml2-lib=PATHLIST],
+ [specify directories for installed libxml2 library])])
+
+if test "x$use_libgcobol" = xyes && test "x$libgcobol_cv_have_int128" = xyes;
then
+ AC_MSG_CHECKING([for libxml2])
+ if test
"x$with_target_libxml2$with_target_libxml2_include$with_target_libxml2_lib" =
x; then
+ dnl no libxml2 options, assuming libxml2 in default locations
+ LIBXML2_CPPFLAGS="-I /usr/include/libxml2"
+ LIBXML2_LIBS="-lxml2"
+ else
+ dnl libxml2 options passed by configure flags
+ if test "x$with_target_libxml2_include" = x && test
"x$with_target_libxml2_lib" != x; then
+ AC_MSG_ERROR([found --with-target-libxml2-lib but
--with-target-libxml2-include missing])
+ elif test "x$with_target_libxml2_include" != x && test
"x$with_target_libxml2_lib" = x; then
+ AC_MSG_ERROR([found --with-target-libxml2-include but
--with-target-libxml2-lib missing])
+ else
+ AC_MSG_RESULT([using paths configured with --with-target-libxml2
options])
+ fi
+ mldir=`${CC-gcc} --print-multi-directory 2>/dev/null`
+ libxml2_val=
+ if test "x$with_target_libxml2" != x; then
+ for i in `echo $with_target_libxml2 | tr ',' ' '`; do
+ case "$i" in
+ *=*) sd=${i%%=*}; d=${i#*=} ;;
+ *) sd=.; d=$i ;;
+ esac
+ if test "$mldir" = "$sd"; then
+ libxml2_val=$d
+ fi
+ done
+ if test "x$libxml2_val" = x; then
+ AC_MSG_ERROR([no multilib path ($mldir) found in
--with-target-libxml2])
+ fi
+ libxml2_inc_dir="$libxml2_val/include"
+ libxml2_lib_dir="$libxml2_val/lib"
+ fi
+ libxml2_val=
+ if test "x$with_target_libxml2_include" != x; then
+ for i in `echo $with_target_libxml2_include | tr ',' ' '`; do
+ case "$i" in
+ *=*) sd=${i%%=*}; d=${i#*=} ;;
+ *) sd=.; d=$i; fallback=$i ;;
+ esac
+ if test "$mldir" = "$sd"; then
+ libxml2_val=$d
+ fi
+ done
+ if test "x$libxml2_val" = x && test "x$libxml2_inc_dir" = x && test
"x$fallback" != x; then
+ libxml2_inc_dir="$fallback"
+ elif test "x$libxml2_val" = x; then
+ AC_MSG_ERROR([no multilib path ($mldir) found in
--with-target-libxml2-include])
+ else
+ libxml2_inc_dir="$libxml2_val"
+ fi
+ fi
+ libxml2_val=
+ if test "x$with_target_libxml2_lib" != x; then
+ for i in `echo $with_target_libxml2_lib | tr ',' ' '`; do
+ case "$i" in
+ *=*) sd=${i%%=*}; d=${i#*=} ;;
+ *) sd=.; d=$i ;;
+ esac
+ if test "$mldir" = "$sd"; then
+ libxml2_val=$d
+ fi
+ done
+ if test "x$libxml2_val" = x; then
+ AC_MSG_ERROR([no multilib path ($mldir) found in
--with-target-libxml2-lib])
+ fi
+ libxml2_lib_dir="$libxml2_val"
+ fi
+ if test "x$libxml2_inc_dir" = x; then
+ AC_MSG_ERROR([no multilib path ($mldir) found in
--with-target-libxml2-include])
+ fi
+ if test "x$libxml2_lib_dir" = x; then
+ AC_MSG_ERROR([no multilib path ($mldir) found in
--with-target-libxml2-lib])
+ fi
+ LIBXML2_CPPFLAGS="-I$libxml2_inc_dir"
+ LIBXML2_LIBS="-L$libxml2_lib_dir -lxml2"
+ AC_MSG_RESULT([found])
+ fi
+else
+ LIBXML2_CPPFLAGS=
+ LIBXML2_LIBS=
+fi
+AC_SUBST(LIBXML2_CPPFLAGS)
+AC_SUBST(LIBXML2_LIBS)
# Copied from gcc/configure.ac. 2025-06-05 R.J.Dubner
# At least for glibc, clock_gettime is in librt. But don't pull that
--- libgcobol/Makefile.am.jj 2026-02-13 10:32:21.503992411 +0100
+++ libgcobol/Makefile.am 2026-02-13 12:54:49.278640762 +0100
@@ -85,7 +85,7 @@ nobase_libsubinclude_HEADERS = \
WARN_CFLAGS = -W -Wall -Wwrite-strings
AM_CPPFLAGS = -I. -I posix/shim $(LIBQUADINCLUDE)
-AM_CPPFLAGS += -I /usr/include/libxml2
+AM_CPPFLAGS += $(LIBXML2_CPPFLAGS)
AM_CFLAGS = $(XCFLAGS)
AM_CXXFLAGS = $(XCFLAGS)
@@ -103,7 +103,7 @@ endif
libgcobol_la_LINK = $(CXXLINK) $(libgcobol_la_LDFLAGS)
version_arg = -version-info $(LIBGCOBOL_VERSION)
libgcobol_la_LDFLAGS = $(LTLDFLAGS) $(LIBQUADLIB) $(LTLIBICONV) \
- $(extra_ldflags_libgcobol) $(LIBS) $(version_arg)
+ $(extra_ldflags_libgcobol) $(LIBS) $(LIBXML2_LIBS) $(version_arg)
libgcobol_la_DEPENDENCIES = libgcobol.spec $(LIBQUADLIB_DEP)
endif BUILD_LIBGCOBOL
--- libgcobol/configure.jj 2025-12-29 13:59:51.122075881 +0100
+++ libgcobol/configure 2026-02-13 12:53:58.624496524 +0100
@@ -644,6 +644,8 @@ LIBQUADINCLUDE
LIBQUADLIB_DEP
LIBQUADLIB
LIBQUADSPEC
+LIBXML2_LIBS
+LIBXML2_CPPFLAGS
extra_ldflags_libgcobol
LIBGCOBOL_VERSION
BUILD_LIBGCOBOL_FALSE
@@ -803,6 +805,9 @@ with_toolexeclibdir
enable_rpath
with_libiconv_prefix
with_libiconv_type
+with_target_libxml2
+with_target_libxml2_include
+with_target_libxml2_lib
enable_libquadmath
with_gcc_major_version_only
'
@@ -1472,6 +1477,16 @@ Optional Packages:
--with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
--without-libiconv-prefix don't search for libiconv in includedir and
libdir
--with-libiconv-type=TYPE type of library to search for
(auto/static/shared)
+ --with-target-libxml2=PATHLIST
+ specify prefix directory for installed libxml2
+ package. Equivalent to
+ --with-target-libxml2-include=PATH/include plus
+ --with-target-libxml2-lib=PATH/lib
+ --with-target-libxml2-include=PATHLIST
+ specify directories for installed libxml2 include
+ files
+ --with-target-libxml2-lib=PATHLIST
+ specify directories for installed libxml2 library
--with-gcc-major-version-only
use only GCC major number in filesystem paths
@@ -12199,7 +12214,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12202 "configure"
+#line 12217 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12305,7 +12320,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12308 "configure"
+#line 12323 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -17666,99 +17681,111 @@ fi
# These are libxml2.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlSAXUserParseMemory in
-lxml2" >&5
-$as_echo_n "checking for xmlSAXUserParseMemory in -lxml2... " >&6; }
-if ${ac_cv_lib_xml2_xmlSAXUserParseMemory+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lxml2 $LIBS"
-if test x$gcc_no_link = xyes; then
- as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES."
"$LINENO" 5
-fi
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char xmlSAXUserParseMemory ();
-int
-main ()
-{
-return xmlSAXUserParseMemory ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
- ac_cv_lib_xml2_xmlSAXUserParseMemory=yes
-else
- ac_cv_lib_xml2_xmlSAXUserParseMemory=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+# Check whether --with-target-libxml2 was given.
+if test "${with_target_libxml2+set}" = set; then :
+ withval=$with_target_libxml2;
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result:
$ac_cv_lib_xml2_xmlSAXUserParseMemory" >&5
-$as_echo "$ac_cv_lib_xml2_xmlSAXUserParseMemory" >&6; }
-if test "x$ac_cv_lib_xml2_xmlSAXUserParseMemory" = xyes; then :
- LIBS="-lxml2 $LIBS"
-$as_echo "#define HAVE_SAX_XML_PARSER 1" >>confdefs.h
+# Check whether --with-target-libxml2-include was given.
+if test "${with_target_libxml2_include+set}" = set; then :
+ withval=$with_target_libxml2_include;
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlParseChunk in -lxml2"
>&5
-$as_echo_n "checking for xmlParseChunk in -lxml2... " >&6; }
-if ${ac_cv_lib_xml2_xmlParseChunk+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lxml2 $LIBS"
-if test x$gcc_no_link = xyes; then
- as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES."
"$LINENO" 5
-fi
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char xmlParseChunk ();
-int
-main ()
-{
-return xmlParseChunk ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
- ac_cv_lib_xml2_xmlParseChunk=yes
-else
- ac_cv_lib_xml2_xmlParseChunk=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+# Check whether --with-target-libxml2-lib was given.
+if test "${with_target_libxml2_lib+set}" = set; then :
+ withval=$with_target_libxml2_lib;
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result:
$ac_cv_lib_xml2_xmlParseChunk" >&5
-$as_echo "$ac_cv_lib_xml2_xmlParseChunk" >&6; }
-if test "x$ac_cv_lib_xml2_xmlParseChunk" = xyes; then :
- LIBS="-lxml2 $LIBS"
-$as_echo "#define HAVE_SAX_XML_PARSER 1" >>confdefs.h
+if test "x$use_libgcobol" = xyes && test "x$libgcobol_cv_have_int128" = xyes;
then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libxml2" >&5
+$as_echo_n "checking for libxml2... " >&6; }
+ if test
"x$with_target_libxml2$with_target_libxml2_include$with_target_libxml2_lib" =
x; then
+ LIBXML2_CPPFLAGS="-I /usr/include/libxml2"
+ LIBXML2_LIBS="-lxml2"
+ else
+ if test "x$with_target_libxml2_include" = x && test
"x$with_target_libxml2_lib" != x; then
+ as_fn_error $? "found --with-target-libxml2-lib but
--with-target-libxml2-include missing" "$LINENO" 5
+ elif test "x$with_target_libxml2_include" != x && test
"x$with_target_libxml2_lib" = x; then
+ as_fn_error $? "found --with-target-libxml2-include but
--with-target-libxml2-lib missing" "$LINENO" 5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: using paths configured
with --with-target-libxml2 options" >&5
+$as_echo "using paths configured with --with-target-libxml2 options" >&6; }
+ fi
+ mldir=`${CC-gcc} --print-multi-directory 2>/dev/null`
+ libxml2_val=
+ if test "x$with_target_libxml2" != x; then
+ for i in `echo $with_target_libxml2 | tr ',' ' '`; do
+ case "$i" in
+ *=*) sd=${i%%=*}; d=${i#*=} ;;
+ *) sd=.; d=$i ;;
+ esac
+ if test "$mldir" = "$sd"; then
+ libxml2_val=$d
+ fi
+ done
+ if test "x$libxml2_val" = x; then
+ as_fn_error $? "no multilib path ($mldir) found in
--with-target-libxml2" "$LINENO" 5
+ fi
+ libxml2_inc_dir="$libxml2_val/include"
+ libxml2_lib_dir="$libxml2_val/lib"
+ fi
+ libxml2_val=
+ if test "x$with_target_libxml2_include" != x; then
+ for i in `echo $with_target_libxml2_include | tr ',' ' '`; do
+ case "$i" in
+ *=*) sd=${i%%=*}; d=${i#*=} ;;
+ *) sd=.; d=$i; fallback=$i ;;
+ esac
+ if test "$mldir" = "$sd"; then
+ libxml2_val=$d
+ fi
+ done
+ if test "x$libxml2_val" = x && test "x$libxml2_inc_dir" = x && test
"x$fallback" != x; then
+ libxml2_inc_dir="$fallback"
+ elif test "x$libxml2_val" = x; then
+ as_fn_error $? "no multilib path ($mldir) found in
--with-target-libxml2-include" "$LINENO" 5
+ else
+ libxml2_inc_dir="$libxml2_val"
+ fi
+ fi
+ libxml2_val=
+ if test "x$with_target_libxml2_lib" != x; then
+ for i in `echo $with_target_libxml2_lib | tr ',' ' '`; do
+ case "$i" in
+ *=*) sd=${i%%=*}; d=${i#*=} ;;
+ *) sd=.; d=$i ;;
+ esac
+ if test "$mldir" = "$sd"; then
+ libxml2_val=$d
+ fi
+ done
+ if test "x$libxml2_val" = x; then
+ as_fn_error $? "no multilib path ($mldir) found in
--with-target-libxml2-lib" "$LINENO" 5
+ fi
+ libxml2_lib_dir="$libxml2_val"
+ fi
+ if test "x$libxml2_inc_dir" = x; then
+ as_fn_error $? "no multilib path ($mldir) found in
--with-target-libxml2-include" "$LINENO" 5
+ fi
+ if test "x$libxml2_lib_dir" = x; then
+ as_fn_error $? "no multilib path ($mldir) found in
--with-target-libxml2-lib" "$LINENO" 5
+ fi
+ LIBXML2_CPPFLAGS="-I$libxml2_inc_dir"
+ LIBXML2_LIBS="-L$libxml2_lib_dir -lxml2"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
+$as_echo "found" >&6; }
+ fi
+else
+ LIBXML2_CPPFLAGS=
+ LIBXML2_LIBS=
fi
+
# Copied from gcc/configure.ac. 2025-06-05 R.J.Dubner
# At least for glibc, clock_gettime is in librt. But don't pull that
# in if it still doesn't give us the function we want.
--- libgcobol/config.h.in.jj 2025-11-14 11:00:36.950839386 +0100
+++ libgcobol/config.h.in 2026-02-13 12:54:05.029908657 +0100
@@ -55,9 +55,6 @@
/* Define to 1 if you have the `random_r' function. */
#undef HAVE_RANDOM_R
-/* Define to 1 if you have the `xmlParseChunk' function. */
-#undef HAVE_SAX_XML_PARSER
-
/* Define to 1 if you have the `setstate_r' function. */
#undef HAVE_SETSTATE_R
--- libgcobol/Makefile.in.jj 2026-02-13 10:32:21.503992411 +0100
+++ libgcobol/Makefile.in 2026-02-13 12:54:56.534641774 +0100
@@ -312,6 +312,8 @@ LIBQUADLIB_DEP = @LIBQUADLIB_DEP@
LIBQUADSPEC = @LIBQUADSPEC@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
+LIBXML2_CPPFLAGS = @LIBXML2_CPPFLAGS@
+LIBXML2_LIBS = @LIBXML2_LIBS@
LIPO = @LIPO@
LLVM_CONFIG = @LLVM_CONFIG@
LN_S = @LN_S@
@@ -454,8 +456,7 @@ gcc_version := $(shell @get_gcc_base_ver
@BUILD_LIBGCOBOL_TRUE@WARN_CFLAGS = -W -Wall -Wwrite-strings
@BUILD_LIBGCOBOL_TRUE@AM_CPPFLAGS = -I. -I posix/shim \
-@BUILD_LIBGCOBOL_TRUE@ $(LIBQUADINCLUDE) -I \
-@BUILD_LIBGCOBOL_TRUE@ /usr/include/libxml2
+@BUILD_LIBGCOBOL_TRUE@ $(LIBQUADINCLUDE) $(LIBXML2_CPPFLAGS)
@BUILD_LIBGCOBOL_TRUE@AM_CFLAGS = $(XCFLAGS)
@BUILD_LIBGCOBOL_TRUE@AM_CXXFLAGS = $(XCFLAGS) $(WARN_CFLAGS) \
@BUILD_LIBGCOBOL_TRUE@ -DIN_TARGET_LIBS -fstrict-aliasing \
@@ -465,7 +466,7 @@ gcc_version := $(shell @get_gcc_base_ver
@BUILD_LIBGCOBOL_TRUE@libgcobol_la_LINK = $(CXXLINK) $(libgcobol_la_LDFLAGS)
@BUILD_LIBGCOBOL_TRUE@version_arg = -version-info $(LIBGCOBOL_VERSION)
@BUILD_LIBGCOBOL_TRUE@libgcobol_la_LDFLAGS = $(LTLDFLAGS) $(LIBQUADLIB)
$(LTLIBICONV) \
-@BUILD_LIBGCOBOL_TRUE@ $(extra_ldflags_libgcobol) $(LIBS) $(version_arg)
+@BUILD_LIBGCOBOL_TRUE@ $(extra_ldflags_libgcobol) $(LIBS) $(LIBXML2_LIBS)
$(version_arg)
@BUILD_LIBGCOBOL_TRUE@libgcobol_la_DEPENDENCIES = libgcobol.spec
$(LIBQUADLIB_DEP)
all: config.h
--- gcc/doc/install.texi.jj 2026-01-31 10:16:31.970164455 +0100
+++ gcc/doc/install.texi 2026-02-13 13:04:57.409374772 +0100
@@ -3063,6 +3063,31 @@ to be available for each multilib varian
@samp{zlib} is only used when the system installed library is not available.
@end table
+@subheading COBOL-Specific Options
+
+The following options apply to the build of the COBOL runtime library.
+
+@table @code
+@item --with-target-libxml2=@var{list}
+@itemx --with-target-libxml2-include=@var{list}
+@itemx --with-target-libxml2-lib=@var{list}
+Specify search directories for the libxml2 header files and
+libraries. @var{list} is a comma separated list of key value pairs of the
+form @samp{@var{multilibdir}=@var{path}}, where the default multilib key
+is named as @samp{.} (dot), or is omitted (e.g.@:
+@samp{--with-target-libxml2=/opt/libxml2,32=/opt-libxml2-32}).
+
+The options @option{--with-target-libxml2-include} and
+@option{--with-target-libxml2-lib} must always be specified together
+for each multilib variant and they take precedence over
+@option{--with-target-libxml2}. If @option{--with-target-libxml2-include}
+is missing values for a multilib, then the value for the default
+multilib is used (e.g.@:
@samp{--with-target-libxml2-include=/opt/libxml2/include}
+@samp{--with-target-libxml2-lib=/opt/libxml2/lib64,32=/opt-libxml2/lib32}).
+If none of these options are specified, the library is assumed in
+default locations.
+@end table
+
@html
<hr />
<p>
Jakub