| 1 |
/* Operating system specific defines to be used when targeting GCC for |
| 2 |
hosting on Windows 32/64 via mingw-w64 runtime, using GNU tools and |
| 3 |
the Windows API Library. |
| 4 |
Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 5 |
|
| 6 |
This file is part of GCC. |
| 7 |
|
| 8 |
GCC is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GCC is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with GCC; see the file COPYING3. If not see |
| 20 |
<http://www.gnu.org/licenses/>. */ |
| 21 |
|
| 22 |
/* Enable -municode feature and support optional pthread support. */ |
| 23 |
|
| 24 |
#undef CPP_SPEC |
| 25 |
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \ |
| 26 |
"%{municode:-DUNICODE} " \ |
| 27 |
"%{" SPEC_PTHREAD1 ":-D_REENTRANT} " \ |
| 28 |
"%{" SPEC_PTHREAD2 ":-U_REENTRANT} " \ |
| 29 |
"%{mcrtdll=crtdll*:-U__MSVCRT__ -D__CRTDLL__} " \ |
| 30 |
"%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \ |
| 31 |
"%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \ |
| 32 |
"%{mcrtdll=msvcrt40*:-D__MSVCRT_VERSION__=0x400} " \ |
| 33 |
"%{mcrtdll=msvcr40*:-D__MSVCRT_VERSION__=0x400} " \ |
| 34 |
"%{mcrtdll=msvcrtd*:-D__MSVCRT_VERSION__=0x600} " \ |
| 35 |
"%{mcrtdll=msvcrt-os*:-D__MSVCRT_VERSION__=0x700} " \ |
| 36 |
"%{mcrtdll=msvcr70*:-D__MSVCRT_VERSION__=0x700} " \ |
| 37 |
"%{mcrtdll=msvcr71*:-D__MSVCRT_VERSION__=0x701} " \ |
| 38 |
"%{mcrtdll=msvcr80*:-D__MSVCRT_VERSION__=0x800} " \ |
| 39 |
"%{mcrtdll=msvcr90*:-D__MSVCRT_VERSION__=0x900} " \ |
| 40 |
"%{mcrtdll=msvcr100*:-D__MSVCRT_VERSION__=0xA00} " \ |
| 41 |
"%{mcrtdll=msvcr110*:-D__MSVCRT_VERSION__=0xB00} " \ |
| 42 |
"%{mcrtdll=msvcr120*:-D__MSVCRT_VERSION__=0xC00} " \ |
| 43 |
"%{mcrtdll=ucrt*:-D_UCRT} " |
| 44 |
|
| 45 |
#undef REAL_LIBGCC_SPEC |
| 46 |
#define REAL_LIBGCC_SPEC \ |
| 47 |
"%{mthreads:-lmingwthrd} -lmingw32 \ |
| 48 |
" SHARED_LIBGCC_SPEC " \ |
| 49 |
-lmingwex %{!mcrtdll=*:-lmsvcrt} %{mcrtdll=*:-l%*} \ |
| 50 |
-lkernel32 " MCFGTHREAD_SPEC |
| 51 |
|
| 52 |
#undef STARTFILE_SPEC |
| 53 |
#define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \ |
| 54 |
%{!shared:%{!mdll:%{!municode:crt2%O%s}}} \ |
| 55 |
%{!shared:%{!mdll:%{municode:crt2u%O%s}}} \ |
| 56 |
%{pg:gcrt2%O%s} \ |
| 57 |
crtbegin.o%s \ |
| 58 |
%{fvtable-verify=none:%s; \ |
| 59 |
fvtable-verify=preinit:vtv_start.o%s; \ |
| 60 |
fvtable-verify=std:vtv_start.o%s}" |
| 61 |
|
| 62 |
/* Enable multilib. */ |
| 63 |
|
| 64 |
#undef ASM_SPEC |
| 65 |
#define ASM_SPEC "%{m32:--32} %{m64:--64}" |
| 66 |
|
| 67 |
#undef LIB_SPEC |
| 68 |
#define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \ |
| 69 |
"%{" SPEC_PTHREAD2 ": } " \ |
| 70 |
"%{mwindows:-lgdi32 -lcomdlg32} " \ |
| 71 |
"%{fvtable-verify=preinit:-lvtv -lpsapi; \ |
| 72 |
fvtable-verify=std:-lvtv -lpsapi} " \ |
| 73 |
"-ladvapi32 -lshell32 -luser32 -lkernel32" |
| 74 |
|
| 75 |
#undef SPEC_32 |
| 76 |
#undef SPEC_64 |
| 77 |
#if TARGET_64BIT_DEFAULT |
| 78 |
#define SPEC_32 "m32" |
| 79 |
#define SPEC_64 "!m32" |
| 80 |
#else |
| 81 |
#define SPEC_32 "!m64" |
| 82 |
#define SPEC_64 "m64" |
| 83 |
#endif |
| 84 |
|
| 85 |
#undef SUB_LINK_ENTRY32 |
| 86 |
#undef SUB_LINK_ENTRY64 |
| 87 |
#define SUB_LINK_ENTRY32 "-e _DllMainCRTStartup@12" |
| 88 |
#if defined(USE_MINGW64_LEADING_UNDERSCORES) |
| 89 |
#define SUB_LINK_ENTRY64 "-e _DllMainCRTStartup" |
| 90 |
#else |
| 91 |
#define SUB_LINK_ENTRY64 "-e DllMainCRTStartup" |
| 92 |
#endif |
| 93 |
|
| 94 |
#undef SUB_LINK_SPEC |
| 95 |
#undef SUB_LINK_ENTRY |
| 96 |
#define SUB_LINK_SPEC "%{" SPEC_64 ":-m i386pep} %{" SPEC_32 ":-m i386pe}" |
| 97 |
#define SUB_LINK_ENTRY "%{" SPEC_64 ":" SUB_LINK_ENTRY64 "} %{" SPEC_32 ":" SUB_LINK_ENTRY32 "}" |
| 98 |
|
| 99 |
#undef MULTILIB_DEFAULTS |
| 100 |
#if TARGET_64BIT_DEFAULT |
| 101 |
#define MULTILIB_DEFAULTS { "m64" } |
| 102 |
#else |
| 103 |
#define MULTILIB_DEFAULTS { "m32" } |
| 104 |
#endif |
| 105 |
|
| 106 |
#undef LINK_SPEC_LARGE_ADDR_AWARE |
| 107 |
#if MINGW_DEFAULT_LARGE_ADDR_AWARE |
| 108 |
# define LINK_SPEC_LARGE_ADDR_AWARE \ |
| 109 |
"%{!shared:%{!mdll:%{" SPEC_32 ":--large-address-aware}}}" |
| 110 |
#else |
| 111 |
# define LINK_SPEC_LARGE_ADDR_AWARE "" |
| 112 |
#endif |
| 113 |
|
| 114 |
#undef LINK_SPEC_DISABLE_DYNAMICBASE |
| 115 |
#if HAVE_LD_PE_DISABLE_DYNAMICBASE |
| 116 |
# define LINK_SPEC_DISABLE_DYNAMICBASE \ |
| 117 |
"%{!shared:%{!mdll:%{no-pie:--disable-dynamicbase}}}" |
| 118 |
#else |
| 119 |
# define LINK_SPEC_DISABLE_DYNAMICBASE "" |
| 120 |
#endif |
| 121 |
|
| 122 |
#undef LINK_SPEC |
| 123 |
#define LINK_SPEC SUB_LINK_SPEC " %{mwindows:--subsystem windows} \ |
| 124 |
%{mconsole:--subsystem console} \ |
| 125 |
%{shared: %{mdll: %eshared and mdll are not compatible}} \ |
| 126 |
%{shared: --shared} %{mdll:--dll} \ |
| 127 |
%{static:-Bstatic} %{!static:-Bdynamic} \ |
| 128 |
%{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \ |
| 129 |
" LINK_SPEC_LARGE_ADDR_AWARE "\ |
| 130 |
" LINK_SPEC_DISABLE_DYNAMICBASE "\ |
| 131 |
%(shared_libgcc_undefs)" |
| 132 |
|
| 133 |
/* Enable sincos optimization, overriding cygming.h. sincos, sincosf |
| 134 |
and sincosl functions are available on mingw-w64, but not on the |
| 135 |
original mingw32. */ |
| 136 |
#undef TARGET_LIBC_HAS_FUNCTION |
| 137 |
#define TARGET_LIBC_HAS_FUNCTION gnu_libc_has_function |