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]

Re: [build] Only support -gstabs on Mac OS X if assember supports it (PR target/67973)


Mike Stump <mikestump@comcast.net> writes:

> On Dec 15, 2015, at 5:35 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>> Right: I'm effectively keeping just the first configure test for .stabs
>> support in the assembler to enable or disable
>> DBX_DEBUG/DBX_DEBUGGING_INFO.  I'll post it later since …
>
>> ... testing revealed another instance of static assumptions which hurts
>> us now: while support for -gstabs* is checked for dynamically in
>> lib/gcc-dg.exp and lib/gfortran-dg.exp for the debug.exp tests, there
>> are a couple of testcases that use -gstabs* unconditionally, but have a
>> hardcoded list of targets that support those options.  I'll introduce a
>> new effective-target keyword (simply checking if -gstabs is accepted
>> should be enough) to also perform this test dynamically and repost once
>> it's tested.
>
> Sounds good.

Here's what I came up with.  Tested with the appropriate runtest
invocations both in a tree with the Xcode 7/LLVM as without stabs
support, where the tests come out UNSUPPORTED, and another one with the
Xcode 6.4/gas as with stabs, where they PASS.

I've left alone two testcases using -gstabs* which are guaranteed to
work without the keyword:

	gcc.target/powerpc/stabs-attrib-vect-darwin.c
	gcc.target/s390/20041216-1.c	

In case the current test for stabs (checking if one can compile/assemble
with -gstabs) isn't enough on some of the targets currently listed
explicitly, it could easily be augmented.

Ok for mainline?

	Rainer


2015-12-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc:
	PR target/67973
	* configure.ac (gcc_cv_as_stabs_directive): New test.
	* configure: Regenerate.
	* config.in: Regenerate.
	* config/darwin.h (DBX_DEBUGGING_INFO): Wrap in
	HAVE_AS_STABS_DIRECTIVE.
	(PREFERRED_DEBUGGING_TYPE): Likewise.
	* config/i386/darwin.h (PREFERRED_DEBUGGING_TYPE): Only include
	DBX_DEBUG if HAVE_AS_STABS_DIRECTIVE.

	* doc/sourcebuild.texi (Effective-Target Keywords, Environment
	attributes): Document stabs.

	gcc/testsuite:
	* lib/target-supports.exp (check_effective_target_stabs): New
	proc.
	* g++.dg/cpp0x/alias-decl-debug-0.C: Restrict to stabs targets.
	* g++.dg/other/PR23205.C: Likewise.
	* g++.dg/other/pr23205-2.C: Likewise.
	* gcc.dg/20040813-1.c: Likewise.
	* gcc.dg/darwin-20040809-2.c: Likewise.
	* objc.dg/stabs-1.m: Likewise.

# HG changeset patch
# Parent  c7950a736b94d8efa4a0120ac24359bc446b4c0b
Only support -gstabs on Mac OS X if assember supports it (PR target/67973)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -400,12 +400,13 @@ extern GTY(()) int darwin_ms_struct;
 
 #define ASM_DEBUG_SPEC  "%{g*:%{!g0:%{!gdwarf*:--gstabs}}}"
 
-/* We still allow output of STABS.  */
-
+/* We still allow output of STABS if the assembler supports it.  */
+#ifdef HAVE_AS_STABS_DIRECTIVE
 #define DBX_DEBUGGING_INFO 1
