PATCH: allow linking with msvcrtd.dll by using -mmsvcrtd

David Fraser <[email protected]> Wed, 19 Feb 2003 14:04:55 +0200
Newsgroups gmane.comp.gnu.mingw.patches
Message-ID <[email protected]>
Hi

This patch allows linking with msvcrtd.dll. It builds libmsvcrtd.a and 
libmoldnamed.a (which is the same as libmoldname, but links to 
msvcrtd.dll instead of msvcrt.dll).

I have also included a patch for gcc specs which links to msvcrtd 
instead of msvcrt if -mmsvcrtd is specified. (This is important, 
-lmsvcrtd won't work because links to msvcrt are created by -mwindows).

I'm not sure what the best thing to do with the patch to gcc specs is as 
it probably belongs to cygwin, not mingw.

David
msvcrtd.patch (text/plain, 10.5 KB)
Index: Makefile.in
===================================================================
RCS file: /cvsroot/mingw/runtime/Makefile.in,v
retrieving revision 1.18
diff -u -r1.18 Makefile.in
--- Makefile.in	8 Feb 2003 14:59:32 -0000	1.18
+++ Makefile.in	19 Feb 2003 11:19:19 -0000
@@ -154,8 +154,8 @@
 	     pseudo-reloc.o pseudo-reloc-list.o
 MOLD_OBJS = ctype_old.o string_old.o
 
-LIBS = libcrtdll.a libmsvcrt.a libmsvcrt20.a libmsvcrt40.a libmingw32.a \
-       libcoldname.a libmoldname.a $(LIBM_A) libmingwthrd.a
+LIBS = libcrtdll.a libmsvcrt.a libmsvcrtd.a libmsvcrt20.a libmsvcrt40.a libmingw32.a \
+       libcoldname.a libmoldname.a libmoldnamed.a $(LIBM_A) libmingwthrd.a
 
 DLLS = $(THREAD_DLL_NAME)
 
@@ -163,7 +163,7 @@
 Makefile.in README TODO config.guess config.sub configure configure.in \
 crt1.c crtdll.def crtmt.c crtst.c ctype_old.c  dllcrt1.c dllmain.c \
 gccmain.c init.c install-sh jamfile main.c mkinstalldirs moldname-crtdll.def \
-moldname-msvcrt.def moldname.def moldname.def.in msvcrt.def msvcrt20.def \
+moldname-msvcrt.def moldname.def moldname.def.in msvcrt.def msvcrtd.def msvcrt20.def \
 msvcrt40.def mthr.c mthr_init.c mthr_stub.c readme.txt string_old.c \
 CRT_fp8.c CRT_fp10.c test_headers.c txtmode.c binmode.c pseudo-reloc.c \
 pseudo-reloc-list.c
@@ -256,6 +256,14 @@
 	$(AR) rc $@ $(MOLD_OBJS)
 	$(RANLIB) $@
 
+libmoldnamed.a: $(srcdir)/moldname-msvcrt.def $(MOLD_OBJS)
+	$(DLLTOOL) --as $(AS) -k -U	\
+		--dllname msvcrtd.dll	\
+		--def $(srcdir)/moldname-msvcrt.def	\
+		--output-lib $@
+	$(AR) rc $@ $(MOLD_OBJS)
+	$(RANLIB) $@
+
 # The special rules are necessary.
 crt1.o dllcrt1.o:
 	$(CC) -c -D__CRTDLL__ -U__MSVCRT__ $(ALL_CFLAGS) $< -o $@
@@ -399,6 +407,7 @@
 #
 libcrtdll.a: $(srcdir)/crtdll.def
 libmsvcrt.a: $(srcdir)/msvcrt.def
+libmsvcrtd.a: $(srcdir)/msvcrtd.def
 libmsvcrt20.a: $(srcdir)/msvcrt20.def
 libmsvcrt40.a: $(srcdir)/msvcrt40.def
 CRT_noglob.o: $(srcdir)/CRT_noglob.c
Index: msvcrtd.def
===================================================================
RCS file: /cvsroot/mingw/runtime/msvcrtd.def,v
retrieving revision 0.0
diff -u /dev/null msvcrtd.def
--- /dev/null	Thu Apr 11 16:25:15 2002
+++ msvcrtd.def	Fri Jun 14 17:12:54 2002
@@ -0,0 +1,737 @@
+;
+; msvcrt.def
+;
+; Exports from msvcrt.dll. Msvcrt.dll appears to be distributed with
+; Internet Explorer 4.0, and may be more common in the future, but
+; right now it seems like a risky choice. There are differences, although
+; they seem to be minor overall, between the exports from msvcrt and msvcrt20.
+; However, for most purposes the two sets are interchangable.
+;
+; NOTE: All exports, except for what appeared to be C++ mangled names,
+;       are included. Not all functions have prototypes in the headers
+;       (and some aren't functions at all).
+;
+; Contributors:
+;  Created by Colin Peters <[email protected]>
+;
+;  THIS SOFTWARE IS NOT COPYRIGHTED
+;
+;  This source code is offered for use in the public domain. You may
+;  use, modify or distribute it freely.
+;
+;  This code is distributed in the hope that it will be useful but
+;  WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
+;  DISCLAMED. This includes but is not limited to warrenties of
+;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+;
+; $Revision: 1.5 $
+; $Author: earnie $
+; $Date: 2002/06/14 15:12:54 $
+;
+EXPORTS
+_CIacos
+_CIasin
+_CIatan
+_CIatan2
+_CIcos
+_CIcosh
+_CIexp
+_CIfmod
+_CIlog
+_CIlog10
+_CIpow
+_CIsin
+_CIsinh
+_CIsqrt
+_CItan
+_CItanh
+_CxxThrowException
+_EH_prolog
+_Getdays
+_Getmonths
+_Gettnames
+_HUGE DATA
+_Strftime
+_XcptFilter
+__CxxFrameHandler
+__CxxLongjmpUnwind
+__RTCastToVoid
+__RTDynamicCast
+__RTtypeid
+__STRINGTOLD
+__argc DATA
+__argv DATA
+__badioinfo
+__crtCompareStringA
+__crtGetLocaleInfoW
+__crtLCMapStringA
+__dllonexit
+__doserrno
+__fpecode
+__getmainargs
+__initenv DATA
+__isascii
+__iscsym
+__iscsymf
+__lc_codepage
+__lc_handle
+__lconv_init
+__mb_cur_max DATA
+__p___argc
+__p___argv
+__p___initenv
+__p___mb_cur_max
+__p___wargv
+__p___winitenv
+__p__acmdln
+__p__amblksiz
+__p__commode
+__p__daylight
+__p__dstbias
+__p__environ
+__p__fileinfo
+__p__fmode
+__p__iob
+__p__mbctype
+__p__osver
+__p__pctype
+__p__pgmptr
+__p__pwctype
+__p__timezone
+__p__tzname
+__p__wcmdln
+__p__wenviron
+__p__winmajor
+__p__winminor
+__p__winver
+__p__wpgmptr
+__pioinfo
+__pxcptinfoptrs
+__set_app_type
+__setlc_active
+__setusermatherr
+__threadhandle
+__threadid
+__toascii
+__unDName
+__unguarded_readlc_active
+__wargv DATA
+__wgetmainargs
+__winitenv DATA
+_abnormal_termination
+_access
+_acmdln DATA
+_adj_fdiv_m16i
+_adj_fdiv_m32
+_adj_fdiv_m32i
+_adj_fdiv_m64
+_adj_fdiv_r
+_adj_fdivr_m16i
+_adj_fdivr_m32
+_adj_fdivr_m32i
+_adj_fdivr_m64
+_adj_fpatan
+_adj_fprem
+_adj_fprem1
+_adj_fptan
+_adjust_fdiv DATA
+_aexit_rtn DATA
+_amsg_exit
+_assert
+_atodbl
+_atoi64
+_atoldbl
+_beep
+_beginthread
+_beginthreadex
+_c_exit
+_cabs
+_callnewh
+_cexit
+_cgets
+_chdir
+_chdrive
+_chgsign
+_chmod
+_chsize
+_clearfp
+_close
+_commit
+_commode DATA
+_control87
+_controlfp
+_copysign
+_cprintf
+_cputs
+_creat
+_cscanf
+_ctype DATA
+_cwait
+_daylight DATA
+_dstbias
+_dup
+_dup2
+_ecvt
+_endthread
+_endthreadex
+_environ DATA
+_eof
+_errno
+_except_handler2
+_except_handler3
+_execl
+_execle
+_execlp
+_execlpe
+_execv
+_execve
+_execvp
+_execvpe
+_exit
+_expand
+_fcloseall
+_fcvt
+_fdopen
+_fgetchar
+_fgetwchar
+_filbuf
+_fileinfo DATA
+_filelength
+_filelengthi64
+_fileno
+_findclose
+_findfirst
+_findfirsti64
+_findnext
+_findnexti64
+_finite
+_flsbuf
+_flushall
+_fmode DATA
+_fpclass
+_fpieee_flt
+_fpreset DATA
+_fputchar
+_fputwchar
+_fsopen
+_fstat
+_fstati64
+_ftime
+_ftol
+_fullpath
+_futime
+_gcvt
+_get_osfhandle
+_get_sbh_threshold
+_getch
+_getche
+_getcwd
+_getdcwd
+_getdiskfree
+_getdllprocaddr
+_getdrive
+_getdrives
+_getmaxstdio
+_getmbcp
+_getpid
+_getsystime
+_getw
+_getws
+_global_unwind2
+_heapadd
+_heapchk
+_heapmin
+_heapset
+_heapused
+_heapwalk
+_hypot
+_i64toa
+_i64tow
+_initterm
+_inp
+_inpd
+_inpw
+_iob DATA
+_isatty
+_isctype
+_ismbbalnum
+_ismbbalpha
+_ismbbgraph
+_ismbbkalnum
+_ismbbkana
+_ismbbkprint
+_ismbbkpunct
+_ismbblead
+_ismbbprint
+_ismbbpunct
+_ismbbtrail
+_ismbcalnum
+_ismbcalpha
+_ismbcdigit
+_ismbcgraph
+_ismbchira
+_ismbckata
+_ismbcl0
+_ismbcl1
+_ismbcl2
+_ismbclegal
+_ismbclower
+_ismbcprint
+_ismbcpunct
+_ismbcspace
+_ismbcsymbol
+_ismbcupper
+_ismbslead
+_ismbstrail
+_isnan
+_itoa
+_itow
+_j0
+_j1
+_jn
+_kbhit
+_lfind
+_loaddll
+_local_unwind2
+_lock
+_locking
+_logb
+_longjmpex
+_lrotl
+_lrotr
+_lsearch
+_lseek
+_lseeki64
+_ltoa
+_ltow
+_makepath
+_mbbtombc
+_mbbtype
+_mbccpy
+_mbcjistojms
+_mbcjmstojis
+_mbclen
+_mbctohira
+_mbctokata
+_mbctolower
+_mbctombb
+_mbctoupper
+_mbctype DATA
+_mbsbtype
+_mbscat
+_mbschr
+_mbscmp
+_mbscoll
+_mbscpy
+_mbscspn
+_mbsdec
+_mbsdup
+_mbsicmp
+_mbsicoll
+_mbsinc
+_mbslen
+_mbslwr
+_mbsnbcat
+_mbsnbcmp
+_mbsnbcnt
+_mbsnbcoll
+_mbsnbcpy
+_mbsnbicmp
+_mbsnbicoll
+_mbsnbset
+_mbsncat
+_mbsnccnt
+_mbsncmp
+_mbsncoll
+_mbsncpy
+_mbsnextc
+_mbsnicmp
+_mbsnicoll
+_mbsninc
+_mbsnset
+_mbspbrk
+_mbsrchr
+_mbsrev
+_mbsset
+_mbsspn
+_mbsspnp
+_mbsstr
+_mbstok
+_mbstrlen
+_mbsupr
+_memccpy
+_memicmp
+_mkdir
+_mktemp
+_msize
+_nextafter
+_onexit DATA
+_open
+_open_osfhandle
+_osver DATA
+_outp
+_outpd
+_outpw
+_pclose
+_pctype DATA
+_pgmptr DATA
+_pipe
+_popen
+_purecall
+_putch
+_putenv
+_putw
+_putws
+_pwctype DATA
+_read
+_rmdir
+_rmtmp
+_rotl
+_rotr
+_safe_fdiv
+_safe_fdivr
+_safe_fprem
+_safe_fprem1
+_scalb
+_searchenv
+_seh_longjmp_unwind
+_set_error_mode
+_set_sbh_threshold
+_seterrormode
+_setjmp
+_setjmp3
+_setmaxstdio
+_setmbcp
+_setmode
+_setsystime
+_sleep
+_snprintf
+_snwprintf
+_sopen
+_spawnl
+_spawnle
+_spawnlp
+_spawnlpe
+_spawnv
+_spawnve
+_spawnvp
+_spawnvpe
+_splitpath
+_stat
+_stati64
+_statusfp
+_strcmpi
+_strdate
+_strdup
+_strerror
+_stricmp
+_stricoll
+_strlwr
+_strncoll
+_strnicmp
+_strnicoll
+_strnset
+_strrev
+_strset
+_strtime
+_strupr
+_swab
+_sys_errlist DATA
+_sys_nerr DATA
+_tell
+_telli64
+_tempnam
+_timezone DATA
+_tolower
+_toupper
+_tzname DATA
+_tzset
+_ui64toa
+_ui64tow
+_ultoa
+_ultow
+_umask
+_ungetch
+_unlink
+_unloaddll
+_unlock
+_utime
+_vsnprintf
+_vsnwprintf
+_waccess
+_wasctime
+_wchdir
+_wchmod
+_wcmdln DATA
+_wcreat
+_wcsdup
+_wcsicmp
+_wcsicoll
+_wcslwr
+_wcsncoll
+_wcsnicmp
+_wcsnicoll
+_wcsnset
+_wcsrev
+_wcsset
+_wcsupr
+_wctime
+_wenviron DATA
+_wexecl
+_wexecle
+_wexeclp
+_wexeclpe
+_wexecv
+_wexecve
+_wexecvp
+_wexecvpe
+_wfdopen
+_wfindfirst
+_wfindfirsti64
+_wfindnext
+_wfindnexti64
+_wfopen
+_wfreopen
+_wfsopen
+_wfullpath
+_wgetcwd
+_wgetdcwd
+_wgetenv
+_winmajor DATA
+_winminor DATA
+_winver DATA
+_wmakepath
+_wmkdir
+_wmktemp
+_wopen
+_wperror
+_wpgmptr DATA
+_wpopen
+_wputenv
+_wremove
+_wrename
+_write
+_wrmdir
+_wsearchenv
+_wsetlocale
+_wsopen
+_wspawnl
+_wspawnle
+_wspawnlp
+_wspawnlpe
+_wspawnv
+_wspawnve
+_wspawnvp
+_wspawnvpe
+_wsplitpath
+_wstat
+_wstati64
+_wstrdate
+_wstrtime
+_wsystem
+_wtempnam
+_wtmpnam
+_wtoi
+_wtoi64
+_wtol
+_wunlink
+_wutime
+_y0
+_y1
+_yn
+abort
+abs
+acos
+asctime
+asin
+atan
+atan2
+atexit DATA
+atof
+atoi
+atol
+bsearch
+calloc
+ceil
+clearerr
+clock
+cos
+cosh
+ctime
+difftime
+div
+exit
+exp
+fabs
+fclose
+feof
+ferror
+fflush
+fgetc
+fgetpos
+fgets
+fgetwc
+fgetws
+floor
+fmod
+fopen
+fprintf
+fputc
+fputs
+fputwc
+fputws
+fread
+free
+freopen
+frexp
+fscanf
+fseek
+fsetpos
+ftell
+fwprintf
+fwrite
+fwscanf
+getc
+getchar
+getenv
+gets
+getwc
+getwchar
+gmtime
+is_wctype
+isalnum
+isalpha
+iscntrl
+isdigit
+isgraph
+isleadbyte
+islower
+isprint
+ispunct
+isspace
+isupper
+iswalnum
+iswalpha
+iswascii
+iswcntrl
+iswctype
+iswdigit
+iswgraph
+iswlower
+iswprint
+iswpunct
+iswspace
+iswupper
+iswxdigit
+isxdigit
+labs
+ldexp
+ldiv
+localeconv
+localtime
+log
+log10
+longjmp
+malloc
+mblen
+mbstowcs
+mbtowc
+memchr
+memcmp
+memcpy
+memmove
+memset
+mktime
+modf
+perror
+pow
+printf
+putc
+putchar
+puts
+putwc
+putwchar
+qsort
+raise
+rand
+realloc
+remove
+rename
+rewind
+scanf
+setbuf
+setlocale
+setvbuf
+signal
+sin
+sinh
+sprintf
+sqrt
+srand
+sscanf
+strcat
+strchr
+strcmp
+strcoll
+strcpy
+strcspn
+strerror
+strftime
+strlen
+strncat
+strncmp
+strncpy
+strpbrk
+strrchr
+strspn
+strstr
+strtod
+strtok
+strtol
+strtoul
+strxfrm
+swprintf
+swscanf
+system
+tan
+tanh
+time
+tmpfile
+tmpnam
+tolower
+toupper
+towlower
+towupper
+ungetc
+ungetwc
+vfprintf
+vfwprintf
+vprintf
+vsprintf
+vswprintf
+vwprintf
+wcscat
+wcschr
+wcscmp
+wcscoll
+wcscpy
+wcscspn
+wcsftime
+wcslen
+wcsncat
+wcsncmp
+wcsncpy
+wcspbrk
+wcsrchr
+wcsspn
+wcsstr
+wcstod
+wcstok
+wcstol
+wcstombs
+wcstoul
+wcsxfrm
+wctomb
+wprintf
+wscanf
+
msvcrtd-specs.patch (text/plain, 797 B)
diff -u /usr/local/src/cross-compile/gcc-i386-mingw32msvc/gcc/specs /usr/local/cross-tools/lib/gcc-lib/i386-mingw32msvc/3.2/specs
--- /usr/local/src/cross-compile/gcc-i386-mingw32msvc/gcc/specs       Fri Sep 27 15:24:13 2002
+++ /usr/local/cross-tools/lib/gcc-lib/i386-mingw32msvc/3.2/specs       Wed Feb 19 12:38:06 2003
@@ -48,7 +48,7 @@
 %{pg:-lgmon} %{mwindows:-lgdi32 -lcomdlg32}                   -luser32 -lkernel32 -ladvapi32 -lshell32

 *libgcc:
-%{mthreads:-lmingwthrd} -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt
+%{mthreads:-lmingwthrd} -lmingw32 -lgcc %{mmsvcrtd: -lmoldnamed} %{!mmsvcrtd: -lmoldname} -lmingwex %{mmsvcrtd: -lmsvcrtd} %{!mmsvcrtd: -lmsvcrt}

 *startfile:
 %{shared|mdll:dllcrt2%O%s}   %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s}   %{!fno-exceptions:crtbegin%O%s}