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-2023 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  
      30  #undef STARTFILE_SPEC
      31  #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
      32    %{!shared:%{!mdll:%{!municode:crt2%O%s}}} \
      33    %{!shared:%{!mdll:%{municode:crt2u%O%s}}} \
      34    %{pg:gcrt2%O%s} \
      35    crtbegin.o%s \
      36    %{fvtable-verify=none:%s; \
      37      fvtable-verify=preinit:vtv_start.o%s; \
      38      fvtable-verify=std:vtv_start.o%s}"
      39  
      40  /* Enable multilib.  */
      41  
      42  #undef ASM_SPEC
      43  #define ASM_SPEC "%{m32:--32} %{m64:--64}"
      44  
      45  #undef LIB_SPEC
      46  #define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \
      47  		 "%{" SPEC_PTHREAD2 ": } " \
      48  		 "%{mwindows:-lgdi32 -lcomdlg32} " \
      49       "%{fvtable-verify=preinit:-lvtv -lpsapi; \
      50          fvtable-verify=std:-lvtv -lpsapi} " \
      51  		 "-ladvapi32 -lshell32 -luser32 -lkernel32"
      52  
      53  #undef SPEC_32
      54  #undef SPEC_64
      55  #if TARGET_64BIT_DEFAULT
      56  #define SPEC_32 "m32"
      57  #define SPEC_64 "!m32"
      58  #else
      59  #define SPEC_32 "!m64"
      60  #define SPEC_64 "m64"
      61  #endif
      62  
      63  #undef SUB_LINK_ENTRY32
      64  #undef SUB_LINK_ENTRY64
      65  #define SUB_LINK_ENTRY32 "-e _DllMainCRTStartup@12"
      66  #if defined(USE_MINGW64_LEADING_UNDERSCORES)
      67  #define SUB_LINK_ENTRY64 "-e _DllMainCRTStartup"
      68  #else
      69  #define SUB_LINK_ENTRY64 "-e DllMainCRTStartup"
      70  #endif
      71  
      72  #undef SUB_LINK_SPEC
      73  #undef SUB_LINK_ENTRY
      74  #define SUB_LINK_SPEC "%{" SPEC_64 ":-m i386pep} %{" SPEC_32 ":-m i386pe}"
      75  #define SUB_LINK_ENTRY "%{" SPEC_64 ":" SUB_LINK_ENTRY64 "} %{" SPEC_32 ":" SUB_LINK_ENTRY32 "}"
      76  
      77  #undef MULTILIB_DEFAULTS
      78  #if TARGET_64BIT_DEFAULT
      79  #define MULTILIB_DEFAULTS { "m64" }
      80  #else
      81  #define MULTILIB_DEFAULTS { "m32" }
      82  #endif
      83  
      84  #undef LINK_SPEC_LARGE_ADDR_AWARE
      85  #if MINGW_DEFAULT_LARGE_ADDR_AWARE
      86  # define LINK_SPEC_LARGE_ADDR_AWARE \
      87    "%{!shared:%{!mdll:%{" SPEC_32 ":--large-address-aware}}}"
      88  #else
      89  # define LINK_SPEC_LARGE_ADDR_AWARE ""
      90  #endif
      91  
      92  #undef LINK_SPEC_DISABLE_DYNAMICBASE
      93  #if HAVE_LD_PE_DISABLE_DYNAMICBASE
      94  # define LINK_SPEC_DISABLE_DYNAMICBASE \
      95    "%{!shared:%{!mdll:%{no-pie:--disable-dynamicbase}}}"
      96  #else
      97  # define LINK_SPEC_DISABLE_DYNAMICBASE ""
      98  #endif
      99  
     100  #undef LINK_SPEC
     101  #define LINK_SPEC SUB_LINK_SPEC " %{mwindows:--subsystem windows} \
     102    %{mconsole:--subsystem console} \
     103    %{shared: %{mdll: %eshared and mdll are not compatible}} \
     104    %{shared: --shared} %{mdll:--dll} \
     105    %{static:-Bstatic} %{!static:-Bdynamic} \
     106    %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \
     107    " LINK_SPEC_LARGE_ADDR_AWARE "\
     108    " LINK_SPEC_DISABLE_DYNAMICBASE "\
     109    %(shared_libgcc_undefs)"
     110  
     111  /* Enable sincos optimization, overriding cygming.h.  sincos, sincosf
     112     and sincosl functions are available on mingw-w64, but not on the
     113     original mingw32.  */
     114  #undef TARGET_LIBC_HAS_FUNCTION
     115  #define TARGET_LIBC_HAS_FUNCTION gnu_libc_has_function