This patch enables building glibc-2.2.5 using TCC and GNU Make 4.x and Mes C Library. * Makefile: Do not assemble from stdin, use file indirection. * Makefile: Add new target: install-lib-all. * Makefile: Avoid building stub DOC. * [_LIBC_REENTRANT]: Add missing guarding. * [MES_BOOTSTRAP]: Disable some GCC extensions. * [MES_BOOTSTRAP]: Add missing GCC div/mod defines. Upstream status: Not presented upstream. diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/config.h.in glibc-2.2.5/config.h.in --- ../glibc-2.2.5/config.h.in 2001-11-16 02:02:56.000000000 +0100 +++ glibc-2.2.5/config.h.in 2018-06-17 21:30:02.313029074 +0200 @@ -1,3 +1,10 @@ +#if MES_BOOTSTRAP && BOOTSTRAP_GLIBC +#undef __umoddi3 +#define __umoddi3(a,b) ((a)%(b)) +#undef __udivdi3 +#define __udivdi3(a,b) ((a)/(b)) +#endif + #if !defined ASSEMBLER && !defined _ISOMAC && !defined __OPTIMIZE__ # error "glibc cannot be compiled without optimization" #endif diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/configure glibc-2.2.5/configure --- ../glibc-2.2.5/configure 2002-01-08 23:16:44.000000000 +0100 +++ glibc-2.2.5/configure 2018-06-07 20:47:26.608895319 +0200 @@ -1530,7 +1530,7 @@ echo "configure:1530: checking version o ac_prog_version=`$MAKE --version 2>&1 | sed -n 's/^.*GNU Make[^0-9]*\([0-9][0-9.]*\).*$/\1/p'` case $ac_prog_version in '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; - 3.79* | 3.[89]*) + 3.79* | 3.[89]* | 4.*) ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/Makeconfig glibc-2.2.5/Makeconfig --- ../glibc-2.2.5/Makeconfig 2001-09-12 20:49:45.000000000 +0200 +++ glibc-2.2.5/Makeconfig 2018-06-20 16:33:35.472167202 +0200 @@ -400,7 +400,7 @@ ifndef +link $(start-installed-name))\ $(+preinit) $(link-extra-libs) \ $(common-objpfx)libc% $(+postinit),$^) \ - $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit) + $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit) -lc -lgcc2 endif # Command for statically linking programs with the C library. ifndef +link-static @@ -412,7 +412,7 @@ ifndef +link-static $(start-installed-name))\ $(+preinit) $(link-extra-libs-static) \ $(common-objpfx)libc% $(+postinit),$^) \ - $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit) + $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit) -lc -lgcc2 endif # Command for statically linking bounded-pointer programs with the C library. ifndef +link-bounded @@ -424,7 +424,7 @@ ifndef +link-bounded $(start-installed-name))\ $(+preinit) $(link-extra-libs-bounded) \ $(common-objpfx)libc% $(+postinit),$^) \ - $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit) + $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit) -lc -lgcc2 endif ifndef config-LDFLAGS ifeq (yesyes,$(build-shared)$(elf)) diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/Makerules glibc-2.2.5/Makerules --- ../glibc-2.2.5/Makerules 2001-11-16 02:02:19.000000000 +0100 +++ glibc-2.2.5/Makerules 2018-06-10 15:03:42.390329860 +0200 @@ -748,6 +748,18 @@ endef installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\ $(inst_libdir)/$(patsubst %,$(libtype$o),\ $(libprefix)$(libc-name))) + +ifeq (yes,$(build-shared)) +install-lib-all: $(inst_libdir)/libc.a \ + $(inst_slibdir)/libc.so$(libc.so-version) \ + $(inst_slibdir)/libc-$(version).so \ + $(inst_libdir)/libc.so \ + install-lib +else +install-lib-all: $(inst_libdir)/libc.a \ + install-lib +endif + install: $(installed-libcs) $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force) $(make-target-directory) diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/misc/syslog.c glibc-2.2.5/misc/syslog.c --- ../glibc-2.2.5/misc/syslog.c 2001-08-31 01:13:49.000000000 +0200 +++ glibc-2.2.5/misc/syslog.c 2018-06-09 09:01:20.008918690 +0200 @@ -216,9 +216,11 @@ vsyslog(pri, fmt, ap) /* Prepare for multiple users. We have to take care: open and write are cancellation points. */ +#if _LIBC_REENTRANT __libc_cleanup_region_start (1, (void (*) (void *)) cancel_handler, &oldaction_ptr); __libc_lock_lock (syslog_lock); +#endif /* Prepare for a broken connection. */ memset (&action, 0, sizeof (action)); @@ -268,9 +270,11 @@ vsyslog(pri, fmt, ap) if (sigpipe == 0) __sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL); +#if _LIBC_REENTRANT /* End of critical section. */ __libc_cleanup_region_end (0); __libc_lock_unlock (syslog_lock); +#endif free (buf); } @@ -326,16 +330,20 @@ openlog_internal(const char *ident, int void openlog (const char *ident, int logstat, int logfac) { +#if _LIBC_REENTRANT /* Protect against multiple users. */ __libc_cleanup_region_start (1, (void (*) __P ((void *))) __libc_mutex_unlock, &syslog_lock); __libc_lock_lock (syslog_lock); +#endif openlog_internal (ident, logstat, logfac); +#if _LIBC_REENTRANT /* Free the lock. */ __libc_cleanup_region_end (1); +#endif } static void @@ -358,18 +366,22 @@ closelog_internal() void closelog () { +#if _LIBC_REENTRANT /* Protect against multiple users. */ __libc_cleanup_region_start (1, (void (*) __P ((void *))) __libc_mutex_unlock, &syslog_lock); __libc_lock_lock (syslog_lock); +#endif closelog_internal (); LogTag = NULL; LogType = SOCK_DGRAM; /* this is the default */ +#if _LIBC_REENTRANT /* Free the lock. */ __libc_cleanup_region_end (1); +#endif } #ifdef _LIBC_REENTRANT diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/Rules glibc-2.2.5/Rules --- ../glibc-2.2.5/Rules 2001-08-30 00:44:35.000000000 +0200 +++ glibc-2.2.5/Rules 2018-06-09 08:15:54.880683675 +0200 @@ -218,7 +218,7 @@ endif fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \ filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \ iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \ - fopen_max=$${fopen_max:-16}; \ + fopen_max=$${fu_fopen_max:-16}; \ filename_max=$${filename_max:-1024}; \ if [ -z $$iov_max ]; then \ define_iov_max="# undef IOV_MAX"; \ diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/stdio-common/perror.c glibc-2.2.5/stdio-common/perror.c --- ../glibc-2.2.5/stdio-common/perror.c 20