首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Haskell和Bazel

使用Haskell和Bazel
EN

Stack Overflow用户
提问于 2020-01-09 18:16:54
回答 1查看 293关注 0票数 2

Windows 10 (x64)

我想在Bazel中使用Haskell (2.0.0)。我在Windows 10 (x64)计算机上执行了以下步骤:

代码语言:javascript
复制
git clone https://github.com/tweag/rules_haskell/
cd rules_haskell
cd tutorial
bazel build //...

这将产生以下结果:

代码语言:javascript
复制
INFO: Call stack for the definition of repository 'rules_haskell_ghc_windows_amd64' which is a _ghc_bindist (rule definition at C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl:289:16):
 - C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl:409:5
 - C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl:445:9
 - C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/toolchain.bzl:320:5
 - D:/dev/rules_haskell/tutorial/WORKSPACE:22:1
ERROR: An error occurred during the fetch of repository 'rules_haskell_ghc_windows_amd64':
   Traceback (most recent call last):
        File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 194
                _find_python(ctx)
        File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 461, in _find_python
                repository_ctx.execute(<1 more arguments>)
Argument 0 of execute is neither a path nor a string.
ERROR: D:/dev/rules_haskell/tutorial/lib/BUILD.bazel:6:1: //lib:booleans depends on @rules_haskell_ghc_windows_amd64//:toolchain-impl in repository @rules_haskell_ghc_windows_amd64 which failed to fetch. no such package '@rules_haskell_ghc_windows_amd64//': Traceback (most recent call last):
        File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 194
                _find_python(ctx)
        File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 461, in _find_python
                repository_ctx.execute(<1 more arguments>)
Argument 0 of execute is neither a path nor a string.
ERROR: Analysis of target '//lib:booleans' failed; build aborted: no such package '@rules_haskell_ghc_windows_amd64//': Traceback (most recent call last):
        File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 194
                _find_python(ctx)
        File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 461, in _find_python
                repository_ctx.execute(<1 more arguments>)
Argument 0 of execute is neither a path nor a string.
INFO: Elapsed time: 11.900s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (27 packages loaded, 44 targets configured)

我安装了msys2python3 (Vesion 3.7.6),就像描述的这里一样。

该错误似乎发生在_find_python中。My变量($Env:Path)包含python.exe的路径。

有人成功地在Windows 10上构建本教程吗?

天蓝色管道似乎可以在Windows上构建Haskell规则:

要使这一工作发挥作用,似乎需要两个步骤:

步骤1 (Powershell):

代码语言:javascript
复制
Write-Host "Enable long path behavior"
# See https://learn.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 displayName: "Enable da long paths"

步骤2 (bash):

代码语言:javascript
复制
# Remove 'C:\Program Files ' (ending on space) from PATH.
# See https://github.com/bazelbuild/bazel/issues/10481
export PATH="$(sed 's,:/c/Program Files $,,' <<<"$PATH")"
echo "PATH='$PATH'"

我不知道如何在(本地) Windows 10机器上复制这种情况

Ubuntu18.04

代码语言:javascript
复制
git clone https://github.com/tweag/rules_haskell/
cd rules_haskell
cd tutorial
bazel build //...

这将产生以下结果:

代码语言:javascript
复制
INFO: Analyzed 3 targets (0 packages loaded, 0 targets configured).
INFO: Found 3 targets...
ERROR: /home/newton/dev/rules_haskell/tutorial/lib/BUILD.bazel:6:1: HaskellLinkDynamicLibrary lib/libHSlibZSbooleans-ghc8.6.5.so failed (Exit 1) ghc_wrapper failed: error executing command bazel-out/host/bin/external/rules_haskell/haskell/ghc_wrapper bazel-out/k8-fastbuild/bin/lib/compile_flags_booleans_HaskellLinkDynamicLibrary ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
/usr/bin/ld.gold: error: cannot find -lgmp
collect2: error: ld returned 1 exit status
`cc_wrapper-python' failed in phase `Linker'. (Exit code: 1)
INFO: Elapsed time: 0.554s, Critical Path: 0.37s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

使用Ubuntu (BazelVersion2.0.0)而不是Windows构建教程也不适合我。有什么暗示吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-09 19:19:11

Ubuntu18.04的解决方案

通过安装以下软件包解决了Ubuntu上的构建问题:

代码语言:javascript
复制
sudo apt-get install build-essential libffi-dev libgmp-dev libtinfo5 libtinfo-dev python python3

Windows 10 x64

安装了Visual 2019时出现了问题。通过重写cc_toolchain,可以修复以下问题:

代码语言:javascript
复制
bazel run --crosstool_top=@rules_haskell_ghc_windows_amd64//:cc_toolchain //:HelloHaskell
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59669961

复制
相关文章

相似问题

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