unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dani Moncayo <dmoncayo@gmail.com>
To: 19111@debbugs.gnu.org
Subject: bug#19111: 25.0.50; 32 bits temacs.exe is linked with wrong image-base when built on 64 bit Windows host
Date: Sat, 29 Nov 2014 11:07:14 +0100	[thread overview]
Message-ID: <CAH8Pv0gcWYYCh0xPe6zN7b_XHH83A4E0MAwNkyajwO_BYjBwPw@mail.gmail.com> (raw)
In-Reply-To: <CAH8Pv0g9jWZie4U6ijGE8rh4rAef0envZ96XzNMBx+31m6L40w@mail.gmail.com>

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

Hello,

I have to say that I still don't like the way of determining the host
platform on MinGW builds, because we are setting $host and $canonical
to a value (the compiler's target) that is not guaranteed to be
canonical (and in fact is not canonical in the cases I've tried, see
below).

The following table shows the canonical host (as given by
'build-aux/config.guess') and gcc target taken from the 5 different
build environments for MS-Windows I know of:

#  MSYS type     $MSYSTEM   canonical host      gcc target
-  -----------   --------   -----------------   ------------------
1  MSYS          MINGW32    i686-pc-mingw32     mingw32
2  MSYS2-32bit   MINGW32    i686-pc-mingw32     i686-w64-mingw32
3  MSYS2-32bit   MINGW64    i686-pc-mingw64     x86_64-w64-mingw32
4  MSYS2-64bit   MINGW32    x86_64-pc-mingw32   i686-w64-mingw32
5  MSYS2-64bit   MINGW64    x86_64-pc-mingw64   x86_64-w64-mingw32
------------------------------------------------------------------

As you can see, our problem is only in the environments 3 and 4, where
the first part of the canonical triplet (CPU in CPU-VENDOR-OS) is not
what we want.

But note that this problem is easily fixable: the CPU we want can be
deduced from the OS part of the triplet:
* mingw32 --> i686
* mingw64 --> x86_64

The following patch (also attached) is an attempt to fix this.

WDYT?

diff --git a/configure.ac b/configure.ac
index 010abc8..d7a17f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,32 +142,18 @@ case $host in
  *-mingw*)

   if test -z "$host_alias"; then
-
-      # No --host argument was given to 'configure'; therefore $host
-      # was set to a default value based on the build platform.  But
-      # this default value may be wrong if we are building from a
-      # 64-bit MSYS[2] pre-configured to build 32-bit MinGW programs.
-      # Therefore, we'll try to get the right host platform from the
-      # compiler's target.
-
-      AC_MSG_CHECKING([the compiler's target])
-      if test -z "$CC"; then
-  cc=gcc
-      else
-  cc=$CC
-      fi
-      cc_target=`$cc -v 2>&1 | sed -n 's/Target: //p'`
-      case "$cc_target" in
-          *-*) host=$cc_target
-      ;;
-          "") AC_MSG_ERROR([Impossible to obtain $cc compiler target.
-Please explicitly provide --host.])
-              ;;
-  *) AC_MSG_WARN([Compiler reported non-standard target.
-Defaulting to $host.])
-              ;;
-      esac
-      AC_MSG_RESULT([$host])
+    # No --host argument was given; therefore $host was set to $build.
+    # But this default value is wrong if we are building from MSYS2
+    # 64-bit with the mingw32 shell, or from MSYS2 32-bit with the
+    # mingw64 shell.  So we have to amend $host in those cases.
+    host1=`AS_ECHO $host | sed \
+      -e 's/x86_64-pc-mingw32/i686-pc-mingw32/' \
+      -e 's/i686-pc-mingw64/x86_64-pc-mingw64/'`
+
+    if test "$host1" != "$host"; then
+      host=$host1
+      AC_MSG_WARN([host system type amended to $host])
+    fi
   fi

   . $srcdir/nt/mingw-cfg.site



-- 
Dani Moncayo

[-- Attachment #2: tmp.diff --]
[-- Type: text/plain, Size: 1663 bytes --]

diff --git a/configure.ac b/configure.ac
index 010abc8..d7a17f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,32 +142,18 @@ case $host in
  *-mingw*)
 
   if test -z "$host_alias"; then
