| 1 |
/* Configuration common to all targets running Picolibc. |
| 2 |
Copyright (C) 2026 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This file is part of GCC. |
| 5 |
|
| 6 |
GCC is free software; you can redistribute it and/or modify it |
| 7 |
under the terms of the GNU General Public License as published |
| 8 |
by the Free Software Foundation; either version 3, or (at your |
| 9 |
option) any later version. |
| 10 |
|
| 11 |
GCC is distributed in the hope that it will be useful, but WITHOUT |
| 12 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 14 |
License for more details. |
| 15 |
|
| 16 |
Under Section 7 of GPL version 3, you are granted additional |
| 17 |
permissions described in the GCC Runtime Library Exception, version |
| 18 |
3.1, as published by the Free Software Foundation. |
| 19 |
|
| 20 |
You should have received a copy of the GNU General Public License and |
| 21 |
a copy of the GCC Runtime Library Exception along with this program; |
| 22 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 23 |
<http://www.gnu.org/licenses/>. */ |
| 24 |
|
| 25 |
#define PICOLIBC_LD "picolibc.ld" |
| 26 |
#define PICOLIBCPP_LD "picolibcpp.ld" |
| 27 |
|
| 28 |
#ifdef ENABLE_MULTILIB_SPACE |
| 29 |
#define EXCEPT_FILE_ELSE(_except, _noexcept) "%:if-driverlang(c++%{Os:SKIP} " _except " " _noexcept ")" |
| 30 |
#define EXCEPT_FILE(_except) "%:if-driverlang(c++%{Os:SKIP} " _except ")" |
| 31 |
#else |
| 32 |
#define EXCEPT_FILE_ELSE(_except, _noexcept) "%:if-driverlang(c++ " _except " " _noexcept ")" |
| 33 |
#define EXCEPT_FILE(_except) "%:if-driverlang(c++%{Os:SKIP} " _except ")" |
| 34 |
#endif |
| 35 |
|
| 36 |
#define PICOLIBC_SCRIPT EXCEPT_FILE_ELSE(PICOLIBCPP_LD, PICOLIBC_LD) |
| 37 |
#define PICOLIBC_CRTEND EXCEPT_FILE("crtend%O%s") |
| 38 |
#define PICOLIBC_CRTBEGIN EXCEPT_FILE("crtbegin%O%s") |
| 39 |
|
| 40 |
/* Default to local-exec TLS model. */ |
| 41 |
#undef OS_CC1_SPEC |
| 42 |
#define OS_CC1_SPEC " %{!ftls-model=*:-ftls-model=local-exec}" |
| 43 |
|
| 44 |
/* Pass along preprocessor definitions when --printf or --scanf are specified */ |
| 45 |
#define LIBC_CPP_SPEC \ |
| 46 |
" %{-printf=*: -D_PICOLIBC_PRINTF='%*'}" \ |
| 47 |
" %{-scanf=*: -D_PICOLIBC_SCANF='%*'}" |
| 48 |
|
| 49 |
/* |
| 50 |
* Add picolibc.ld if not using -shared, -r or -T and we can find it. |
| 51 |
* Define vfprintf if --printf is set |
| 52 |
* Define vfscanf if --scanf is set |
| 53 |
*/ |
| 54 |
#define LIBC_LINK_SPEC \ |
| 55 |
" %{!shared:%{!r:%{!T*: %:if-exists-then-else(%:find-file(" PICOLIBC_SCRIPT ") -T%:find-file(" PICOLIBC_SCRIPT "))}}}" \ |
| 56 |
" %{-printf=*:--defsym=" USER_LABEL_PREFIX "vfprintf=" USER_LABEL_PREFIX "__%*_vfprintf}" \ |
| 57 |
" %{-scanf=*:--defsym=" USER_LABEL_PREFIX "vfscanf=" USER_LABEL_PREFIX "__%*_vfscanf}" |
| 58 |
|
| 59 |
/* |
| 60 |
* Place the C library, libgcc and any oslib in a link group to resolve |
| 61 |
* interdependencies |
| 62 |
*/ |
| 63 |
#undef LIB_SPEC |
| 64 |
#define LIB_SPEC "--start-group -lc %{-oslib=*:-l%*} %(libgcc) --end-group" |
| 65 |
|
| 66 |
#undef ENDFILE_SPEC |
| 67 |
#define ENDFILE_SPEC PICOLIBC_CRTEND |
| 68 |
|
| 69 |
/* Select alternate crt0 version if --crt0 is specified */ |
| 70 |
#undef STARTFILE_SPEC |
| 71 |
#define STARTFILE_SPEC "%{-crt0=*:crt0-%*%O%s; :crt0%O%s} " PICOLIBC_CRTBEGIN |
| 72 |
|
| 73 |
#define EH_TABLES_CAN_BE_READ_ONLY 1 |