Successful build of gcc 7.1.0

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Successful build of gcc 7.1.0

David Gressett-5
I have successfully built gcc 7.1.0 for MinGW

It would not build with the in-tree gmp, so I removed it and
the related mpfr and mpc. I kept isl and built using the
MinGW-supplied libraries. The gmp problem will become a separate
detective work project.

The patch situation has changed, as a number of the patches
that I needed in my previous 5.3.0 and 6.3.0 builds are no
longer needed; they have been applied to the upstream gcc sources.
I have added one completely new patch which fixes a build
failure in libstdc++. It is the last patch below. It is adequate
for building in the MinGW environment, but needs some #ifdef
improvements in order to be submitted to the upstream gcc project.

The pkgspec file that I used was  almost the same as the one I used
for mu 6.3.0  build. The configuration options that I used are shown
below:

# Configuration options for GCC build
#
option configure --prefix=/mingw
option configure --disable-win32-registry
option configure --target=$ARCH --with-arch=i586
option configure --enable-languages=c,c++,objc,obj-c++,fortran,ada
option configure --enable-static --enable-shared --enable-threads
option configure --with-dwarf2 --disable-sjlj-exceptions
option configure --enable-version-specific-runtime-libs
option configure --with-libiconv-prefix=/mingw
option configure --with-libintl-prefix=/mingw
option configure --enable-libstdcxx-debug
option configure --with-tune=generic
option configure --enable-libgomp
option configure --disable-libvtv
option configure --enable-nls

The patches are included below, and are delimited with lines of dashes.
Some of them are almost identical to the original patches for the
MinGW gcc 5.3 release, and so I have retained the original file names,
but all of these patches have been newly generated by using diff to
compare original and patched gcc 7.1.0 source code.

01-mingw-w64-brain-damage.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/gcc/config/i386/mingw32.h gcc-7.1.0-working/gcc/config/i386/mingw32.h
--- gcc-7.1.0-current/gcc/config/i386/mingw32.h 2017-01-17 01:23:40 -0600
+++ gcc-7.1.0-working/gcc/config/i386/mingw32.h 2017-05-02 14:49:43 -0500
@@ -159,22 +159,41 @@ along with GCC; see the file COPYING3.
    %{fvtable-verify=none:%s; \
     fvtable-verify=preinit:vtv_end.o%s; \
     fvtable-verify=std:vtv_end.o%s} \
   crtend.o%s"
 
-/* Override startfile prefix defaults.  */
+#if MINGW_W64_BRAIN_DAMAGE
+/* FIXME: override startfile prefix defaults; unconditionally disabled.
+
+   This may suit the mingw-w64 developers, but it seems to unnecessarily
+   restrict installation path choice; besides, the original defaults seem
+   to work just fine for me (KDM).  */
+
 #ifndef STANDARD_STARTFILE_PREFIX_1
 #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
 #endif
 #ifndef STANDARD_STARTFILE_PREFIX_2
 #define STANDARD_STARTFILE_PREFIX_2 ""
 #endif
 
-/* For native mingw-version we need to take care that NATIVE_SYSTEM_HEADER_DIR
-   macro contains POSIX-style path.  See bug 52947.  */
+/* FIXME: work around bug 52947; unconditionally disabled, for now.
+
+   This gross hack works around an issue when building under MSYS:
+   for native mingw-version we need to ensure that NATIVE_SYSTEM_HEADER_DIR
+   is defined to represent a POSIX-style path.  Unfortunately, MSYS passes
+   the definition from the makefile, after translation to a fully device
+   qualified native windows absolute path; TARGET_SYSTEM_ROOT is passed
+   in similarly translated format, and the concatenation of the pair
+   becomes invalid as a path name.
+
+   The hack may suit mingw-w64 developers, but it's too restrictive for
+   general use, and may even produce bogus path references, such as
+   described by bug 56279.  */
+
 #undef NATIVE_SYSTEM_HEADER_DIR
 #define NATIVE_SYSTEM_HEADER_DIR "/mingw/include"
+#endif /* MINGW_W64_BRAIN_DAMAGE */
 
 /* Output STRING, a string representing a filename, to FILE.
    We canonicalize it to be in Unix format (backslashes are replaced
    forward slashes.  */
 #undef OUTPUT_QUOTED_STRING
