On Tue, 29 Jan 2013 10:20:19 +0000
Simon Marlow <[email protected]> wrote:

> On 27/01/13 21:21, Sergei Trofimovich wrote:
> > simple build.mk:
> >
> > SRC_CC_OPTS+=-O2 -pipe
> >
> > BUILD_DOCBOOK_PDF  = NO
> > BUILD_DOCBOOK_PS   = NO
> > BUILD_DOCBOOK_HTML = NO
> > HADDOCK_DOCS       = NO
> > SRC_HC_OPTS+=-w
> >
> > Stage1Only=YES
> > GhcUnregisterised=YES
> > SplitObjs=NO
> >
> > Leads to failures of missing stage2:
> >
> > "inplace/lib/unlit"  utils/count_lines/count_lines.lprl 
> > utils/count_lines/dist/count_lines.prl
> > "inplace/bin/ghc-stage2" -optc-O2 -optc-pipe 
> > -optc-Ilibraries/primitive/cbits 
> > -optc-I'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/work/ghc-9999/libraries/base/include'
> >  
> > -optc-I'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/work/ghc-9999/rts/dist/build'
> >  
> > -optc-I'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/work/ghc-9999/includes'
> >  
> > -optc-I'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/work/ghc-9999/includes/dist-derivedconstants/header'
> >  -static  -H32m -O  -w    -package-name primitive-0.4.0.1 
> > -hide-all-packages -i -ilibraries/primitive/. 
> > -ilibraries/primitive/dist-install/build 
> > -ilibraries/primitive/dist-install/build/autogen 
> > -Ilibraries/primitive/dist-install/build 
> > -Ilibraries/primitive/dist-install/build/autogen 
> > -Ilibraries/primitive/cbits    -optP-include 
> > -optPlibraries/primitive/dist-install/build/autogen/cabal_macros.h -package 
> > base-4.7.0.0 -package ghc-prim-0.3.1.0  -O2 -XHaskell98 -XCPP -O2  
> > -no-user-package-db -rtsopts      -c libraries/prim
> itive/cbits/primitive-memops.c -o 
> libraries/primitive/dist-install/build/cbits/primitive-memops.o
> > "inplace/bin/ghc-stage2" -optc-O2 -optc-pipe 
> > -optc-Ilibraries/primitive/cbits 
> > -optc-I'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/work/ghc-9999/libraries/base/include'
> >  
> > -optc-I'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/work/ghc-9999/rts/dist/build'
> >  
> > -optc-I'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/work/ghc-9999/includes'
> >  
> > -optc-I'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/work/ghc-9999/includes/dist-derivedconstants/header'
> >  -static -prof  -H32m -O  -w    -package-name primitive-0.4.0.1 
> > -hide-all-packages -i -ilibraries/primitive/. 
> > -ilibraries/primitive/dist-install/build 
> > -ilibraries/primitive/dist-install/build/autogen 
> > -Ilibraries/primitive/dist-install/build 
> > -Ilibraries/primitive/dist-install/build/autogen 
> > -Ilibraries/primitive/cbits    -optP-include 
> > -optPlibraries/primitive/dist-install/build/autogen/cabal_macros.h -package 
> > base-4.7.0.0 -package ghc-prim-0.3.1.0  -O2 -XHaskell98 -XCPP -O2  
> > -no-user-package-db -rtsopts      -c librarie
> s/primitive/cbits/primitive-memops.c -o 
> libraries/primitive/dist-install/build/cbits/primitive-memops.p_o
> > /bin/sh: inplace/bin/ghc-stage2: No such file or directory
> > make[1]: *** 
> > [libraries/primitive/dist-install/build/cbits/primitive-memops.o] Error 127
> > make[1]: *** Waiting for unfinished jobs....
> > /bin/sh: inplace/bin/ghc-stage2: No such file or directory
> 
> I just pushed a patch that should fix this.  Part of the problem is that 
> the --no-dph flag to sync-all doesn't disable the primitive & vector 
> repos like it used to, because they are now submodules.  I've fixed it 
> in the build system instead.

