PATCH: Do not use glob on MinGW hosts
Mark Mitchell
mark@codesourcery.com
Wed Feb 16 12:03:00 GMT 2005
When building a MinGW-hosted Linux-targeted compiler, we get a
compilation failure in the linker. The problem is that the linker
wants to use "glob" to handle "#include" directives in /etc/ld.so.conf
(appropriately adjusted for sysroot, of course) -- but Windows does
not have this routine.
This patch avoids the use of glob -- by assuming the the included file
is just a literal pathname rather than a glob pattern. As #include's
in ld.so.conf are rare, and glob-pattern includes are rarer, this
seems like a satisfactory solution.
(Ideally, we'd have a version of "glob" in libiberty, but we don't.
And, providing one is a bit complicated int that we really want to
match the GLIBC semantics for "glob", whereas on Windows it might make
sense to use FindFirstFile/FindNextFile, which are somewhat
different.)
OK to apply?
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2005-02-15 Mark Mitchell <mark@codesourcery.com>
* configure.in (AC_CHECK_FUNCS): Add glob.
* configure: Regenerated.
* emultempl/elf32.em (<glob.h>): Do not include if HAVE_GLOB is
not defined.
(gld${EMULATION_NAME}_parse_ld_so_conf_include): Do not use glob
if HAVE_GLOB is not defined.
Index: ld/configure.in
===================================================================
RCS file: /cvs/src/src/ld/configure.in,v
retrieving revision 1.25
diff -c -5 -p -r1.25 configure.in
*** ld/configure.in 12 Jan 2005 22:12:24 -0000 1.25
--- ld/configure.in 16 Feb 2005 06:12:25 -0000
*************** AC_SUBST(HDEFINES)
*** 117,127 ****
AC_SUBST(HOSTING_CRT0)
AC_SUBST(HOSTING_LIBS)
AC_SUBST(NATIVE_LIB_DIRS)
AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h)
! AC_CHECK_FUNCS(sbrk realpath)
AC_HEADER_DIRENT
BFD_BINARY_FOPEN
BFD_NEED_DECLARATION(strstr)
--- 117,127 ----
AC_SUBST(HOSTING_CRT0)
AC_SUBST(HOSTING_LIBS)
AC_SUBST(NATIVE_LIB_DIRS)
AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h)
! AC_CHECK_FUNCS(sbrk realpath glob)
AC_HEADER_DIRENT
BFD_BINARY_FOPEN
BFD_NEED_DECLARATION(strstr)
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.128
diff -c -5 -p -r1.128 elf32.em
*** ld/emultempl/elf32.em 11 Feb 2005 23:52:03 -0000 1.128
--- ld/emultempl/elf32.em 16 Feb 2005 06:12:25 -0000
*************** EOF
*** 65,75 ****
--- 65,77 ----
if [ "x${USE_LIBPATH}" = xyes ] ; then
case ${target} in
*-*-linux-gnu*)
cat >>e${EMULATION_NAME}.c <<EOF
+ #ifdef HAVE_GLOB
#include <glob.h>
+ #endif
EOF
;;
esac
fi
*************** static void
*** 537,547 ****
--- 539,551 ----
gld${EMULATION_NAME}_parse_ld_so_conf_include
(struct gld${EMULATION_NAME}_ld_so_conf *info, const char *filename,
const char *pattern)
{
char *newp = NULL;
+ #ifdef HAVE_GLOB
glob_t gl;
+ #endif
if (pattern[0] != '/')
{
char *p = strrchr (filename, '/');
size_t patlen = strlen (pattern) + 1;
*************** gld${EMULATION_NAME}_parse_ld_so_conf_in
*** 550,567 ****
--- 554,576 ----
memcpy (newp, filename, p - filename + 1);
memcpy (newp + (p - filename + 1), pattern, patlen);
pattern = newp;
}
+ #ifdef HAVE_GLOB
if (glob (pattern, 0, NULL, &gl) == 0)
{
size_t i;
for (i = 0; i < gl.gl_pathc; ++i)
gld${EMULATION_NAME}_parse_ld_so_conf (info, gl.gl_pathv[i]);
globfree (&gl);
}
+ #else
+ /* If we do not have glob, treat the pattern as a literal filename. */
+ gld${EMULATION_NAME}_parse_ld_so_conf (info, pattern);
+ #endif
if (newp)
free (newp);
}
More information about the Binutils
mailing list