Skip to content

Commit 2e146cc

Browse files
keith-packardnashif
authored andcommitted
Move picolibc cpp additions to new LIBC_CPP_SPEC
This avoids smashing target-specific CPP_SPEC values. Signed-off-by: Keith Packard <[email protected]>
1 parent 3578a4d commit 2e146cc

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

gcc/config/picolibc-spec.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#define OS_CC1_SPEC " %{!ftls-model=*:-ftls-model=local-exec}"
3030

3131
/* Pass along preprocessor definitions when --printf or --scanf are specified */
32-
#undef CPP_SPEC
33-
#define CPP_SPEC \
32+
#undef LIBC_CPP_SPEC
33+
#define LIBC_CPP_SPEC \
3434
"%{-printf=*: -D_PICOLIBC_PRINTF='%*'}" \
3535
" %{-scanf=*: -D_PICOLIBC_SCANF='%*'}"
3636

@@ -39,8 +39,8 @@
3939
* Define vfprintf if --printf is set
4040
* Define vfscanf if --scanf is set
4141
*/
42-
#undef LINK_LIBC_SPEC
43-
#define LINK_LIBC_SPEC \
42+
#undef LIBC_LINK_SPEC
43+
#define LIBC_LINK_SPEC \
4444
"%{!shared:%{!r:%{!T*: %:if-exists-then-else(%:find-file(" PICOLIBC_LD ") -T" PICOLIBC_LD ")}}}" \
4545
" %{-printf=*:--defsym=" USER_LABEL_PREFIX "vfprintf=" USER_LABEL_PREFIX "__%*_vfprintf}" \
4646
" %{-scanf=*:--defsym=" USER_LABEL_PREFIX "vfscanf=" USER_LABEL_PREFIX "__%*_vfscanf}"

gcc/gcc.cc

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,13 @@ proper position among the other output files. */
723723
#define CPP_SPEC ""
724724
#endif
725725

726+
/* libc can define LIBC_CPP_SPEC to provide extra args to the C preprocessor
727+
or extra switch-translations. */
728+
729+
#ifndef LIBC_CPP_SPEC
730+
#define LIBC_CPP_SPEC ""
731+
#endif
732+
726733
/* Operating systems can define OS_CC1_SPEC to provide extra args to cc1 and
727734
cc1plus or extra switch-translations. The OS_CC1_SPEC is appended
728735
to CC1_SPEC in the initialization of cc1_spec. */
@@ -748,6 +755,12 @@ proper position among the other output files. */
748755
#define LINK_SPEC ""
749756
#endif
750757

758+
/* libc can define LIBC_LINK_SPEC to provide extra args to the linker
759+
or extra switch-translations. */
760+
#ifndef LIBC_LINK_SPEC
761+
#define LIBC_LINK_SPEC ""
762+
#endif
763+
751764
/* config.h can define LIB_SPEC to override the default libraries. */
752765
#ifndef LIB_SPEC
753766
#define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
@@ -1201,14 +1214,14 @@ proper position among the other output files. */
12011214

12021215
static const char *asm_debug = ASM_DEBUG_SPEC;
12031216
static const char *asm_debug_option = ASM_DEBUG_OPTION_SPEC;
1204-
static const char *cpp_spec = CPP_SPEC;
1217+
static const char *cpp_spec = CPP_SPEC LIBC_CPP_SPEC;
12051218
static const char *cc1_spec = CC1_SPEC OS_CC1_SPEC;
12061219
static const char *cc1plus_spec = CC1PLUS_SPEC;
12071220
static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC;
12081221
static const char *link_ssp_spec = LINK_SSP_SPEC;
12091222
static const char *asm_spec = ASM_SPEC;
12101223
static const char *asm_final_spec = ASM_FINAL_SPEC;
1211-
static const char *link_spec = LINK_SPEC;
1224+
static const char *link_spec = LINK_SPEC LIBC_LINK_SPEC;
12121225
static const char *lib_spec = LIB_SPEC;
12131226
static const char *link_gomp_spec = "";
12141227
static const char *libgcc_spec = LIBGCC_SPEC;
@@ -1984,7 +1997,7 @@ init_spec (void)
19841997
#endif
19851998

19861999
#if defined LINK_EH_SPEC || defined LINK_BUILDID_SPEC || \
1987-
defined LINKER_HASH_STYLE || defined LINK_LIBC_SPEC
2000+
defined LINKER_HASH_STYLE
19882001
# ifdef LINK_BUILDID_SPEC
19892002
/* Prepend LINK_BUILDID_SPEC to whatever link_spec we had before. */
19902003
obstack_grow (&obstack, LINK_BUILDID_SPEC, sizeof (LINK_BUILDID_SPEC) - 1);
@@ -2002,10 +2015,6 @@ init_spec (void)
20022015
obstack_grow (&obstack, LINKER_HASH_STYLE, sizeof (LINKER_HASH_STYLE) - 1);
20032016
obstack_1grow (&obstack, ' ');
20042017
}
2005-
# endif
2006-
# ifdef LINK_LIBC_SPEC
2007-
/* Prepend LINK_LIBC_SPEC to whatever link_spec we had before. */
2008-
obstack_grow (&obstack, LINK_LIBC_SPEC, sizeof (LINK_LIBC_SPEC) - 1);
20092018
# endif
20102019
obstack_grow0 (&obstack, link_spec, strlen (link_spec));
20112020
link_spec = XOBFINISH (&obstack, const char *);

0 commit comments

Comments
 (0)