-----------------------------------------------------------------------


02-mingw32-float.h.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/gcc/ginclude/float.h gcc-7.1.0-working/gcc/ginclude/float.h
--- gcc-7.1.0-current/gcc/ginclude/float.h 2017-01-01 06:07:43 -0600
+++ gcc-7.1.0-working/gcc/ginclude/float.h 2017-05-02 15:17:02 -0500
@@ -501,6 +501,16 @@ see the files COPYING3 and COPYING.RUNTI
 #undef DEC_EVAL_METHOD
 #define DEC_EVAL_METHOD __DEC_EVAL_METHOD__
 
 #endif /* __STDC_WANT_DEC_FP__ */
 
+#if defined (__MINGW32__) && ! defined (_MINGW_FLOAT_H_)
+/* MinGW.org's runtime libraries provide a supplementary float.h, which
+ * must also be included to complement this one.  Ideally that MinGW.org
+ * header should be included first, and it will include this one, but in
+ * a default configuration it doesn't normally happen this way; when we
+ * didn't see it first, include the MinGW.org header now!
+ */
+# include_next <float.h>
+#endif
+
 #endif /* _FLOAT_H___ */
-----------------------------------------------------------------------


03-ada-largefile.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/gcc/ada/adaint.c gcc-7.1.0-working/gcc/ada/adaint.c
--- gcc-7.1.0-current/gcc/ada/adaint.c 2017-02-01 15:36:09 -0600
+++ gcc-7.1.0-working/gcc/ada/adaint.c 2017-05-02 15:40:03 -0500
@@ -1345,20 +1345,20 @@ win32_filetime (HANDLE h)
   return (time_t) 0;
 }
 
 /* As above but starting from a FILETIME.  */
 static void
-f2t (const FILETIME *ft, __time64_t *t)
+f2t (const FILETIME *ft, GNAT_TIME_T *t)
 {
   union
   {
     FILETIME ft_time;
     unsigned long long ull_time;
   } t_write;
 
   t_write.ft_time = *ft;
-  *t = (__time64_t) (t_write.ull_time / 10000000ULL - w32_epoch_offset);
+  *t = (GNAT_TIME_T) (t_write.ull_time / 10000000ULL - w32_epoch_offset);
 }
 #endif
 
 /* Return a GNAT time stamp given a file name.  */
 
@@ -1367,11 +1367,11 @@ __gnat_file_time_name_attr (char* name,
 {
    if (attr->timestamp == (OS_Time)-2) {
 #if defined (_WIN32)
       BOOL res;
       WIN32_FILE_ATTRIBUTE_DATA fad;
-      __time64_t ret = -1;
+      GNAT_TIME_T ret = -1;
       TCHAR wname[GNAT_MAX_PATH_LEN];
       S2WSC (wname, name, GNAT_MAX_PATH_LEN);
 
       if ((res = GetFileAttributesEx (wname, GetFileExInfoStandard, &fad)))
  f2t (&fad.ftLastWriteTime, &ret);
diff -pNar -U 5 gcc-7.1.0-current/gcc/ada/adaint.h gcc-7.1.0-working/gcc/ada/adaint.h
--- gcc-7.1.0-current/gcc/ada/adaint.h 2017-01-20 08:49:28 -0600
+++ gcc-7.1.0-working/gcc/ada/adaint.h 2017-05-02 15:42:33 -0500
@@ -57,17 +57,27 @@ extern "C" {
 #define GNAT_STAT stat64
 #define GNAT_FSTAT fstat64
 #define GNAT_LSTAT lstat64
 #define GNAT_STRUCT_STAT struct stat64
 
-#elif defined(_WIN32)
+#elif defined(_WIN64)
 #define GNAT_FOPEN fopen64
 #define GNAT_OPEN open
 #define GNAT_STAT stat64
 #define GNAT_FSTAT fstat64
 #define GNAT_LSTAT lstat
 #define GNAT_STRUCT_STAT struct stat64
+#define GNAT_TIME_T __time64_t
+
+#elif defined(_WIN32)
+#define GNAT_FOPEN fopen64
+#define GNAT_OPEN open
+#define GNAT_STAT _stati64
+#define GNAT_FSTAT _fstati64
+#define GNAT_LSTAT _stati64
+#define GNAT_STRUCT_STAT struct _stati64
+#define GNAT_TIME_T time_t
 
 #elif defined(__APPLE__)
 
 # include <TargetConditionals.h>
 
diff -pNar -U 5 gcc-7.1.0-current/gcc/ada/cstreams.c gcc-7.1.0-working/gcc/ada/cstreams.c
--- gcc-7.1.0-current/gcc/ada/cstreams.c 2016-04-18 07:27:10 -0500
+++ gcc-7.1.0-working/gcc/ada/cstreams.c 2017-05-02 15:58:57 -0500
@@ -262,11 +262,11 @@ __gnat_full_name (char *nam, char *buffe
 #endif
 
   return buffer;
 }
 
-#ifdef _WIN32
+#ifdef _WIN64
   /* On Windows we want to use the fseek/fteel supporting large files. This
      issue is due to the fact that a long on Win64 is still a 32 bits value */
 __int64
 __gnat_ftell64 (FILE *stream)
 {
-----------------------------------------------------------------------


04-eh-frame-begin.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/libgcc/config/i386/cygming-crtbegin.c gcc-7.1.0-working/libgcc/config/i386/cygming-crtbegin.c
--- gcc-7.1.0-current/libgcc/config/i386/cygming-crtbegin.c 2017-01-21 02:52:32 -0600
+++ gcc-7.1.0-working/libgcc/config/i386/cygming-crtbegin.c 2017-05-02 16:30:14 -0500
@@ -76,11 +76,11 @@ __deregister_frame_info (__attribute__((
 #endif
 
 /* Stick a label at the beginning of the frame unwind info so we can
    register/deregister it with the exception handling library code.  */
 #if DWARF2_UNWIND_INFO
-static EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]
+EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]
   __attribute__((used, section(__LIBGCC_EH_FRAME_SECTION_NAME__), aligned(4)))
   = { };
 
 static struct object obj;
 
-----------------------------------------------------------------------


05-ssp-wincrypt.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/libssp/ssp.c gcc-7.1.0-working/libssp/ssp.c
--- gcc-7.1.0-current/libssp/ssp.c 2017-04-01 19:35:58 -0500
+++ gcc-7.1.0-working/libssp/ssp.c 2017-05-02 16:49:17 -0500
@@ -64,10 +64,14 @@ see the files COPYING3 and COPYING.RUNTI
 #endif
 #ifdef HAVE_SYSLOG_H
 # include <syslog.h>
 #endif
 
+#if defined (_WIN32) && !defined (__CYGWIN__)
+#include <wincrypt.h>
+#endif
+
 void *__stack_chk_guard = 0;
 
 static void __attribute__ ((constructor))
 __guard_setup (void)
 {
-----------------------------------------------------------------------


06-fortran-ldflags.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/libgfortran/Makefile.am gcc-7.1.0-working/libgfortran/Makefile.am
--- gcc-7.1.0-current/libgfortran/Makefile.am 2017-01-17 03:38:48 -0600
+++ gcc-7.1.0-working/libgfortran/Makefile.am 2017-05-02 17:01:31 -0500
@@ -44,11 +44,11 @@ libgfortran_la_LDFLAGS = -version-info `
 libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
 
 cafexeclib_LTLIBRARIES = libcaf_single.la
 cafexeclibdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
 libcaf_single_la_SOURCES = caf/single.c
-libcaf_single_la_LDFLAGS = -static
+libcaf_single_la_LDFLAGS = -static -no-undefined
 libcaf_single_la_DEPENDENCIES = caf/libcaf.h
 libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS)
 
 if IEEE_SUPPORT
 fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
diff -pNar -U 5 gcc-7.1.0-current/libgfortran/Makefile.in gcc-7.1.0-working/libgfortran/Makefile.in
--- gcc-7.1.0-current/libgfortran/Makefile.in 2017-05-02 07:43:57 -0500
+++ gcc-7.1.0-working/libgfortran/Makefile.in 2017-05-02 17:03:13 -0500
@@ -588,11 +588,11 @@ libgfortran_la_LDFLAGS = -version-info `
 
 libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
 cafexeclib_LTLIBRARIES = libcaf_single.la
 cafexeclibdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
 libcaf_single_la_SOURCES = caf/single.c
-libcaf_single_la_LDFLAGS = -static
+libcaf_single_la_LDFLAGS = -static -static -no-undefined
 libcaf_single_la_DEPENDENCIES = caf/libcaf.h
 libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS)
 @IEEE_SUPPORT_TRUE@fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
 @IEEE_SUPPORT_TRUE@nodist_finclude_HEADERS = ieee_arithmetic.mod ieee_exceptions.mod ieee_features.mod
 AM_CPPFLAGS = -iquote$(srcdir)/io -I$(srcdir)/$(MULTISRCTOP)../gcc \
-----------------------------------------------------------------------


07-ada-gnattools.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/gnattools/Makefile.in gcc-7.1.0-working/gnattools/Makefile.in
--- gcc-7.1.0-current/gnattools/Makefile.in 2016-05-16 03:55:12 -0500
+++ gcc-7.1.0-working/gnattools/Makefile.in 2017-05-02 18:13:36 -0500
@@ -195,11 +195,11 @@ gnattools-native: $(GCC_DIR)/stamp-tools
  $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
   $(TOOLS_FLAGS_TO_PASS_NATIVE) \
   ../../gnatmake$(exeext) ../../gnatlink$(exeext)
  # gnattools2
  $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
-  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
+  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools $(EXTRA_GNATTOOLS)
 
 # gnatmake/link can be built with recent gnatmake/link if they are available.
 # This is especially convenient for building cross tools or for rebuilding
 # the tools when the original bootstrap has already be done.
 regnattools: $(GCC_DIR)/stamp-gnatlib-rts
@@ -207,20 +207,20 @@ regnattools: $(GCC_DIR)/stamp-gnatlib-rt
  $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
   $(TOOLS_FLAGS_TO_PASS_RE) INCLUDES="" \
   gnatmake-re gnatlink-re
  # gnattools2
  $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
-  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
+  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools $(EXTRA_GNATTOOLS)
 
 gnattools-cross: $(GCC_DIR)/stamp-tools
  # gnattools1-re
  $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
   $(TOOLS_FLAGS_TO_PASS_CROSS) INCLUDES="" \
   gnatmake-re gnatlink-re
  # gnattools2
  $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
-  $(TOOLS_FLAGS_TO_PASS_CROSS) common-tools
+  $(TOOLS_FLAGS_TO_PASS_CROSS) common-tools $(EXTRA_GNATTOOLS)
 
 # Other
 # -----
 
 # Check uninstalled version.
-----------------------------------------------------------------------


08-libiberty-lrealpath.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/libiberty/lrealpath.c gcc-7.1.0-working/libiberty/lrealpath.c
--- gcc-7.1.0-current/libiberty/lrealpath.c 2017-01-04 05:30:51 -0600
+++ gcc-7.1.0-working/libiberty/lrealpath.c 2017-05-02 18:26:27 -0500
@@ -136,18 +136,30 @@ lrealpath (const char *filename)
      It also converts all forward slashes to back slashes.  */
 #if defined (_WIN32)
   {
     char buf[MAX_PATH];
     char* basename;
+ char* slash;
     DWORD len = GetFullPathName (filename, MAX_PATH, buf, &basename);
     if (len == 0 || len > MAX_PATH - 1)
       return strdup (filename);
     else
       {
- /* The file system is case-preserving but case-insensitive,
-   Canonicalize to lowercase, using the codepage associated
-   with the process locale.  */
+ /* Turn all back slashes back back into forward slashes
+   and don't make it all lowercase.
+   Rationale:
+   Windows is as happy with / as it is with \. This will
+   have been built using Cygwin, MSYS* or cross-compiled
+   from a system where dirsep is / so it is cleaner just
+   to keep the dirseps as / (and the case un-modified).
+   This way, the value will be consistent with the build
+   system and string operations (be they internal to this
+   software or external to it, e.g. processing map files
+   with sed) work as expected.  */
+ slash = buf;
+ while ((slash = strchr(slash,'\\')) !=  NULL)
+    *slash = '/';
         CharLowerBuff (buf, len);
         return strdup (buf);
       }
   }
 #endif
-----------------------------------------------------------------------


09-ada-implibs.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/gcc/ada/gcc-interface/Makefile.in gcc-7.1.0-working/gcc/ada/gcc-interface/Makefile.in
--- gcc-7.1.0-current/gcc/ada/gcc-interface/Makefile.in 2017-03-28 05:29:34 -0500
+++ gcc-7.1.0-working/gcc/ada/gcc-interface/Makefile.in 2017-05-02 18:39:49 -0500
@@ -2850,17 +2850,19 @@ gnatlib-shared-default:
                 | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \
  $(PICFLAG_FOR_TARGET) \
  -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
  $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
  $(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ -Wl,-out-implib,libgnat$(hyphen)$(LIBRARY_VERSION).dll.a \
  $(MISCLIB) -lm
  cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
                 | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \
  $(PICFLAG_FOR_TARGET) \
  -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
  $(GNATRTL_TASKING_OBJS) \
  $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ -Wl,-out-implib,libgnarl$(hyphen)$(LIBRARY_VERSION).dll.a \
  $(THREADSLIB)
  cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
  libgnat$(soext)
  cd $(RTSDIR); $(LN_S) libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
  libgnarl$(soext)
-----------------------------------------------------------------------


10-libstdcpp-aligned-alloc.patch
-----------------------------------------------------------------------
diff -pNar -U 5 gcc-7.1.0-current/libstdc++-v3/libsupc++/del_opa.cc gcc-7.1.0-working/libstdc++-v3/libsupc++/del_opa.cc
--- gcc-7.1.0-current/libstdc++-v3/libsupc++/del_opa.cc 2017-01-26 08:30:45 -0600
+++ gcc-7.1.0-working/libstdc++-v3/libsupc++/del_opa.cc 2017-05-02 18:50:00 -0500
@@ -22,10 +22,11 @@
 // a copy of the GCC Runtime Library Exception along with this program;
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
 #include <bits/c++config.h>
+#include <malloc.h>
 
 #if !_GLIBCXX_HOSTED
 // A freestanding C runtime may not provide "free" -- but there is no
 // other reasonable way to implement "operator delete".
 namespace std
@@ -48,11 +49,11 @@ operator delete(void* ptr, std::align_va
 {
 #if _GLIBCXX_HAVE_ALIGNED_ALLOC || _GLIBCXX_HAVE_POSIX_MEMALIGN \
     || _GLIBCXX_HAVE_MEMALIGN
   std::free (ptr);
 #elif _GLIBCXX_HAVE__ALIGNED_MALLOC
-  _aligned_free (ptr);
+  __mingw_aligned_free (ptr);
 #else
   if (ptr)
     std::free (((void **) ptr)[-1]); // See aligned_alloc in new_opa.cc
 #endif
 }
diff -pNar -U 5 gcc-7.1.0-current/libstdc++-v3/libsupc++/new_opa.cc gcc-7.1.0-working/libstdc++-v3/libsupc++/new_opa.cc
--- gcc-7.1.0-current/libstdc++-v3/libsupc++/new_opa.cc 2017-01-26 08:30:45 -0600
+++ gcc-7.1.0-working/libstdc++-v3/libsupc++/new_opa.cc 2017-05-02 18:52:08 -0500
@@ -24,18 +24,19 @@
 // <http://www.gnu.org/licenses/>.
 
 #include <bits/c++config.h>
 #include <stdlib.h>
 #include <bits/exception_defines.h>
+#include <malloc.h>
 #include "new"
 
 using std::new_handler;
 using std::bad_alloc;
 
 #if !_GLIBCXX_HAVE_ALIGNED_ALLOC
 #if _GLIBCXX_HAVE__ALIGNED_MALLOC
-#define aligned_alloc(al,sz) _aligned_malloc(sz,al)
+#define aligned_alloc(al,sz) __mingw_aligned_malloc(sz,al)
 #elif _GLIBCXX_HAVE_POSIX_MEMALIGN
 static inline void*
 aligned_alloc (std::size_t al, std::size_t sz)
 {
   void *ptr;
-----------------------------------------------------------------------










------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-dvlpr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-dvlpr