首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为target=aarch64-apple-ios构建GHC 9.2.1时出错

为target=aarch64-apple-ios构建GHC 9.2.1时出错
EN

Stack Overflow用户
提问于 2022-02-21 14:58:36
回答 1查看 235关注 0票数 0

我有一个用Haskell写的库,我想在iOS和安卓应用程序中使用。库主要包含业务逻辑和网络,没有GUI调用,因此使用iOS或安卓应用程序的库只是使用C调用单个入口点的问题。我首先从iOS目标开始。

据我所知,为了将Haskell源代码编译成一个Mach-O aarch64对象文件(以后可以链接到iOS应用程序),我需要用一个目标aarch64 apple-ios编译GHC编译器。

下面是我如何编译GHC的过程:

  1. 首先使用以下shell.nix创建一个nix-shell:

代码语言:javascript
复制
let
  unstable = import <unstable> { };
in
{ nixpkgs ? import <nixpkgs> {} }:
  nixpkgs.mkShell {
    nativeBuildInputs = [ 
      nixpkgs.automake 
      nixpkgs.autoconf 
      nixpkgs.python38
      nixpkgs.haskell.compiler.ghc8107
      nixpkgs.cabal-install
      nixpkgs.sphinx
      unstable.clang_13
      nixpkgs.llvmPackages_13.llvm
      nixpkgs.gmp
      nixpkgs.gnumake
      nixpkgs.git
    ];
    shellHook =
    ''
      cabal install alex-3.2.6 happy-1.20.0 
      export PATH=$PATH:~/.cabal/bin
    '';
  }

然后从nix-shell内部运行以下命令:

代码语言:javascript
复制
git config --global url."git://github.com/ghc/packages-".insteadOf     git://github.com/ghc/packages/ 
git config --global url."http://github.com/ghc/packages-".insteadOf    http://github.com/ghc/packages/ 
git config --global url."https://github.com/ghc/packages-".insteadOf   https://github.com/ghc/packages/ 
git config --global url."ssh://git@github.com/ghc/packages-".insteadOf ssh://git@github.com/ghc/packages/ 
git config --global url."git@github.com:ghc/packages-".insteadOf       git@github.com:ghc/packages/ 

git clone --recurse-submodules git://github.com/ghc/ghc
cd ghc
git checkout ghc-9.2.1-release
git submodule update --init --recursive
echo "HADDOCK_DOCS = NO" >> mk/build.mk
./boot
./configure --target=aarch64-apple-ios -disable-large-address-space
make -j

然后,我得到以下编译错误:

代码语言:javascript
复制
rts/StgCRun.c:965:11: error:
     error: unknown register name '%x19' in asm
            : "%x19", "%x20", "%x21", "%x22", "%x23", "%x24", "%x25", "%x26", "%x27", "%x28",
              ^
    |
965 |         : "%x19", "%x20", "%x21", "%x22", "%x23", "%x24", "%x25", "%x26", "%x27", "%x28",
    |           ^
1 error generated.
`clang' failed in phase `C Compiler'. (Exit code: 1)
make[1]: *** [rts/ghc.mk:345: rts/dist/build/StgCRun.o] Error 1
make: *** [Makefile:128: all] Error 2

我试着用hadrian构建,得到了完全相同的结果。我正在建造的机器是: macOS蒙特利12.1

有没有人知道如何解决这个问题?GHC9.2.1是否立即支持iOS和安卓目标,还是需要进行任何类型的编译器修补?

EN

回答 1

Stack Overflow用户

发布于 2022-02-23 09:30:50

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71208444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档