public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH]. Fix  HAVE_SYS_SDT_H for cross-compilation
@ 2012-12-18 14:42 Christian Bruel
  2012-12-18 14:48 ` Jakub Jelinek
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Bruel @ 2012-12-18 14:42 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 779 bytes --]

Hello,

Canadian Cross Builds fail to build libgcc/unwind-dw2.c

...
../../../../libgcc/unwind-dw2.c:42:21: fatal error: sys/sdt.h: No such
file or directory
...

when the build machine has sys/sdt.h installed (systemtap-sdt-devel),
but not the target's, because of this:

#ifdef HAVE_SYS_SDT_H
#include <sys/sdt.h>
#endif

This appears to be because auto-host.h unconditionally defines
HAVE_SYS_SDT_H from config.in, that should be guarded with #ifndef
USED_FOR_TARGET

This patch changes the sys/sdt.h detection to the standard macro to
correctly generate it. And need to regenerate configure and config.in.

Checked for x86 native boostrap OK and SH4-linux Cross and Native builds
on host (with and without systemtap host header installed)

OK for trunk ?

Thanks,

Christian

[-- Attachment #2: cross-sdt.patch --]
[-- Type: text/x-patch, Size: 3927 bytes --]

2012-12-18  Christian Bruel  <christian.bruel@st.com>

	* configure.ac: Check sys/sdt.h with AC_CHECK_HEADERS.
	* configure: Regenerate.
	* config.in: Regenerat.e

Index: gcc/configure
===================================================================
--- gcc/configure	(revision 194574)
+++ gcc/configure	(working copy)
@@ -8286,7 +8286,7 @@ fi
 
 for ac_header in limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
 		 fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
-		 sys/resource.h sys/param.h sys/times.h sys/stat.h \
+		 sys/resource.h sys/param.h sys/times.h sys/sdt.h sys/stat.h \
 		 direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h libintl.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -26716,20 +26716,6 @@ $as_echo "#define TARGET_LIBC_PROVIDES_SSP 1" >>co
 
 fi
 
-# Test for <sys/sdt.h> on the target.
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
-$as_echo_n "checking sys/sdt.h in the target C library... " >&6; }
-have_sys_sdt_h=no
-if test -f $target_header_dir/sys/sdt.h; then
-  have_sys_sdt_h=yes
-
-$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
-$as_echo "$have_sys_sdt_h" >&6; }
-
 # Check if TFmode long double should be used by default or not.
 # Some glibc targets used DFmode long double, but with glibc 2.4
 # and later they can use TFmode.
Index: gcc/config.in
===================================================================
--- gcc/config.in	(revision 194574)
+++ gcc/config.in	(working copy)
@@ -266,12 +266,6 @@
 #endif
 
 
-/* Define if your assembler supports SPARC4 instructions. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_AS_SPARC4
-#endif
-
-
 /* Define if your assembler supports fprnd. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_FPRND
@@ -477,6 +471,12 @@
 #endif
 
 
+/* Define if your assembler supports SPARC4 instructions. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_SPARC4
+#endif
+
+
 /* Define if your assembler and linker support GOTDATA_OP relocs. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_SPARC_GOTDATA_OP
@@ -1228,7 +1228,7 @@
 #endif
 
 
-/* Define if your PowerPC64 linker supports a large TOC. */
+/* Define if your AIX linker supports a large TOC. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_LD_LARGE_TOC
 #endif
@@ -1470,9 +1470,12 @@
 #endif
 
 
-/* Define if your target C library provides sys/sdt.h */
+/* Define to 1 if you have the <sys/sdt.h> header file. */
+#ifndef USED_FOR_TARGET
 #undef HAVE_SYS_SDT_H
+#endif
 
+
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_SYS_STAT_H
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 194574)
+++ gcc/configure.ac	(working copy)
@@ -940,7 +940,7 @@ ACX_HEADER_STRING
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
 		 fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
-		 sys/resource.h sys/param.h sys/times.h sys/stat.h \
+		 sys/resource.h sys/param.h sys/times.h sys/sdt.h sys/stat.h \
 		 direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h libintl.h)
 
 # Check for thread headers.
@@ -4718,17 +4718,6 @@ if test x$gcc_cv_libc_provides_ssp = xyes; then
 	    [Define if your target C library provides stack protector support])
 fi
 
-# Test for <sys/sdt.h> on the target.
-GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
-AC_MSG_CHECKING(sys/sdt.h in the target C library)
-have_sys_sdt_h=no
-if test -f $target_header_dir/sys/sdt.h; then
-  have_sys_sdt_h=yes
-  AC_DEFINE(HAVE_SYS_SDT_H, 1,
-            [Define if your target C library provides sys/sdt.h])
-fi
-AC_MSG_RESULT($have_sys_sdt_h)
-
 # Check if TFmode long double should be used by default or not.
 # Some glibc targets used DFmode long double, but with glibc 2.4
 # and later they can use TFmode.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]. Fix  HAVE_SYS_SDT_H for cross-compilation
  2012-12-18 14:42 [PATCH]. Fix HAVE_SYS_SDT_H for cross-compilation Christian Bruel
@ 2012-12-18 14:48 ` Jakub Jelinek
  2012-12-18 15:00   ` Christian Bruel
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2012-12-18 14:48 UTC (permalink / raw)
  To: Christian Bruel; +Cc: gcc-patches

On Tue, Dec 18, 2012 at 03:41:58PM +0100, Christian Bruel wrote:
> Canadian Cross Builds fail to build libgcc/unwind-dw2.c
> 
> ...
> ../../../../libgcc/unwind-dw2.c:42:21: fatal error: sys/sdt.h: No such
> file or directory
> ...
> 
> when the build machine has sys/sdt.h installed (systemtap-sdt-devel),
> but not the target's, because of this:
> 
> #ifdef HAVE_SYS_SDT_H
> #include <sys/sdt.h>
> #endif
> 
> This appears to be because auto-host.h unconditionally defines
> HAVE_SYS_SDT_H from config.in, that should be guarded with #ifndef
> USED_FOR_TARGET
> 
> This patch changes the sys/sdt.h detection to the standard macro to
> correctly generate it. And need to regenerate configure and config.in.
> 
> Checked for x86 native boostrap OK and SH4-linux Cross and Native builds
> on host (with and without systemtap host header installed)
> 
> OK for trunk ?

That doesn't look like a correct fix.  If HAVE_SYS_SDT_H define is always
guarded with #ifndef USED_FOR_TARGET, then it will never be used in the
target unwind-dw2.c where it is supposed to be used if available.
The configury snippet was clearly looking for target sys/sdt.h header:
if test -f $target_header_dir/sys/sdt.h; then
  have_sys_sdt_h=yes

so the question is why it found a host header instead in your case.

	Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]. Fix  HAVE_SYS_SDT_H for cross-compilation
  2012-12-18 14:48 ` Jakub Jelinek
