cross compile

18997 ワード

mingw版のgemは通常cまたはc++を拡張し、コンパイルされたsoを直接含み、ruby 1をサポートするなどrubyバージョンに対応する.8と1.9は、それぞれlib/1.8とlib/1.9にあります.今は2.0をサポートします.archlinuxで2.0に対応するsoをいくつかコンパイルしました.nokogiri、eventmachine、mysql 2、yajl-ruby、bcrypt-ruby、windowsに使います.
#archlinux上装mingw

pacman -S mingw32-gcc

# rake-compiler

gem i rake-compiler
rake-compiler cross-ruby VERSION=2.0.0-p0 HOST=i486-mingw32

#=> --host=i486-mingw32 --target=i486-mingw32 --build=x86_64-unknown-linux-gnu --enable-shared --disable-install-doc --without-tk --without-tcl --prefix=/root/.rake-compiler/ruby/ruby-2.0.0-p0 build_alias=x86_64-unknown-linux-gnu host_alias=i486-mingw32 target_alias=i486-mingw32

#mingw対応soを得る

gem i nokogiri -v 1.5.6
cd /usr/local/lib/ruby/gems/2.0.0/gems/nokogiri-1.5.6/

rake cross compile #   ,      

i486-mingw32-strip nokogiri.so #   

#mingw版gemを入手
rake cross native gem

mingw版nokogiriをコンパイルする前提は、mingw版のlibiconv、libxml 2、libxslt、zlibをインストールすることです.こんなに依存するスクリプトを書くのは間違いが避けられないので、HOW_を書くほうがいいです.TO
# nokogiri 1.5.6
に頼る
## libiconv 1.13.1

wget http://mirror.anl.gov/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xzvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1

./configure --host=i486-mingw32 --enable-static --disable-shared --prefix=/usr/i486-mingw32/libiconv/1.13.1
make && make install

## libxml2 2.8.0

wget ftp://xmlsoft.org/libxml2/libxml2-2.8.0.tar.gz
tar xzvf libxml2-2.8.0.tar.gz
cd libxml2-2.8.0/

./configure --host=i486-mingw32 --enable-static --disable-shared --prefix=/usr/i486-mingw32/libxml2/2.8.0
make && make install

## libxslt 1.1.26

wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar xzvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26

in xsltproc/testThreads.c line 203 and 245:

tid[i]=(pthread_t)-1;

should be

tid[i].p= NULL;
tid[i].x=-1;

./configure --host=i486-mingw32 --enable-static --disable-shared --with-libxml-prefix=/usr/i486-mingw32/libxml2/2.8.0 --without-python --without-crypto CFLAGS=-DIN_LIBXML --prefix=/usr/i486-mingw32/libxslt/1.1.26
make && make install

## zlib 1.2.7
on win32/Makefile.gcc line 44
  
PREFIX =

should be
  
PREFIX = i486-mingw32-

make -f win32/Makefile.gcc BINARY_PATH=/usr/i486-mingw32/zlib/1.2.7/bin INCLUDE_PATH=/usr/i486-mingw32/zlib/1.2.7/include LIBRARY_PATH=/usr/i486-mingw32/zlib/1.2.7/lib install

## ext

gem i nokogiri -v 1.5.6

cd /usr/local/lib/ruby/gems/2.0.0/gems/nokogiri-1.5.6/

in tasks/cross_compile.rb line 97 and 127:
  
sh 

should be
  
system

in Rakefile line 103 change to:

ext.cross_platform = ["x86-mingw32"]

touch ports/libiconv-1.13.1.installed && touch ports/libxml2-2.7.7.installed && touch ports/libxslt-1.1.26.installed && touch ports/zlib-1.2.7.installed

cd ext/nokogiri && make clean
cd ../../

rake cross compile

エラー(tmp/x 86-mingw 32/nokogiri/2.0.0が生成されました)

cd /usr/local/lib/ruby/gems/2.0.0/gems/nokogiri-1.5.6/tmp/x86-mingw32/nokogiri/2.0.0

export ports_dir=/usr/i486-mingw32
/usr/local/bin/ruby -I. -rfake ../../../../ext/nokogiri/extconf.rb --with-iconv-include=$ports_dir/libiconv/1.13.1/include --with-iconv-lib=$ports_dir/libiconv/1.13.1/lib --with-xml2-include=$ports_dir/libxml2/2.8.0/include --with-xml2-lib=$ports_dir/libxml2/2.8.0/lib --with-xslt-include=$ports_dir/libxslt/1.1.26/include --with-xslt-lib=$ports_dir/libxslt/1.1.26/lib --with-zlib-include=$ports_dir/zlib/1.2.7/include --with-zlib-lib=$ports_dir/zlib/1.2.7/lib
make clean && make

# eventmachine 1.0.1
に頼る
## openssl 1.0.1e

./Configure --prefix=/usr/i486-mingw32 no-asm mingw
make CC=i486-mingw32-gcc AR="i486-mingw32-ar r" RANLIB=i486-mingw32-ranlib && make install

## ext

gem i eventmachine -v 1.0.1
cd /usr/local/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.1/

cd ext && make clean
cd fastfilereader && make clean
cd ../../

rake cross compile

## rubyeventmachine

# cd tmp/x86-mingw32/rubyeventmachine/2.0.0
# /usr/local/bin/ruby -I. -rfake ../../../../ext/extconf.rb --with-ssl-dir=/usr/i486-mingw32

## fastfilereader

# cd tmp/x86-mingw32/fastfilereaderext/2.0.0
# /usr/local/bin/ruby -I. -rfake ../../../../ext/fastfilereader/extconf.rb

# mysql2

# copy mysql-connector-c-noinstall-6.0.2-win32.zip to /usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/vendor/

cd /usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11

cd ext/mysql2 && make clean
cd ../../

rake cross compile 

# cd tmp/x86-mingw32/mysql2/2.0.0
# /usr/local/bin/ruby -I. -rfake ../../../../ext/mysql2/extconf.rb --with-mysql-include=/usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/vendor/mysql-connector-c-noinstall-6.0.2-win32/include --with-mysql-lib=/usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/vendor/mysql-connector-c-noinstall-6.0.2-win32/lib

# yajl-ruby

gem i yajl-ruby -v 1.1.0
cd /usr/local/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.1.0/

cd ext/yajl && make clean
cd ../../

rake cross compile

# cd tmp/x86-mingw32/yajl/2.0.0
# /usr/local/bin/ruby -I. -rfake ../../../../ext/yajl/extconf.rb

# bcrypt-ruby

gem i bcrypt-ruby -v 3.0.1
cd /usr/local/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.0.1/

in Rakefile line 2 should be

require 'rubygems/package_task'

line 7 should be

require 'rdoc/task'

line 40 should be

rd = RDoc::Task.new do |rdoc|

line 47 should be

Gem::PackageTask.new(GEMSPEC) do |pkg|

cd ext/mri && make clean
cd ../../

rake cross compile

# cd tmp/x86-mingw32/bcrypt_ext/2.0.0
# /usr/local/bin/ruby -I. -rfake ../../../../ext/mri/extconf.rb

64ビットのオペレーティングシステムはmingw-w 64をインストールできます.

wget https://aur.archlinux.org/packages/mi/mingw-w64-binutils/mingw-w64-binutils.tar.gz
wget https://aur.archlinux.org/packages/mi/mingw-w64-headers/mingw-w64-headers.tar.gz
wget https://aur.archlinux.org/packages/mi/mingw-w64-headers-bootstrap/mingw-w64-headers-bootstrap.tar.gz
wget https://aur.archlinux.org/packages/mi/mingw-w64-gcc-base/mingw-w64-gcc-base.tar.gz
wget https://aur.archlinux.org/packages/mi/mingw-w64-crt/mingw-w64-crt.tar.gz
wget https://aur.archlinux.org/packages/mi/mingw-w64-winpthreads/mingw-w64-winpthreads.tar.gz
wget https://aur.archlinux.org/packages/mi/mingw-w64-gcc/mingw-w64-gcc.tar.gz

1. mingw-w64-binutils
tar xzvf mingw-w64-binutils.tar.gz
cd mingw-w64-binutils
makepkg -s --asroot
pacman -U mingw-w64-binutils-2.23.1-1-x86_64.pkg.tar.xz

2. mingw-w64-headers
3. mingw-w64-headers-bootstrap
4. mingw-w64-gcc-base
5. mingw-w64-crt
6. mingw-w64-winpthreads (replace mingw-w64-headers-bootstrap)
7. mingw-w64-gcc (replace mingw-w64-gcc-base)

mingw-w 64シリーズパッケージはaurで、依存は少し結合してまだ解決していません.mingw-w 64-gccのPKGBUILDにはエラーのadaが含まれています.
build()--enable-languages=c,lto,c++,objc,obj-c+,fortran,adaadaを取り除く;
package()strip${pkgdir}/usr/libexec/gcc/${_target}/${pkgver}/{cc 1*,collect 2,gnat 1,f 951,lto*}gnat 1を除去します.
make mingw-w 64-gcc-baseとmingw-w 64-gccはgcc/doc/cppoptsを間違えた.texi:806:@itemx must follow@itemパッチ適用http://gcc.gnu.org/ml/gcc-patches/2012-10/msg02505.html
invoke.texiはまだ1箇所漏れています

@itemx -fdump-rtl-pro_and_epilogue

should be

@item -fdump-rtl-pro_and_epilogue

diff -au a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi

md5sum gcc-4.7.2-itemx_must_follow_item.patch

in PKGBUILD、sourceとmd 5 sumsにこのパッチを追加、build()セグメントに追加

patch -Np1 -i ${srcdir}/gcc-4.7.2-itemx_must_follow_item.patch

gcc-4.7.2-itemx_must_follow_item.patch

diff -au a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
--- a/gcc/doc/invoke.texi 2013-03-05 12:08:45 +0800
+++ b/gcc/doc/invoke.texi 2013-03-05 14:16:27 +0800
@@ -1592,7 +1592,7 @@
 this will become the default.  The name @samp{gnu9x} is deprecated.
 
 @item gnu11
-@item gnu1x
+@itemx gnu1x
 GNU dialect of ISO C11.  Support is incomplete and experimental.  The
 name @samp{gnu1x} is deprecated.
 
@@ -5179,7 +5179,7 @@
 e.g. With -fdbg-cnt=dce:10,tail_call:0
 dbg_cnt(dce) will return true only for first 10 invocations
 
-@itemx -fenable-@var{kind}-@var{pass}
+@item -fenable-@var{kind}-@var{pass}
 @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
 @opindex fdisable-
 @opindex fenable-
@@ -5327,11 +5327,11 @@
 @option{-fdump-rtl-ce3} enable dumping after the three
 if conversion passes.
 
-@itemx -fdump-rtl-cprop_hardreg
+@item -fdump-rtl-cprop_hardreg
 @opindex fdump-rtl-cprop_hardreg
 Dump after hard register copy propagation.
 
-@itemx -fdump-rtl-csa
+@item -fdump-rtl-csa
 @opindex fdump-rtl-csa
 Dump after combining stack adjustments.
 
@@ -5342,11 +5342,11 @@
 @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
 the two common sub-expression elimination passes.
 
-@itemx -fdump-rtl-dce
+@item -fdump-rtl-dce
 @opindex fdump-rtl-dce
 Dump after the standalone dead code elimination passes.
 
-@itemx -fdump-rtl-dbr
+@item -fdump-rtl-dbr
 @opindex fdump-rtl-dbr
 Dump after delayed branch scheduling.
 
