Commits

Iain Buclaw committed 4c48cc8

Re-apply relocatable executable with MinGW patches.

  • Participants
  • Parent commits bc121f1

Comments (0)

Files changed (3)

 gcc_d_target_include_dir=$(gcc_d_include_dir)/$(target_noncanonical)
 
 ifeq ($(D_gcc_main_ver),4.6)
-  D_EXTRA_DEFINES += -DLIBPHOBOS=\"gphobos$(D_ver_suffix)\"
+  D_LIBPHOBOS = -DLIBPHOBOS=\"gphobos$(D_ver_suffix)\"
 else
-  D_EXTRA_DEFINES += -DLIBPHOBOS=\"-lgphobos$(D_ver_suffix)\" 
+  D_LIBPHOBOS = -DLIBPHOBOS=\"-lgphobos$(D_ver_suffix)\" 
 endif
 
 D_EXTRA_DEFINES += -DD_GCC_VER=$(subst .,,$(D_gcc_main_ver))
-#D_EXTRA_DEFINES += -DD_PHOBOS_DIR=\"$(gcc_d_include_dir)\"
-#D_EXTRA_DEFINES += -DD_PHOBOS_TARGET_DIR=\"$(gcc_d_target_include_dir)\"
+
+# May be adjusted in d-incpath.cc
+PHOBOS_DIRS = -DD_PHOBOS_DIR=\"$(gcc_d_include_dir)\"
+PHOBOS_DIRS += -DD_PHOBOS_TARGET_DIR=\"$(gcc_d_target_include_dir)\"
 
 # Actual names to use when installing a cross-compiler.
 D_CROSS_NAME = $(D_INSTALL_NAME)
 	@ ls d/id.h
 
 d/d-confdefs.h: d/Make-lang.in
-	echo "#define D_PHOBOS_DIR \""$(gcc_d_include_dir)"\"" > $@
-	echo "#define D_PHOBOS_TARGET_DIR \""$(gcc_d_target_include_dir)"\"" >> $@
+	#echo "#define D_PHOBOS_DIR \""$(gcc_d_include_dir)"\"" > $@
+	#echo "#define D_PHOBOS_TARGET_DIR \""$(gcc_d_target_include_dir)"\"" >> $@
 	$(srcdir)/d/target-ver-syms.sh $(target) >> $@
 
+d/d-incpath.glue.o: d/d-incpath.cc $(D_TREE_H) d/d-confdefs.h
+	$(CXX) $(ALL_D_CXXFLAGS) $(PHOBOS_DIRS) -DGCC_SAFE_DMD=1 -o $@ -c $<
+
 d/id.gen.o: d/id.c $(D_DMD_H)
 d/impcnvtab.gen.o: d/impcnvtab.c $(D_DMD_H)
 d/d-lang.glue.o: d/d-lang.cc $(D_TREE_H) d/d-confdefs.h options.h
 d/d-gt.cglue.o: d/d-gt.c $(D_TREE_H)
 d/d-builtins.cglue.o: d/d-builtins.c $(D_TREE_H) $(D_BI_ATTRS)
 d/d-builtins2.glue.o: d/d-builtins.c $(D_TREE_H)
-d/d-incpath.glue.o: d/d-incpath.cc $(D_TREE_H) d/d-confdefs.h
 d/todt.dmd.o: $(D_DMD_H)
 d/toobj.dmd.o: $(D_DMD_H)
 d/typinf.dmd.o: $(D_DMD_H)
 	(SHLIB_LINK='$(SHLIB_LINK)' \
 	SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
-		$(ALL_D_CFLAGS) \
+		$(ALL_D_CFLAGS) $(D_LIBPHOBOS) \
 		$(INCLUDES) -o $@ $(srcdir)/d/d-spec.c)
 
 D_ALL_OBJS = $(D_GENERATED_OBJS) $(D_BORROWED_C_OBJS) $(D_DMD_OBJS) $(D_GLUE_OBJS)
 static char * make_absolute (char * path);
 
 
+/* support for the -mno-cygwin switch copied from cygwin.h, cygwin2.c  */
+#ifndef CYGWIN_MINGW_SUBDIR
+#define CYGWIN_MINGW_SUBDIR "/mingw"
+#endif
+#define CYGWIN_MINGW_SUBDIR_LEN (sizeof (CYGWIN_MINGW_SUBDIR) - 1)
+
+char cygwin_d_phobos_dir[sizeof(D_PHOBOS_DIR) + 1
+        + (CYGWIN_MINGW_SUBDIR_LEN)] = D_PHOBOS_DIR;
+#undef D_PHOBOS_DIR
+#define D_PHOBOS_DIR (cygwin_d_phobos_dir)
+char cygwin_d_target_dir[sizeof(D_PHOBOS_TARGET_DIR) + 1
+        + (CYGWIN_MINGW_SUBDIR_LEN)] = D_PHOBOS_TARGET_DIR;
+#undef D_PHOBOS_TARGET_DIR
+#define D_PHOBOS_TARGET_DIR (cygwin_d_target_dir)
+
+static void
+maybe_fixup_phobos_target()
+{
+#ifdef D_OS_VERSYM
+    char * env = getenv("GCC_CYGWIN_MINGW");
+    char * p;
+    char ** av;
+
+    static char *d_cvt_to_mingw[] = {
+        cygwin_d_phobos_dir,
+        cygwin_d_target_dir,
+        NULL
+    };
+    if (!strcmp(D_OS_VERSYM, "Cygwin") && env && *env == '1')
+    {
+        for (av = d_cvt_to_mingw; *av; av++)
+        {
+            int sawcygwin = 0;
+            while ((p = strstr (*av, "-cygwin")))
+            {
+                char *over = p + sizeof ("-cygwin") - 1;
+                memmove (over + 1, over, strlen (over));
+                memcpy (p, "-mingw32", sizeof("-mingw32") - 1);
+                p = ++over;
+                while (ISALNUM (*p))
+                    p++;
+                strcpy (over, p);
+                sawcygwin = 1;
+            }
+            if (!sawcygwin && !strstr (*av, "mingw"))
+                strcat (*av, CYGWIN_MINGW_SUBDIR);
+        }
+    }
+#endif
+}
+
 /* Read ENV_VAR for a PATH_SEPARATOR-separated list of file names; and
    append all the names to the import search path.  */
 
 void
 register_import_chains ()
 {
+    maybe_fixup_phobos_target();
+
     // %%TODO: front or back?
     if (std_inc)
     {
 }
 #endif
 
-// support for the -mno-cygwin switch
-// copied from cygwin.h, cygwin2.c
-#ifndef CYGWIN_MINGW_SUBDIR
-#define CYGWIN_MINGW_SUBDIR "/mingw"
-#endif
-#define CYGWIN_MINGW_SUBDIR_LEN (sizeof (CYGWIN_MINGW_SUBDIR) - 1)
-
-char cygwin_d_phobos_dir[sizeof(D_PHOBOS_DIR) + 1
-        + (CYGWIN_MINGW_SUBDIR_LEN)] = D_PHOBOS_DIR;
-#undef D_PHOBOS_DIR
-#define D_PHOBOS_DIR (cygwin_d_phobos_dir)
-char cygwin_d_target_dir[sizeof(D_PHOBOS_TARGET_DIR) + 1
-        + (CYGWIN_MINGW_SUBDIR_LEN)] = D_PHOBOS_TARGET_DIR;
-#undef D_PHOBOS_TARGET_DIR
-#define D_PHOBOS_TARGET_DIR (cygwin_d_target_dir)
-
 #ifdef D_OS_VERSYM
 const char * cygwin_d_os_versym = D_OS_VERSYM;
 #undef D_OS_VERSYM
 #define D_OS_VERSYM cygwin_d_os_versym
 #endif
 
-void
-maybe_fixup_cygwin()
+static void
+maybe_fixup_os_versym()
 {
 #ifdef D_OS_VERSYM
     char * env = getenv("GCC_CYGWIN_MINGW");
-    char * p;
-    char ** av;
 
-    static char *d_cvt_to_mingw[] = {
-        cygwin_d_phobos_dir,
-        cygwin_d_target_dir,
-        NULL
-    };
-    if (!strcmp(cygwin_d_os_versym,"cygwin") && env && *env == '1')
+    if (!strcmp(D_OS_VERSYM, "Cygwin") && env && *env == '1')
     {
         cygwin_d_os_versym = "Win32";
-
-        for (av = d_cvt_to_mingw; *av; av++)
-        {
-            int sawcygwin = 0;
-            while ((p = strstr (*av, "-cygwin")))
-            {
-                char *over = p + sizeof ("-cygwin") - 1;
-                memmove (over + 1, over, strlen (over));
-                memcpy (p, "-mingw32", sizeof("-mingw32") - 1);
-                p = ++over;
-                while (ISALNUM (*p))
-                    p++;
-                strcpy (over, p);
-                sawcygwin = 1;
-            }
-            if (!sawcygwin && !strstr (*av, "mingw"))
-                strcat (*av, CYGWIN_MINGW_SUBDIR);
-        }
     }
 #endif
 }
     gcc_d_backend_init();
     real_t::init();
 
-    maybe_fixup_cygwin();
+    maybe_fixup_os_versym();
 
     VersionCondition::addPredefinedGlobalIdent("GNU");
 #if V2