diff --git a/README.md b/README.md index fbc3a4a..327f1a8 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ If you require compatibility with distributions that use `i586`, you can either: * 2020-02-07: setenv script is now installed to `$PREFIX/bin/$TARGET-setenv`. * 2019-06-06: `master` is now the default branch again. -### Current package versions, as of 2024-05-30: +### Current package versions, as of 2024-06-22: -* gcc 12.2.0 +* gcc 14.1.0 * binutils 2.42 * gdb 14.2 * djgpp 2.05 / cvs diff --git a/build-djgpp.sh b/build-djgpp.sh index 0ca92d0..1f1132a 100755 --- a/build-djgpp.sh +++ b/build-djgpp.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +DJCROSS_METHOD=djcross DJGPP_DOWNLOAD_BASE="http://www.mirrorservice.org/sites/ftp.delorie.com/pub" PACKAGE_SOURCES="djgpp binutils common" source script/init.sh @@ -139,77 +140,76 @@ fi cd ${BASE}/build/ if [ ! -z ${GCC_VERSION} ]; then - # build gcc - untar ${DJCROSS_GCC_ARCHIVE} || exit 1 - cd djcross-gcc-${GCC_VERSION}/ - - BUILDDIR=`pwd` - export PATH="${BUILDDIR}/tmpinst/bin:$PATH" + TMPINST="${BASE}/build/tmpinst" + export PATH="${TMPINST}/bin:$PATH" - if [ ! -e ${BUILDDIR}/tmpinst/autoconf-${AUTOCONF_VERSION}-built ]; then + if [ ! -e ${TMPINST}/autoconf-version ] || [ "$(cat ${TMPINST}/autoconf-version)" != "${AUTOCONF_VERSION}" ]; then echo "Building autoconf" - cd $BUILDDIR + cd ${BASE}/build/ || exit 1 untar ${AUTOCONF_ARCHIVE} || exit 1 cd autoconf-${AUTOCONF_VERSION}/ - ./configure --prefix=$BUILDDIR/tmpinst || exit 1 + ./configure --prefix=${TMPINST} || exit 1 ${MAKE_J} DESTDIR= all install || exit 1 - rm ${BUILDDIR}/tmpinst/autoconf-*-built - touch ${BUILDDIR}/tmpinst/autoconf-${AUTOCONF_VERSION}-built + echo ${AUTOCONF_VERSION} > ${TMPINST}/autoconf-version else echo "autoconf already built, skipping." fi - if [ ! -e ${BUILDDIR}/tmpinst/automake-${AUTOMAKE_VERSION}-built ]; then + if [ ! -e ${TMPINST}/automake-version ] || [ "$(cat ${TMPINST}/automake-version)" != "${AUTOMAKE_VERSION}" ]; then echo "Building automake" - cd $BUILDDIR + cd ${BASE}/build/ || exit 1 untar ${AUTOMAKE_ARCHIVE} || exit 1 cd automake-${AUTOMAKE_VERSION}/ - ./configure --prefix=$BUILDDIR/tmpinst || exit 1 + ./configure --prefix=${TMPINST} || exit 1 ${MAKE} DESTDIR= all install || exit 1 - rm ${BUILDDIR}/tmpinst/automake-*-built - touch ${BUILDDIR}/tmpinst/automake-${AUTOMAKE_VERSION}-built + echo ${AUTOMAKE_VERSION} > ${TMPINST}/automake-version else echo "automake already built, skipping." fi - cd $BUILDDIR - - if [ ! -e gcc-unpacked ]; then - rm -rf $BUILDDIR/gnu/ + cd ${BASE}/build/ - if [ `uname` = "FreeBSD" ]; then - # The --verbose option is not recognized by BSD patch - sed -i 's/patch --verbose/patch/' unpack-gcc.sh || exit 1 - fi - - case ${GCC_VERSION} in - 4.7.3) UNPACK_PATCH=patch-unpack-gcc-4.7.3.txt ;; - 4.8.0) ;& - 4.8.1) ;& - 4.8.2) UNPACK_PATCH=patch-unpack-gcc-4.8.0.txt ;; - *) UNPACK_PATCH=patch-unpack-gcc.txt ;; - esac + # build gcc + BUILDDIR="${BASE}/build/djcross-gcc-${GCC_VERSION}" + mkdir -p ${BUILDDIR} - patch -p1 -u < ${BASE}/patch/${UNPACK_PATCH} || exit 1 + if [ ! -e ${BUILDDIR}/gcc-unpacked ]; then + rm -rf ${BUILDDIR}/gnu/ echo "Unpacking gcc..." - mkdir gnu/ - cd gnu/ || exit 1 + mkdir -p ${BUILDDIR}/gnu/ + cd ${BUILDDIR}/gnu/ || exit 1 untar ${GCC_ARCHIVE} cd .. - echo "Running unpack-gcc.sh" - sh unpack-gcc.sh --no-djgpp-source || exit 1 + if [ "${DJCROSS_METHOD}" = 'djcross' ]; then + ( cd ${BASE}/build/ && untar ${DJCROSS_GCC_ARCHIVE} ) || exit 1 + + if [ `uname` = "FreeBSD" ]; then + # The --verbose option is not recognized by BSD patch + sed -i 's/patch --verbose/patch/' unpack-gcc.sh || exit 1 + fi + + case ${GCC_VERSION} in + 4.7.3) UNPACK_PATCH=patch-unpack-gcc-4.7.3.txt ;; + 4.8.0) ;& + 4.8.1) ;& + 4.8.2) UNPACK_PATCH=patch-unpack-gcc-4.8.0.txt ;; + *) UNPACK_PATCH=patch-unpack-gcc.txt ;; + esac + + patch -p1 -u < ${BASE}/patch/${UNPACK_PATCH} || exit 1 + + echo "Running unpack-gcc.sh" + sh unpack-gcc.sh --no-djgpp-source || exit 1 + fi # patch gnu/gcc-X.XX/gcc/doc/gcc.texi echo "Patch gcc/doc/gcc.texi" cd gnu/gcc-*/gcc/doc || exit 1 sed -i "s/[^^]@\(\(tex\)\|\(end\)\)/\n@\1/g" gcc.texi || exit 1 - cd - - - cd $BUILDDIR/ - pushd gnu/gcc-${GCC_VERSION} || exit 1 + cd ${BUILDDIR}/gnu/gcc-${GCC_VERSION} || exit 1 if [ ! -z ${BUILD_DEB} ]; then echo "Unpacking gcc dependencies" @@ -226,17 +226,16 @@ if [ ! -z ${GCC_VERSION} ]; then # apply extra patches if necessary cat ${BASE}/patch/djgpp-gcc-${GCC_VERSION}/* | patch -p1 -u || exit 1 - popd - touch gcc-unpacked + touch ${BUILDDIR}/gcc-unpacked else echo "gcc already unpacked, skipping." fi echo "Building gcc (stage 1)" - mkdir -p djcross - cd djcross || exit 1 + mkdir -p ${BUILDDIR}/djcross + cd ${BUILDDIR}/djcross || exit 1 TEMP_CFLAGS="$CFLAGS" TEMP_CXXFLAGS="$CXXFLAGS" @@ -256,7 +255,7 @@ if [ ! -z ${GCC_VERSION} ]; then sleep 5 fi - cp ${DST}/bin/${TARGET}-stubify ${BUILDDIR}/tmpinst/bin/stubify || exit 1 + cp ${DST}/bin/${TARGET}-stubify ${TMPINST}/bin/stubify || exit 1 ${MAKE_J} all-gcc || exit 1 echo "Installing gcc (stage 1)" @@ -326,7 +325,7 @@ if [ ! -z ${GCC_VERSION} ]; then echo "Installing gcc (stage 2)" ${SUDO} ${MAKE_J} install-strip || \ ${SUDO} ${MAKE_J} install-strip || exit 1 - ${SUDO} ${MAKE_J} -C mpfr install DESTDIR=${BASE}/build/tmpinst + ${SUDO} ${MAKE_J} -C mpfr install DESTDIR=${TMPINST} CFLAGS="$TEMP_CFLAGS" CXXFLAGS="$TEMP_CXXFLAGS" diff --git a/common/gcc b/common/gcc index 5fcb86e..6561122 100644 --- a/common/gcc +++ b/common/gcc @@ -1 +1 @@ -source common/gcc-12.2.0 +source common/gcc-14.1.0 diff --git a/common/gcc-13.1.0 b/common/gcc-13.1.0 new file mode 100644 index 0000000..bebd885 --- /dev/null +++ b/common/gcc-13.1.0 @@ -0,0 +1,14 @@ +GCC_VERSION=13.1.0 +GCC_VERSION_SHORT=13.10 +AUTOCONF_VERSION=2.69 +AUTOMAKE_VERSION=1.15.1 + +GCC_ARCHIVE="http://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz" +AUTOCONF_ARCHIVE="http://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.xz" +AUTOMAKE_ARCHIVE="http://ftp.gnu.org/gnu/automake/automake-${AUTOMAKE_VERSION}.tar.xz" + +GCC_CONFIGURE_OPTIONS="--disable-plugin \ + --enable-lto \ + ${GCC_CONFIGURE_OPTIONS}" + +DJCROSS_METHOD=patch diff --git a/common/gcc-13.2.0 b/common/gcc-13.2.0 new file mode 100644 index 0000000..533b50c --- /dev/null +++ b/common/gcc-13.2.0 @@ -0,0 +1,14 @@ +GCC_VERSION=13.2.0 +GCC_VERSION_SHORT=13.20 +AUTOCONF_VERSION=2.69 +AUTOMAKE_VERSION=1.15.1 + +GCC_ARCHIVE="http://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz" +AUTOCONF_ARCHIVE="http://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.xz" +AUTOMAKE_ARCHIVE="http://ftp.gnu.org/gnu/automake/automake-${AUTOMAKE_VERSION}.tar.xz" + +GCC_CONFIGURE_OPTIONS="--disable-plugin \ + --enable-lto \ + ${GCC_CONFIGURE_OPTIONS}" + +DJCROSS_METHOD=patch diff --git a/common/gcc-14.1.0 b/common/gcc-14.1.0 new file mode 100644 index 0000000..53ec7ea --- /dev/null +++ b/common/gcc-14.1.0 @@ -0,0 +1,14 @@ +GCC_VERSION=14.1.0 +GCC_VERSION_SHORT=14.10 +AUTOCONF_VERSION=2.69 +AUTOMAKE_VERSION=1.15.1 + +GCC_ARCHIVE="http://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz" +AUTOCONF_ARCHIVE="http://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.xz" +AUTOMAKE_ARCHIVE="http://ftp.gnu.org/gnu/automake/automake-${AUTOMAKE_VERSION}.tar.xz" + +GCC_CONFIGURE_OPTIONS="--disable-plugin \ + --enable-lto \ + ${GCC_CONFIGURE_OPTIONS}" + +DJCROSS_METHOD=patch diff --git a/debian/changelog b/debian/changelog index 0ca17b2..96d38ae 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,9 @@ djgpp-toolchain (12) UNRELEASED; urgency=medium * Set 'Architecture: all' for library packages. * binutils version 2.42. + * gcc version 14.1.0. - -- jwt27 Thu, 30 May 2024 19:31:25 +0200 + -- jwt27 Sat, 22 Jun 2024 19:31:21 +0200 djgpp-toolchain (11) unstable; urgency=medium diff --git a/djgpp/gcc b/djgpp/gcc deleted file mode 100644 index 8a63372..0000000 --- a/djgpp/gcc +++ /dev/null @@ -1 +0,0 @@ -source common/gcc diff --git a/patch/djgpp-gcc-13.1.0/0000-djcross.patch b/patch/djgpp-gcc-13.1.0/0000-djcross.patch new file mode 100644 index 0000000..b3d421a --- /dev/null +++ b/patch/djgpp-gcc-13.1.0/0000-djcross.patch @@ -0,0 +1,977 @@ +diff --git a/Makefile.in b/Makefile.in +index 06a9398e172..c5f04e56422 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -1472,7 +1472,6 @@ dvi-host: maybe-dvi-itcl + dvi-host: maybe-dvi-ld + dvi-host: maybe-dvi-libbacktrace + dvi-host: maybe-dvi-libcpp +-dvi-host: maybe-dvi-libcody + dvi-host: maybe-dvi-libdecnumber + dvi-host: maybe-dvi-libgui + dvi-host: maybe-dvi-libiberty +@@ -1562,7 +1561,6 @@ pdf-host: maybe-pdf-itcl + pdf-host: maybe-pdf-ld + pdf-host: maybe-pdf-libbacktrace + pdf-host: maybe-pdf-libcpp +-pdf-host: maybe-pdf-libcody + pdf-host: maybe-pdf-libdecnumber + pdf-host: maybe-pdf-libgui + pdf-host: maybe-pdf-libiberty +@@ -1652,7 +1650,6 @@ html-host: maybe-html-itcl + html-host: maybe-html-ld + html-host: maybe-html-libbacktrace + html-host: maybe-html-libcpp +-html-host: maybe-html-libcody + html-host: maybe-html-libdecnumber + html-host: maybe-html-libgui + html-host: maybe-html-libiberty +@@ -1742,7 +1739,6 @@ TAGS-host: maybe-TAGS-itcl + TAGS-host: maybe-TAGS-ld + TAGS-host: maybe-TAGS-libbacktrace + TAGS-host: maybe-TAGS-libcpp +-TAGS-host: maybe-TAGS-libcody + TAGS-host: maybe-TAGS-libdecnumber + TAGS-host: maybe-TAGS-libgui + TAGS-host: maybe-TAGS-libiberty +@@ -1832,7 +1828,6 @@ install-info-host: maybe-install-info-itcl + install-info-host: maybe-install-info-ld + install-info-host: maybe-install-info-libbacktrace + install-info-host: maybe-install-info-libcpp +-install-info-host: maybe-install-info-libcody + install-info-host: maybe-install-info-libdecnumber + install-info-host: maybe-install-info-libgui + install-info-host: maybe-install-info-libiberty +@@ -2012,7 +2007,6 @@ install-pdf-host: maybe-install-pdf-itcl + install-pdf-host: maybe-install-pdf-ld + install-pdf-host: maybe-install-pdf-libbacktrace + install-pdf-host: maybe-install-pdf-libcpp +-install-pdf-host: maybe-install-pdf-libcody + install-pdf-host: maybe-install-pdf-libdecnumber + install-pdf-host: maybe-install-pdf-libgui + install-pdf-host: maybe-install-pdf-libiberty +@@ -2102,7 +2096,6 @@ install-html-host: maybe-install-html-itcl + install-html-host: maybe-install-html-ld + install-html-host: maybe-install-html-libbacktrace + install-html-host: maybe-install-html-libcpp +-install-html-host: maybe-install-html-libcody + install-html-host: maybe-install-html-libdecnumber + install-html-host: maybe-install-html-libgui + install-html-host: maybe-install-html-libiberty +diff --git a/c++tools/resolver.cc b/c++tools/resolver.cc +index d1f009cab64..ce1e29da817 100644 +--- a/c++tools/resolver.cc ++++ b/c++tools/resolver.cc +@@ -33,13 +33,13 @@ along with GCC; see the file COPYING3. If not see + #define MAPPED_READING 0 + #else + #ifdef IN_GCC +-#if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0 ++#if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0 && !defined(__DJGPP__) + #define MAPPED_READING 1 + #else + #define MAPPED_READING 0 + #endif + #else +-#ifdef HAVE_SYS_MMAN_H ++#if defined(HAVE_SYS_MMAN_H) && !defined(__DJGPP__) + #include + #define MAPPED_READING 1 + #else +diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c +index 8522094164e..d850d27a3dc 100644 +--- a/gcc/ada/adaint.c ++++ b/gcc/ada/adaint.c +@@ -295,6 +295,12 @@ char __gnat_dir_separator = DIR_SEPARATOR; + + char __gnat_path_separator = PATH_SEPARATOR; + ++#ifdef __DJGPP__ ++int __gnat_is_djgpp = 1; ++#else ++int __gnat_is_djgpp = 0; ++#endif ++ + /* The GNAT_LIBRARY_TEMPLATE contains a list of expressions that define + the base filenames that libraries specified with -lsomelib options + may have. This is used by GNATMAKE to check whether an executable +@@ -589,7 +595,11 @@ __gnat_try_lock (char *dir, char *file) + int + __gnat_get_maximum_file_name_length (void) + { ++#if defined (__DJGPP__) ++ return (_use_lfn(".")) ? -1 : 8; ++#else + return -1; ++#endif + } + + /* Return nonzero if file names are case sensitive. */ +diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in +index 9507f2f0920..f6ca2911534 100644 +--- a/gcc/ada/gcc-interface/Make-lang.in ++++ b/gcc/ada/gcc-interface/Make-lang.in +@@ -1166,7 +1166,7 @@ ada/generated/gnatvsn.ads: ada/gnatvsn.ads BASE-VER ada/GNAT_DATE + s=`cat $(srcdir)/BASE-VER | sed -e "s/\([0-9]*\)\.\([0-9]*\)\..*/-\1\2/g"`; \ + d=`if test -f $(srcdir)/ada/GNAT_DATE; then \ + cat $(srcdir)/ada/GNAT_DATE; else date +%Y%m%d; fi`; \ +- cat $< | sed -e "/Version/s/(\([0-9]\{8\}\).*)/($$d$$s)/g" >$@ ++ cat $< | sed -e "/Version/s/(\([0-9]\{8\}\).*)/($$d$$s)/g" | tr -d \\\015 >$@ + + ada/gnatvsn.o : ada/gnatvsn.adb ada/generated/gnatvsn.ads + $(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(ADA_OUTPUT_OPTION) +diff --git a/gcc/ada/libgnarl/s-taprop__dummy.adb b/gcc/ada/libgnarl/s-taprop__dummy.adb +index ced2a0c6f3c..34af507e275 100644 +--- a/gcc/ada/libgnarl/s-taprop__dummy.adb ++++ b/gcc/ada/libgnarl/s-taprop__dummy.adb +@@ -37,7 +37,7 @@ + package body System.Task_Primitives.Operations is + + use System.Tasking; +- use System.Parameters; ++-- use System.Parameters; + + pragma Warnings (Off); + -- Turn off warnings since so many unreferenced parameters +diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb +index 2647b981b18..0d31b3f1b39 100644 +--- a/gcc/ada/libgnat/s-os_lib.adb ++++ b/gcc/ada/libgnat/s-os_lib.adb +@@ -73,7 +73,7 @@ package body System.OS_Lib is + + -- The following are used by Create_Temp_File + +- First_Temp_File_Name : constant String := "GNAT-TEMP-000000.TMP"; ++ First_Temp_File_Name : constant String := "GA000000.TMP"; + -- Used to initialize Current_Temp_File_Name and Temp_File_Name_Last_Digit + + Current_Temp_File_Name : String := First_Temp_File_Name; +@@ -2275,9 +2275,10 @@ package body System.OS_Lib is + -- * Check the drive letter + -- * Remove all double-quotes + +- if On_Windows then ++ if On_Windows ++ and then Is_Djgpp = 0 ++ then + -- Replace all '/' by '\' +- + for Index in 1 .. End_Path loop + if Path_Buffer (Index) = '/' then + Path_Buffer (Index) := Directory_Separator; +diff --git a/gcc/ada/libgnat/s-os_lib.ads b/gcc/ada/libgnat/s-os_lib.ads +index 9be09b39bf6..340fe0b9e42 100644 +--- a/gcc/ada/libgnat/s-os_lib.ads ++++ b/gcc/ada/libgnat/s-os_lib.ads +@@ -1100,9 +1100,12 @@ package System.OS_Lib is + Path_Separator : constant Character; + -- The character to separate paths in an environment variable value + ++ Is_Djgpp : constant Integer; ++ + private + pragma Import (C, Path_Separator, "__gnat_path_separator"); + pragma Import (C, Directory_Separator, "__gnat_dir_separator"); ++ pragma Import (C, Is_Djgpp, "__gnat_is_djgpp"); + pragma Import (C, Current_Time, "__gnat_current_time"); + pragma Import (C, Current_Process_Id, "__gnat_current_process_id"); + +diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c +index 5480e55a5bb..010f8204aad 100644 +--- a/gcc/ada/s-oscons-tmplt.c ++++ b/gcc/ada/s-oscons-tmplt.c +@@ -121,7 +121,7 @@ pragma Style_Checks ("M32766"); + **/ + + # include +-#elif !defined(__MINGW32__) ++#elif !defined(__MINGW32__) && !defined(__DJGPP__) + #include + #endif + +diff --git a/gcc/collect2.cc b/gcc/collect2.cc +index 63b9a0c233a..795bd01ca3b 100644 +--- a/gcc/collect2.cc ++++ b/gcc/collect2.cc +@@ -1159,18 +1159,27 @@ main (int argc, char **argv) + *ld1++ = *ld2++ = ld_file_name; + + /* Make temp file names. */ ++ ++#ifdef __DJGPP__ ++#define CDTOR_C_NAME ".ctc" ++#define CDTOR_O_NAME ".cto" ++#else ++#define CDTOR_C_NAME ".cdtor.c" ++#define CDTOR_O_NAME ".cdtor.o" ++#endif ++ + if (save_temps) + { +- c_file = concat (output_file, ".cdtor.c", NULL); +- o_file = concat (output_file, ".cdtor.o", NULL); ++ c_file = concat (output_file, CDTOR_C_NAME, NULL); ++ o_file = concat (output_file, CDTOR_O_NAME, NULL); + #ifdef COLLECT_EXPORT_LIST + export_file = concat (output_file, ".x", NULL); + #endif + } + else + { +- c_file = make_temp_file (".cdtor.c"); +- o_file = make_temp_file (".cdtor.o"); ++ c_file = make_temp_file (CDTOR_C_NAME); ++ o_file = make_temp_file (CDTOR_O_NAME); + #ifdef COLLECT_EXPORT_LIST + export_file = make_temp_file (".x"); + #endif +diff --git a/gcc/config/i386/djgpp.cc b/gcc/config/i386/djgpp.cc +index 0b83451fda5..897079e6c68 100644 +--- a/gcc/config/i386/djgpp.cc ++++ b/gcc/config/i386/djgpp.cc +@@ -36,6 +36,8 @@ i386_djgpp_asm_named_section(const char *name, unsigned int flags, + *f++ = 'w'; + if (flags & SECTION_CODE) + *f++ = 'x'; ++ if (flags & SECTION_BSS) ++ *f++ = 'b'; + + /* LTO sections need 1-byte alignment to avoid confusing the + zlib decompression algorithm with trailing zero pad bytes. */ +diff --git a/gcc/config/i386/xm-djgpp.h b/gcc/config/i386/xm-djgpp.h +index de2c1795dbc..4063ba28632 100644 +--- a/gcc/config/i386/xm-djgpp.h ++++ b/gcc/config/i386/xm-djgpp.h +@@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see + #undef NATIVE_SYSTEM_HEADER_DIR + #define NATIVE_SYSTEM_HEADER_DIR "/dev/env/DJDIR/include/" + ++//#undef PREFIX_INCLUDE_DIR ++ + /* Search for as.exe and ld.exe in DJGPP's binary directory. */ + #undef MD_EXEC_PREFIX + #define MD_EXEC_PREFIX "/dev/env/DJDIR/bin/" +@@ -107,6 +109,11 @@ along with GCC; see the file COPYING3. If not see + (PATH) = xstrdup (fixed_path); \ + } + ++/* Rename libstdc++ to libstdcxx as the first name is not valid for DOS */ ++#define LIBSTDCXX "stdcxx" ++#define LIBSTDCXX_PROFILE "stdcxx" ++#define LIBSTDCXX_STATIC "stdcxx" ++ + #undef MAX_OFILE_ALIGNMENT + #define MAX_OFILE_ALIGNMENT 128 + +diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc +index 39e80df2d25..641849f1c01 100644 +--- a/gcc/cp/mapper-client.cc ++++ b/gcc/cp/mapper-client.cc +@@ -19,7 +19,7 @@ along with GCC; see the file COPYING3. If not see + . */ + + #include "config.h" +-#if defined (__unix__) ++#if defined (__unix__) && !defined(__DJGPP__) + // Solaris11's socket header used bcopy, which we poison. cody.hh + // will include it later under the above check + #include +diff --git a/gcc/diagnostic-show-locus.cc b/gcc/diagnostic-show-locus.cc +index 0514815b51f..6b5285b5330 100644 +--- a/gcc/diagnostic-show-locus.cc ++++ b/gcc/diagnostic-show-locus.cc +@@ -5721,7 +5721,9 @@ diagnostic_show_locus_cc_tests () + for_each_line_table_case (test_fixit_replace_containing_newline); + for_each_line_table_case (test_fixit_deletion_affecting_newline); + for_each_line_table_case (test_tab_expansion); ++#ifndef __DJGPP__ + for_each_line_table_case (test_escaping_bytes_1); ++#endif + for_each_line_table_case (test_escaping_bytes_2); + + test_line_numbers_multiline_range (); +diff --git a/gcc/gcov-tool.cc b/gcc/gcov-tool.cc +index 76173fdaef7..6fd0066ef20 100644 +--- a/gcc/gcov-tool.cc ++++ b/gcc/gcov-tool.cc +@@ -58,11 +58,18 @@ static bool verbose; + + /* Remove file NAME if it has a gcda suffix. */ + ++#ifdef __DJGPP__ ++static int ++unlink_gcda_file (const char *name, ++ struct stat *status ATTRIBUTE_UNUSED, ++ int type ATTRIBUTE_UNUSED) ++#else + static int + unlink_gcda_file (const char *name, + const struct stat *status ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, + struct FTW *ftwbuf ATTRIBUTE_UNUSED) ++#endif + { + int ret = 0; + int len = strlen (name); +@@ -84,7 +91,11 @@ static int + unlink_profile_dir (const char *path ATTRIBUTE_UNUSED) + { + #if HAVE_FTW_H ++#ifdef __DJGPP__ ++ return ftw(path, unlink_gcda_file, 64); ++#else + return nftw(path, unlink_gcda_file, 64, FTW_DEPTH | FTW_PHYS); ++#endif + #else + return -1; + #endif +diff --git a/gcc/ggc-common.cc b/gcc/ggc-common.cc +index db317f49993..8d1de076010 100644 +--- a/gcc/ggc-common.cc ++++ b/gcc/ggc-common.cc +@@ -31,6 +31,12 @@ along with GCC; see the file COPYING3. If not see + #include "plugin.h" + #include "options.h" + ++#ifdef __DJGPP__ ++extern "C" { ++#include ++} ++#endif ++ + /* When true, protect the contents of the identifier hash table. */ + bool ggc_protect_identifiers = true; + +diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h +index 45021e48b8f..1f7f051e54b 100644 +--- a/gcc/ginclude/float.h ++++ b/gcc/ginclude/float.h +@@ -25,6 +25,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + * ISO C Standard: 5.2.4.2.2 Characteristics of floating types + */ + ++#ifdef __DJGPP__ ++#include_next ++#endif ++ + #ifndef _FLOAT_H___ + #define _FLOAT_H___ + +diff --git a/include/libiberty.h b/include/libiberty.h +index 1d5c779fcff..787507dfe93 100644 +--- a/include/libiberty.h ++++ b/include/libiberty.h +@@ -108,6 +108,7 @@ extern int countargv (char * const *); + #if defined (__GNU_LIBRARY__ ) || defined (__linux__) \ + || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) \ + || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) \ ++ || defined (__DJGPP__) \ + || defined (__DragonFly__) || defined (HAVE_DECL_BASENAME) + extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1); + #else +diff --git a/libcody/cody.hh b/libcody/cody.hh +index 789ce9e70b7..8794e4dd8e6 100644 +--- a/libcody/cody.hh ++++ b/libcody/cody.hh +@@ -20,6 +20,12 @@ + #endif + #endif + ++// Do not use networking for DJGPP even if it defines __unix__ ++#ifdef __DJGPP__ ++#undef CODY_NETWORKING ++#define CODY_NETWORKING 0 ++#endif ++ + // C++ + #include + #include +diff --git a/libcpp/files.cc b/libcpp/files.cc +index 3f8a8106ec8..343965d84bd 100644 +--- a/libcpp/files.cc ++++ b/libcpp/files.cc +@@ -747,6 +747,10 @@ read_file_guts (cpp_reader *pfile, _cpp_file *file, location_t loc, + cpp_error_at (pfile, CPP_DL_WARNING, loc, + "%s is shorter than expected", file->path); + ++/* For DOS we should handle DOS EOF character (0x1A, ^Z). It is ++ only done if it is really the last character of the file */ ++ if (total>0 && buf[total-1]==0x1A) total--; ++ + file->buffer = _cpp_convert_input (pfile, + input_charset, + buf, size + 16, total, +diff --git a/libcpp/lex.cc b/libcpp/lex.cc +index 45ea16a91bc..b0e7a219d10 100644 +--- a/libcpp/lex.cc ++++ b/libcpp/lex.cc +@@ -505,6 +505,13 @@ init_vectorized_lexer (void) + search_line_fast_type impl = search_line_acc_char; + int minimum = 0; + ++// [FIXME][DJGPP] Using SSE here causes preprocessor to randomly ++// [FIXME][DJGPP] fail when run under Windows 10 32 bit (and maybe ++// [FIXME][DJGPP] some other systems (I have observed similar ++// [FIXME][DJGPP] behavior earlier with DJGPP v2.03p2 under Windows ++// [FIXME][DJGPP] Vista ++#ifndef __DJGPP__ ++ + #if defined(__SSE4_2__) + minimum = 3; + #elif defined(__SSE2__) +@@ -531,6 +538,8 @@ init_vectorized_lexer (void) + impl = search_line_mmx; + } + ++#endif // __DJGPP__ ++ + search_line_fast = impl; + } + +diff --git a/libffi/src/x86/sysv.S b/libffi/src/x86/sysv.S +index c7a0fb51b48..5c724e24d8b 100644 +--- a/libffi/src/x86/sysv.S ++++ b/libffi/src/x86/sysv.S +@@ -968,7 +968,7 @@ ENDF(C(__x86.get_pc_thunk.dx)) + #ifdef __APPLE__ + .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support + EHFrame0: +-#elif defined(X86_WIN32) ++#elif defined(X86_WIN32) || defined(__DJGPP__) + .section .eh_frame,"r" + #elif defined(HAVE_AS_X86_64_UNWIND_SECTION_TYPE) + .section .eh_frame,EH_FRAME_FLAGS,@unwind +diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c +index d547c103cab..d939b1e1cbb 100644 +--- a/libgcc/libgcov-util.c ++++ b/libgcc/libgcov-util.c +@@ -381,7 +381,11 @@ read_gcda_file (const char *filename) + + static int + ftw_read_file (const char *filename, ++#ifdef __DJGPP__ ++ struct stat *status ATTRIBUTE_UNUSED, ++#else + const struct stat *status ATTRIBUTE_UNUSED, ++#endif + int type) + { + size_t filename_len; +diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h +index 92df440d401..7df201fe40a 100644 +--- a/libgcc/libgcov.h ++++ b/libgcc/libgcov.h +@@ -163,6 +163,11 @@ extern struct gcov_info *gcov_list; + + #endif /* !IN_GCOV_TOOL */ + ++#ifdef __DJGPP__ ++#include ++#undef HAVE_SYS_MMAN_H ++#endif // __DJGPP__ ++ + #if defined(inhibit_libc) + #define IN_LIBGCOV (-1) + #else +diff --git a/libgfortran/intrinsics/chmod.c b/libgfortran/intrinsics/chmod.c +index 850c2ccebbf..ee17e421c29 100644 +--- a/libgfortran/intrinsics/chmod.c ++++ b/libgfortran/intrinsics/chmod.c +@@ -445,7 +445,7 @@ clause_done: + if ((ugo[2] || honor_umask) && !rwxXstugo[8]) + file_mode = (file_mode & ~(S_IROTH | S_IWOTH | S_IXOTH)) + | (new_mode & (S_IROTH | S_IWOTH | S_IXOTH)); +-#ifndef __VXWORKS__ ++#if !defined(__VXWORKS__) && !defined(__DJGPP__) + if (is_dir && rwxXstugo[5]) + file_mode |= S_ISVTX; + else if (!is_dir) +@@ -457,7 +457,7 @@ clause_done: + { + /* Clear '-'. */ + file_mode &= ~new_mode; +-#if !defined( __MINGW32__) && !defined (__VXWORKS__) ++#if !defined( __MINGW32__) && !defined (__VXWORKS__) && !defined(__DJGPP__) + if (rwxXstugo[5] || !is_dir) + file_mode &= ~S_ISVTX; + #endif +@@ -465,7 +465,7 @@ clause_done: + else if (set_mode == 3) + { + file_mode |= new_mode; +-#if !defined (__MINGW32__) && !defined (__VXWORKS__) ++#if !defined (__MINGW32__) && !defined (__VXWORKS__) && !defined(__DJGPP__) + if (rwxXstugo[5] && is_dir) + file_mode |= S_ISVTX; + else if (!is_dir) +diff --git a/libgfortran/intrinsics/execute_command_line.c b/libgfortran/intrinsics/execute_command_line.c +index c2bcaf05f0b..889bd637f18 100644 +--- a/libgfortran/intrinsics/execute_command_line.c ++++ b/libgfortran/intrinsics/execute_command_line.c +@@ -98,7 +98,7 @@ execute_command_line (const char *command, bool wait, int *exitstat, + + set_cmdstat (cmdstat, EXEC_NOERROR); + +-#if defined(HAVE_SIGACTION) && defined(HAVE_WAITPID) ++#if defined(HAVE_SIGACTION) && defined(HAVE_WAITPID) && !defined(__DJGPP__) + static bool sig_init_saved; + bool sig_init = __atomic_load_n (&sig_init_saved, __ATOMIC_RELAXED); + if (!sig_init) +diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c +index ba12be08252..7ac07f3f4a8 100644 +--- a/libgfortran/io/unix.c ++++ b/libgfortran/io/unix.c +@@ -221,6 +221,9 @@ typedef struct + } + unix_stream; + ++#ifdef __DJGPP__ ++#include ++#endif + + /* fix_fd()-- Given a file descriptor, make sure it is not one of the + standard descriptors, returning a non-standard descriptor. If the +@@ -1222,8 +1225,13 @@ tempfile_open (const char *tempdir, char **fname) + char *template = xmalloc (tempdirlen + 23); + + #ifdef HAVE_MKSTEMP ++#ifdef __DJGPP__ ++ /* Default filename is too long for DOS */ ++ snprintf (template, tempdirlen + 23, "%s/gfXXXXXX", tempdir); ++#else + snprintf (template, tempdirlen + 23, "%s%sgfortrantmpXXXXXX", + tempdir, slash); ++#endif + + #ifdef HAVE_UMASK + /* Temporarily set the umask such that the file has 0600 permissions. */ +@@ -1589,6 +1597,13 @@ open_external (st_parameter_open *opp, unit_flags *flags) + return NULL; + fd = fix_fd (fd); + ++#ifdef __DJGPP__ ++ if (flags->form == FORM_UNFORMATTED) ++ { ++ setmode (fd, O_BINARY); ++ } ++#endif ++ + if (open_share (opp, fd, flags) < 0) + return NULL; + +diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c +index 1b970e7a773..0eb30c02a60 100644 +--- a/libiberty/make-relative-prefix.c ++++ b/libiberty/make-relative-prefix.c +@@ -65,6 +65,7 @@ relative prefix can be found, return @code{NULL}. + + #include "ansidecl.h" + #include "libiberty.h" ++#include "filenames.h" + + #ifndef R_OK + #define R_OK 4 +@@ -340,7 +341,7 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix, + { + for (i = 0; i < bin_num; i++) + { +- if (strcmp (prog_dirs[i], bin_dirs[i]) != 0) ++ if (FILENAME_CMP (prog_dirs[i], bin_dirs[i]) != 0) + break; + } + +@@ -356,7 +357,7 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix, + n = (prefix_num < bin_num) ? prefix_num : bin_num; + for (common = 0; common < n; common++) + { +- if (strcmp (bin_dirs[common], prefix_dirs[common]) != 0) ++ if (FILENAME_CMP (bin_dirs[common], prefix_dirs[common]) != 0) + break; + } + +diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c +index 1d2f21d6c5c..885d29c9c72 100644 +--- a/libiberty/make-temp-file.c ++++ b/libiberty/make-temp-file.c +@@ -52,6 +52,7 @@ Boston, MA 02110-1301, USA. */ + #endif + + #include "libiberty.h" ++#include "filenames.h" + extern int mkstemps (char *, int); + + /* '/' works just fine on MS-DOS based systems. */ +@@ -154,7 +155,8 @@ choose_tmpdir (void) + len = strlen (base); + tmpdir = XNEWVEC (char, len + 2); + strcpy (tmpdir, base); +- tmpdir[len] = DIR_SEPARATOR; ++ if (len>0 && !IS_DIR_SEPARATOR(tmpdir[len-1])) ++ tmpdir[len] = DIR_SEPARATOR; + tmpdir[len+1] = '\0'; + memoized_tmpdir = tmpdir; + #else /* defined(_WIN32) && !defined(__CYGWIN__) */ +diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c +index eee07039984..2997ae21655 100644 +--- a/libiberty/simple-object-elf.c ++++ b/libiberty/simple-object-elf.c +@@ -1293,7 +1293,9 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj, + } + if (new_i - 1 >= SHN_LORESERVE) + { ++#ifdef ENOTSUP + *err = ENOTSUP; ++#endif + return "Too many copied sections"; + } + eow->shdrs = XNEWVEC (unsigned char, shdr_size * (new_i - 1)); +diff --git a/libquadmath/printf/quadmath-printf.h b/libquadmath/printf/quadmath-printf.h +index 32ebcec928c..96498b7c408 100644 +--- a/libquadmath/printf/quadmath-printf.h ++++ b/libquadmath/printf/quadmath-printf.h +@@ -29,7 +29,8 @@ Boston, MA 02110-1301, USA. */ + #ifdef HAVE_CTYPE_H + #include + #endif +-#ifdef HAVE_WCHAR_H ++#if defined(HAVE_WCHAR_H) && !defined(__DJGPP__) ++/* DJGPP wchar.h is not good enough */ + #include + #endif + #ifdef HAVE_WCTYPE_H +@@ -44,7 +45,7 @@ Boston, MA 02110-1301, USA. */ + #include "quadmath-imp.h" + #include "gmp-impl.h" + +-#ifdef HAVE_WCHAR_H ++#if defined(HAVE_WCHAR_H) && !defined(__DJGPP__) + #define L_(x) L##x + #else + #define L_(x) x +diff --git a/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc b/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc +index 55cbcaf92c4..f3603555909 100644 +--- a/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc ++++ b/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc +@@ -45,7 +45,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), +- _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), ++ _M_toupper(__dj_ctype_toupper+1), _M_tolower(__dj_ctype_tolower+1), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); +@@ -56,7 +56,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + + ctype::ctype(const mask* __table, bool __del, size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), +- _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), ++ _M_toupper(__dj_ctype_toupper+1), _M_tolower(__dj_ctype_tolower+1), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); +diff --git a/libstdc++-v3/config/os/djgpp/error_constants.h b/libstdc++-v3/config/os/djgpp/error_constants.h +index 834f2e04b43..f2ae54a6c76 100644 +--- a/libstdc++-v3/config/os/djgpp/error_constants.h ++++ b/libstdc++-v3/config/os/djgpp/error_constants.h +@@ -33,16 +33,42 @@ + #include + #include + ++// Include Watt-32 errno list, if present ++#if defined __has_include && __has_include() ++#include ++#endif ++ ++#ifndef EOPNOTSUPP ++// Use same value as in wat3222br6.zip file net/watt/sys/djgpp.err ++#define EOPNOTSUPP 52 ++#endif ++ ++#ifndef ENOTSUP ++#define ENOTSUP 101 ++#endif ++ + namespace std _GLIBCXX_VISIBILITY(default) + { + _GLIBCXX_BEGIN_NAMESPACE_VERSION + + enum class errc + { +-// address_family_not_supported = EAFNOSUPPORT, +-// address_in_use = EADDRINUSE, +-// address_not_available = EADDRNOTAVAIL, +-// already_connected = EISCONN, ++#ifdef EAFNOSUPPORT ++ address_family_not_supported = EAFNOSUPPORT, ++#endif ++ ++#ifdef EADDRINUSE ++ address_in_use = EADDRINUSE, ++#endif ++ ++#ifdef EADDRNOTAVAIL ++ address_not_available = EADDRNOTAVAIL, ++#endif ++ ++#ifdef EISCONN ++ already_connected = EISCONN, ++#endif ++ + argument_list_too_long = E2BIG, + argument_out_of_domain = EDOM, + bad_address = EFAULT, +@@ -53,12 +79,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + #endif + + broken_pipe = EPIPE, +-// connection_aborted = ECONNABORTED, +-// connection_already_in_progress = EALREADY, +-// connection_refused = ECONNREFUSED, +-// connection_reset = ECONNRESET, ++ ++#ifdef ECONNABORTED ++ connection_aborted = ECONNABORTED, ++#endif ++ ++#ifdef EALREADY ++ connection_already_in_progress = EALREADY, ++#endif ++ ++#ifdef ECONNREFUSED ++ connection_refused = ECONNREFUSED, ++#endif ++ ++#ifdef ECONNRESET ++ connection_reset = ECONNRESET, ++#endif ++ + cross_device_link = EXDEV, +-// destination_address_required = EDESTADDRREQ, ++ ++#ifdef EDESTADDRREQ ++ destination_address_required = EDESTADDRREQ, ++#endif ++ + device_or_resource_busy = EBUSY, + directory_not_empty = ENOTEMPTY, + executable_format_error = ENOEXEC, +@@ -66,7 +109,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + file_too_large = EFBIG, + filename_too_long = ENAMETOOLONG, + function_not_supported = ENOSYS, +-// host_unreachable = EHOSTUNREACH, ++ ++#ifdef EHOSTUNREACH ++ host_unreachable = EHOSTUNREACH, ++#endif + + #ifdef EIDRM + identifier_removed = EIDRM, +@@ -79,11 +125,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + invalid_seek = ESPIPE, + io_error = EIO, + is_a_directory = EISDIR, +-// message_size = EMSGSIZE, +-// network_down = ENETDOWN, +-// network_reset = ENETRESET, +-// network_unreachable = ENETUNREACH, +-// no_buffer_space = ENOBUFS, ++ ++#ifdef EMSGSIZE ++ message_size = EMSGSIZE, ++#endif ++ ++#ifdef ENETDOWN ++ network_down = ENETDOWN, ++#endif ++ ++#ifdef ENETRESET ++ network_reset = ENETRESET, ++#endif ++ ++#ifdef ENETUNREACH ++ network_unreachable = ENETUNREACH, ++#endif ++ ++#ifdef ENOBUFS ++ no_buffer_space = ENOBUFS, ++#endif ++ + no_child_process = ECHILD, + + #ifdef ENOLINK +@@ -96,8 +158,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + no_message_available = ENODATA, + #endif + +-// no_message = ENOMSG, +-// no_protocol_option = ENOPROTOOPT, ++#ifdef ENOMSG ++ no_message = ENOMSG, ++#endif ++ ++#ifdef ENOPROTOOPT ++ no_protocol_option = ENOPROTOOPT, ++#endif ++ + no_space_on_device = ENOSPC, + + #ifdef ENOSR +@@ -109,13 +177,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + no_such_file_or_directory = ENOENT, + no_such_process = ESRCH, + not_a_directory = ENOTDIR, +-// not_a_socket = ENOTSOCK, ++ ++#ifdef ENOTSOCK ++ not_a_socket = ENOTSOCK, ++#endif + + #ifdef ENOSTR + not_a_stream = ENOSTR, + #endif + +-// not_connected = ENOTCONN, ++#ifdef ENOTCONN ++ not_connected = ENOTCONN, ++#endif ++ + not_enough_memory = ENOMEM, + + #ifdef ENOTSUP +@@ -126,10 +200,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + operation_canceled = ECANCELED, + #endif + +-// operation_in_progress = EINPROGRESS, ++#ifdef EINPROGRESS ++ operation_in_progress = EINPROGRESS, ++#endif ++ + operation_not_permitted = EPERM, +-// operation_not_supported = EOPNOTSUPP, +-// operation_would_block = EWOULDBLOCK, ++ operation_not_supported = EOPNOTSUPP, ++ ++#ifdef EWOULDBLOCK ++ operation_would_block = EWOULDBLOCK, ++#endif + + #ifdef EOWNERDEAD + owner_dead = EOWNERDEAD, +@@ -141,7 +221,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + protocol_error = EPROTO, + #endif + +-// protocol_not_supported = EPROTONOSUPPORT, ++#ifdef EPROTONOSUPPORT ++ protocol_not_supported = EPROTONOSUPPORT, ++#endif ++ + read_only_file_system = EROFS, + resource_deadlock_would_occur = EDEADLK, + resource_unavailable_try_again = EAGAIN, +@@ -159,7 +242,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + text_file_busy = ETXTBSY, + #endif + +-// timed_out = ETIMEDOUT, ++#ifdef ETIMEDOUT ++ timed_out = ETIMEDOUT, ++#endif ++ + too_many_files_open_in_system = ENFILE, + too_many_files_open = EMFILE, + too_many_links = EMLINK, +@@ -169,7 +255,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + value_too_large = EOVERFLOW, + #endif + +-// wrong_protocol_type = EPROTOTYPE ++#ifdef EPROTOTYPE ++ wrong_protocol_type = EPROTOTYPE ++#endif + }; + + _GLIBCXX_END_NAMESPACE_VERSION +diff --git a/libstdc++-v3/include/experimental/bits/fs_path.h b/libstdc++-v3/include/experimental/bits/fs_path.h +index e0e47188bb9..488c3043815 100644 +--- a/libstdc++-v3/include/experimental/bits/fs_path.h ++++ b/libstdc++-v3/include/experimental/bits/fs_path.h +@@ -53,6 +53,11 @@ + # include + #endif + ++#if defined(__DJGPP__) ++# define _GLIBCXX_FILESYSTEM_IS_DJGPP 1 ++# include ++#endif ++ + namespace std _GLIBCXX_VISIBILITY(default) + { + _GLIBCXX_BEGIN_NAMESPACE_VERSION +@@ -515,6 +520,8 @@ namespace __detail + { + #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + return __ch == L'/' || __ch == preferred_separator; ++#elif defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) ++ return __ch == '/' || __ch == '\\'; + #else + return __ch == '/'; + #endif +@@ -1027,6 +1034,9 @@ namespace __detail + #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + std::replace(_M_pathname.begin(), _M_pathname.end(), L'/', + preferred_separator); ++#elif defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) ++ std::replace(_M_pathname.begin(), _M_pathname.end(), '\\', ++ preferred_separator); + #endif + return *this; + } +@@ -1249,7 +1259,7 @@ namespace __detail + inline bool + path::is_absolute() const + { +-#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS ++#if defined(_GLIBCXX_FILESYSTEM_IS_WINDOWS) || defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) + return has_root_name() && has_root_directory(); + #else + return has_root_directory(); +diff --git a/libstdc++-v3/src/c++11/shared_ptr.cc b/libstdc++-v3/src/c++11/shared_ptr.cc +index 74e879e5828..a4785c71eaa 100644 +--- a/libstdc++-v3/src/c++11/shared_ptr.cc ++++ b/libstdc++-v3/src/c++11/shared_ptr.cc +@@ -35,7 +35,12 @@ namespace __gnu_internal _GLIBCXX_VISIBILITY(hidden) + get_mutex(unsigned char i) + { + // increase alignment to put each lock on a separate cache line ++ // increase alignment to put each lock on a separate cache line ++#ifdef __DJGPP__ ++ struct M : __gnu_cxx::__mutex { }; ++#else + struct alignas(64) M : __gnu_cxx::__mutex { }; ++#endif + // Use a static buffer, so that the mutexes are not destructed + // before potential users (or at all) + static __attribute__ ((aligned(__alignof__(M)))) +diff --git a/libstdc++-v3/src/filesystem/path.cc b/libstdc++-v3/src/filesystem/path.cc +index 4c218bdae49..6c345d2e51b 100644 +--- a/libstdc++-v3/src/filesystem/path.cc ++++ b/libstdc++-v3/src/filesystem/path.cc +@@ -411,8 +411,13 @@ path::_M_split_cmpts() + _M_add_root_dir(0); + ++pos; + } +-#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS ++#if defined(_GLIBCXX_FILESYSTEM_IS_WINDOWS) \ ++ || defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) ++#ifdef __DJGPP__ ++ else if (len > 1 && pathname[1] == ':') ++#else + else if (len > 1 && pathname[1] == L':') ++#endif + { + // got disk designator + if (len == 2) diff --git a/patch/djgpp-gcc-13.1.0/0001-lto.patch b/patch/djgpp-gcc-13.1.0/0001-lto.patch new file mode 100644 index 0000000..50086a1 --- /dev/null +++ b/patch/djgpp-gcc-13.1.0/0001-lto.patch @@ -0,0 +1,10 @@ +--- a/configure ++++ b/configure +@@ -6177,7 +6177,7 @@ + # Among non-ELF, only Windows platforms support the lto-plugin so far. + # Build it unless LTO was explicitly disabled. + case $target in +- *-cygwin* | *-mingw*) build_lto_plugin=$enable_lto ;; ++ *-cygwin* | *-mingw* | *djgpp*) build_lto_plugin=$enable_lto ;; + *) ;; + esac diff --git a/patch/djgpp-gcc-13.2.0/0000-djcross.patch b/patch/djgpp-gcc-13.2.0/0000-djcross.patch new file mode 100644 index 0000000..939b281 --- /dev/null +++ b/patch/djgpp-gcc-13.2.0/0000-djcross.patch @@ -0,0 +1,960 @@ +diff --git a/Makefile.in b/Makefile.in +index 06a9398e172..c5f04e56422 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -1472,7 +1472,6 @@ dvi-host: maybe-dvi-itcl + dvi-host: maybe-dvi-ld + dvi-host: maybe-dvi-libbacktrace + dvi-host: maybe-dvi-libcpp +-dvi-host: maybe-dvi-libcody + dvi-host: maybe-dvi-libdecnumber + dvi-host: maybe-dvi-libgui + dvi-host: maybe-dvi-libiberty +@@ -1562,7 +1561,6 @@ pdf-host: maybe-pdf-itcl + pdf-host: maybe-pdf-ld + pdf-host: maybe-pdf-libbacktrace + pdf-host: maybe-pdf-libcpp +-pdf-host: maybe-pdf-libcody + pdf-host: maybe-pdf-libdecnumber + pdf-host: maybe-pdf-libgui + pdf-host: maybe-pdf-libiberty +@@ -1652,7 +1650,6 @@ html-host: maybe-html-itcl + html-host: maybe-html-ld + html-host: maybe-html-libbacktrace + html-host: maybe-html-libcpp +-html-host: maybe-html-libcody + html-host: maybe-html-libdecnumber + html-host: maybe-html-libgui + html-host: maybe-html-libiberty +@@ -1742,7 +1739,6 @@ TAGS-host: maybe-TAGS-itcl + TAGS-host: maybe-TAGS-ld + TAGS-host: maybe-TAGS-libbacktrace + TAGS-host: maybe-TAGS-libcpp +-TAGS-host: maybe-TAGS-libcody + TAGS-host: maybe-TAGS-libdecnumber + TAGS-host: maybe-TAGS-libgui + TAGS-host: maybe-TAGS-libiberty +@@ -1832,7 +1828,6 @@ install-info-host: maybe-install-info-itcl + install-info-host: maybe-install-info-ld + install-info-host: maybe-install-info-libbacktrace + install-info-host: maybe-install-info-libcpp +-install-info-host: maybe-install-info-libcody + install-info-host: maybe-install-info-libdecnumber + install-info-host: maybe-install-info-libgui + install-info-host: maybe-install-info-libiberty +@@ -2012,7 +2007,6 @@ install-pdf-host: maybe-install-pdf-itcl + install-pdf-host: maybe-install-pdf-ld + install-pdf-host: maybe-install-pdf-libbacktrace + install-pdf-host: maybe-install-pdf-libcpp +-install-pdf-host: maybe-install-pdf-libcody + install-pdf-host: maybe-install-pdf-libdecnumber + install-pdf-host: maybe-install-pdf-libgui + install-pdf-host: maybe-install-pdf-libiberty +@@ -2102,7 +2096,6 @@ install-html-host: maybe-install-html-itcl + install-html-host: maybe-install-html-ld + install-html-host: maybe-install-html-libbacktrace + install-html-host: maybe-install-html-libcpp +-install-html-host: maybe-install-html-libcody + install-html-host: maybe-install-html-libdecnumber + install-html-host: maybe-install-html-libgui + install-html-host: maybe-install-html-libiberty +diff --git a/c++tools/resolver.cc b/c++tools/resolver.cc +index d1f009cab64..ce1e29da817 100644 +--- a/c++tools/resolver.cc ++++ b/c++tools/resolver.cc +@@ -33,13 +33,13 @@ along with GCC; see the file COPYING3. If not see + #define MAPPED_READING 0 + #else + #ifdef IN_GCC +-#if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0 ++#if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0 && !defined(__DJGPP__) + #define MAPPED_READING 1 + #else + #define MAPPED_READING 0 + #endif + #else +-#ifdef HAVE_SYS_MMAN_H ++#if defined(HAVE_SYS_MMAN_H) && !defined(__DJGPP__) + #include + #define MAPPED_READING 1 + #else +diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c +index 2a193efc002..0930c9671f8 100644 +--- a/gcc/ada/adaint.c ++++ b/gcc/ada/adaint.c +@@ -298,6 +298,12 @@ char __gnat_dir_separator = DIR_SEPARATOR; + + char __gnat_path_separator = PATH_SEPARATOR; + ++#ifdef __DJGPP__ ++int __gnat_is_djgpp = 1; ++#else ++int __gnat_is_djgpp = 0; ++#endif ++ + /* The GNAT_LIBRARY_TEMPLATE contains a list of expressions that define + the base filenames that libraries specified with -lsomelib options + may have. This is used by GNATMAKE to check whether an executable +@@ -592,7 +598,11 @@ __gnat_try_lock (char *dir, char *file) + int + __gnat_get_maximum_file_name_length (void) + { ++#if defined (__DJGPP__) ++ return (_use_lfn(".")) ? -1 : 8; ++#else + return -1; ++#endif + } + + /* Return nonzero if file names are case sensitive. */ +diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in +index 9507f2f0920..f6ca2911534 100644 +--- a/gcc/ada/gcc-interface/Make-lang.in ++++ b/gcc/ada/gcc-interface/Make-lang.in +@@ -1166,7 +1166,7 @@ ada/generated/gnatvsn.ads: ada/gnatvsn.ads BASE-VER ada/GNAT_DATE + s=`cat $(srcdir)/BASE-VER | sed -e "s/\([0-9]*\)\.\([0-9]*\)\..*/-\1\2/g"`; \ + d=`if test -f $(srcdir)/ada/GNAT_DATE; then \ + cat $(srcdir)/ada/GNAT_DATE; else date +%Y%m%d; fi`; \ +- cat $< | sed -e "/Version/s/(\([0-9]\{8\}\).*)/($$d$$s)/g" >$@ ++ cat $< | sed -e "/Version/s/(\([0-9]\{8\}\).*)/($$d$$s)/g" | tr -d \\\015 >$@ + + ada/gnatvsn.o : ada/gnatvsn.adb ada/generated/gnatvsn.ads + $(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(ADA_OUTPUT_OPTION) +diff --git a/gcc/ada/libgnarl/s-taprop__dummy.adb b/gcc/ada/libgnarl/s-taprop__dummy.adb +index ced2a0c6f3c..34af507e275 100644 +--- a/gcc/ada/libgnarl/s-taprop__dummy.adb ++++ b/gcc/ada/libgnarl/s-taprop__dummy.adb +@@ -37,7 +37,7 @@ + package body System.Task_Primitives.Operations is + + use System.Tasking; +- use System.Parameters; ++-- use System.Parameters; + + pragma Warnings (Off); + -- Turn off warnings since so many unreferenced parameters +diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb +index 2647b981b18..0d31b3f1b39 100644 +--- a/gcc/ada/libgnat/s-os_lib.adb ++++ b/gcc/ada/libgnat/s-os_lib.adb +@@ -73,7 +73,7 @@ package body System.OS_Lib is + + -- The following are used by Create_Temp_File + +- First_Temp_File_Name : constant String := "GNAT-TEMP-000000.TMP"; ++ First_Temp_File_Name : constant String := "GA000000.TMP"; + -- Used to initialize Current_Temp_File_Name and Temp_File_Name_Last_Digit + + Current_Temp_File_Name : String := First_Temp_File_Name; +@@ -2275,9 +2275,10 @@ package body System.OS_Lib is + -- * Check the drive letter + -- * Remove all double-quotes + +- if On_Windows then ++ if On_Windows ++ and then Is_Djgpp = 0 ++ then + -- Replace all '/' by '\' +- + for Index in 1 .. End_Path loop + if Path_Buffer (Index) = '/' then + Path_Buffer (Index) := Directory_Separator; +diff --git a/gcc/ada/libgnat/s-os_lib.ads b/gcc/ada/libgnat/s-os_lib.ads +index 9be09b39bf6..340fe0b9e42 100644 +--- a/gcc/ada/libgnat/s-os_lib.ads ++++ b/gcc/ada/libgnat/s-os_lib.ads +@@ -1100,9 +1100,12 @@ package System.OS_Lib is + Path_Separator : constant Character; + -- The character to separate paths in an environment variable value + ++ Is_Djgpp : constant Integer; ++ + private + pragma Import (C, Path_Separator, "__gnat_path_separator"); + pragma Import (C, Directory_Separator, "__gnat_dir_separator"); ++ pragma Import (C, Is_Djgpp, "__gnat_is_djgpp"); + pragma Import (C, Current_Time, "__gnat_current_time"); + pragma Import (C, Current_Process_Id, "__gnat_current_process_id"); + +diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c +index 5480e55a5bb..010f8204aad 100644 +--- a/gcc/ada/s-oscons-tmplt.c ++++ b/gcc/ada/s-oscons-tmplt.c +@@ -121,7 +121,7 @@ pragma Style_Checks ("M32766"); + **/ + + # include +-#elif !defined(__MINGW32__) ++#elif !defined(__MINGW32__) && !defined(__DJGPP__) + #include + #endif + +diff --git a/gcc/collect2.cc b/gcc/collect2.cc +index 63b9a0c233a..795bd01ca3b 100644 +--- a/gcc/collect2.cc ++++ b/gcc/collect2.cc +@@ -1159,18 +1159,27 @@ main (int argc, char **argv) + *ld1++ = *ld2++ = ld_file_name; + + /* Make temp file names. */ ++ ++#ifdef __DJGPP__ ++#define CDTOR_C_NAME ".ctc" ++#define CDTOR_O_NAME ".cto" ++#else ++#define CDTOR_C_NAME ".cdtor.c" ++#define CDTOR_O_NAME ".cdtor.o" ++#endif ++ + if (save_temps) + { +- c_file = concat (output_file, ".cdtor.c", NULL); +- o_file = concat (output_file, ".cdtor.o", NULL); ++ c_file = concat (output_file, CDTOR_C_NAME, NULL); ++ o_file = concat (output_file, CDTOR_O_NAME, NULL); + #ifdef COLLECT_EXPORT_LIST + export_file = concat (output_file, ".x", NULL); + #endif + } + else + { +- c_file = make_temp_file (".cdtor.c"); +- o_file = make_temp_file (".cdtor.o"); ++ c_file = make_temp_file (CDTOR_C_NAME); ++ o_file = make_temp_file (CDTOR_O_NAME); + #ifdef COLLECT_EXPORT_LIST + export_file = make_temp_file (".x"); + #endif +diff --git a/gcc/config/i386/djgpp.cc b/gcc/config/i386/djgpp.cc +index 0b83451fda5..897079e6c68 100644 +--- a/gcc/config/i386/djgpp.cc ++++ b/gcc/config/i386/djgpp.cc +@@ -36,6 +36,8 @@ i386_djgpp_asm_named_section(const char *name, unsigned int flags, + *f++ = 'w'; + if (flags & SECTION_CODE) + *f++ = 'x'; ++ if (flags & SECTION_BSS) ++ *f++ = 'b'; + + /* LTO sections need 1-byte alignment to avoid confusing the + zlib decompression algorithm with trailing zero pad bytes. */ +diff --git a/gcc/config/i386/xm-djgpp.h b/gcc/config/i386/xm-djgpp.h +index de2c1795dbc..4063ba28632 100644 +--- a/gcc/config/i386/xm-djgpp.h ++++ b/gcc/config/i386/xm-djgpp.h +@@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see + #undef NATIVE_SYSTEM_HEADER_DIR + #define NATIVE_SYSTEM_HEADER_DIR "/dev/env/DJDIR/include/" + ++//#undef PREFIX_INCLUDE_DIR ++ + /* Search for as.exe and ld.exe in DJGPP's binary directory. */ + #undef MD_EXEC_PREFIX + #define MD_EXEC_PREFIX "/dev/env/DJDIR/bin/" +@@ -107,6 +109,11 @@ along with GCC; see the file COPYING3. If not see + (PATH) = xstrdup (fixed_path); \ + } + ++/* Rename libstdc++ to libstdcxx as the first name is not valid for DOS */ ++#define LIBSTDCXX "stdcxx" ++#define LIBSTDCXX_PROFILE "stdcxx" ++#define LIBSTDCXX_STATIC "stdcxx" ++ + #undef MAX_OFILE_ALIGNMENT + #define MAX_OFILE_ALIGNMENT 128 + +diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc +index 39e80df2d25..641849f1c01 100644 +--- a/gcc/cp/mapper-client.cc ++++ b/gcc/cp/mapper-client.cc +@@ -19,7 +19,7 @@ along with GCC; see the file COPYING3. If not see + . */ + + #include "config.h" +-#if defined (__unix__) ++#if defined (__unix__) && !defined(__DJGPP__) + // Solaris11's socket header used bcopy, which we poison. cody.hh + // will include it later under the above check + #include +diff --git a/gcc/diagnostic-show-locus.cc b/gcc/diagnostic-show-locus.cc +index 0514815b51f..6b5285b5330 100644 +--- a/gcc/diagnostic-show-locus.cc ++++ b/gcc/diagnostic-show-locus.cc +@@ -5721,7 +5721,9 @@ diagnostic_show_locus_cc_tests () + for_each_line_table_case (test_fixit_replace_containing_newline); + for_each_line_table_case (test_fixit_deletion_affecting_newline); + for_each_line_table_case (test_tab_expansion); ++#ifndef __DJGPP__ + for_each_line_table_case (test_escaping_bytes_1); ++#endif + for_each_line_table_case (test_escaping_bytes_2); + + test_line_numbers_multiline_range (); +diff --git a/gcc/gcov-tool.cc b/gcc/gcov-tool.cc +index 76173fdaef7..6fd0066ef20 100644 +--- a/gcc/gcov-tool.cc ++++ b/gcc/gcov-tool.cc +@@ -58,11 +58,18 @@ static bool verbose; + + /* Remove file NAME if it has a gcda suffix. */ + ++#ifdef __DJGPP__ ++static int ++unlink_gcda_file (const char *name, ++ struct stat *status ATTRIBUTE_UNUSED, ++ int type ATTRIBUTE_UNUSED) ++#else + static int + unlink_gcda_file (const char *name, + const struct stat *status ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, + struct FTW *ftwbuf ATTRIBUTE_UNUSED) ++#endif + { + int ret = 0; + int len = strlen (name); +@@ -84,7 +91,11 @@ static int + unlink_profile_dir (const char *path ATTRIBUTE_UNUSED) + { + #if HAVE_FTW_H ++#ifdef __DJGPP__ ++ return ftw(path, unlink_gcda_file, 64); ++#else + return nftw(path, unlink_gcda_file, 64, FTW_DEPTH | FTW_PHYS); ++#endif + #else + return -1; + #endif +diff --git a/gcc/ggc-common.cc b/gcc/ggc-common.cc +index db317f49993..8d1de076010 100644 +--- a/gcc/ggc-common.cc ++++ b/gcc/ggc-common.cc +@@ -31,6 +31,12 @@ along with GCC; see the file COPYING3. If not see + #include "plugin.h" + #include "options.h" + ++#ifdef __DJGPP__ ++extern "C" { ++#include ++} ++#endif ++ + /* When true, protect the contents of the identifier hash table. */ + bool ggc_protect_identifiers = true; + +diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h +index 45021e48b8f..1f7f051e54b 100644 +--- a/gcc/ginclude/float.h ++++ b/gcc/ginclude/float.h +@@ -25,6 +25,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + * ISO C Standard: 5.2.4.2.2 Characteristics of floating types + */ + ++#ifdef __DJGPP__ ++#include_next ++#endif ++ + #ifndef _FLOAT_H___ + #define _FLOAT_H___ + +diff --git a/include/libiberty.h b/include/libiberty.h +index 1d5c779fcff..787507dfe93 100644 +--- a/include/libiberty.h ++++ b/include/libiberty.h +@@ -108,6 +108,7 @@ extern int countargv (char * const *); + #if defined (__GNU_LIBRARY__ ) || defined (__linux__) \ + || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) \ + || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) \ ++ || defined (__DJGPP__) \ + || defined (__DragonFly__) || defined (HAVE_DECL_BASENAME) + extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1); + #else +diff --git a/libcody/cody.hh b/libcody/cody.hh +index 789ce9e70b7..8794e4dd8e6 100644 +--- a/libcody/cody.hh ++++ b/libcody/cody.hh +@@ -20,6 +20,12 @@ + #endif + #endif + ++// Do not use networking for DJGPP even if it defines __unix__ ++#ifdef __DJGPP__ ++#undef CODY_NETWORKING ++#define CODY_NETWORKING 0 ++#endif ++ + // C++ + #include + #include +diff --git a/libcpp/files.cc b/libcpp/files.cc +index 3f8a8106ec8..343965d84bd 100644 +--- a/libcpp/files.cc ++++ b/libcpp/files.cc +@@ -747,6 +747,10 @@ read_file_guts (cpp_reader *pfile, _cpp_file *file, location_t loc, + cpp_error_at (pfile, CPP_DL_WARNING, loc, + "%s is shorter than expected", file->path); + ++/* For DOS we should handle DOS EOF character (0x1A, ^Z). It is ++ only done if it is really the last character of the file */ ++ if (total>0 && buf[total-1]==0x1A) total--; ++ + file->buffer = _cpp_convert_input (pfile, + input_charset, + buf, size + 16, total, +diff --git a/libcpp/lex.cc b/libcpp/lex.cc +index 45ea16a91bc..b0e7a219d10 100644 +--- a/libcpp/lex.cc ++++ b/libcpp/lex.cc +@@ -505,6 +505,13 @@ init_vectorized_lexer (void) + search_line_fast_type impl = search_line_acc_char; + int minimum = 0; + ++// [FIXME][DJGPP] Using SSE here causes preprocessor to randomly ++// [FIXME][DJGPP] fail when run under Windows 10 32 bit (and maybe ++// [FIXME][DJGPP] some other systems (I have observed similar ++// [FIXME][DJGPP] behavior earlier with DJGPP v2.03p2 under Windows ++// [FIXME][DJGPP] Vista ++#ifndef __DJGPP__ ++ + #if defined(__SSE4_2__) + minimum = 3; + #elif defined(__SSE2__) +@@ -531,6 +538,8 @@ init_vectorized_lexer (void) + impl = search_line_mmx; + } + ++#endif // __DJGPP__ ++ + search_line_fast = impl; + } + +diff --git a/libffi/src/x86/sysv.S b/libffi/src/x86/sysv.S +index c7a0fb51b48..5c724e24d8b 100644 +--- a/libffi/src/x86/sysv.S ++++ b/libffi/src/x86/sysv.S +@@ -968,7 +968,7 @@ ENDF(C(__x86.get_pc_thunk.dx)) + #ifdef __APPLE__ + .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support + EHFrame0: +-#elif defined(X86_WIN32) ++#elif defined(X86_WIN32) || defined(__DJGPP__) + .section .eh_frame,"r" + #elif defined(HAVE_AS_X86_64_UNWIND_SECTION_TYPE) + .section .eh_frame,EH_FRAME_FLAGS,@unwind +diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c +index d547c103cab..d939b1e1cbb 100644 +--- a/libgcc/libgcov-util.c ++++ b/libgcc/libgcov-util.c +@@ -381,7 +381,11 @@ read_gcda_file (const char *filename) + + static int + ftw_read_file (const char *filename, ++#ifdef __DJGPP__ ++ struct stat *status ATTRIBUTE_UNUSED, ++#else + const struct stat *status ATTRIBUTE_UNUSED, ++#endif + int type) + { + size_t filename_len; +diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h +index 92df440d401..7df201fe40a 100644 +--- a/libgcc/libgcov.h ++++ b/libgcc/libgcov.h +@@ -163,6 +163,11 @@ extern struct gcov_info *gcov_list; + + #endif /* !IN_GCOV_TOOL */ + ++#ifdef __DJGPP__ ++#include ++#undef HAVE_SYS_MMAN_H ++#endif // __DJGPP__ ++ + #if defined(inhibit_libc) + #define IN_LIBGCOV (-1) + #else +diff --git a/libgfortran/intrinsics/chmod.c b/libgfortran/intrinsics/chmod.c +index 850c2ccebbf..ee17e421c29 100644 +--- a/libgfortran/intrinsics/chmod.c ++++ b/libgfortran/intrinsics/chmod.c +@@ -445,7 +445,7 @@ clause_done: + if ((ugo[2] || honor_umask) && !rwxXstugo[8]) + file_mode = (file_mode & ~(S_IROTH | S_IWOTH | S_IXOTH)) + | (new_mode & (S_IROTH | S_IWOTH | S_IXOTH)); +-#ifndef __VXWORKS__ ++#if !defined(__VXWORKS__) && !defined(__DJGPP__) + if (is_dir && rwxXstugo[5]) + file_mode |= S_ISVTX; + else if (!is_dir) +@@ -457,7 +457,7 @@ clause_done: + { + /* Clear '-'. */ + file_mode &= ~new_mode; +-#if !defined( __MINGW32__) && !defined (__VXWORKS__) ++#if !defined( __MINGW32__) && !defined (__VXWORKS__) && !defined(__DJGPP__) + if (rwxXstugo[5] || !is_dir) + file_mode &= ~S_ISVTX; + #endif +@@ -465,7 +465,7 @@ clause_done: + else if (set_mode == 3) + { + file_mode |= new_mode; +-#if !defined (__MINGW32__) && !defined (__VXWORKS__) ++#if !defined (__MINGW32__) && !defined (__VXWORKS__) && !defined(__DJGPP__) + if (rwxXstugo[5] && is_dir) + file_mode |= S_ISVTX; + else if (!is_dir) +diff --git a/libgfortran/intrinsics/execute_command_line.c b/libgfortran/intrinsics/execute_command_line.c +index c2bcaf05f0b..889bd637f18 100644 +--- a/libgfortran/intrinsics/execute_command_line.c ++++ b/libgfortran/intrinsics/execute_command_line.c +@@ -98,7 +98,7 @@ execute_command_line (const char *command, bool wait, int *exitstat, + + set_cmdstat (cmdstat, EXEC_NOERROR); + +-#if defined(HAVE_SIGACTION) && defined(HAVE_WAITPID) ++#if defined(HAVE_SIGACTION) && defined(HAVE_WAITPID) && !defined(__DJGPP__) + static bool sig_init_saved; + bool sig_init = __atomic_load_n (&sig_init_saved, __ATOMIC_RELAXED); + if (!sig_init) +diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c +index ba12be08252..7ac07f3f4a8 100644 +--- a/libgfortran/io/unix.c ++++ b/libgfortran/io/unix.c +@@ -221,6 +221,9 @@ typedef struct + } + unix_stream; + ++#ifdef __DJGPP__ ++#include ++#endif + + /* fix_fd()-- Given a file descriptor, make sure it is not one of the + standard descriptors, returning a non-standard descriptor. If the +@@ -1222,8 +1225,13 @@ tempfile_open (const char *tempdir, char **fname) + char *template = xmalloc (tempdirlen + 23); + + #ifdef HAVE_MKSTEMP ++#ifdef __DJGPP__ ++ /* Default filename is too long for DOS */ ++ snprintf (template, tempdirlen + 23, "%s/gfXXXXXX", tempdir); ++#else + snprintf (template, tempdirlen + 23, "%s%sgfortrantmpXXXXXX", + tempdir, slash); ++#endif + + #ifdef HAVE_UMASK + /* Temporarily set the umask such that the file has 0600 permissions. */ +@@ -1589,6 +1597,13 @@ open_external (st_parameter_open *opp, unit_flags *flags) + return NULL; + fd = fix_fd (fd); + ++#ifdef __DJGPP__ ++ if (flags->form == FORM_UNFORMATTED) ++ { ++ setmode (fd, O_BINARY); ++ } ++#endif ++ + if (open_share (opp, fd, flags) < 0) + return NULL; + +diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c +index 1b970e7a773..0eb30c02a60 100644 +--- a/libiberty/make-relative-prefix.c ++++ b/libiberty/make-relative-prefix.c +@@ -65,6 +65,7 @@ relative prefix can be found, return @code{NULL}. + + #include "ansidecl.h" + #include "libiberty.h" ++#include "filenames.h" + + #ifndef R_OK + #define R_OK 4 +@@ -340,7 +341,7 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix, + { + for (i = 0; i < bin_num; i++) + { +- if (strcmp (prog_dirs[i], bin_dirs[i]) != 0) ++ if (FILENAME_CMP (prog_dirs[i], bin_dirs[i]) != 0) + break; + } + +@@ -356,7 +357,7 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix, + n = (prefix_num < bin_num) ? prefix_num : bin_num; + for (common = 0; common < n; common++) + { +- if (strcmp (bin_dirs[common], prefix_dirs[common]) != 0) ++ if (FILENAME_CMP (bin_dirs[common], prefix_dirs[common]) != 0) + break; + } + +diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c +index 1d2f21d6c5c..885d29c9c72 100644 +--- a/libiberty/make-temp-file.c ++++ b/libiberty/make-temp-file.c +@@ -52,6 +52,7 @@ Boston, MA 02110-1301, USA. */ + #endif + + #include "libiberty.h" ++#include "filenames.h" + extern int mkstemps (char *, int); + + /* '/' works just fine on MS-DOS based systems. */ +@@ -154,7 +155,8 @@ choose_tmpdir (void) + len = strlen (base); + tmpdir = XNEWVEC (char, len + 2); + strcpy (tmpdir, base); +- tmpdir[len] = DIR_SEPARATOR; ++ if (len>0 && !IS_DIR_SEPARATOR(tmpdir[len-1])) ++ tmpdir[len] = DIR_SEPARATOR; + tmpdir[len+1] = '\0'; + memoized_tmpdir = tmpdir; + #else /* defined(_WIN32) && !defined(__CYGWIN__) */ +diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c +index eee07039984..2997ae21655 100644 +--- a/libiberty/simple-object-elf.c ++++ b/libiberty/simple-object-elf.c +@@ -1293,7 +1293,9 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj, + } + if (new_i - 1 >= SHN_LORESERVE) + { ++#ifdef ENOTSUP + *err = ENOTSUP; ++#endif + return "Too many copied sections"; + } + eow->shdrs = XNEWVEC (unsigned char, shdr_size * (new_i - 1)); +diff --git a/libquadmath/printf/quadmath-printf.h b/libquadmath/printf/quadmath-printf.h +index 32ebcec928c..96498b7c408 100644 +--- a/libquadmath/printf/quadmath-printf.h ++++ b/libquadmath/printf/quadmath-printf.h +@@ -29,7 +29,8 @@ Boston, MA 02110-1301, USA. */ + #ifdef HAVE_CTYPE_H + #include + #endif +-#ifdef HAVE_WCHAR_H ++#if defined(HAVE_WCHAR_H) && !defined(__DJGPP__) ++/* DJGPP wchar.h is not good enough */ + #include + #endif + #ifdef HAVE_WCTYPE_H +@@ -44,7 +45,7 @@ Boston, MA 02110-1301, USA. */ + #include "quadmath-imp.h" + #include "gmp-impl.h" + +-#ifdef HAVE_WCHAR_H ++#if defined(HAVE_WCHAR_H) && !defined(__DJGPP__) + #define L_(x) L##x + #else + #define L_(x) x +diff --git a/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc b/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc +index 55cbcaf92c4..f3603555909 100644 +--- a/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc ++++ b/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc +@@ -45,7 +45,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), +- _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), ++ _M_toupper(__dj_ctype_toupper+1), _M_tolower(__dj_ctype_tolower+1), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); +@@ -56,7 +56,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + + ctype::ctype(const mask* __table, bool __del, size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), +- _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), ++ _M_toupper(__dj_ctype_toupper+1), _M_tolower(__dj_ctype_tolower+1), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); +diff --git a/libstdc++-v3/config/os/djgpp/error_constants.h b/libstdc++-v3/config/os/djgpp/error_constants.h +index 834f2e04b43..f2ae54a6c76 100644 +--- a/libstdc++-v3/config/os/djgpp/error_constants.h ++++ b/libstdc++-v3/config/os/djgpp/error_constants.h +@@ -33,16 +33,42 @@ + #include + #include + ++// Include Watt-32 errno list, if present ++#if defined __has_include && __has_include() ++#include ++#endif ++ ++#ifndef EOPNOTSUPP ++// Use same value as in wat3222br6.zip file net/watt/sys/djgpp.err ++#define EOPNOTSUPP 52 ++#endif ++ ++#ifndef ENOTSUP ++#define ENOTSUP 101 ++#endif ++ + namespace std _GLIBCXX_VISIBILITY(default) + { + _GLIBCXX_BEGIN_NAMESPACE_VERSION + + enum class errc + { +-// address_family_not_supported = EAFNOSUPPORT, +-// address_in_use = EADDRINUSE, +-// address_not_available = EADDRNOTAVAIL, +-// already_connected = EISCONN, ++#ifdef EAFNOSUPPORT ++ address_family_not_supported = EAFNOSUPPORT, ++#endif ++ ++#ifdef EADDRINUSE ++ address_in_use = EADDRINUSE, ++#endif ++ ++#ifdef EADDRNOTAVAIL ++ address_not_available = EADDRNOTAVAIL, ++#endif ++ ++#ifdef EISCONN ++ already_connected = EISCONN, ++#endif ++ + argument_list_too_long = E2BIG, + argument_out_of_domain = EDOM, + bad_address = EFAULT, +@@ -53,12 +79,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + #endif + + broken_pipe = EPIPE, +-// connection_aborted = ECONNABORTED, +-// connection_already_in_progress = EALREADY, +-// connection_refused = ECONNREFUSED, +-// connection_reset = ECONNRESET, ++ ++#ifdef ECONNABORTED ++ connection_aborted = ECONNABORTED, ++#endif ++ ++#ifdef EALREADY ++ connection_already_in_progress = EALREADY, ++#endif ++ ++#ifdef ECONNREFUSED ++ connection_refused = ECONNREFUSED, ++#endif ++ ++#ifdef ECONNRESET ++ connection_reset = ECONNRESET, ++#endif ++ + cross_device_link = EXDEV, +-// destination_address_required = EDESTADDRREQ, ++ ++#ifdef EDESTADDRREQ ++ destination_address_required = EDESTADDRREQ, ++#endif ++ + device_or_resource_busy = EBUSY, + directory_not_empty = ENOTEMPTY, + executable_format_error = ENOEXEC, +@@ -66,7 +109,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + file_too_large = EFBIG, + filename_too_long = ENAMETOOLONG, + function_not_supported = ENOSYS, +-// host_unreachable = EHOSTUNREACH, ++ ++#ifdef EHOSTUNREACH ++ host_unreachable = EHOSTUNREACH, ++#endif + + #ifdef EIDRM + identifier_removed = EIDRM, +@@ -79,11 +125,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + invalid_seek = ESPIPE, + io_error = EIO, + is_a_directory = EISDIR, +-// message_size = EMSGSIZE, +-// network_down = ENETDOWN, +-// network_reset = ENETRESET, +-// network_unreachable = ENETUNREACH, +-// no_buffer_space = ENOBUFS, ++ ++#ifdef EMSGSIZE ++ message_size = EMSGSIZE, ++#endif ++ ++#ifdef ENETDOWN ++ network_down = ENETDOWN, ++#endif ++ ++#ifdef ENETRESET ++ network_reset = ENETRESET, ++#endif ++ ++#ifdef ENETUNREACH ++ network_unreachable = ENETUNREACH, ++#endif ++ ++#ifdef ENOBUFS ++ no_buffer_space = ENOBUFS, ++#endif ++ + no_child_process = ECHILD, + + #ifdef ENOLINK +@@ -96,8 +158,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + no_message_available = ENODATA, + #endif + +-// no_message = ENOMSG, +-// no_protocol_option = ENOPROTOOPT, ++#ifdef ENOMSG ++ no_message = ENOMSG, ++#endif ++ ++#ifdef ENOPROTOOPT ++ no_protocol_option = ENOPROTOOPT, ++#endif ++ + no_space_on_device = ENOSPC, + + #ifdef ENOSR +@@ -109,13 +177,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + no_such_file_or_directory = ENOENT, + no_such_process = ESRCH, + not_a_directory = ENOTDIR, +-// not_a_socket = ENOTSOCK, ++ ++#ifdef ENOTSOCK ++ not_a_socket = ENOTSOCK, ++#endif + + #ifdef ENOSTR + not_a_stream = ENOSTR, + #endif + +-// not_connected = ENOTCONN, ++#ifdef ENOTCONN ++ not_connected = ENOTCONN, ++#endif ++ + not_enough_memory = ENOMEM, + + #ifdef ENOTSUP +@@ -126,10 +200,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + operation_canceled = ECANCELED, + #endif + +-// operation_in_progress = EINPROGRESS, ++#ifdef EINPROGRESS ++ operation_in_progress = EINPROGRESS, ++#endif ++ + operation_not_permitted = EPERM, +-// operation_not_supported = EOPNOTSUPP, +-// operation_would_block = EWOULDBLOCK, ++ operation_not_supported = EOPNOTSUPP, ++ ++#ifdef EWOULDBLOCK ++ operation_would_block = EWOULDBLOCK, ++#endif + + #ifdef EOWNERDEAD + owner_dead = EOWNERDEAD, +@@ -141,7 +221,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + protocol_error = EPROTO, + #endif + +-// protocol_not_supported = EPROTONOSUPPORT, ++#ifdef EPROTONOSUPPORT ++ protocol_not_supported = EPROTONOSUPPORT, ++#endif ++ + read_only_file_system = EROFS, + resource_deadlock_would_occur = EDEADLK, + resource_unavailable_try_again = EAGAIN, +@@ -159,7 +242,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + text_file_busy = ETXTBSY, + #endif + +-// timed_out = ETIMEDOUT, ++#ifdef ETIMEDOUT ++ timed_out = ETIMEDOUT, ++#endif ++ + too_many_files_open_in_system = ENFILE, + too_many_files_open = EMFILE, + too_many_links = EMLINK, +@@ -169,7 +255,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + value_too_large = EOVERFLOW, + #endif + +-// wrong_protocol_type = EPROTOTYPE ++#ifdef EPROTOTYPE ++ wrong_protocol_type = EPROTOTYPE ++#endif + }; + + _GLIBCXX_END_NAMESPACE_VERSION +diff --git a/libstdc++-v3/include/experimental/bits/fs_path.h b/libstdc++-v3/include/experimental/bits/fs_path.h +index e0e47188bb9..488c3043815 100644 +--- a/libstdc++-v3/include/experimental/bits/fs_path.h ++++ b/libstdc++-v3/include/experimental/bits/fs_path.h +@@ -53,6 +53,11 @@ + # include + #endif + ++#if defined(__DJGPP__) ++# define _GLIBCXX_FILESYSTEM_IS_DJGPP 1 ++# include ++#endif ++ + namespace std _GLIBCXX_VISIBILITY(default) + { + _GLIBCXX_BEGIN_NAMESPACE_VERSION +@@ -515,6 +520,8 @@ namespace __detail + { + #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + return __ch == L'/' || __ch == preferred_separator; ++#elif defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) ++ return __ch == '/' || __ch == '\\'; + #else + return __ch == '/'; + #endif +@@ -1027,6 +1034,9 @@ namespace __detail + #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + std::replace(_M_pathname.begin(), _M_pathname.end(), L'/', + preferred_separator); ++#elif defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) ++ std::replace(_M_pathname.begin(), _M_pathname.end(), '\\', ++ preferred_separator); + #endif + return *this; + } +@@ -1249,7 +1259,7 @@ namespace __detail + inline bool + path::is_absolute() const + { +-#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS ++#if defined(_GLIBCXX_FILESYSTEM_IS_WINDOWS) || defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) + return has_root_name() && has_root_directory(); + #else + return has_root_directory(); +diff --git a/libstdc++-v3/src/filesystem/path.cc b/libstdc++-v3/src/filesystem/path.cc +index 4c218bdae49..6c345d2e51b 100644 +--- a/libstdc++-v3/src/filesystem/path.cc ++++ b/libstdc++-v3/src/filesystem/path.cc +@@ -411,8 +411,13 @@ path::_M_split_cmpts() + _M_add_root_dir(0); + ++pos; + } +-#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS ++#if defined(_GLIBCXX_FILESYSTEM_IS_WINDOWS) \ ++ || defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) ++#ifdef __DJGPP__ ++ else if (len > 1 && pathname[1] == ':') ++#else + else if (len > 1 && pathname[1] == L':') ++#endif + { + // got disk designator + if (len == 2) diff --git a/patch/djgpp-gcc-13.2.0/0001-lto.patch b/patch/djgpp-gcc-13.2.0/0001-lto.patch new file mode 100644 index 0000000..50086a1 --- /dev/null +++ b/patch/djgpp-gcc-13.2.0/0001-lto.patch @@ -0,0 +1,10 @@ +--- a/configure ++++ b/configure +@@ -6177,7 +6177,7 @@ + # Among non-ELF, only Windows platforms support the lto-plugin so far. + # Build it unless LTO was explicitly disabled. + case $target in +- *-cygwin* | *-mingw*) build_lto_plugin=$enable_lto ;; ++ *-cygwin* | *-mingw* | *djgpp*) build_lto_plugin=$enable_lto ;; + *) ;; + esac diff --git a/patch/djgpp-gcc-14.1.0/0000-djcross.patch b/patch/djgpp-gcc-14.1.0/0000-djcross.patch new file mode 100644 index 0000000..6fde412 --- /dev/null +++ b/patch/djgpp-gcc-14.1.0/0000-djcross.patch @@ -0,0 +1,900 @@ +diff --git a/c++tools/resolver.cc b/c++tools/resolver.cc +index 1cd583c750c..534cb35037e 100644 +--- a/c++tools/resolver.cc ++++ b/c++tools/resolver.cc +@@ -33,13 +33,13 @@ along with GCC; see the file COPYING3. If not see + #define MAPPED_READING 0 + #else + #ifdef IN_GCC +-#if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0 ++#if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0 && !defined(__DJGPP__) + #define MAPPED_READING 1 + #else + #define MAPPED_READING 0 + #endif + #else +-#ifdef HAVE_SYS_MMAN_H ++#if defined(HAVE_SYS_MMAN_H) && !defined(__DJGPP__) + #include + #define MAPPED_READING 1 + #else +diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c +index 74aa3c4128e..5bc56e89b37 100644 +--- a/gcc/ada/adaint.c ++++ b/gcc/ada/adaint.c +@@ -302,6 +302,12 @@ char __gnat_dir_separator = DIR_SEPARATOR; + + char __gnat_path_separator = PATH_SEPARATOR; + ++#ifdef __DJGPP__ ++int __gnat_is_djgpp = 1; ++#else ++int __gnat_is_djgpp = 0; ++#endif ++ + /* The GNAT_LIBRARY_TEMPLATE contains a list of expressions that define + the base filenames that libraries specified with -lsomelib options + may have. This is used by GNATMAKE to check whether an executable +@@ -596,7 +602,11 @@ __gnat_try_lock (char *dir, char *file) + int + __gnat_get_maximum_file_name_length (void) + { ++#if defined (__DJGPP__) ++ return (_use_lfn(".")) ? -1 : 8; ++#else + return -1; ++#endif + } + + /* Return nonzero if file names are case sensitive. */ +diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in +index f6404c0b1eb1..b7a161d1eae5 100644 +--- a/gcc/ada/gcc-interface/Make-lang.in ++++ b/gcc/ada/gcc-interface/Make-lang.in +@@ -1200,7 +1200,7 @@ ada/generated/gnatvsn.ads: ada/gnatvsn.ads BASE-VER ada/GNAT_DATE + s=`cat $(srcdir)/BASE-VER | sed -e "s/\([0-9]*\)\.\([0-9]*\)\..*/-\1\2/g"`; \ + d=`if test -f $(srcdir)/ada/GNAT_DATE; then \ + cat $(srcdir)/ada/GNAT_DATE; else date +%Y%m%d; fi`; \ +- cat $< | sed -e "/Version/s/(\([0-9]\{8\}\).*)/($$d$$s)/g" >$@ ++ cat $< | sed -e "/Version/s/(\([0-9]\{8\}\).*)/($$d$$s)/g" | tr -d \\\015 >$@ + + ada/gnatvsn.o : ada/gnatvsn.adb ada/generated/gnatvsn.ads + $(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(ADA_OUTPUT_OPTION) +diff --git a/gcc/ada/libgnarl/s-taprop__dummy.adb b/gcc/ada/libgnarl/s-taprop__dummy.adb +index 90c4cd4cf72f..fac564646408 100644 +--- a/gcc/ada/libgnarl/s-taprop__dummy.adb ++++ b/gcc/ada/libgnarl/s-taprop__dummy.adb +@@ -37,7 +37,7 @@ + package body System.Task_Primitives.Operations is + + use System.Tasking; +- use System.Parameters; ++-- use System.Parameters; + + pragma Warnings (Off); + -- Turn off warnings since so many unreferenced parameters +diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb +index 20e109aaa0ba..dbc5c9a8647f 100644 +--- a/gcc/ada/libgnat/s-os_lib.adb ++++ b/gcc/ada/libgnat/s-os_lib.adb +@@ -73,7 +73,7 @@ package body System.OS_Lib is + + -- The following are used by Create_Temp_File + +- First_Temp_File_Name : constant String := "GNAT-TEMP-000000.TMP"; ++ First_Temp_File_Name : constant String := "GA000000.TMP"; + -- Used to initialize Current_Temp_File_Name and Temp_File_Name_Last_Digit + + Current_Temp_File_Name : String := First_Temp_File_Name; +@@ -2275,9 +2275,10 @@ package body System.OS_Lib is + -- * Check the drive letter + -- * Remove all double-quotes + +- if On_Windows then ++ if On_Windows ++ and then Is_Djgpp = 0 ++ then + -- Replace all '/' by '\' +- + for Index in 1 .. End_Path loop + if Path_Buffer (Index) = '/' then + Path_Buffer (Index) := Directory_Separator; +diff --git a/gcc/ada/libgnat/s-os_lib.ads b/gcc/ada/libgnat/s-os_lib.ads +index 46e11f708a20..49453581ff82 100644 +--- a/gcc/ada/libgnat/s-os_lib.ads ++++ b/gcc/ada/libgnat/s-os_lib.ads +@@ -1100,9 +1100,12 @@ package System.OS_Lib is + Path_Separator : constant Character; + -- The character to separate paths in an environment variable value + ++ Is_Djgpp : constant Integer; ++ + private + pragma Import (C, Path_Separator, "__gnat_path_separator"); + pragma Import (C, Directory_Separator, "__gnat_dir_separator"); ++ pragma Import (C, Is_Djgpp, "__gnat_is_djgpp"); + pragma Import (C, Current_Time, "__gnat_current_time"); + pragma Import (C, Current_Process_Id, "__gnat_current_process_id"); + +diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c +index 4e512b96031..d17aec7b85e 100644 +--- a/gcc/ada/s-oscons-tmplt.c ++++ b/gcc/ada/s-oscons-tmplt.c +@@ -121,7 +121,7 @@ pragma Style_Checks ("M32766"); + **/ + + # include +-#elif !defined(__MINGW32__) ++#elif !defined(__MINGW32__) && !defined(__DJGPP__) + #include + #endif + +diff --git a/gcc/collect2.cc b/gcc/collect2.cc +index 902014a9cc1..cfe1a503532 100644 +--- a/gcc/collect2.cc ++++ b/gcc/collect2.cc +@@ -1162,18 +1162,27 @@ main (int argc, char **argv) + *ld1++ = *ld2++ = ld_file_name; + + /* Make temp file names. */ ++ ++#ifdef __DJGPP__ ++#define CDTOR_C_NAME ".ctc" ++#define CDTOR_O_NAME ".cto" ++#else ++#define CDTOR_C_NAME ".cdtor.c" ++#define CDTOR_O_NAME ".cdtor.o" ++#endif ++ + if (save_temps) + { +- c_file = concat (output_file, ".cdtor.c", NULL); +- o_file = concat (output_file, ".cdtor.o", NULL); ++ c_file = concat (output_file, CDTOR_C_NAME, NULL); ++ o_file = concat (output_file, CDTOR_O_NAME, NULL); + #ifdef COLLECT_EXPORT_LIST + export_file = concat (output_file, ".x", NULL); + #endif + } + else + { +- c_file = make_temp_file (".cdtor.c"); +- o_file = make_temp_file (".cdtor.o"); ++ c_file = make_temp_file (CDTOR_C_NAME); ++ o_file = make_temp_file (CDTOR_O_NAME); + #ifdef COLLECT_EXPORT_LIST + export_file = make_temp_file (".x"); + #endif +diff --git a/gcc/config/i386/djgpp.cc b/gcc/config/i386/djgpp.cc +index a553c771d4f1..0519294a6248 100644 +--- a/gcc/config/i386/djgpp.cc ++++ b/gcc/config/i386/djgpp.cc +@@ -36,6 +36,8 @@ i386_djgpp_asm_named_section(const char *name, unsigned int flags, + *f++ = 'w'; + if (flags & SECTION_CODE) + *f++ = 'x'; ++ if (flags & SECTION_BSS) ++ *f++ = 'b'; + + /* LTO sections need 1-byte alignment to avoid confusing the + zlib decompression algorithm with trailing zero pad bytes. */ +diff --git a/gcc/config/i386/xm-djgpp.h b/gcc/config/i386/xm-djgpp.h +index ee9e400be142..6b34b8c39814 100644 +--- a/gcc/config/i386/xm-djgpp.h ++++ b/gcc/config/i386/xm-djgpp.h +@@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see + #undef NATIVE_SYSTEM_HEADER_DIR + #define NATIVE_SYSTEM_HEADER_DIR "/dev/env/DJDIR/include/" + ++//#undef PREFIX_INCLUDE_DIR ++ + /* Search for as.exe and ld.exe in DJGPP's binary directory. */ + #undef MD_EXEC_PREFIX + #define MD_EXEC_PREFIX "/dev/env/DJDIR/bin/" +@@ -107,6 +109,11 @@ along with GCC; see the file COPYING3. If not see + (PATH) = xstrdup (fixed_path); \ + } + ++/* Rename libstdc++ to libstdcxx as the first name is not valid for DOS */ ++#define LIBSTDCXX "stdcxx" ++#define LIBSTDCXX_PROFILE "stdcxx" ++#define LIBSTDCXX_STATIC "stdcxx" ++ + #undef MAX_OFILE_ALIGNMENT + #define MAX_OFILE_ALIGNMENT 128 + +diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc +index f76fc03b76f..f4494be34e4 100644 +--- a/gcc/cp/mapper-client.cc ++++ b/gcc/cp/mapper-client.cc +@@ -19,7 +19,7 @@ along with GCC; see the file COPYING3. If not see + . */ + + #include "config.h" +-#if defined (__unix__) ++#if defined (__unix__) && !defined(__DJGPP__) + // Solaris11's socket header used bcopy, which we poison. cody.hh + // will include it later under the above check + #include +diff --git a/gcc/diagnostic-show-locus.cc b/gcc/diagnostic-show-locus.cc +index ceccc0b793d..047eab85ef8 100644 +--- a/gcc/diagnostic-show-locus.cc ++++ b/gcc/diagnostic-show-locus.cc +@@ -5796,7 +5796,9 @@ diagnostic_show_locus_cc_tests () + for_each_line_table_case (test_fixit_replace_containing_newline); + for_each_line_table_case (test_fixit_deletion_affecting_newline); + for_each_line_table_case (test_tab_expansion); ++#ifndef __DJGPP__ + for_each_line_table_case (test_escaping_bytes_1); ++#endif + for_each_line_table_case (test_escaping_bytes_2); + + test_line_numbers_multiline_range (); +diff --git a/gcc/gcov-tool.cc b/gcc/gcov-tool.cc +index 100f7357bcf..5955592bb92 100644 +--- a/gcc/gcov-tool.cc ++++ b/gcc/gcov-tool.cc +@@ -58,11 +58,18 @@ static bool verbose; + + /* Remove file NAME if it has a gcda suffix. */ + ++#ifdef __DJGPP__ ++static int ++unlink_gcda_file (const char *name, ++ struct stat *status ATTRIBUTE_UNUSED, ++ int type ATTRIBUTE_UNUSED) ++#else + static int + unlink_gcda_file (const char *name, + const struct stat *status ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, + struct FTW *ftwbuf ATTRIBUTE_UNUSED) ++#endif + { + int ret = 0; + int len = strlen (name); +@@ -84,7 +91,11 @@ static int + unlink_profile_dir (const char *path ATTRIBUTE_UNUSED) + { + #if HAVE_FTW_H ++#ifdef __DJGPP__ ++ return ftw(path, unlink_gcda_file, 64); ++#else + return nftw(path, unlink_gcda_file, 64, FTW_DEPTH | FTW_PHYS); ++#endif + #else + return -1; + #endif +diff --git a/gcc/ggc-common.cc b/gcc/ggc-common.cc +index caf456f7244..b0d385116d5 100644 +--- a/gcc/ggc-common.cc ++++ b/gcc/ggc-common.cc +@@ -31,6 +31,12 @@ along with GCC; see the file COPYING3. If not see + #include "plugin.h" + #include "options.h" + ++#ifdef __DJGPP__ ++extern "C" { ++#include ++} ++#endif ++ + /* When true, protect the contents of the identifier hash table. */ + bool ggc_protect_identifiers = true; + +diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h +index 47f41f90fedc..685cad344bff 100644 +--- a/gcc/ginclude/float.h ++++ b/gcc/ginclude/float.h +@@ -25,6 +25,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + * ISO C Standard: 5.2.4.2.2 Characteristics of floating types + */ + ++#ifdef __DJGPP__ ++#include_next ++#endif ++ + #ifndef _FLOAT_H___ + #define _FLOAT_H___ + +diff --git a/include/libiberty.h b/include/libiberty.h +index 32385911690..b22dbc7ea26 100644 +--- a/include/libiberty.h ++++ b/include/libiberty.h +@@ -108,6 +108,7 @@ extern int countargv (char * const *); + #if defined (__GNU_LIBRARY__ ) || defined (__linux__) \ + || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) \ + || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) \ ++ || defined (__DJGPP__) \ + || defined (__DragonFly__) || defined (HAVE_DECL_BASENAME) + extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1); + #else +diff --git a/libcody/cody.hh b/libcody/cody.hh +index 789ce9e70b7..8794e4dd8e6 100644 +--- a/libcody/cody.hh ++++ b/libcody/cody.hh +@@ -20,6 +20,12 @@ + #endif + #endif + ++// Do not use networking for DJGPP even if it defines __unix__ ++#ifdef __DJGPP__ ++#undef CODY_NETWORKING ++#define CODY_NETWORKING 0 ++#endif ++ + // C++ + #include + #include +diff --git a/libcpp/files.cc b/libcpp/files.cc +index c61df339e20..42a6888451d 100644 +--- a/libcpp/files.cc ++++ b/libcpp/files.cc +@@ -763,6 +763,10 @@ read_file_guts (cpp_reader *pfile, _cpp_file *file, location_t loc, + cpp_error_at (pfile, CPP_DL_WARNING, loc, + "%s is shorter than expected", file->path); + ++/* For DOS we should handle DOS EOF character (0x1A, ^Z). It is ++ only done if it is really the last character of the file */ ++ if (total>0 && buf[total-1]==0x1A) total--; ++ + file->buffer = _cpp_convert_input (pfile, + input_charset, + buf, size + 16, total, +diff --git a/libcpp/lex.cc b/libcpp/lex.cc +index c9e44e6cccc..4933e81dfbc 100644 +--- a/libcpp/lex.cc ++++ b/libcpp/lex.cc +@@ -505,6 +505,13 @@ init_vectorized_lexer (void) + search_line_fast_type impl = search_line_acc_char; + int minimum = 0; + ++// [FIXME][DJGPP] Using SSE here causes preprocessor to randomly ++// [FIXME][DJGPP] fail when run under Windows 10 32 bit (and maybe ++// [FIXME][DJGPP] some other systems (I have observed similar ++// [FIXME][DJGPP] behavior earlier with DJGPP v2.03p2 under Windows ++// [FIXME][DJGPP] Vista ++#ifndef __DJGPP__ ++ + #if defined(__SSE4_2__) + minimum = 3; + #elif defined(__SSE2__) +@@ -531,6 +538,8 @@ init_vectorized_lexer (void) + impl = search_line_mmx; + } + ++#endif // __DJGPP__ ++ + search_line_fast = impl; + } + +diff --git a/libffi/src/x86/sysv.S b/libffi/src/x86/sysv.S +index c7a0fb51b48c..5c724e24d8ba 100644 +--- a/libffi/src/x86/sysv.S ++++ b/libffi/src/x86/sysv.S +@@ -968,7 +968,7 @@ ENDF(C(__x86.get_pc_thunk.dx)) + #ifdef __APPLE__ + .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support + EHFrame0: +-#elif defined(X86_WIN32) ++#elif defined(X86_WIN32) || defined(__DJGPP__) + .section .eh_frame,"r" + #elif defined(HAVE_AS_X86_64_UNWIND_SECTION_TYPE) + .section .eh_frame,EH_FRAME_FLAGS,@unwind +diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c +index ba4b90a480d..e5652169bb2 100644 +--- a/libgcc/libgcov-util.c ++++ b/libgcc/libgcov-util.c +@@ -381,7 +381,11 @@ read_gcda_file (const char *filename) + + static int + ftw_read_file (const char *filename, ++#ifdef __DJGPP__ ++ struct stat *status ATTRIBUTE_UNUSED, ++#else + const struct stat *status ATTRIBUTE_UNUSED, ++#endif + int type) + { + size_t filename_len; +diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h +index 9d83a27ed90..10d638a5055 100644 +--- a/libgcc/libgcov.h ++++ b/libgcc/libgcov.h +@@ -159,6 +159,11 @@ extern struct gcov_info *gcov_list; + + #endif /* !IN_GCOV_TOOL */ + ++#ifdef __DJGPP__ ++#include ++#undef HAVE_SYS_MMAN_H ++#endif // __DJGPP__ ++ + #if defined(inhibit_libc) + #define IN_LIBGCOV (-1) + #else +diff --git a/libgfortran/intrinsics/chmod.c b/libgfortran/intrinsics/chmod.c +index 47502a7e9ec3..a9297ccb9de9 100644 +--- a/libgfortran/intrinsics/chmod.c ++++ b/libgfortran/intrinsics/chmod.c +@@ -445,7 +445,7 @@ clause_done: + if ((ugo[2] || honor_umask) && !rwxXstugo[8]) + file_mode = (file_mode & ~(S_IROTH | S_IWOTH | S_IXOTH)) + | (new_mode & (S_IROTH | S_IWOTH | S_IXOTH)); +-#ifndef __VXWORKS__ ++#if !defined(__VXWORKS__) && !defined(__DJGPP__) + if (is_dir && rwxXstugo[5]) + file_mode |= S_ISVTX; + else if (!is_dir) +@@ -457,7 +457,7 @@ clause_done: + { + /* Clear '-'. */ + file_mode &= ~new_mode; +-#if !defined( __MINGW32__) && !defined (__VXWORKS__) ++#if !defined( __MINGW32__) && !defined (__VXWORKS__) && !defined(__DJGPP__) + if (rwxXstugo[5] || !is_dir) + file_mode &= ~S_ISVTX; + #endif +@@ -465,7 +465,7 @@ clause_done: + else if (set_mode == 3) + { + file_mode |= new_mode; +-#if !defined (__MINGW32__) && !defined (__VXWORKS__) ++#if !defined (__MINGW32__) && !defined (__VXWORKS__) && !defined(__DJGPP__) + if (rwxXstugo[5] && is_dir) + file_mode |= S_ISVTX; + else if (!is_dir) +diff --git a/libgfortran/intrinsics/execute_command_line.c b/libgfortran/intrinsics/execute_command_line.c +index 9bf009e0f620..0a5c6fbdd3f4 100644 +--- a/libgfortran/intrinsics/execute_command_line.c ++++ b/libgfortran/intrinsics/execute_command_line.c +@@ -98,7 +98,7 @@ execute_command_line (const char *command, bool wait, int *exitstat, + + set_cmdstat (cmdstat, EXEC_NOERROR); + +-#if defined(HAVE_SIGACTION) && defined(HAVE_WAITPID) ++#if defined(HAVE_SIGACTION) && defined(HAVE_WAITPID) && !defined(__DJGPP__) + static bool sig_init_saved; + bool sig_init = __atomic_load_n (&sig_init_saved, __ATOMIC_RELAXED); + if (!sig_init) +diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c +index 16600c855f2c..8ab0585ac74e 100644 +--- a/libgfortran/io/unix.c ++++ b/libgfortran/io/unix.c +@@ -221,6 +221,9 @@ typedef struct + } + unix_stream; + ++#ifdef __DJGPP__ ++#include ++#endif + + /* fix_fd()-- Given a file descriptor, make sure it is not one of the + standard descriptors, returning a non-standard descriptor. If the +@@ -1221,8 +1224,13 @@ tempfile_open (const char *tempdir, char **fname) + char *template = xmalloc (tempdirlen + 23); + + #ifdef HAVE_MKSTEMP ++#ifdef __DJGPP__ ++ /* Default filename is too long for DOS */ ++ snprintf (template, tempdirlen + 23, "%s/gfXXXXXX", tempdir); ++#else + snprintf (template, tempdirlen + 23, "%s%sgfortrantmpXXXXXX", + tempdir, slash); ++#endif + + #ifdef HAVE_UMASK + /* Temporarily set the umask such that the file has 0600 permissions. */ +@@ -1588,6 +1596,13 @@ open_external (st_parameter_open *opp, unit_flags *flags) + return NULL; + fd = fix_fd (fd); + ++#ifdef __DJGPP__ ++ if (flags->form == FORM_UNFORMATTED) ++ { ++ setmode (fd, O_BINARY); ++ } ++#endif ++ + if (open_share (opp, fd, flags) < 0) + return NULL; + +diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c +index 23920a8b282..9be3222a06c 100644 +--- a/libiberty/make-relative-prefix.c ++++ b/libiberty/make-relative-prefix.c +@@ -65,6 +65,7 @@ relative prefix can be found, return @code{NULL}. + + #include "ansidecl.h" + #include "libiberty.h" ++#include "filenames.h" + + #ifndef R_OK + #define R_OK 4 +@@ -340,7 +341,7 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix, + { + for (i = 0; i < bin_num; i++) + { +- if (strcmp (prog_dirs[i], bin_dirs[i]) != 0) ++ if (FILENAME_CMP (prog_dirs[i], bin_dirs[i]) != 0) + break; + } + +@@ -356,7 +357,7 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix, + n = (prefix_num < bin_num) ? prefix_num : bin_num; + for (common = 0; common < n; common++) + { +- if (strcmp (bin_dirs[common], prefix_dirs[common]) != 0) ++ if (FILENAME_CMP (bin_dirs[common], prefix_dirs[common]) != 0) + break; + } + +diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c +index 23b467035d5..15e03693c1b 100644 +--- a/libiberty/make-temp-file.c ++++ b/libiberty/make-temp-file.c +@@ -52,6 +52,7 @@ Boston, MA 02110-1301, USA. */ + #endif + + #include "libiberty.h" ++#include "filenames.h" + extern int mkstemps (char *, int); + + /* '/' works just fine on MS-DOS based systems. */ +@@ -154,7 +155,8 @@ choose_tmpdir (void) + len = strlen (base); + tmpdir = XNEWVEC (char, len + 2); + strcpy (tmpdir, base); +- tmpdir[len] = DIR_SEPARATOR; ++ if (len>0 && !IS_DIR_SEPARATOR(tmpdir[len-1])) ++ tmpdir[len] = DIR_SEPARATOR; + tmpdir[len+1] = '\0'; + memoized_tmpdir = tmpdir; + #else /* defined(_WIN32) && !defined(__CYGWIN__) */ +diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c +index c09c216656c..fdd826a1aba 100644 +--- a/libiberty/simple-object-elf.c ++++ b/libiberty/simple-object-elf.c +@@ -1293,7 +1293,9 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj, + } + if (new_i - 1 >= SHN_LORESERVE) + { ++#ifdef ENOTSUP + *err = ENOTSUP; ++#endif + return "Too many copied sections"; + } + eow->shdrs = XNEWVEC (unsigned char, shdr_size * (new_i - 1)); +diff --git a/libquadmath/printf/quadmath-printf.h b/libquadmath/printf/quadmath-printf.h +index 32ebcec928cb..96498b7c4083 100644 +--- a/libquadmath/printf/quadmath-printf.h ++++ b/libquadmath/printf/quadmath-printf.h +@@ -29,7 +29,8 @@ Boston, MA 02110-1301, USA. */ + #ifdef HAVE_CTYPE_H + #include + #endif +-#ifdef HAVE_WCHAR_H ++#if defined(HAVE_WCHAR_H) && !defined(__DJGPP__) ++/* DJGPP wchar.h is not good enough */ + #include + #endif + #ifdef HAVE_WCTYPE_H +@@ -44,7 +45,7 @@ Boston, MA 02110-1301, USA. */ + #include "quadmath-imp.h" + #include "gmp-impl.h" + +-#ifdef HAVE_WCHAR_H ++#if defined(HAVE_WCHAR_H) && !defined(__DJGPP__) + #define L_(x) L##x + #else + #define L_(x) x +diff --git a/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc b/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc +index fc4fed3546c6..8dcc81460791 100644 +--- a/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc ++++ b/libstdc++-v3/config/os/djgpp/ctype_configure_char.cc +@@ -45,7 +45,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), +- _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), ++ _M_toupper(__dj_ctype_toupper+1), _M_tolower(__dj_ctype_tolower+1), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); +@@ -56,7 +56,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + + ctype::ctype(const mask* __table, bool __del, size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del), +- _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), ++ _M_toupper(__dj_ctype_toupper+1), _M_tolower(__dj_ctype_tolower+1), + _M_table(__table ? __table : classic_table()) + { + memset(_M_widen, 0, sizeof(_M_widen)); +diff --git a/libstdc++-v3/config/os/djgpp/error_constants.h b/libstdc++-v3/config/os/djgpp/error_constants.h +index 758507fb126d..fa5c753e7b4c 100644 +--- a/libstdc++-v3/config/os/djgpp/error_constants.h ++++ b/libstdc++-v3/config/os/djgpp/error_constants.h +@@ -33,16 +33,42 @@ + #include + #include + ++// Include Watt-32 errno list, if present ++#if defined __has_include && __has_include() ++#include ++#endif ++ ++#ifndef EOPNOTSUPP ++// Use same value as in wat3222br6.zip file net/watt/sys/djgpp.err ++#define EOPNOTSUPP 52 ++#endif ++ ++#ifndef ENOTSUP ++#define ENOTSUP 101 ++#endif ++ + namespace std _GLIBCXX_VISIBILITY(default) + { + _GLIBCXX_BEGIN_NAMESPACE_VERSION + + enum class errc + { +-// address_family_not_supported = EAFNOSUPPORT, +-// address_in_use = EADDRINUSE, +-// address_not_available = EADDRNOTAVAIL, +-// already_connected = EISCONN, ++#ifdef EAFNOSUPPORT ++ address_family_not_supported = EAFNOSUPPORT, ++#endif ++ ++#ifdef EADDRINUSE ++ address_in_use = EADDRINUSE, ++#endif ++ ++#ifdef EADDRNOTAVAIL ++ address_not_available = EADDRNOTAVAIL, ++#endif ++ ++#ifdef EISCONN ++ already_connected = EISCONN, ++#endif ++ + argument_list_too_long = E2BIG, + argument_out_of_domain = EDOM, + bad_address = EFAULT, +@@ -53,12 +79,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + #endif + + broken_pipe = EPIPE, +-// connection_aborted = ECONNABORTED, +-// connection_already_in_progress = EALREADY, +-// connection_refused = ECONNREFUSED, +-// connection_reset = ECONNRESET, ++ ++#ifdef ECONNABORTED ++ connection_aborted = ECONNABORTED, ++#endif ++ ++#ifdef EALREADY ++ connection_already_in_progress = EALREADY, ++#endif ++ ++#ifdef ECONNREFUSED ++ connection_refused = ECONNREFUSED, ++#endif ++ ++#ifdef ECONNRESET ++ connection_reset = ECONNRESET, ++#endif ++ + cross_device_link = EXDEV, +-// destination_address_required = EDESTADDRREQ, ++ ++#ifdef EDESTADDRREQ ++ destination_address_required = EDESTADDRREQ, ++#endif ++ + device_or_resource_busy = EBUSY, + directory_not_empty = ENOTEMPTY, + executable_format_error = ENOEXEC, +@@ -66,7 +109,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + file_too_large = EFBIG, + filename_too_long = ENAMETOOLONG, + function_not_supported = ENOSYS, +-// host_unreachable = EHOSTUNREACH, ++ ++#ifdef EHOSTUNREACH ++ host_unreachable = EHOSTUNREACH, ++#endif + + #ifdef EIDRM + identifier_removed = EIDRM, +@@ -79,11 +125,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + invalid_seek = ESPIPE, + io_error = EIO, + is_a_directory = EISDIR, +-// message_size = EMSGSIZE, +-// network_down = ENETDOWN, +-// network_reset = ENETRESET, +-// network_unreachable = ENETUNREACH, +-// no_buffer_space = ENOBUFS, ++ ++#ifdef EMSGSIZE ++ message_size = EMSGSIZE, ++#endif ++ ++#ifdef ENETDOWN ++ network_down = ENETDOWN, ++#endif ++ ++#ifdef ENETRESET ++ network_reset = ENETRESET, ++#endif ++ ++#ifdef ENETUNREACH ++ network_unreachable = ENETUNREACH, ++#endif ++ ++#ifdef ENOBUFS ++ no_buffer_space = ENOBUFS, ++#endif ++ + no_child_process = ECHILD, + + #ifdef ENOLINK +@@ -96,8 +158,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + no_message_available = ENODATA, + #endif + +-// no_message = ENOMSG, +-// no_protocol_option = ENOPROTOOPT, ++#ifdef ENOMSG ++ no_message = ENOMSG, ++#endif ++ ++#ifdef ENOPROTOOPT ++ no_protocol_option = ENOPROTOOPT, ++#endif ++ + no_space_on_device = ENOSPC, + + #ifdef ENOSR +@@ -109,13 +177,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + no_such_file_or_directory = ENOENT, + no_such_process = ESRCH, + not_a_directory = ENOTDIR, +-// not_a_socket = ENOTSOCK, ++ ++#ifdef ENOTSOCK ++ not_a_socket = ENOTSOCK, ++#endif + + #ifdef ENOSTR + not_a_stream = ENOSTR, + #endif + +-// not_connected = ENOTCONN, ++#ifdef ENOTCONN ++ not_connected = ENOTCONN, ++#endif ++ + not_enough_memory = ENOMEM, + + #ifdef ENOTSUP +@@ -126,10 +200,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + operation_canceled = ECANCELED, + #endif + +-// operation_in_progress = EINPROGRESS, ++#ifdef EINPROGRESS ++ operation_in_progress = EINPROGRESS, ++#endif ++ + operation_not_permitted = EPERM, +-// operation_not_supported = EOPNOTSUPP, +-// operation_would_block = EWOULDBLOCK, ++ operation_not_supported = EOPNOTSUPP, ++ ++#ifdef EWOULDBLOCK ++ operation_would_block = EWOULDBLOCK, ++#endif + + #ifdef EOWNERDEAD + owner_dead = EOWNERDEAD, +@@ -141,7 +221,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + protocol_error = EPROTO, + #endif + +-// protocol_not_supported = EPROTONOSUPPORT, ++#ifdef EPROTONOSUPPORT ++ protocol_not_supported = EPROTONOSUPPORT, ++#endif ++ + read_only_file_system = EROFS, + resource_deadlock_would_occur = EDEADLK, + resource_unavailable_try_again = EAGAIN, +@@ -159,7 +242,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + text_file_busy = ETXTBSY, + #endif + +-// timed_out = ETIMEDOUT, ++#ifdef ETIMEDOUT ++ timed_out = ETIMEDOUT, ++#endif ++ + too_many_files_open_in_system = ENFILE, + too_many_files_open = EMFILE, + too_many_links = EMLINK, +@@ -169,7 +255,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + value_too_large = EOVERFLOW, + #endif + +-// wrong_protocol_type = EPROTOTYPE ++#ifdef EPROTOTYPE ++ wrong_protocol_type = EPROTOTYPE ++#endif + }; + + _GLIBCXX_END_NAMESPACE_VERSION +diff --git a/libstdc++-v3/include/experimental/bits/fs_path.h b/libstdc++-v3/include/experimental/bits/fs_path.h +index 5008e26af8db..3591d6764be3 100644 +--- a/libstdc++-v3/include/experimental/bits/fs_path.h ++++ b/libstdc++-v3/include/experimental/bits/fs_path.h +@@ -53,6 +53,11 @@ + # include + #endif + ++#if defined(__DJGPP__) ++# define _GLIBCXX_FILESYSTEM_IS_DJGPP 1 ++# include ++#endif ++ + namespace std _GLIBCXX_VISIBILITY(default) + { + _GLIBCXX_BEGIN_NAMESPACE_VERSION +@@ -515,6 +520,8 @@ namespace __detail + { + #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + return __ch == L'/' || __ch == preferred_separator; ++#elif defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) ++ return __ch == '/' || __ch == '\\'; + #else + return __ch == '/'; + #endif +@@ -1027,6 +1034,9 @@ namespace __detail + #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + std::replace(_M_pathname.begin(), _M_pathname.end(), L'/', + preferred_separator); ++#elif defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) ++ std::replace(_M_pathname.begin(), _M_pathname.end(), '\\', ++ preferred_separator); + #endif + return *this; + } +@@ -1249,7 +1259,7 @@ namespace __detail + inline bool + path::is_absolute() const + { +-#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS ++#if defined(_GLIBCXX_FILESYSTEM_IS_WINDOWS) || defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) + return has_root_name() && has_root_directory(); + #else + return has_root_directory(); +diff --git a/libstdc++-v3/src/filesystem/path.cc b/libstdc++-v3/src/filesystem/path.cc +index 7dbbd4402004..5a87bfe13dbc 100644 +--- a/libstdc++-v3/src/filesystem/path.cc ++++ b/libstdc++-v3/src/filesystem/path.cc +@@ -411,8 +411,13 @@ path::_M_split_cmpts() + _M_add_root_dir(0); + ++pos; + } +-#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS ++#if defined(_GLIBCXX_FILESYSTEM_IS_WINDOWS) \ ++ || defined(_GLIBCXX_FILESYSTEM_IS_DJGPP) ++#ifdef __DJGPP__ ++ else if (len > 1 && pathname[1] == ':') ++#else + else if (len > 1 && pathname[1] == L':') ++#endif + { + // got disk designator + if (len == 2) diff --git a/patch/djgpp-gcc-14.1.0/0001-lto.patch b/patch/djgpp-gcc-14.1.0/0001-lto.patch new file mode 100644 index 0000000..50086a1 --- /dev/null +++ b/patch/djgpp-gcc-14.1.0/0001-lto.patch @@ -0,0 +1,10 @@ +--- a/configure ++++ b/configure +@@ -6177,7 +6177,7 @@ + # Among non-ELF, only Windows platforms support the lto-plugin so far. + # Build it unless LTO was explicitly disabled. + case $target in +- *-cygwin* | *-mingw*) build_lto_plugin=$enable_lto ;; ++ *-cygwin* | *-mingw* | *djgpp*) build_lto_plugin=$enable_lto ;; + *) ;; + esac diff --git a/script/check-deps-and-confirm.sh b/script/check-deps-and-confirm.sh index 8dce597..c87b72f 100644 --- a/script/check-deps-and-confirm.sh +++ b/script/check-deps-and-confirm.sh @@ -11,7 +11,7 @@ if [ -z ${IGNORE_DEPENDENCIES} ]; then done fi -if [ ! -z ${GCC_VERSION} ] && [ -z ${DJCROSS_GCC_ARCHIVE} ]; then +if [ ! -z ${GCC_VERSION} ] && [ -z ${DJCROSS_GCC_ARCHIVE} ] && [ "${DJCROSS_METHOD}" == 'djcross' ]; then DJCROSS_GCC_ARCHIVE="${DJGPP_DOWNLOAD_BASE}/djgpp/rpms/djcross-gcc-${GCC_VERSION}/djcross-gcc-${GCC_VERSION}.tar.bz2" # djcross-gcc-X.XX-tar.* maybe moved from /djgpp/rpms/ to /djgpp/deleted/rpms/ directory. OLD_DJCROSS_GCC_ARCHIVE=${DJCROSS_GCC_ARCHIVE/rpms\//deleted\/rpms\/} @@ -25,7 +25,7 @@ esac if [ ! -z ${BUILD_DEB} ] && [ ! -z ${GCC_VERSION} ]; then GMP_VERSION=${GMP_VERSION:-6.2.1} MPFR_VERSION=${MPFR_VERSION:-4.1.0} - MPC_VERSION=${MPC_VERSION:-1.2.0} + MPC_VERSION=${MPC_VERSION:-1.2.1} ISL_VERSION=${ISL_VERSION:-0.24} GMP_ARCHIVE="http://ftpmirror.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz"