This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] unify -posix/-pthread cpp handling for gnu-user targets


Many Linux targets duplicate the cpp spec macros for turning -posix/-thread
into the right defines.  Some Linux targets forget to do this entirely and
can be hard to notice.  Add common definitions to the gnu headers (since
these are really in relation to the C library) and drop the duplications in
the target headers.

I've tested a few targets (aarch64, cris, x86_64) to make sure -dumpspecs
still includes the right content.

Some targets still define -posix/-pthread in SUBTARGET_CPP_SPEC and in
CPP_SUBTARGET_SPEC, but I can't seem to find any reference to either of
those defines.  Are they dead/confused code and I should just delete it ?

2015-05-28  Mike Frysinger  <vapier@gentoo.org>

	* config/aarch64/aarch64-linux.h (CPP_SPEC): Delete.
	* config/alpha/linux.h (CPP_SPEC): Delete.
	* config/arm/linux-gas.h (SUBTARGET_CPP_SPEC): Change to
	GNU_USER_CPP_SPEC.
	* config/cris/linux.h (CRIS_CPP_SUBTARGET_SPEC): Remove -pthread.
	* config/gnu-user.h (GNU_USER_CPP_SPEC, CPP_SPEC): Define.
	* config/gnu.h (GNU_USER_CPP_SPEC): Define.
	(CPP_SPEC): Change to GNU_USER_CPP_SPEC.
	* config/i386/gnu-user-common.h (CPP_SPEC): Delete.
	* config/ia64/linux.h (CPP_SPEC): Delete.
	* config/m32r/linux.h (SUBTARGET_CPP_SPEC): Change to
	GNU_USER_CPP_SPEC.
	* config/m68k/linux.h (CPP_SPEC): Delete.
	* config/microblaze/linux.h (CPP_SPEC): Delete.
	* config/mips/gnu-user.h (SUBTARGET_CPP_SPEC): Change to
	GNU_USER_CPP_SPEC.
	* config/mn10300/linux.h (SUBTARGET_CPP_SPEC): Change to
	GNU_USER_CPP_SPEC.
	* config/nios2/linux.h (CPP_SPEC): Delete.
	* config/pa/pa-linux.h (CPP_SPEC): Delete.
	* config/s390/linux.h (CPP_SPEC): Delete.
	* config/sh/linux.h (SUBTARGET_CPP_SPEC): Change to
	GNU_USER_CPP_SPEC.
	* config/sparc/linux.h (SUBTARGET_CPP_SPEC): Change to
	GNU_USER_CPP_SPEC.
	* config/sparc/linux64.h (SUBTARGET_CPP_SPEC): Change to
	GNU_USER_CPP_SPEC.
	* config/tilegx/linux.h (CPP_SPEC): Delete.
	* config/tilepro/linux.h (CPP_SPEC): Delete.
	* config/vax/linux.h (CPP_SPEC): Delete.
	* config/xtensa/linux.h (SUBTARGET_CPP_SPEC): Change to
	GNU_USER_CPP_SPEC.
---
 gcc/config/aarch64/aarch64-linux.h | 2 --
 gcc/config/alpha/linux.h           | 3 ---
 gcc/config/arm/linux-gas.h         | 2 +-
 gcc/config/cris/linux.h            | 6 ++----
 gcc/config/gnu-user.h              | 5 +++++
 gcc/config/gnu.h                   | 3 ++-
 gcc/config/i386/gnu-user-common.h  | 3 ---
 gcc/config/ia64/linux.h            | 2 --
 gcc/config/m32r/linux.h            | 5 ++---
 gcc/config/m68k/linux.h            | 3 ---
 gcc/config/microblaze/linux.h      | 3 ---
 gcc/config/mips/gnu-user.h         | 2 +-
 gcc/config/mn10300/linux.h         | 6 +++---
 gcc/config/nios2/linux.h           | 3 ---
 gcc/config/pa/pa-linux.h           | 3 ---
 gcc/config/s390/linux.h            | 2 --
 gcc/config/sh/linux.h              | 5 ++---
 gcc/config/sparc/linux.h           | 3 +--
 gcc/config/sparc/linux64.h         | 5 +----
 gcc/config/tilegx/linux.h          | 3 ---
 gcc/config/tilepro/linux.h         | 3 ---
 gcc/config/vax/linux.h             | 3 ---
 gcc/config/xtensa/linux.h          | 2 +-
 23 files changed, 21 insertions(+), 56 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 1600a32..7d356dd 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -32,8 +32,6 @@
 #undef  CC1_SPEC
 #define CC1_SPEC GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC
 
-#define CPP_SPEC "%{pthread:-D_REENTRANT}"
-
 #define LINUX_TARGET_LINK_SPEC  "%{h*}		\
    %{static:-Bstatic}				\
    %{shared:-shared}				\
diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
index 475ea06..e609f38 100644
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
@@ -39,9 +39,6 @@ along with GCC; see the file COPYING3.  If not see
    %{shared:-lc} \
    %{!shared: %{profile:-lc_p}%{!profile:-lc}}"
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
 /* Show that we need a GP when profiling.  */
 #undef TARGET_PROFILING_NEEDS_GP
 #define TARGET_PROFILING_NEEDS_GP 1
diff --git a/gcc/config/arm/linux-gas.h b/gcc/config/arm/linux-gas.h
index d3a3196..6ce62c7 100644
--- a/gcc/config/arm/linux-gas.h
+++ b/gcc/config/arm/linux-gas.h
@@ -31,7 +31,7 @@
 #define DEFAULT_SIGNED_CHAR 0
 
 #undef  SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC  "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+#define SUBTARGET_CPP_SPEC GNU_USER_CPP_SPEC
 
 #undef  SIZE_TYPE
 #define SIZE_TYPE "unsigned int"
diff --git a/gcc/config/cris/linux.h b/gcc/config/cris/linux.h
index 262aac5..043a1ac 100644
--- a/gcc/config/cris/linux.h
+++ b/gcc/config/cris/linux.h
@@ -54,12 +54,10 @@ along with GCC; see the file COPYING3.  If not see
 #undef CRIS_CPP_SUBTARGET_SPEC
 #if TARGET_CPU_DEFAULT == 32
 # define CRIS_CPP_SUBTARGET_SPEC \
-  "%{pthread:-D_REENTRANT}\
-   %{!march=*:%{!mcpu=*:-D__arch_v32 -D__CRIS_arch_version=32}}"
+  "%{!march=*:%{!mcpu=*:-D__arch_v32 -D__CRIS_arch_version=32}}"
 #else
 # define CRIS_CPP_SUBTARGET_SPEC \
-  "%{pthread:-D_REENTRANT}\
-   %{!march=*:%{!mcpu=*:-D__arch_v10 -D__CRIS_arch_version=10}}"
+  "%{!march=*:%{!mcpu=*:-D__arch_v10 -D__CRIS_arch_version=10}}"
 #endif
 
 #undef CRIS_CC1_SUBTARGET_SPEC
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 2fcb55d..f0dc3a6 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -81,6 +81,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define CC1_SPEC GNU_USER_TARGET_CC1_SPEC
 #endif
 
+/* Provide GCC options for standard feature-test macros.  */
+#undef CPP_SPEC
+#define GNU_USER_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+#define CPP_SPEC GNU_USER_CPP_SPEC
+
 /* The GNU C++ standard library requires that these macros be defined.  */
 #undef CPLUSPLUS_CPP_SPEC
 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
diff --git a/gcc/config/gnu.h b/gcc/config/gnu.h
index 03df7e7..4a62e56 100644
--- a/gcc/config/gnu.h
+++ b/gcc/config/gnu.h
@@ -21,7 +21,8 @@ along with GCC.  If not, see <http://www.gnu.org/licenses/>.
 
 /* Provide GCC options for standard feature-test macros.  */
 #undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
+#define GNU_USER_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+#define CPP_SPEC GNU_USER_CPP_SPEC
 
 /* Default C library spec.  */
 #undef LIB_SPEC
diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h
index bd32fe2..1a40f1f 100644
--- a/gcc/config/i386/gnu-user-common.h
+++ b/gcc/config/i386/gnu-user-common.h
@@ -36,9 +36,6 @@ along with GCC; see the file COPYING3.  If not see
     }								\
   while (0)
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
 #undef GNU_USER_TARGET_CC1_SPEC
 #define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"
 
diff --git a/gcc/config/ia64/linux.h b/gcc/config/ia64/linux.h
index f6ef6d7..52ad480 100644
--- a/gcc/config/ia64/linux.h
+++ b/gcc/config/ia64/linux.h
@@ -66,8 +66,6 @@ do {						\
       -dynamic-linker " GNU_USER_DYNAMIC_LINKER "} \
       %{static:-static}}"
 
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
 #define JMP_BUF_SIZE  76
 
 /* Override linux.h LINK_EH_SPEC definition.
diff --git a/gcc/config/m32r/linux.h b/gcc/config/m32r/linux.h
index 1bb6297..04884bc 100644
--- a/gcc/config/m32r/linux.h
+++ b/gcc/config/m32r/linux.h
@@ -81,9 +81,8 @@
   "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 #undef  SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC "\
-   %{posix:-D_POSIX_SOURCE} \
-   %{pthread:-D_REENTRANT -D_PTHREADS} \
+#define SUBTARGET_CPP_SPEC GNU_USER_CPP_SPEC "\
+   %{pthread:-D_PTHREADS} \
 "
                                                                                 
 #define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
diff --git a/gcc/config/m68k/linux.h b/gcc/config/m68k/linux.h
index 5c19d84..c225173 100644
--- a/gcc/config/m68k/linux.h
+++ b/gcc/config/m68k/linux.h
@@ -60,9 +60,6 @@ along with GCC; see the file COPYING3.  If not see
 /* Target OS builtins.  */
 #define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
    for the special GCC options -static and -shared, which allow us to
    link things in one of these three modes by applying the appropriate
diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
index 655a70f..a7faa7d 100644
--- a/gcc/config/microblaze/linux.h
+++ b/gcc/config/microblaze/linux.h
@@ -22,9 +22,6 @@
 #undef TARGET_SUPPORTS_PIC
 #define TARGET_SUPPORTS_PIC 1
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
 #undef TLS_NEEDS_GOT
 #define TLS_NEEDS_GOT 1
 