Yeah, your change fixed 'make' for stage1only.
make install does not work though (and didn't before):

$ make install 
DESTDIR=/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image/
...
Installing library in
/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image/usr/lib64/ghc-7.7.20130129/bin-package-db-0.0.0.0
CROSS_COMPILE="ia64-unknown-linux-gnu-" "inplace/bin/ghc-cabal" copy "strip" 
libraries/hoopl dist-install 
'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image' '/usr' 
'/usr/lib64/ghc-7.7.20130129' '/usr/share/doc/ghc-9999/html/libraries'  
Installing library in
/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image/usr/lib64/ghc-7.7.20130129/hoopl-3.10.0.0
CROSS_COMPILE="ia64-unknown-linux-gnu-" "inplace/bin/ghc-cabal" copy "strip" 
libraries/transformers dist-install 
'/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image' '/usr' 
'/usr/lib64/ghc-7.7.20130129' '/usr/share/doc/ghc-9999/html/libraries'
Installing library in
/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image/usr/lib64/ghc-7.7.20130129/transformers-0.3.0.0
"/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image/usr/lib64/ghc-7.7.20130129/bin/ghc-pkg"
 --force --global-package-db 
"/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image/usr/lib64/ghc-7.7.20130129/package.conf.d"
 update rts/package.conf.install
/bin/sh: 
/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image/usr/lib64/ghc-7.7.20130129/bin/ghc-pkg:
 No such file or directory
make[1]: *** [install_packages] Error 127

$ ls 
/var/tmp/portage/cross-ia64-unknown-linux-gnu/ghc-9999/image/usr/lib64/ghc-7.7.20130129/bin/
ghc  hsc2hs

I've decided to stress-test cross-compilation a bit more
(tried --target=x86_64-w64-mingw32)
and found out more fun cases where ghc needs to be tuned:
[some patches attached]

Unfixed issues:
- buld system has a WINDOWS=YES/NO switch,
but it does not distinct between --build=windows
and --target=windows:

  * It tries to build 'touch' on linux host and fails
  * It tries to build a 'unix' package for windows target
  * cabal gets confused and gets 'os(windows) ==false'
     for a stage1 with --target=windows

Otherwise it almost works.

Thanks again!

-- 

  Sergei
diff --git a/configure.ac b/configure.ac
index b679520..7553a7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,17 +5,23 @@ AC_CONFIG_SRCDIR([include/HsBase.h])
 
 AC_CONFIG_HEADERS([include/HsBaseConfig.h include/EventConfig.h])
 
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+
 AC_ARG_WITH([cc],
             [C compiler],
             [CC=$withval])
 AC_PROG_CC()
 
-case `uname -s` in
-    MINGW*|CYGWIN*)
+AC_MSG_CHECKING(for WINDOWS platform)
+case $host in
+    *mingw32*|*cygwin*)
         WINDOWS=YES;;
     *)
         WINDOWS=NO;;
 esac
+AC_MSG_RESULT($WINDOWS)
 
 # do we have long longs?
 AC_CHECK_TYPES([long long])
From 2b90703124216ade987c8bfbb899402906c3970e Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <[email protected]>
Date: Mon, 28 Jan 2013 12:02:37 +0300
Subject: [PATCH] hsc2hs: use configuration of current compiler, not built

Fixed bootstrap failure on linux for --target=mingw32 of such kind:

"/usr/bin/ghc" -o utils/hsc2hs/dist/build/tmp/hsc2hs -static  -H32m -O  -w  -package-db libraries/bootstrapping.conf  -hide-all-packages -i -iutils/hsc2hs/. -iutils/hsc2hs/dist/build -iutils/hsc2hs/dist/build/autogen -Iutils/hsc2hs/dist/build -Iutils/hsc2hs/dist/build/autogen     -optP-include -optPutils/hsc2hs/dist/build/autogen/cabal_macros.h -package base-4.6.0.0 -package containers-0.5.0.0 -package directory-1.2.0.0 -package filepath-1.3.0.1 -package process-1.1.0.2  -XHaskell98 -XCPP -XForeignFunctionInterface  -no-user-package-db -rtsopts      -odir utils/hsc2hs/dist/build -hidir utils/hsc2hs/dist/build -stubdir utils/hsc2hs/dist/build -hisuf hi -osuf  o -hcsuf hc   utils/hsc2hs/dist/build/Main.o utils/hsc2hs/dist/build/HSCParser.o utils/hsc2hs/dist/build/DirectCodegen.o utils/hsc2hs/dist/build/CrossCodegen.o utils/hsc2hs/dist/build/UtilsCodegen.o utils/hsc2hs/dist/build/Common.o utils/hsc2hs/dist/build/C.o utils/hsc2hs/dist/build/Flags.o utils/hsc2hs/dist/build/Paths_hsc2hs.o
utils/hsc2hs/dist/build/Main.o: In function `s4cN_info':
(.text+0x182): undefined reference to `GetModuleFileNameW'

Signed-off-by: Sergei Trofimovich <[email protected]>
---
 Main.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Main.hs b/Main.hs
index 30b3a2d..5309179 100644
--- a/Main.hs
+++ b/Main.hs
@@ -11,7 +11,7 @@
 -- See the documentation in the Users' Guide for more details.
 
 #if defined(__GLASGOW_HASKELL__) && !defined(BUILD_NHC)
-#include "../../includes/ghcconfig.h"
+#include "ghcconfig.h"
 #endif
 
 import Control.Monad            ( liftM, forM_ )
-- 
1.8.1.1

From 08706d265281cd31408ec1160db9f4746685f123 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <[email protected]>
Date: Mon, 28 Jan 2013 00:25:34 +0300
Subject: [PATCH] GHC_CONVERT_VENDOR: allow 'w64' vendor, like
 x86_64-w64-mingw32

Gentoo calls 'w64' a mingw flavour with mingw-w64 runtime.

Signed-off-by: Sergei Trofimovich <[email protected]>
---
 aclocal.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 9f9593a..30d492c 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1812,7 +1812,7 @@ case "$1" in
 # converts vendor from gnu to ghc naming, and assigns the result to $target_var
 AC_DEFUN([GHC_CONVERT_VENDOR],[
   case "$1" in
-  pc|gentoo) # like i686-pc-linux-gnu and i686-gentoo-freebsd8
+  pc|gentoo|w64) # like i686-pc-linux-gnu, i686-gentoo-freebsd8, x86_64-w64-mingw32
     $2="unknown"
     ;;
   softfloat) # like armv5tel-softfloat-linux-gnueabi
-- 
1.8.1.1

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ghc-devs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/ghc-devs

Reply via email to