+#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+#endif
 
 #define DWARF2_DEBUGGING_INFO 1
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
 
 #define DEBUG_FRAME_SECTION	"__DWARF,__debug_frame,regular,debug"
 #define DEBUG_INFO_SECTION	"__DWARF,__debug_info,regular,debug"
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -226,7 +226,11 @@ do {									\
    compiles default to stabs+.  darwin9+ defaults to dwarf-2.  */
 #ifndef DARWIN_PREFER_DWARF
 #undef PREFERRED_DEBUGGING_TYPE
+#ifdef HAVE_AS_STABS_DIRECTIVE
 #define PREFERRED_DEBUGGING_TYPE (TARGET_64BIT ? DWARF2_DEBUG : DBX_DEBUG)
+#else
+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+#endif
 #endif
 
 /* Darwin uses the standard DWARF register numbers but the default
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2909,6 +2909,11 @@ AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_MERGE,
   [`if test $gcc_cv_as_shf_merge = yes; then echo 1; else echo 0; fi`],
 [Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.])
 
+gcc_GAS_CHECK_FEATURE([stabs directive], gcc_cv_as_stabs_directive, ,,
+[.stabs "gcc2_compiled.",60,0,0,0],,
+[AC_DEFINE(HAVE_AS_STABS_DIRECTIVE, 1,
+  [Define if your assembler supports .stabs.])])
+
 gcc_GAS_CHECK_FEATURE([COMDAT group support (GNU as)],
  gcc_cv_as_comdat_group,
  [elf,2,16,0], [--fatal-warnings],
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1824,6 +1824,9 @@ time) should be run on this target.  Thi
 Test system runs executables on a simulator (i.e. slowly) rather than
 hardware (i.e. fast).
 
+@item stabs
+Target supports the stabs debugging format.
+
 @item stdint_types
 Target has the basic signed and unsigned C types in @code{stdint.h}.
 This will be obsolete when GCC ensures a working @code{stdint.h} for
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-debug-0.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-debug-0.C
--- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-debug-0.C
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-debug-0.C
@@ -1,6 +1,5 @@
 // Origin: PR c++/51032
-// { dg-do compile { target c++11 } }
-// { dg-skip-if "No stabs" { aarch64*-*-* mmix-*-* *-*-aix* alpha*-*-* hppa*64*-*-* ia64-*-* *-*-vxworks* nios2-*-* } { "*" } { "" } }
+// { dg-do compile { target { c++11 && stabs } } }
 // { dg-options "-gstabs+" }
 
 template <class C>
diff --git a/gcc/testsuite/g++.dg/other/PR23205.C b/gcc/testsuite/g++.dg/other/PR23205.C
--- a/gcc/testsuite/g++.dg/other/PR23205.C
+++ b/gcc/testsuite/g++.dg/other/PR23205.C
@@ -1,5 +1,4 @@
-/* { dg-do compile } */
-/* { dg-skip-if "No stabs" { aarch64*-*-* mmix-*-* *-*-aix* alpha*-*-* hppa*64*-*-* ia64-*-* nios2-*-* tile*-*-* *-*-vxworks } { "*" } { "" } } */
+/* { dg-do compile { target stabs } } */
 /* { dg-options "-gstabs+ -fno-eliminate-unused-debug-types" } */
 
 const int foobar = 4;
diff --git a/gcc/testsuite/g++.dg/other/pr23205-2.C b/gcc/testsuite/g++.dg/other/pr23205-2.C
--- a/gcc/testsuite/g++.dg/other/pr23205-2.C
+++ b/gcc/testsuite/g++.dg/other/pr23205-2.C
@@ -1,5 +1,4 @@
-/* { dg-do compile } */
-/* { dg-skip-if "No stabs" { aarch64*-*-* mmix-*-* *-*-aix* alpha*-*-* hppa*64*-*-* ia64-*-* tile*-*-* nios2-*-* } { "*" } { "" } } */
+/* { dg-do compile { target stabs } } */
 /* { dg-options "-gstabs+ -fno-eliminate-unused-debug-types -ftoplevel-reorder" } */
 
 const int foobar = 4;
diff --git a/gcc/testsuite/gcc.dg/20040813-1.c b/gcc/testsuite/gcc.dg/20040813-1.c
--- a/gcc/testsuite/gcc.dg/20040813-1.c
+++ b/gcc/testsuite/gcc.dg/20040813-1.c
@@ -1,8 +1,7 @@
 /* Test lang in N_SO stab.  */
 /* Contributed by Devang Patel  <dpatel@apple.com>  */
 
-/* { dg-do compile } */
-/* { dg-skip-if "No stabs" { aarch64*-*-* mmix-*-* *-*-aix* alpha*-*-* hppa*64*-*-* ia64-*-* tile*-*-* nios2-*-* *-*-vxworks* nvptx-*-* } { "*" } { "" } } */
+/* { dg-do compile { target stabs } } */
 /* { dg-options "-gstabs" } */
 
 int
diff --git a/gcc/testsuite/gcc.dg/darwin-20040809-2.c b/gcc/testsuite/gcc.dg/darwin-20040809-2.c
--- a/gcc/testsuite/gcc.dg/darwin-20040809-2.c
+++ b/gcc/testsuite/gcc.dg/darwin-20040809-2.c
@@ -1,7 +1,7 @@
 /* Test dead code strip support.  */
 /* Contributed by Devang Patel  <dpatel@apple.com>  */
 
-/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-do compile { target { *-*-darwin* && stabs } } } */
 /* { dg-options "-gstabs+ -fno-eliminate-unused-debug-symbols" } */
 
 int
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -938,6 +938,15 @@ proc check_effective_target_pthread {} {
     } "-pthread"]
 }
 
+# Return 1 if compilation with -gstabs is error-free for trivial
+# code, 0 otherwise.
+
+proc check_effective_target_stabs {} {
+    return [check_no_compiler_messages stabs object {
+	void foo (void) { }
+    } "-gstabs"]
+}
+
 # Return 1 if compilation with -mpe-aligned-commons is error-free
 # for trivial code, 0 otherwise.
 
diff --git a/gcc/testsuite/objc.dg/stabs-1.m b/gcc/testsuite/objc.dg/stabs-1.m
--- a/gcc/testsuite/objc.dg/stabs-1.m
+++ b/gcc/testsuite/objc.dg/stabs-1.m
@@ -1,8 +1,7 @@
 /* Check if the final SO STABS record goes into the .text section.  */
 /* Contributed by Ziemowit Laski <zlaski@apple.com> */
 
-/* { dg-do compile } */
-/* { dg-skip-if "No stabs" { mmix-*-* *-*-aix* alpha*-*-* hppa*64*-*-* ia64-*-* } { "*" } { "" } } */
+/* { dg-do compile { target stabs } } */
 /* { dg-options "-gstabs" } */
 
 @interface MyClass
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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