@@ -5391,7 +5391,7 @@
 @opindex fdump-rtl-initvals
 Dump after the computation of the initial value sets.
 
-@itemx -fdump-rtl-into_cfglayout
+@item -fdump-rtl-into_cfglayout
 @opindex fdump-rtl-into_cfglayout
 Dump after converting to cfglayout mode.
 
@@ -5421,7 +5421,7 @@
 @opindex fdump-rtl-rnreg
 Dump after register renumbering.
 
-@itemx -fdump-rtl-outof_cfglayout
+@item -fdump-rtl-outof_cfglayout
 @opindex fdump-rtl-outof_cfglayout
 Dump after converting from cfglayout mode.
 
@@ -5433,7 +5433,7 @@
 @opindex fdump-rtl-postreload
 Dump after post-reload optimizations.
 
-@itemx -fdump-rtl-pro_and_epilogue
+@item -fdump-rtl-pro_and_epilogue
 @opindex fdump-rtl-pro_and_epilogue
 Dump after generating the function prologues and epilogues.
 
@@ -10494,10 +10494,10 @@
 The default is @option{-mfp-mode=caller}
 
 @item -mnosplit-lohi
+@itemx -mno-postinc
+@itemx -mno-postmodify
 @opindex mnosplit-lohi
-@item -mno-postinc
 @opindex mno-postinc
-@item -mno-postmodify
 @opindex mno-postmodify
 Code generation tweaks that disable, respectively, splitting of 32-bit
 loads, generation of post-increment addresses, and generation of
@@ -11409,7 +11409,7 @@
 memory and if @code{-mshort-calls} is not set.
 
 @item __AVR_HAVE_EIJMP_EICALL__
-@item __AVR_3_BYTE_PC__
+@itemx __AVR_3_BYTE_PC__
 The device has the @code{EIJMP} and @code{EICALL} instructions.
 This is the case for devices with more than 128@tie{}KiB of program memory.
 This also means that the program counter
@@ -11420,13 +11420,13 @@
 with up to 128@tie{}KiB of program memory.
 
 @item __AVR_HAVE_8BIT_SP__
-@item __AVR_HAVE_16BIT_SP__
+@itemx __AVR_HAVE_16BIT_SP__
 The stack pointer (SP) register is treated as 8-bit respectively
 16-bit register by the compiler.
 The definition of these macros is affected by @code{-mtiny-stack}.
 
 @item __AVR_HAVE_SPH__
-@item __AVR_SP8__
+@itemx __AVR_SP8__
 The device has the SPH (high part of stack pointer) special function
 register or has an 8-bit stack pointer, respectively.
 The definition of these macros is affected by @code{-mmcu=} and
@@ -11434,9 +11434,9 @@
 by @code{-msp8}.
 
 @item __AVR_HAVE_RAMPD__
-@item __AVR_HAVE_RAMPX__
-@item __AVR_HAVE_RAMPY__
-@item __AVR_HAVE_RAMPZ__
+@itemx __AVR_HAVE_RAMPX__
+@itemx __AVR_HAVE_RAMPY__
+@itemx __AVR_HAVE_RAMPZ__
 The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
 @code{RAMPZ} special function register, respectively.
 
@@ -11444,7 +11444,7 @@
 This macro reflects the @code{-mno-interrupts} command line option.
 
 @item __AVR_ERRATA_SKIP__
-@item __AVR_ERRATA_SKIP_JMP_CALL__
+@itemx __AVR_ERRATA_SKIP_JMP_CALL__
 Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
 instructions because of a hardware erratum.  Skip instructions are
 @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
@@ -17971,7 +17971,7 @@
 @option{-mhitachi} is given.
 
 @item -mieee
-@item -mno-ieee
+@itemx -mno-ieee
 @opindex mieee
 @opindex mnoieee
 Control the IEEE compliance of floating-point comparisons, which affects the
diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi
index 27b1095..a2eb79d 100644
--- a/gcc/doc/cppopts.texi
+++ b/gcc/doc/cppopts.texi
@@ -1,5 +1,5 @@
 @c Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-@c 2010, Free Software Foundation, Inc.
+@c 2010, 2012, Free Software Foundation, Inc.
 @c This is part of the CPP and GCC manuals.
 @c For copying conditions, see the file gcc.texi.
 
@@ -805,7 +805,7 @@ Replacement:      [    ]    @{    @}    #    \    ^    |    ~
 Enable special code to work around file systems which only permit very
 short file names, such as MS-DOS@.
 
-@itemx --help
+@item --help
 @itemx --target-help
 @opindex help
 @opindex target-help
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index fb1becb..5c4f8fd 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1251,10 +1251,10 @@ The @code{__flash} qualifier will locate data in the
 instruction. Pointers to this address space are 16 bits wide.
 
 @item __flash1
-@item __flash2
-@item __flash3
-@item __flash4
-@item __flash5
+@itemx __flash2
+@itemx __flash3
+@itemx __flash4
+@itemx __flash5
 @cindex @code{__flash1} AVR Named Address Spaces
 @cindex @code{__flash2} AVR Named Address Spaces
 @cindex @code{__flash3} AVR Named Address Spaces
diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi
index c739731..e878811 100644
--- a/gcc/doc/generic.texi
+++ b/gcc/doc/generic.texi
@@ -1,4 +1,4 @@
-@c Copyright (c) 2004, 2005, 2007, 2008, 2010 Free Software Foundation, Inc.
+@c Copyright (c) 2004, 2005, 2007, 2008, 2010, 2012 Free Software Foundation, Inc.
 @c Free Software Foundation, Inc.
 @c This is part of the GCC manual.
 @c For copying conditions, see the file gcc.texi.
@@ -1417,13 +1417,13 @@ generate these expressions anyhow, if it can tell that strictness does
 not matter.  The type of the operands and that of the result are
 always of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
 
-@itemx POINTER_PLUS_EXPR
+@item POINTER_PLUS_EXPR
 This node represents pointer arithmetic.  The first operand is always
 a pointer/reference type.  The second operand is always an unsigned
 integer type compatible with sizetype.  This is the only binary
 arithmetic operand that can operate on pointer types.
 
-@itemx PLUS_EXPR
+@item PLUS_EXPR
 @itemx MINUS_EXPR
 @itemx MULT_EXPR
 These nodes represent various binary arithmetic operations.
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index dfbdc4c..bca0d8f 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -4483,8 +4483,8 @@ means of constraints requiring operands 1 and 0 to be the same location.
 @cindex @code{ior@var{m}3} instruction pattern
 @cindex @code{xor@var{m}3} instruction pattern
 @item @samp{ssadd@var{m}3}, @samp{usadd@var{m}3}
-@item @samp{sub@var{m}3}, @samp{sssub@var{m}3}, @samp{ussub@var{m}3}
-@item @samp{mul@var{m}3}, @samp{ssmul@var{m}3}, @samp{usmul@var{m}3}
+@itemx @samp{sub@var{m}3}, @samp{sssub@var{m}3}, @samp{ussub@var{m}3}
+@itemx @samp{mul@var{m}3}, @samp{ssmul@var{m}3}, @samp{usmul@var{m}3}
 @itemx @samp{div@var{m}3}, @samp{ssdiv@var{m}3}
 @itemx @samp{udiv@var{m}3}, @samp{usdiv@var{m}3}
 @itemx @samp{mod@var{m}3}, @samp{umod@var{m}3}
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 89e7712..ec8263f 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -691,7 +691,7 @@ standard rule in @file{gcc/Makefile.in} to the variable
 @code{lang_checks}.
 
 @table @code
-@itemx all.cross
+@item all.cross
 @itemx start.encap
 @itemx rest.encap
 FIXME: exactly what goes in each of these targets?

install eventmachine x64
https://github.com/eventmachine/eventmachine/pull/411