@ 2012-12-18 15:00   ` Christian Bruel
  0 siblings, 0 replies; 7+ messages in thread
From: Christian Bruel @ 2012-12-18 15:00 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches



On 12/18/2012 03:47 PM, Jakub Jelinek wrote:
> On Tue, Dec 18, 2012 at 03:41:58PM +0100, Christian Bruel wrote:
>> Canadian Cross Builds fail to build libgcc/unwind-dw2.c
>>
>> ...
>> ../../../../libgcc/unwind-dw2.c:42:21: fatal error: sys/sdt.h: No such
>> file or directory
>> ...
>>
>> when the build machine has sys/sdt.h installed (systemtap-sdt-devel),
>> but not the target's, because of this:
>>
>> #ifdef HAVE_SYS_SDT_H
>> #include <sys/sdt.h>
>> #endif
>>
>> This appears to be because auto-host.h unconditionally defines
>> HAVE_SYS_SDT_H from config.in, that should be guarded with #ifndef
>> USED_FOR_TARGET
>>
>> This patch changes the sys/sdt.h detection to the standard macro to
>> correctly generate it. And need to regenerate configure and config.in.
>>
>> Checked for x86 native boostrap OK and SH4-linux Cross and Native builds
>> on host (with and without systemtap host header installed)
>>
>> OK for trunk ?
> 
> That doesn't look like a correct fix.  If HAVE_SYS_SDT_H define is always
> guarded with #ifndef USED_FOR_TARGET, then it will never be used in the
> target unwind-dw2.c where it is supposed to be used if available.
> The configury snippet was clearly looking for target sys/sdt.h header:
> if test -f $target_header_dir/sys/sdt.h; then
>   have_sys_sdt_h=yes
> 

Well, it should be used by unwind-dw2.c, because we have

#include "tconfig.h"

that includes it:

#ifndef GCC_TCONFIG_H
#define GCC_TCONFIG_H
#ifndef USED_FOR_TARGET
# define USED_FOR_TARGET
#endif
#include "auto-host.h"

in which there is :

#ifndef USED_FOR_TARGET
#define HAVE_SYS_SDT_H 1
#endif

So HAVE_SYS_SDT will be defined in unwind-dw2.c on system that need it.

> so the question is why it found a host header instead in your case.

This is for everyone. The auto-host.h is used commonly for the target,
unded the definition of 'USED_FOR_TARGET'

Cheers

Christian

> 
> 	Jakub
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]. Fix HAVE_SYS_SDT_H for cross-compilation
  2013-08-22 17:51 ` Jakub Jelinek
  2013-08-22 18:39   ` Bill Schmidt
@ 2013-08-29  8:38   ` Christian Bruel
  1 sibling, 0 replies; 7+ messages in thread
From: Christian Bruel @ 2013-08-29  8:38 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Bill Schmidt, gcc-patches, antonb

[-- Attachment #1: Type: text/plain, Size: 974 bytes --]

Hello Bill and Jakub

On 08/22/2013 07:47 PM, Jakub Jelinek wrote:
> On Thu, Aug 22, 2013 at 09:39:48AM -0500, Bill Schmidt wrote:
>> Hi Christian and Jakub,
>>
>> I'm curious whether there was ever any resolution for:
>> http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01124.html.
>

Sorry for not having sent a follow up for this.

The problem is that configure was checking for cross features in the
host root dir instead of the cross root dir.

This SDT failure was only the visible part of the problem while building
a Canadian Cross linux hosted GCC, as  we could as well silently test
for different cross/target runtime features :-).

I fixed this problem  by fixing the usage of with_build_sysroot while
checking system features with target_header_dir when host != build.
Checked for legacy issue with various bare or hosted SH4 compilers in
various environments (linux, mingwn, cygwin)

Comments ? does this is seems reasonable to push to trunk ?

Cheers

Christian



[-- Attachment #2: build-sysroot.patch --]
[-- Type: text/x-patch, Size: 1202 bytes --]

2012-12-21  Christian Bruel  <christian.bruel@st.com>

       * configure.ac: Set target_header_dir for with-build-sysroot.
       * configure: Regenerate.

Index: gcc/configure
===================================================================
--- gcc/configure	(revision 202068)
+++ gcc/configure	(working copy)
@@ -27011,6 +27011,8 @@ if test x$host != x$target || test "x$TARGET_SYSTE
   else
     target_header_dir="${with_sysroot}${native_system_header_dir}"
   fi
+elif test x$host != x$build && test "x$with_build_sysroot" != "x"; then
+  target_header_dir="${with_build_sysroot}${native_system_header_dir}"
 else
   target_header_dir=${native_system_header_dir}
 fi
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 202068)
+++ gcc/configure.ac	(working copy)
@@ -4822,6 +4822,8 @@ if test x$host != x$target || test "x$TARGET_SYSTE
   else
     target_header_dir="${with_sysroot}${native_system_header_dir}"
   fi
