Commit c04bdac0 by Kai Tietz

config.gcc (*-*-mingw*): Allow as option the posix threading model.

2011-04-01  Kai Tietz  <ktietz@redhat.com>

	* config.gcc (*-*-mingw*): Allow as option the
	posix threading model.
	* config/i386/mingw32.h ( SPEC_PTHREAD1,  SPEC_PTHREAD2):
	New macros defined dependent to TARGET_USE_PTHREAD_BY_DEFAULT
	definition.
	(CPP_SPEC): Add pthread/no-pthread handling.
	(LIB_SPEC): Likewise.
	* config/i386/mingw-w64.h (CPP_SPEC):Likewise.
	(LIB_SPEC): Likewise.
	* config/i386/t-cygming (SHLIB_PTHREAD_CFLAG): New
	flag to pass -pthread option for shared libgcc build.
	(SHLIB_PTHREAD_LDFLAG): New option to pass -lpthread
	for shared libgcc build.
	* config/i386/t-mingw-pthread: New file.
	* config/i386/mingw-pthread.h (TARGET_USE_PTHREAD_BY_DEFAULT):
	New define to enable use of library pthread by default.
	* config/i386/mingw.opt (pthread): New driver option.
	(no-pthread): New driver option.
	* config/i386/cygming.opt: Make sure trailing empty line
	is retained.
	* config/i386/mingw-w64.opt: Likewise.

From-SVN: r171833
parent 636b4106
......@@ -1410,7 +1410,7 @@ i[34567]86-*-cygwin*)
use_gcc_stdint=wrap
;;
i[34567]86-*-mingw* | x86_64-*-mingw*)
tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h dbxcoff.h i386/cygming.h i386/mingw32.h"
tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h dbxcoff.h i386/cygming.h"
xm_file=i386/xm-mingw32.h
case ${target} in
x86_64-*-* | *-w64-*)
......@@ -1420,6 +1420,10 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
*)
;;
esac
if test x$enable_threads = xposix ; then
tm_file="${tm_file} i386/mingw-pthread.h"
fi
tm_file="${tm_file} i386/mingw32.h"
# This makes the logic if mingw's or the w64 feature set has to be used
case ${target} in
*-w64-*)
......@@ -1490,6 +1494,10 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
"" | yes | win32) thread_file='win32'
tmake_file="${tmake_file} i386/t-gthr-win32"
;;
posix)
thread_file='posix'
tmake_file="i386/t-mingw-pthread ${tmake_file}"
;;
esac
case ${target} in
x86_64-*-mingw*)
......
......@@ -52,3 +52,5 @@ Compile code that relies on Cygwin DLL wrappers to support C++ operator new/dele
posix
Driver
; Retain blank line above
/* Operating system specific defines to be used when targeting GCC for
hosting on Windows 32/64 via mingw-w64 runtime, using GNU tools and
the Windows API Library.
Copyright (C) 2009,
2010 Free Software Foundation, Inc.
Copyright (C) 2009, 2010,
2011 Free Software Foundation, Inc.
This file is part of GCC.
......@@ -20,11 +20,13 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Enable -municode feature. */
/* Enable -municode feature and support optional pthread support. */
#undef CPP_SPEC
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} \
%{municode:-DUNICODE}"
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \
"%{municode:-DUNICODE} " \
"%{" SPEC_PTHREAD1 ":-D_REENTRANCE} " \
"%{" SPEC_PTHREAD2 ":-U_REENTRANCE} "
#undef STARTFILE_SPEC
#define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
......@@ -38,6 +40,12 @@ along with GCC; see the file COPYING3. If not see
#undef ASM_SPEC
#define ASM_SPEC "%{m32:--32} %{m64:--64}"
#undef LIB_SPEC
#define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \
"%{" SPEC_PTHREAD2 ": } " \
"%{mwindows:-lgdi32 -lcomdlg32} " \
"-ladvapi32 -lshell32 -luser32 -lkernel32"
#undef SPEC_32
#undef SPEC_64
#if TARGET_64BIT_DEFAULT
......
......@@ -21,3 +21,5 @@
municode
Target
Use unicode startup and define UNICODE macro
; Retain blank line above.
......@@ -18,6 +18,12 @@
; along with GCC; see the file COPYING3. If not see
; <http://www.gnu.org/licenses/>.
pthread
Driver
no-pthread
Driver
Wpedantic-ms-format
C ObjC C++ ObjC++ Var(warn_pedantic_ms_format) Init(1) Warning
Warn about none ISO msvcrt scanf/printf width extensions
......@@ -25,3 +31,5 @@ Warn about none ISO msvcrt scanf/printf width extensions
fset-stack-executable
Common Report Var(flag_setstackexecutable) Init(1) Optimization
For nested functions on stack executable permission is set.
; Need to retain blank line above.
......@@ -43,6 +43,14 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
#ifndef TARGET_USE_PTHREAD_BY_DEFAULT
#define SPEC_PTHREAD1 "pthread"
#define SPEC_PTHREAD2 "!no-pthread"
#else
#define SPEC_PTHREAD1 "!no-pthread"
#define SPEC_PTHREAD2 "pthread"
#endif
#undef SUB_LINK_ENTRY32
#undef SUB_LINK_ENTRY64
#define SUB_LINK_ENTRY32 "-e _DllMainCRTStartup@12"
......@@ -67,13 +75,17 @@ along with GCC; see the file COPYING3. If not see
#define STANDARD_INCLUDE_COMPONENT "MINGW"
#undef CPP_SPEC
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT}"
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \
"%{" SPEC_PTHREAD1 ":-D_REENTRANCE} " \
"%{" SPEC_PTHREAD2 ": } "
/* For Windows applications, include more libraries, but always include
kernel32. */
#undef LIB_SPEC
#define LIB_SPEC "%{pg:-lgmon} %{mwindows:-lgdi32 -lcomdlg32} \
-ladvapi32 -lshell32 -luser32 -lkernel32"
#define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \
"%{" SPEC_PTHREAD2 ": } " \
"%{mwindows:-lgdi32 -lcomdlg32} " \
"-ladvapi32 -lshell32 -luser32 -lkernel32"
/* Weak symbols do not get resolved if using a Windows dll import lib.
Make the unwind registration references strong undefs. */
......
......@@ -77,16 +77,23 @@ SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual@
ifndef SHLIB_DLLDIR
$(error SHLIB_DLLDIR must be defined)
endif
ifndef SHLIB_PTHREAD_CFLAG
SHLIB_PTHREAD_CFLAG =
endif
ifndef SHLIB_PTHREAD_LDFLAG
SHLIB_PTHREAD_LDFLAG =
endif
SHLIB_LINK = $(LN_S) -f $(SHLIB_MAP) $(SHLIB_MAP).def && \
if [ ! -d $(SHLIB_DIR) ]; then \
mkdir $(SHLIB_DIR); \
else true; fi && \
$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(SHLIB_PTHREAD_CFLAG) \
-shared -nodefaultlibs \
$(SHLIB_MAP).def \
-Wl,--out-implib,$(SHLIB_DIR)/$(SHLIB_IMPLIB).tmp \
-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
$(SHLIB_OBJS) $(SHLIB_LC) && \
$(SHLIB_OBJS) ${SHLIB_PTHREAD_LDFLAG} $(SHLIB_LC) && \
if [ -f $(SHLIB_DIR)/$(SHLIB_SONAME) ]; then \
mv -f $(SHLIB_DIR)/$(SHLIB_SONAME) \
$(SHLIB_DIR)/$(SHLIB_SONAME).backup; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment