Opened 8 months ago

Closed 8 months ago

#8210 closed bug (fixed)

Make fails for Building a GHC cross-compiler for Apple iOS target (i386-apple-darwin11)

Reported by: alen_ribic Owned by: lukexi
Priority: normal Milestone:
Component: Compiler (LLVM) Version: 7.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: x86_64 (amd64)
Type of failure: Building GHC failed Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I followed the instructions for Building a GHC cross-compiler for Apple iOS targets (http://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling/iOS).

I ran the ./configure --target=i386-apple-darwin11 --prefix=/usr/local/ghc-ios-sim/ which ran successfully.
However, make failed with the below error:

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:145:0:
    no such instruction: `vmovss 40(%ebx), %xmm0'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:146:0:
    no such instruction: `vmovss %xmm0, -4(%ebp)'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:155:0:
    no such instruction: `vmovsd 64(%ebx), %xmm0'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:156:0:
    no such instruction: `vmovsd %xmm0, -8(%ebp)'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:165:0:
    no such instruction: `vmovsd 208(%ebx), %xmm0'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:166:0:
    no such instruction: `vmovsd %xmm0, -8(%ebp)'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:663:0:
    no such instruction: `vmovss 4(%ebp), %xmm0'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:664:0:
    no such instruction: `vmovss %xmm0, 40(%ebx)'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:681:0:
    no such instruction: `vmovsd 4(%ebp), %xmm0'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:682:0:
    no such instruction: `vmovsd %xmm0, 64(%ebx)'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:699:0:
    no such instruction: `vmovsd 4(%ebp), %xmm0'

/var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/ghc50871_0/ghc50871_0.s:700:0:
    no such instruction: `vmovsd %xmm0, 208(%ebx)'
make[1]: *** [rts/dist/build/HeapStackCheck.o] Error 1
make: *** [all] Error 2

Setup details my end:

GCC: head

Mac OS X version: 10.8.4

GCC: 4.2.1

LLVM: 3.2svn

XCode: 4.6.3

Change History (17)

comment:1 Changed 8 months ago by alen_ribic

Typo => GCC: head, should be GHC = head

comment:2 Changed 8 months ago by carter

Alen, could you paste your mk/build.mk file you used for doing this run?

comment:3 Changed 8 months ago by lukexi

Hi Alen,
I just added a note yesterday about adding

GhcStage1HcOpts    = -O -fllvm

to the simulator build.mk — do you have that?

If so then it's probably that you're using LLVM 3.2 rather than 3.0. I'm just using the binary http://llvm.org/releases/3.0/clang+llvm-3.0-x86_64-apple-darwin11.tar.gz and I'm pretty sure it's the only one I've had luck with. (If that's it, I'm just going to make it clear on the wiki page that 3.0 is the only one that works right now : )).

Cheers
Luke

comment:4 Changed 8 months ago by alen_ribic

I might have taken the step regarding the build.mk literally. My file at the time of this writing was just:

HADDOCK_DOCS         = NO
BUILD_DOCBOOK_HTML   = NO
BUILD_DOCBOOK_PS     = NO
BUILD_DOCBOOK_PDF    = NO
SPLIT_OBJS           = NO
INTEGER_LIBRARY      = integer-simple
Stage1Only 	     = YES
DYNAMIC_GHC_PROGRAMS = NO
GhcLibWays           = v

comment:5 Changed 8 months ago by lukexi

That's just fine! Just try adding

GhcStage1HcOpts    = -O -fllvm

to the bottom (& re-run perl boot) and then try again.

comment:6 Changed 8 months ago by alen_ribic

Firstly tried adding

GhcStage1HcOpts    = -O -fllvm

and running with my existing LLVM 3.2. The build failed again with the same error as in the description. I actually got a warning during the build that this sort configuration has not been tested with my version of LLVM but that it will go ahead and try the build anyway.
So I just downgraded the LLVM to 3.0, ran the make clean & perl boot and now running the make with iOS simulator configuration.

Will feedback as soon as the build ends.

Version 1, edited 8 months ago by alen_ribic (previous) (next) (diff)

comment:7 follow-up: Changed 8 months ago by carter

alen: did you build your LLVM install with ALL targets support? That is actually important...

comment:8 in reply to: ↑ 7 Changed 8 months ago by alen_ribic

Replying to carter:

alen: did you build your LLVM install with ALL targets support? That is actually important...

According to the docs, yes. And I can confirm at least that during the build process, logs came up with ARM target related log entries.
I'd be happy to rerun the build with suggested flags.

comment:9 Changed 8 months ago by carter

couldn't hurt to double check. At least the brew bottle for llvm doesn't do ARM by default I think. (though i could be cargo culting mind you)

comment:10 Changed 8 months ago by alen_ribic

Ok, so I can confirm that downgrading to LLVM 3.0 worked flawlessly.

So definitely, changing the wiki entry to emphasise LLVM 3.0 rather than any other version for the time being would be a win.

Last edited 8 months ago by alen_ribic (previous) (diff)

comment:11 Changed 8 months ago by alen_ribic

Currently, in the instructions, there is an indication to checkout the latest Cabal/cabal-install (it has the latest required patch).

I built and installed the latest Cabal package and it is listed under ghc-pkg.

Then I ran bootstrap.sh from cabal-install directory but got this error:

Checking installed packages for ghc-7.7.20130831...
Cabal is already installed and the version is ok.
transformers is already installed and the version is ok.
mtl-2.1.2 will be downloaded and installed.
deepseq is already installed and the version is ok.
text-0.11.3.1 will be downloaded and installed.
parsec-3.1.3 will be downloaded and installed.
network-2.4.1.2 will be downloaded and installed.
time is already installed and the version is ok.
HTTP-4000.2.8 will be downloaded and installed.
zlib-0.5.4.1 will be downloaded and installed.
random-1.0.1.1 will be downloaded and installed.
stm-2.4.2 will be downloaded and installed.

Downloading mtl-2.1.2...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13723  100 13723    0     0   8526      0  0:00:01  0:00:01 --:--:-- 11165
[1 of 1] Compiling Main             ( Setup.hs, Setup.o )
Linking Setup.a ...

<no location info>:
    Warning: Couldn't figure out linker information!
             Make sure you're using GNU ld, GNU gold or the built in OS X linker, etc.
ld: warning: could not create compact unwind for .LFB3: non-standard register 5 being saved in prolog
ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _ZCMain_main_info from Setup.o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie
Setup: No cabal file found.
Please create a package description file <pkgname>.cabal

Error during cabal-install bootstrap:
Configuring the mtl package failed

Environment variables I set for bootstrap.sh where:

GHC=i386-apple-darwin11-ghc

GHC_PKG=i386-apple-darwin11-ghc-pkg

Any ideas as to what might be causing this to happen?

[Edited] I can confirm that I can run bootstrap.sh successfully agains the standard build of ghc and ghc-pkg (version tried was 7.6.3).

[Edited-2] Cabal version = 1.18.0, built from head.

-Al

Last edited 8 months ago by alen_ribic (previous) (diff)

comment:12 Changed 8 months ago by alen_ribic

As a follow up to my comment above, I realised I have the latest cabal-install (from head) already built when I built it agains standard ghc (7.6.3). So I went ahead and I ran the example: i386-apple-darwin11-cabal install network, but still got an error but with quite a bit more detail (ran with -v2 flag).

Reading available packages...
Choosing modular solver.
Resolving dependencies...
Ready to install mtl-2.1.2
Ready to install text-0.11.3.1
Waiting for install task to finish...
Extracting
/Users/alen/Library/Haskell/repo-cache/hackage.haskell.org/mtl/2.1.2/mtl-2.1.2.tar.gz
to /var/folders/cv/1jdvk8bj2sjd_zz5x0d9w05h0000gn/T/mtl-2.1.2-24160...
Updating mtl.cabal with the latest revision from the index.
Configuring mtl-2.1.2...
Dependency base ==4.7.0.0: using base-4.7.0.0
Dependency transformers ==0.3.0.0: using transformers-0.3.0.0
'/usr/local/ghc-ios-sim/bin/i386-apple-darwin11-ghc' '--info'
Using Cabal-1.18.0 compiled by ghc-7.6
Using compiler: ghc-7.7.20130831
Using install prefix:
/Users/alen/Library/Haskell/ghc-7.7.20130831/lib/mtl-2.1.2
Binaries installed in:
/Users/alen/Library/Haskell/ghc-7.7.20130831/lib/mtl-2.1.2/bin
Libraries installed in:
/Users/alen/Library/Haskell/ghc-7.7.20130831/lib/mtl-2.1.2/lib
Private binaries installed in:
/Users/alen/Library/Haskell/ghc-7.7.20130831/lib/mtl-2.1.2/libexec
Data files installed in:
/Users/alen/Library/Haskell/ghc-7.7.20130831/lib/mtl-2.1.2/share
Documentation installed in:
/Users/alen/Library/Haskell/ghc-7.7.20130831/lib/mtl-2.1.2/doc
Configuration files installed in:
/Users/alen/Library/Haskell/ghc-7.7.20130831/lib/mtl-2.1.2/etc
Using alex version 3.0.5 found on system at: /usr/bin/alex
Using ar found on system at: /usr/bin/ar
No c2hs found
No cpphs found
No ffihugs found
Using gcc version 4.2.1 given by user at:
/Users/alen/Development/haskell/projects/ghc-ios-scripts/i386-apple-darwin11-gcc
Using ghc version 7.7.20130831 given by user at:
/usr/local/ghc-ios-sim/bin/i386-apple-darwin11-ghc
Using ghc-pkg version 7.7.20130831 given by user at:
/usr/local/ghc-ios-sim/bin/i386-apple-darwin11-ghc-pkg
No greencard found
Using haddock version 2.13.2 found on system at: /usr/bin/haddock
Using happy version 1.18.10 found on system at: /usr/bin/happy
No hmake found
Using hpc version 0.6 found on system at: /usr/bin/hpc
Using hsc2hs version 0.67 found on system at: /usr/bin/hsc2hs
No hscolour found
No hugs found
No jhc found
Using ld given by user at:
/Users/alen/Development/haskell/projects/ghc-ios-scripts/i386-apple-darwin11-ld
No lhc found
No lhc-pkg found
No nhc98 found
Using pkg-config version 0.28 found on system at: /usr/local/bin/pkg-config
Using ranlib found on system at: /usr/bin/ranlib
Using strip found on system at: /usr/bin/strip
Using tar found on system at: /usr/bin/tar
No uhc found
Component build order: library
creating dist/build
creating dist/build/autogen
Building mtl-2.1.2...
Preprocessing library mtl-2.1.2...
Building library...
'/usr/local/ghc-ios-sim/bin/i386-apple-darwin11-ghc' '--info'
'/usr/local/ghc-ios-sim/bin/i386-apple-darwin11-ghc' '--info'
creating dist/build
/usr/local/ghc-ios-sim/bin/i386-apple-darwin11-ghc --make -fbuilding-cabal-package -O -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -package-name mtl-2.1.2 -hide-all-packages -package-db dist/package.conf.inplace -package-id base-4.7.0.0-03ba819d5e9dd4c8377e09180a8091ec -package-id transformers-0.3.0.0-08699d9f0e97d51635b4fa218a540861 -XHaskell98 -XMultiParamTypeClasses -XFunctionalDependencies -XFlexibleInstances Control.Monad.Cont Control.Monad.Cont.Class Control.Monad.Error Control.Monad.Error.Class Control.Monad.Identity Control.Monad.List Control.Monad.RWS Control.Monad.RWS.Class Control.Monad.RWS.Lazy Control.Monad.RWS.Strict Control.Monad.Reader Control.Monad.Reader.Class Control.Monad.State Control.Monad.State.Class Control.Monad.State.Lazy Control.Monad.State.Strict Control.Monad.Trans Control.Monad.Writer Control.Monad.Writer.Class Control.Monad.Writer.Lazy Control.Monad.Writer.Strict -Wall -fno-warn-unused-imports
[ 1 of 21] Compiling Control.Monad.Writer.Class ( Control/Monad/Writer/Class.hs, dist/build/Control/Monad/Writer/Class.o )
[ 2 of 21] Compiling Control.Monad.State.Class ( Control/Monad/State/Class.hs, dist/build/Control/Monad/State/Class.o )
[ 3 of 21] Compiling Control.Monad.Reader.Class ( Control/Monad/Reader/Class.hs, dist/build/Control/Monad/Reader/Class.o )
[ 4 of 21] Compiling Control.Monad.RWS.Class ( Control/Monad/RWS/Class.hs, dist/build/Control/Monad/RWS/Class.o )
[ 5 of 21] Compiling Control.Monad.Identity ( Control/Monad/Identity.hs, dist/build/Control/Monad/Identity.o )
[ 6 of 21] Compiling Control.Monad.Error.Class ( Control/Monad/Error/Class.hs, dist/build/Control/Monad/Error/Class.o )

Control/Monad/Error/Class.hs:58:1: Warning:
    Module ‛Control.Monad.Instances’ is deprecated:
      This module now contains no instances and will be removed in the future
[ 7 of 21] Compiling Control.Monad.Cont.Class ( Control/Monad/Cont/Class.hs, dist/build/Control/Monad/Cont/Class.o )
[ 8 of 21] Compiling Control.Monad.Trans ( Control/Monad/Trans.hs, dist/build/Control/Monad/Trans.o )
[ 9 of 21] Compiling Control.Monad.Error ( Control/Monad/Error.hs, dist/build/Control/Monad/Error.o )

Control/Monad/Error.hs:57:1: Warning:
    Module ‛Control.Monad.Instances’ is deprecated:
      This module now contains no instances and will be removed in the future
[10 of 21] Compiling Control.Monad.List ( Control/Monad/List.hs, dist/build/Control/Monad/List.o )
[11 of 21] Compiling Control.Monad.RWS.Lazy ( Control/Monad/RWS/Lazy.hs, dist/build/Control/Monad/RWS/Lazy.o )
[12 of 21] Compiling Control.Monad.RWS ( Control/Monad/RWS.hs, dist/build/Control/Monad/RWS.o )
[13 of 21] Compiling Control.Monad.Reader ( Control/Monad/Reader.hs, dist/build/Control/Monad/Reader.o )
[14 of 21] Compiling Control.Monad.RWS.Strict ( Control/Monad/RWS/Strict.hs, dist/build/Control/Monad/RWS/Strict.o )
[15 of 21] Compiling Control.Monad.State.Lazy ( Control/Monad/State/Lazy.hs, dist/build/Control/Monad/State/Lazy.o )
[16 of 21] Compiling Control.Monad.State ( Control/Monad/State.hs, dist/build/Control/Monad/State.o )
[17 of 21] Compiling Control.Monad.State.Strict ( Control/Monad/State/Strict.hs, dist/build/Control/Monad/State/Strict.o )
[18 of 21] Compiling Control.Monad.Writer.Lazy ( Control/Monad/Writer/Lazy.hs, dist/build/Control/Monad/Writer/Lazy.o )
[19 of 21] Compiling Control.Monad.Writer ( Control/Monad/Writer.hs, dist/build/Control/Monad/Writer.o )
[20 of 21] Compiling Control.Monad.Writer.Strict ( Control/Monad/Writer/Strict.hs, dist/build/Control/Monad/Writer/Strict.o )
[21 of 21] Compiling Control.Monad.Cont ( Control/Monad/Cont.hs, dist/build/Control/Monad/Cont.o )
/usr/local/ghc-ios-sim/bin/i386-apple-darwin11-ghc --make -fbuilding-cabal-package -O -prof -osuf p_o -hisuf p_hi -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -package-name mtl-2.1.2 -hide-all-packages -package-db dist/package.conf.inplace -package-id base-4.7.0.0-03ba819d5e9dd4c8377e09180a8091ec -package-id transformers-0.3.0.0-08699d9f0e97d51635b4fa218a540861 -XHaskell98 -XMultiParamTypeClasses -XFunctionalDependencies -XFlexibleInstances Control.Monad.Cont Control.Monad.Cont.Class Control.Monad.Error Control.Monad.Error.Class Control.Monad.Identity Control.Monad.List Control.Monad.RWS Control.Monad.RWS.Class Control.Monad.RWS.Lazy Control.Monad.RWS.Strict Control.Monad.Reader Control.Monad.Reader.Class Control.Monad.State Control.Monad.State.Class Control.Monad.State.Lazy Control.Monad.State.Strict Control.Monad.Trans Control.Monad.Writer Control.Monad.Writer.Class Control.Monad.Writer.Lazy Control.Monad.Writer.Strict -Wall -fno-warn-unused-imports

Control/Monad/Cont.hs:1:1:
    Could not find module ‛Prelude’
    Perhaps you haven't installed the profiling libraries for package ‛base’?
    Use -v to see a list of the files searched for.
Failed to install mtl-2.1.2
Waiting for install task to finish...

[Edited]

Some more useful info regarding the existing, installed packages:

i386-apple-darwin11-ghc-pkg list

/usr/local/ghc-ios-sim/lib/ghc-7.7.20130831/package.conf.d

Cabal-1.18.0
array-0.4.0.2
base-4.7.0.0
binary-0.7.1.0
bytestring-0.10.3.0
containers-0.5.2.1
deepseq-1.3.0.2
directory-1.2.0.1
filepath-1.3.0.2
ghc-prim-0.3.1.0
hoopl-3.10.0.0
hpc-0.6.0.1
integer-simple-0.1.1.0
old-locale-1.0.0.5
pretty-1.1.1.0
process-1.2.0.0
rts-1.0
template-haskell-2.9.0.0
time-1.4.1
transformers-0.3.0.0
unix-2.7.0.0
Last edited 8 months ago by alen_ribic (previous) (diff)

comment:13 Changed 8 months ago by alen_ribic

Ok, so I ignored the issue in my above comment and went straight to the next step, i.e. making sure hsc2hs is new enough, etc.

This worked and I can confirm that I have the example running on the iOS device (simulator).
I compiled the sample Haskell source code (.a file) and added it to the xcode project that I then ran on the device simulator. Got both the system outputs as expected (one from Haskell main and another from main.m).

Regarding the problem in my previous comment, I still hope someone can comment, even if it leads to nothing more than some knowledge gain.

comment:14 Changed 8 months ago by alen_ribic

  • Component changed from Compiler to Compiler (LLVM)

Solution to the last problem I experienced following the wiki page instructions (running i386-apple-darwin11-cabal install <pkg>) can be found here https://github.com/ghc-ios/ghc-ios-scripts/issues/2.

comment:15 follow-up: Changed 8 months ago by lukexi

  • Owner set to lukexi

I'll add a note to the CrossCompiling?/iOS page with profiling libraries fix — other than that you're good to go now and I can close this, yeah?

Thanks!

comment:16 in reply to: ↑ 15 Changed 8 months ago by alen_ribic

Replying to lukexi:

I'll add a note to the CrossCompiling?/iOS page with profiling libraries fix — other than that you're good to go now and I can close this, yeah?

Thanks!

Correct, all working my end.

comment:17 Changed 8 months ago by lukexi

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.