| 1 |
/* Definitions for LoongArch systems using GNU (glibc-based) userspace, |
| 2 |
or other userspace with libc derived from glibc. |
| 3 |
Copyright (C) 2021-2025 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
This file is part of GCC. |
| 6 |
|
| 7 |
GCC is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 3, or (at your option) |
| 10 |
any later version. |
| 11 |
|
| 12 |
GCC is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with GCC; see the file COPYING3. If not see |
| 19 |
<http://www.gnu.org/licenses/>. */ |
| 20 |
|
| 21 |
/* Define the size of the wide character type. */ |
| 22 |
#undef WCHAR_TYPE |
| 23 |
#define WCHAR_TYPE "int" |
| 24 |
|
| 25 |
#undef WCHAR_TYPE_SIZE |
| 26 |
#define WCHAR_TYPE_SIZE 32 |
| 27 |
|
| 28 |
|
| 29 |
/* GNU-specific SPEC definitions. */ |
| 30 |
#define GNU_USER_LINK_EMULATION "elf" ABI_GRLEN_SPEC "loongarch" |
| 31 |
|
| 32 |
#undef GLIBC_DYNAMIC_LINKER |
| 33 |
#define GLIBC_DYNAMIC_LINKER \ |
| 34 |
"/lib" ABI_GRLEN_SPEC "/ld-linux-loongarch-" ABI_SPEC ".so.1" |
| 35 |
|
| 36 |
#define MUSL_ABI_SPEC \ |
| 37 |
"%{mabi=lp64d:}" \ |
| 38 |
"%{mabi=lp64f:-sp}" \ |
| 39 |
"%{mabi=lp64s:-sf}" |
| 40 |
|
| 41 |
#undef MUSL_DYNAMIC_LINKER |
| 42 |
#define MUSL_DYNAMIC_LINKER \ |
| 43 |
"/lib/ld-musl-loongarch" ABI_GRLEN_SPEC MUSL_ABI_SPEC ".so.1" |
| 44 |
|
| 45 |
#undef GNU_USER_TARGET_LINK_SPEC |
| 46 |
#define GNU_USER_TARGET_LINK_SPEC \ |
| 47 |
"%{G*} %{shared} -m " GNU_USER_LINK_EMULATION \ |
| 48 |
"%{!shared: %{static} " \ |
| 49 |
"%{!static: %{!static-pie: %{rdynamic:-export-dynamic} " \ |
| 50 |
"-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} " \ |
| 51 |
"%{static-pie: -static -pie --no-dynamic-linker -z text}}" \ |
| 52 |
"%{mno-relax: --no-relax}" |
| 53 |
|
| 54 |
|
| 55 |
/* Similar to standard Linux, but adding -ffast-math support. */ |
| 56 |
#undef GNU_USER_TARGET_MATHFILE_SPEC |
| 57 |
#define GNU_USER_TARGET_MATHFILE_SPEC \ |
| 58 |
"%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}}" |
| 59 |
|
| 60 |
#undef LIB_SPEC |
| 61 |
#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC |
| 62 |
|
| 63 |
#undef LINK_SPEC |
| 64 |
#define LINK_SPEC GNU_USER_TARGET_LINK_SPEC |
| 65 |
|
| 66 |
#undef ENDFILE_SPEC |
| 67 |
#define ENDFILE_SPEC \ |
| 68 |
GNU_USER_TARGET_MATHFILE_SPEC " " \ |
| 69 |
GNU_USER_TARGET_ENDFILE_SPEC |
| 70 |
|
| 71 |
#undef SUBTARGET_CPP_SPEC |
| 72 |
#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" |
| 73 |
|
| 74 |
/* A standard GNU/Linux mapping. On most targets, it is included in |
| 75 |
CC1_SPEC itself by config/linux.h, but loongarch.h overrides CC1_SPEC |
| 76 |
and provides this hook instead. */ |
| 77 |
#undef SUBTARGET_CC1_SPEC |
| 78 |
#define SUBTARGET_CC1_SPEC GNU_USER_TARGET_CC1_SPEC |
| 79 |
|
| 80 |
#define TARGET_OS_CPP_BUILTINS() \ |
| 81 |
do \ |
| 82 |
{ \ |
| 83 |
GNU_USER_TARGET_OS_CPP_BUILTINS (); \ |
| 84 |
/* The GNU C++ standard library requires this. */ \ |
| 85 |
if (c_dialect_cxx ()) \ |
| 86 |
builtin_define ("_GNU_SOURCE"); \ |
| 87 |
} \ |
| 88 |
while (0) |