-
-      # No --host argument was given to 'configure'; therefore $host
-      # was set to a default value based on the build platform.  But
-      # this default value may be wrong if we are building from a
-      # 64-bit MSYS[2] pre-configured to build 32-bit MinGW programs.
-      # Therefore, we'll try to get the right host platform from the
-      # compiler's target.
-
-      AC_MSG_CHECKING([the compiler's target])
-      if test -z "$CC"; then
-	  cc=gcc
-      else
-	  cc=$CC
-      fi
-      cc_target=`$cc -v 2>&1 | sed -n 's/Target: //p'`
-      case "$cc_target" in
-          *-*) host=$cc_target
-	      ;;
-          "") AC_MSG_ERROR([Impossible to obtain $cc compiler target.
-Please explicitly provide --host.])
-              ;;
-	  *) AC_MSG_WARN([Compiler reported non-standard target.
-Defaulting to $host.])
-              ;;
-      esac
-      AC_MSG_RESULT([$host])
+    # No --host argument was given; therefore $host was set to $build.
+    # But this default value is wrong if we are building from MSYS2
+    # 64-bit with the mingw32 shell, or from MSYS2 32-bit with the
+    # mingw64 shell.  So we have to amend $host in those cases.
+    host1=`AS_ECHO $host | sed \
+      -e 's/x86_64-pc-mingw32/i686-pc-mingw32/' \
+      -e 's/i686-pc-mingw64/x86_64-pc-mingw64/'`
+
+    if test "$host1" != "$host"; then
+      host=$host1
+      AC_MSG_WARN([host system type amended to $host])
+    fi
   fi
 
   . $srcdir/nt/mingw-cfg.site

  reply	other threads:[~2014-11-29 10:07 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19 20:27 bug#19111: 25.0.50; 32 bits temacs.exe is linked with wrong image-base when built on 64 bit Windows host Óscar Fuentes
2014-11-19 20:40 ` Eli Zaretskii
2014-11-19 21:27   ` Óscar Fuentes
2014-11-19 21:50     ` Óscar Fuentes
2014-11-19 22:01       ` Óscar Fuentes
2014-11-20  3:45         ` Eli Zaretskii
2014-11-20  3:43       ` Eli Zaretskii
2014-11-20  3:41     ` Eli Zaretskii
2014-11-20  4:10       ` Óscar Fuentes
2014-11-20 16:05         ` Eli Zaretskii
2014-11-20 16:23           ` Óscar Fuentes
2014-11-20 17:12             ` Eli Zaretskii
2014-11-20 18:30               ` Óscar Fuentes
2014-11-20 19:12                 ` Dani Moncayo
2014-11-20 21:03                 ` Eli Zaretskii
2014-11-21  0:07                   ` Óscar Fuentes
2014-11-21  8:28                     ` Eli Zaretskii
2014-11-21 14:15                       ` Óscar Fuentes
2014-11-21 15:03                         ` Eli Zaretskii
2014-11-21 16:06                           ` Dani Moncayo
2014-11-21 17:02                             ` Glenn Morris
2014-11-21 17:17                               ` Dani Moncayo
2014-11-21 17:21                                 ` Glenn Morris
2014-11-21 18:12                           ` Óscar Fuentes
2014-11-21 17:56                     ` Dani Moncayo
2014-11-21 18:01                       ` Dani Moncayo
2014-11-21 18:21                         ` Óscar Fuentes
2014-11-21 18:34                           ` Dani Moncayo
2014-11-21 18:41                             ` Óscar Fuentes
2014-11-21 22:54                               ` Óscar Fuentes
2014-11-22  1:05                                 ` Glenn Morris
2014-11-22  1:13                                   ` Óscar Fuentes
2014-11-25  2:38                                     ` Óscar Fuentes
2014-11-25 20:26                                       ` Dani Moncayo
2014-11-25 20:52                                         ` Óscar Fuentes
2014-11-25 21:13                                           ` Dani Moncayo
2014-11-25 23:41                                             ` Óscar Fuentes
2014-11-25 23:46                                               ` Dani Moncayo
2014-11-26  0:00                                                 ` Óscar Fuentes
2014-11-26  3:49                                                   ` Eli Zaretskii
2014-11-26 20:05                                                     ` Dani Moncayo
2014-11-29 10:07                                                       ` Dani Moncayo [this message]
2014-11-29 10:32                                                         ` Eli Zaretskii
2014-11-29 18:22                                                           ` Dani Moncayo
2014-11-29 18:31                                                             ` Eli Zaretskii
2014-11-29 19:25                                                               ` Dani Moncayo
2014-11-29 20:23                                                                 ` Eli Zaretskii
2014-11-29 20:37                                                                   ` Dani Moncayo
2014-11-29 20:52                                                                     ` Eli Zaretskii
2014-11-29 16:24                                                         ` Óscar Fuentes
2014-11-29 18:37                                                           ` Dani Moncayo
2014-11-29 18:49                                                             ` Eli Zaretskii
2014-11-29 19:23                                                               ` Dani Moncayo
2014-11-29 19:33                                                                 ` Achim Gratz
2014-11-29 19:41                                                                   ` Andreas Schwab
2014-11-29 19:45                                                                 ` Óscar Fuentes
2014-11-29 20:21                                                                 ` Eli Zaretskii
2014-11-25 23:42                                             ` Dani Moncayo
2014-11-22  8:46                                 ` Dani Moncayo
2014-11-22 10:16                                   ` Eli Zaretskii
2014-11-22 15:11                                   ` Óscar Fuentes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH8Pv0gcWYYCh0xPe6zN7b_XHH83A4E0MAwNkyajwO_BYjBwPw@mail.gmail.com \
    --to=dmoncayo@gmail.com \
    --cc=19111@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).