+elif test x$host != x$build && test "x$with_build_sysroot" != "x"; then
+  target_header_dir="${with_build_sysroot}${native_system_header_dir}"
 else
   target_header_dir=${native_system_header_dir}
 fi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]. Fix HAVE_SYS_SDT_H for cross-compilation
  2013-08-22 17:51 ` Jakub Jelinek
@ 2013-08-22 18:39   ` Bill Schmidt
  2013-08-29  8:38   ` Christian Bruel
  1 sibling, 0 replies; 7+ messages in thread
From: Bill Schmidt @ 2013-08-22 18:39 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: christian.bruel, gcc-patches, antonb

On Thu, 2013-08-22 at 19:47 +0200, Jakub Jelinek wrote:
> On Thu, Aug 22, 2013 at 09:39:48AM -0500, Bill Schmidt wrote:
> > Hi Christian and Jakub,
> > 
> > I'm curious whether there was ever any resolution for:
> > http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01124.html.
> 
> The last mail I remember didn't make any sense:
> #include "tconfig.h"
> 
> that includes it:
> 
> #ifndef GCC_TCONFIG_H
> #define GCC_TCONFIG_H
> #ifndef USED_FOR_TARGET
> # define USED_FOR_TARGET
> #endif
> #include "auto-host.h"
> 
> in which there is :
> 
> #ifndef USED_FOR_TARGET
> #define HAVE_SYS_SDT_H 1
> #endif
> 
> That means USED_FOR_TARGET is defined and thus HAVE_SYS_SDT_H is never
> defined, which is not desirable.
> 
> 	Jakub
> 

Yes, that doesn't seem right at all.  OK, thanks.  I'll stick this on a
list as a low-priority item to fix one of these days.

Thanks,
Bill

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]. Fix HAVE_SYS_SDT_H for cross-compilation
  2013-08-22 14:40 Bill Schmidt
@ 2013-08-22 17:51 ` Jakub Jelinek
  2013-08-22 18:39   ` Bill Schmidt
  2013-08-29  8:38   ` Christian Bruel
  0 siblings, 2 replies; 7+ messages in thread
From: Jakub Jelinek @ 2013-08-22 17:51 UTC (permalink / raw)
  To: Bill Schmidt; +Cc: christian.bruel, gcc-patches, antonb

On Thu, Aug 22, 2013 at 09:39:48AM -0500, Bill Schmidt wrote:
> Hi Christian and Jakub,
> 
> I'm curious whether there was ever any resolution for:
> http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01124.html.

The last mail I remember didn't make any sense:
#include "tconfig.h"

that includes it:

#ifndef GCC_TCONFIG_H
#define GCC_TCONFIG_H
#ifndef USED_FOR_TARGET
# define USED_FOR_TARGET
#endif
#include "auto-host.h"

in which there is :

#ifndef USED_FOR_TARGET
#define HAVE_SYS_SDT_H 1
#endif

That means USED_FOR_TARGET is defined and thus HAVE_SYS_SDT_H is never
defined, which is not desirable.

	Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]. Fix HAVE_SYS_SDT_H for cross-compilation
@ 2013-08-22 14:40 Bill Schmidt
  2013-08-22 17:51 ` Jakub Jelinek
  0 siblings, 1 reply; 7+ messages in thread
From: Bill Schmidt @ 2013-08-22 14:40 UTC (permalink / raw)
  To: christian.bruel; +Cc: jakub, gcc-patches, antonb

Hi Christian and Jakub,

I'm curious whether there was ever any resolution for:
http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01124.html.

We've encountered what appears to be the same issue internally when
building a cross for powerpc64le-linux-gnu:

/scratch/tmp/anton/toolchain/build/src/gcc/libgcc/unwind-dw2.c:41:21:
fatal error: sys/sdt.h: No such file or directory
 #include <sys/sdt.h>

The gcc configure is looking at the build machine header files, instead
of the installed headers for the host we're building.  We can work
around this with a build-sysroot, but it seems that shouldn't be
necessary.  Thoughts?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-08-29  8:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-18 14:42 [PATCH]. Fix HAVE_SYS_SDT_H for cross-compilation Christian Bruel
2012-12-18 14:48 ` Jakub Jelinek
2012-12-18 15:00   ` Christian Bruel
2013-08-22 14:40 Bill Schmidt
2013-08-22 17:51 ` Jakub Jelinek
2013-08-22 18:39   ` Bill Schmidt
2013-08-29  8:38   ` Christian Bruel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).