On Tue, 9 Oct 2012 17:58:05 +0200
Kai Tietz <[email protected]> wrote:

> Hi,
> 
> the patch looks in general good to me.  I have one nit about it, which
> needs to be resolved before it can be applied.  As users might use
> older binutils-version without __xd_start/end symbol, it is necessary
> to probe for it in configure and use here a guard to make decision of
> new-linker-script symbols can be used, or not.
> 
> Regards,
> Kai
> 

Yeah. Haven't got complete solution yet.
Almost working one is attached.

Except it does not work for full cross-compiler case
(where any linking is forbidden):

./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32 
--target=x86_64-w64-mingw32 --mandir=/usr/share/man --infodir=/usr/share/info 
--datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib 
--libdir=/usr/lib64

...

checking whetner binutils provide ___crt_xd_start__ definitions... configure: 
error: link tests are not allowed after AC_NO_EXECUTABLES


-- 

  Sergei
From 8b68b948dcc677020f9bc6c47b75b0ad1d40ef17 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <[email protected]>
Date: Wed, 10 Oct 2012 00:12:29 +0300
Subject: [PATCH] crt: handle both binutils (with and without __crtl_xd_
 symbols)

Signed-off-by: Sergei Trofimovich <[email protected]>
---
 Makefile.am     |  2 +-
 configure.ac    | 31 +++++++++++++++++++++++++++++++
 crt/tlssup_xd.c | 19 +++++++++++++++++++
 3 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 crt/tlssup_xd.c

diff --git a/Makefile.am b/Makefile.am
index 97e4dc0..c1cc034 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -82,7 +82,7 @@ src_libmingw32=include/oscalls.h include/internal.h include/sect_attribs.h \
   crt/mingw_custom.c  crt/mingw_helpers.c  \
   crt/pseudo-reloc.c  crt/udll_argv.c      \
   crt/xtxtmode.c      crt/crt_handler.c    \
-  crt/tlsthrd.c       crt/tlsmthread.c     crt/tlsmcrt.c
+  crt/tlsthrd.c       crt/tlsmthread.c     crt/tlsmcrt.c   crt/tlssup_xd.c
 
 src_libmoldname=crt/isascii.c crt/iscsym.c crt/iscsymf.c crt/toascii.c crt/strcasecmp.c crt/strncasecmp.c crt/wcscmpi.c
 src_libscrnsave=libsrc/scrnsave.c
diff --git a/configure.ac b/configure.ac
index 744823d..dd64f1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,6 +77,37 @@ AC_ARG_ENABLE([lib32],
   ])
 AM_CONDITIONAL([LIB32], [test $enable_lib32 = yes])
 
+AC_ARG_ENABLE([crt_xd],
+  [AS_HELP_STRING([--enable-crt_xd],
+    [Rely on binutils providing ___crt_xd_start__ and ___crt_xd_end__ symbols])],
+  [],
+  [AC_MSG_CHECKING([whetner binutils provide ___crt_xd_start__ definitions])
+   _save_LDFLAGS="$LDFLAGS"
+   # test needs to work even when we don't have runtime yet
+   LDFLAGS="$LDFLAGS -nostdlib -nostartfiles"
+   AC_LINK_IFELSE(
+     [AC_LANG_PROGRAM(
+       [[
+extern void * __crt_xd_start__;
+extern void * __crt_xd_end__;
+int __main()
+{
+    return (__crt_xd_start__ == __crt_xd_end__);
+}
+       ]],
+       []
+     )],
+     [enable_crt_xd=yes],
+     [enable_crt_xd=no])
+   AC_MSG_RESULT([$enable_crt_xd])
+   LDFLAGS="$_save_CFLAGS"
+  ])
+
+# fixme:
+if test $enable_crt_xd = yes; then
+  AC_DEFINE(HAVE_CRT_XD_START_END, 1, [Set if binutils provides ___crt_xd_start__ and ___crt_xd_end__])
+fi
+
 AC_ARG_ENABLE([lib64],
   [AS_HELP_STRING([--enable-lib64],
     [Build the Win64 runtime])],
diff --git a/crt/tlssup_xd.c b/crt/tlssup_xd.c
new file mode 100644
index 0000000..bb6c95b
--- /dev/null
+++ b/crt/tlssup_xd.c
@@ -0,0 +1,19 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ *
+ * Written by Sergei Trofimovich <[email protected]>
+ */
+
+#ifndef HAVE_CRT_XD_START_END
+
+#ifndef __INTERNAL_FUNC_DEFINED
+#define __INTERNAL_FUNC_DEFINED
+typedef void (__cdecl *_PVFV)(void);
+#endif
+
+_PVFV __crt_xd_start__ = 0;
+_PVFV __crt_xd_end__   = 0;
+
+#endif /* !HAVE_CRT_XD_START_END */
-- 
1.7.12

Attachment: signature.asc
Description: PGP signature

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to