Patchwork Windows 64 bits support

login
register
mail settings
Submitter Yann Diorcet
Date Oct. 23, 2012, 12:55 p.m.
Message ID <508693BD.30701@gmail.com>
Download mbox | patch
Permalink /patch/193480/
State Changes Requested
Headers show

Comments

Yann Diorcet - Oct. 23, 2012, 12:55 p.m.
Dear list,

I have quickly(but working) made patchs for support x86_64 for win32 
using mingw32-w64 project.

I'am successfully cross compile a 64 bits application using directx 
(awesome).

I don't know very well crosstool-ng (i use mingw32 as base) maybe some 
things are ugly ...

Regards,

Yann Diorcet

diff -urN crosstool-ng-1.16.0/samples/x86_64-w64-mingw32/crosstool.config crosstool-ng-1.16.0win64/samples/x86_64-w64-mingw32/crosstool.config
--- crosstool-ng-1.16.0/samples/x86_64-w64-mingw32/crosstool.config	1970-01-01 01:00:00.000000000 +0100
+++ crosstool-ng-1.16.0win64/samples/x86_64-w64-mingw32/crosstool.config	2012-10-23 11:17:04.284674900 +0200
@@ -0,0 +1,18 @@
+CT_EXPERIMENTAL=y
+CT_LOCAL_TARBALLS_DIR="${HOME}/src"
+CT_SAVE_TARBALLS=y
+CT_LOG_EXTRA=y
+CT_ARCH_64=y
+CT_ARCH_x86=y
+CT_TARGET_VENDOR="w64"
+CT_KERNEL_mingw64=y
+CT_BINUTILS_V_2_21_1a=y
+CT_BINUTILS_PLUGINS=y
+CT_CC_V_4_5_1=y
+CT_CC_LANG_CXX=y
+CT_MINGW_DIRECTX=y
+CT_MINGW_DDK=y
+CT_GMP_V_4_3_2=y
+CT_MPFR_V_2_4_2=y
+CT_PPL_V_0_10_2=y
+CT_CLOOG_V_0_15_10=y
diff -urN crosstool-ng-1.16.0/samples/x86_64-w64-mingw32/reported.by crosstool-ng-1.16.0win64/samples/x86_64-w64-mingw32/reported.by
--- crosstool-ng-1.16.0/samples/x86_64-w64-mingw32/reported.by	1970-01-01 01:00:00.000000000 +0100
+++ crosstool-ng-1.16.0win64/samples/x86_64-w64-mingw32/reported.by	2012-10-23 12:13:25.996572843 +0200
@@ -0,0 +1,3 @@
+reporter_name="Yann Diorcet <diorcet.yann@gmail.com>"
+reporter_url=""
+reporter_comment="Config to build cross-compiler with mingw-w64 as kernel type"
diff -urN crosstool-ng-1.16.0/scripts/build/kernel/mingw64.sh crosstool-ng-1.16.0win64/scripts/build/kernel/mingw64.sh
--- crosstool-ng-1.16.0/scripts/build/kernel/mingw64.sh	1970-01-01 01:00:00.000000000 +0100
+++ crosstool-ng-1.16.0win64/scripts/build/kernel/mingw64.sh	2012-10-23 12:16:04.347473714 +0200
@@ -0,0 +1,83 @@
+# This file declares functions to install the kernel headers for mingw64
+# Copyright 2012 Yann Diorcet
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+CT_DoKernelTupleValues() {
+    CT_TARGET_KERNEL="mingw32"
+    CT_TARGET_SYS=
+}
+
+do_kernel_get() {
+    CT_GetFile "mingw-w64-v${CT_W64API_VERSION}" \
+        http://downloads.sourceforge.net/sourceforge/mingw-w64
+}
+
+do_kernel_extract() {
+    CT_Extract "mingw-w64-v${CT_W64API_VERSION}"
+}
+
+do_kernel_headers() {
+    CT_DoStep INFO "Installing kernel headers"
+
+    mkdir -p "${CT_HEADERS_DIR}"
+#    cp -r ${CT_SRC_DIR}/mingw-w64-v${CT_W64API_VERSION}/include/*   \
+#          ${CT_HEADERS_DIR}
+
+    if [ -n "${CT_MINGW_DIRECTX}" ]; then
+        sdk_opt="directx"
+        if [ -n "${CT_MINGW_DDK}" ]; then
+            sdk_opt="all"
+        fi
+    else
+        if [ -n "${CT_MINGW_DDK}" ]; then
+            sdk_opt="ddk"
+        else
+            sdk_opt="none"
+        fi
+    fi
+
+    CT_mkdir_pushd "${CT_BUILD_DIR}/build-header-build-${CT_BUILD}"
+    gmp_opts+=( "host=${CT_TARGET}" )
+    gmp_opts+=( "prefix=${CT_SYSROOT_DIR}" )
+    gmp_opts+=( "sdk=${sdk_opt}" )
+    do_mingw64_headers_backend "${gmp_opts[@]}"
+
+    CT_Popd
+
+    CT_DoExecLog ALL cp -r ${CT_SYSROOT_DIR}/${CT_TARGET}/include/*   \
+                     ${CT_HEADERS_DIR}
+
+    CT_EndStep
+}
+
+# Build MINGW64 headers
+#     Parameter     : description               : type      : default
+#     host          : machine to run on         : tuple     : (none)
+#     prefix        : prefix to install into    : dir       : (none)
+#     cflags        : host cflags to use        : string    : (empty)
+do_mingw64_headers_backend() {
+    local host
+    local prefix
+    local cflags
+    local arg
+    local sdk
+
+    for arg in "$@"; do
+        eval "${arg// /\\ }"
+    done
+
+    CT_DoLog EXTRA "Configuring Headers"
+
+    CT_DoExecLog CFG                                \
+    "${CT_SRC_DIR}/mingw-w64-v${CT_W64API_VERSION}/mingw-w64-headers/configure" \
+	--build=${CT_BUILD}			    \
+        --host=${host}                              \
+        --prefix="${prefix}"                        \
+        --enable-sdk="${sdk}"
+
+    CT_DoLog EXTRA "Compile Headers"
+    CT_DoExecLog ALL make
+
+    CT_DoLog EXTRA "Installing Headers"
+    CT_DoExecLog ALL make install
+}
diff -urN crosstool-ng-1.16.0/scripts/build/libc/mingw64.sh crosstool-ng-1.16.0win64/scripts/build/libc/mingw64.sh
--- crosstool-ng-1.16.0/scripts/build/libc/mingw64.sh	1970-01-01 01:00:00.000000000 +0100
+++ crosstool-ng-1.16.0win64/scripts/build/libc/mingw64.sh	2012-10-23 12:17:32.577009128 +0200
@@ -0,0 +1,52 @@
+do_libc_get() { 
+    CT_GetFile "mingw-w64-v${CT_W64API_VERSION}" \
+        http://downloads.sourceforge.net/sourceforge/mingw-w64
+}
+
+do_libc_extract() {
+	CT_Extract "mingw-w64-v${CT_W64API_VERSION}"
+}
+
+do_libc_check_config() {
+    :
+}
+
+do_libc_start_files() {
+    CT_DoStep INFO "Installing C library headers"
+
+    # It seems mingw is strangely set up to look into /mingw instead of
+    # /usr (notably when looking for the headers). This symlink is
+    # here to workaround this, and seems to be here to last... :-/
+    CT_DoExecLog ALL ln -sv "${CT_TARGET}" "${CT_SYSROOT_DIR}/mingw"
+
+    CT_EndStep
+}
+
+do_libc() {
+    CT_DoStep INFO "Building MinGW64 files"
+
+    CT_DoLog EXTRA "Configuring W64-CRT"
+
+    mkdir -p "${CT_BUILD_DIR}/build-w64crt"
+    cd "${CT_BUILD_DIR}/build-w64crt"
+
+    CT_DoExecLog CFG                                                  \
+    "${CT_SRC_DIR}/mingw-w64-v${CT_W64API_VERSION}/mingw-w64-crt/configure" \
+        --prefix=${CT_SYSROOT_DIR}                                    \
+        --host=${CT_TARGET}
+
+    CT_DoLog EXTRA "Building W64-CRT"
+    CT_DoExecLog ALL make ${JOBSFLAGS}
+
+    CT_DoLog EXTRA "Installing W64-CRT"
+    CT_DoExecLog ALL make install
+
+    CT_EndStep
+}
+
+do_libc_finish() {
+    CT_DoStep INFO "Installing MinGW64 Development libraries"
+
+    CT_EndStep
+}
+
--
For unsubscribe information see http://sourceware.org/lists.html#faq
Yann E. MORIN - Oct. 23, 2012, 5:16 p.m.
Yann, All,

[Damn it, are we going to a Yann-dominated world? ;-)]

On Tuesday 23 October 2012 Diorcet Yann wrote:
> I have quickly(but working) made patchs for support x86_64 for win32 
> using mingw32-w64 project.
> 
> I'am successfully cross compile a 64 bits application using directx 
> (awesome).
> 
> I don't know very well crosstool-ng (i use mingw32 as base) maybe some 
> things are ugly ...

Thank you for your patches!

However, here are some comments:
  - do not attach the patches; use 'hg send-email' to send your patches,
    they will be properly in-lined in the message body, so they are easier
    to review;
  - send a single changeset that adds all the necessary files at once, even
    the new sample: if only part of the files are present in a changeset,
    that makes this changeset unbuildable;
  - you need to add your Signed-off-by to your patch; see the documetnation:
    "docs/7 - Contributing to crosstool-NG.txt".

There is a step-by-step tutorial in "docs/C - Misc. tutorials.txt", section
titled "Using Mercurial to hack crosstool-NG".

Regards,
Yann E. MORIN.

Patch

diff -urN crosstool-ng-1.16.0/config/kernel/mingw64.in crosstool-ng-1.16.0win64/config/kernel/mingw64.in
--- crosstool-ng-1.16.0/config/kernel/mingw64.in	1970-01-01 01:00:00.000000000 +0100
+++ crosstool-ng-1.16.0win64/config/kernel/mingw64.in	2012-10-21 22:59:43.708325867 +0200
@@ -0,0 +1,33 @@ 
+# mingw64 config options
+
+## depends on EXPERIMENTAL && ( ARCH_x86 && ARCH_64 )
+##
+## select MINGW64
+##
+## help Build a toolchain targeting systems running Windows as host
+
+choice
+    bool
+    prompt "Windows api version"
+
+# Don't remove next line
+# CT_INSERT_VERSION_BELOW
+config W64API_V_2_0_7
+    bool
+    prompt "2.0.7"
+
+config W64API_V_select
+    bool
+    prompt "Other version"
+
+endchoice
+
+config W64API_VERSION
+    string
+    prompt "W64 api version" if W64API_V_select
+# Don't remove next line
+# CT_INSERT_VERSION_STRING_BELOW
+    default "2.0.7" if W64API_V_2_0_7
+    help
+      Enter the version number of the windows api files to use
+
diff -urN crosstool-ng-1.16.0/config/kernel.in crosstool-ng-1.16.0win64/config/kernel.in
--- crosstool-ng-1.16.0/config/kernel.in	2012-08-04 23:41:28.000000000 +0200
+++ crosstool-ng-1.16.0win64/config/kernel.in	2012-10-21 23:06:31.675797912 +0200
@@ -10,6 +10,9 @@ 
 config MINGW32
     bool
 
+config MINGW64
+    bool
+
 # Each target OS (aka kernel) that support shared libraries can select
 # this, so the user can decide whether or not to build a shared library
 # enabled toolchain
diff -urN crosstool-ng-1.16.0/config/libc/eglibc.in crosstool-ng-1.16.0win64/config/libc/eglibc.in
--- crosstool-ng-1.16.0/config/libc/eglibc.in	2012-08-04 23:41:28.000000000 +0200
+++ crosstool-ng-1.16.0win64/config/libc/eglibc.in	2012-10-21 21:53:21.905448311 +0200
@@ -1,6 +1,6 @@ 
 # eglibc options
 
-## depends on ! MINGW32 && ! BARE_METAL && ARCH_USE_MMU
+## depends on ! MINGW32 && ! MINGW64 && ! BARE_METAL && ARCH_USE_MMU
 ##
 ## select LIBC_SUPPORT_NPTL
 ## select LIBC_SUPPORT_LINUXTHREADS
diff -urN crosstool-ng-1.16.0/config/libc/glibc.in crosstool-ng-1.16.0win64/config/libc/glibc.in
--- crosstool-ng-1.16.0/config/libc/glibc.in	2012-08-04 23:41:28.000000000 +0200
+++ crosstool-ng-1.16.0win64/config/libc/glibc.in	2012-10-21 21:54:19.253134414 +0200
@@ -1,6 +1,6 @@ 
 # glibc options
 
-## depends on ! MINGW32 && ! BARE_METAL && ARCH_USE_MMU
+## depends on ! MINGW32 && ! MINGW64 && ! BARE_METAL && ARCH_USE_MMU
 ##
 ## select LIBC_SUPPORT_NPTL
 ##
diff -urN crosstool-ng-1.16.0/config/libc/mingw64.in crosstool-ng-1.16.0win64/config/libc/mingw64.in
--- crosstool-ng-1.16.0/config/libc/mingw64.in	1970-01-01 01:00:00.000000000 +0100
+++ crosstool-ng-1.16.0win64/config/libc/mingw64.in	2012-10-19 20:35:39.126314117 +0200
@@ -0,0 +1,33 @@ 
+# mingw64 options
+
+## depends on MINGW64
+##
+## select LIBC_SUPPORT_WIN32THREADS
+##
+## help The de-facto standard for Mingw distributions.
+
+choice
+    bool
+    prompt "Mingw64 runtime version"
+
+# Don't remove next line
+# CT_INSERT_VERSION_BELOW
+config MINGW64RT_V_3_18
+    bool
+    prompt "3.18"
+
+config MINGW64RT_V_select
+    bool
+    prompt "Other version"
+
+endchoice
+
+config MINGW64RT_VERSION
+    string
+    prompt "Mingw64 runtime version" if MINGW64RT_V_select
+# Don't remove next line
+# CT_INSERT_VERSION_STRING_BELOW
+    default "3.18" if MINGW64RT_V_3_18
+    help
+      Enter the version number of the mingw64 runtime files to use
+
diff -urN crosstool-ng-1.16.0/config/libc/mingw64.in.2 crosstool-ng-1.16.0win64/config/libc/mingw64.in.2
--- crosstool-ng-1.16.0/config/libc/mingw64.in.2	1970-01-01 01:00:00.000000000 +0100
+++ crosstool-ng-1.16.0win64/config/libc/mingw64.in.2	2012-10-23 11:16:31.069590088 +0200
@@ -0,0 +1,10 @@ 
+# Part-2 of mingw C library options: development libraries
+
+config MINGW_DIRECTX
+    bool
+    prompt "Include DirectX development files"
+
+config MINGW_DDK
+    bool
+    prompt "Include DDK development files"
+
diff -urN crosstool-ng-1.16.0/config/libc/uClibc.in crosstool-ng-1.16.0win64/config/libc/uClibc.in
--- crosstool-ng-1.16.0/config/libc/uClibc.in	2012-08-04 23:41:28.000000000 +0200
+++ crosstool-ng-1.16.0win64/config/libc/uClibc.in	2012-10-21 21:54:33.838072664 +0200
@@ -1,6 +1,6 @@ 
 # uClibc options
 
-## depends on ! MINGW32 && ! BARE_METAL
+## depends on ! MINGW32 && ! MINGW64 && ! BARE_METAL
 ##
 ## select LIBC_SUPPORT_LINUXTHREADS
 ## select LIBC_SUPPORT_THREADS_NONE