diff --git a/gcc/config/mips/gnu-user.h b/gcc/config/mips/gnu-user.h
index dd4cf11..73349f4 100644
--- a/gcc/config/mips/gnu-user.h
+++ b/gcc/config/mips/gnu-user.h
@@ -39,7 +39,7 @@ along with GCC; see the file COPYING3.  If not see
   } while (0)
 
 #undef SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+#define SUBTARGET_CPP_SPEC GNU_USER_CPP_SPEC
 
 /* A standard GNU/Linux mapping.  On most targets, it is included in
    CC1_SPEC itself by config/linux.h, but mips.h overrides CC1_SPEC
diff --git a/gcc/config/mn10300/linux.h b/gcc/config/mn10300/linux.h
index e78f4a0..97e3165 100644
--- a/gcc/config/mn10300/linux.h
+++ b/gcc/config/mn10300/linux.h
@@ -25,9 +25,9 @@
 #define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
 
 #undef  CPP_SPEC
-#define CPP_SPEC "%{mam33:-D__AM33__} %{!mam33:-D__AM33__=2 -D__AM33_2__} \
-  %{posix:-D_POSIX_SOURCE} \
-  %{pthread:-D_REENTRANT -D_PTHREADS}"
+#define CPP_SPEC GNU_USER_CPP_SPEC "\
+  %{mam33:-D__AM33__} %{!mam33:-D__AM33__=2 -D__AM33_2__} \
+  %{pthread:-D_PTHREADS}"
 
 #undef  ASM_SPEC
 #define ASM_SPEC ""
diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h
index f43f655..41cad94 100644
--- a/gcc/config/nios2/linux.h
+++ b/gcc/config/nios2/linux.h
@@ -26,9 +26,6 @@
     }                                           \
   while (0)
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1"
 
 #undef LINK_SPEC
diff --git a/gcc/config/pa/pa-linux.h b/gcc/config/pa/pa-linux.h
index f8da185..e4903c5 100644
--- a/gcc/config/pa/pa-linux.h
+++ b/gcc/config/pa/pa-linux.h
@@ -27,9 +27,6 @@ along with GCC; see the file COPYING3.  If not see
     }						\
   while (0)
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
 #undef ASM_SPEC
 #define ASM_SPEC \
   ""
diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
index 21f9825..91d3fcb 100644
--- a/gcc/config/s390/linux.h
+++ b/gcc/config/s390/linux.h
@@ -74,8 +74,6 @@ along with GCC; see the file COPYING3.  If not see
 	%{m31:-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
 	%{m64:-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}}"
 
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
 
 #ifdef TARGET_LIBC_PROVIDES_SSP
diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
index 0f5d614..602f7fb 100644
--- a/gcc/config/sh/linux.h
+++ b/gcc/config/sh/linux.h
@@ -25,9 +25,8 @@ along with GCC; see the file COPYING3.  If not see
 #define DWARF2_UNWIND_INFO 1
 
 #undef SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC "\
-   %{posix:-D_POSIX_SOURCE} \
-   %{pthread:-D_REENTRANT -D_PTHREADS} \
+#define SUBTARGET_CPP_SPEC GNU_USER_CPP_SPEC "\
+   %{pthread:-D_PTHREADS} \
 "
 
 #define TARGET_OS_CPP_BUILTINS() \
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 17e1e86..c3585cb 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -72,8 +72,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
 #define WCHAR_TYPE_SIZE 32
 
 #undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC \
-"%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+#define CPP_SUBTARGET_SPEC GNU_USER_CPP_SPEC
 
 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
    for the special GCC options -static and -shared, which allow us to
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index 43da848..d26163d 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -71,10 +71,7 @@ along with GCC; see the file COPYING3.  If not see
 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
 
 #undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC "\
-%{posix:-D_POSIX_SOURCE} \
-%{pthread:-D_REENTRANT} \
-"
+#define CPP_SUBTARGET_SPEC GNU_USER_CPP_SPEC
 
 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
    for the special GCC options -static and -shared, which allow us to
diff --git a/gcc/config/tilegx/linux.h b/gcc/config/tilegx/linux.h
index cbff114..59027e9 100644
--- a/gcc/config/tilegx/linux.h
+++ b/gcc/config/tilegx/linux.h
@@ -18,9 +18,6 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{pthread:-D_REENTRANT}"
-
 #undef ASM_SPEC
 #define ASM_SPEC "%(endian_spec) %{m32:--32} %{m64:--64}"
 
diff --git a/gcc/config/tilepro/linux.h b/gcc/config/tilepro/linux.h
index 5aee13f..782e305 100644
--- a/gcc/config/tilepro/linux.h
+++ b/gcc/config/tilepro/linux.h
@@ -18,9 +18,6 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{pthread:-D_REENTRANT}"
-
 #undef	LINK_SPEC
 #define LINK_SPEC "\
   %{shared:-shared} \
diff --git a/gcc/config/vax/linux.h b/gcc/config/vax/linux.h
index 0765ed9..e3690eb 100644
--- a/gcc/config/vax/linux.h
+++ b/gcc/config/vax/linux.h
@@ -28,9 +28,6 @@ along with GCC; see the file COPYING3.  If not see
 #undef TARGET_BSD_DIVMOD
 #define TARGET_BSD_DIVMOD 0
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
 #undef ASM_SPEC
 #define ASM_SPEC "%{" FPIC_SPEC ":-k}"
 
diff --git a/gcc/config/xtensa/linux.h b/gcc/config/xtensa/linux.h
index 675aacf..0794b04 100644
--- a/gcc/config/xtensa/linux.h
+++ b/gcc/config/xtensa/linux.h
@@ -21,7 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
 
 #undef SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+#define SUBTARGET_CPP_SPEC GNU_USER_CPP_SPEC
 
 #undef SIZE_TYPE
 #define SIZE_TYPE "unsigned int"
-- 
2.4.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]