macOS 上的堆栈构建

2024-04-27

我是新来的haskell。我有最简单的程序。

#!/usr/bin/env stack
-- stack --resolver lts-13.7 script

module Main where

import Lib

main :: IO ()
main = putStrLn "Hello World"

它确实适用于stack

 $stack ./Main.hs
Hello World
(base) 19:48:11/app $

但它在任何更奢侈的事情上都会遭受相当可怕的灭亡:

$stack build --test --haddock --no-haddock-hyperlink-source;
Stack has not been tested with GHC versions above 8.6, and using 8.8.3, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
[1 of 2] Compiling Main             ( /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim   ( /Users/steve/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /Users/steve/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /Users/steve/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3 ...
ld64.lld: warning: ignoring unknown argument: --gc-sections
ld64.lld: warning: ignoring unknown argument: -u
(maybe 50 of these ..)
ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -search_paths_first
ld64.lld: warning: ignoring unknown argument: -dead_strip_dylibs
ld64.lld: warning: -sdk_version is required when emitting min version load command.  Setting sdk version to match provided min version
Cannot open /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.o: bad relocation (Invalid pointer diff) in section __TEXT/__text (r1_address=21c, r1_type=5, r1_extern=1, r1_length=2, r1_pcrel=0, r1_symbolnum=37), (r2_address=21c, r2_type=0, r2_extern=1, r2_length=2, r2_pcrel=0, r2_symbolnum=30)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building simple Setup.hs using:
      /Users/steve/.stack/programs/x86_64-osx/ghc-8.8.3/bin/ghc-8.8.3 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.0.1.0 /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.hs /Users/steve/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /Users/steve/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3
    Process exited with code: ExitFailure 1

我尝试搜索这些,但没有遇到明显的匹配/解决方案。尖端?

Update haskell and stack是这样安装的:

brew install haskell-stack

另一个更新我正在尝试导航以从haskell platform.

提问者是not在左侧字段中关闭,而是按照Haskell platform https://www.haskell.org/platform/ https://www.haskell.org/platform/

no那里有下载链接,所以我们求助于谷歌搜索下载ghcup这导致我们https://www.haskell.org/ghcup/ https://www.haskell.org/ghcup/

然后运行命令

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

结果是:

$curl --proto '=https' --tlsv1.2 -sSfhttps://get-ghcup.haskell.org https://get-ghcup.haskell.org | sh

这确实安装了ghcup正确地

 $ghcup
ghcup 0.0.8
GHC up toolchain installer

USAGE:
    ghcup [FLAGS] <SUBCOMMAND>

下一个:cabal。谷歌搜索让我发现:https://hackage.haskell.org/package/cabal-install https://hackage.haskell.org/package/cabal-install

我下载了 cabal-install 压缩包https://hackage.haskell.org/package/cabal-install-3.2.0.0/cabal-install-3.2.0.0.tar.gz https://hackage.haskell.org/package/cabal-install-3.2.0.0/cabal-install-3.2.0.0.tar.gz

这位可不太合作。错误的简短版本是:

ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -search_paths_first
ld64.lld: warning: ignoring unknown argument: -dead_strip_dylibs
ld64.lld: warning: -sdk_version is required when emitting min version load command.  Setting sdk version to match provided min version
Cannot open ./Distribution/Compat/Async.o: bad relocation (Invalid pointer diff) in section __TEXT/__text (r1_address=2338, r1_type=5, r1_extern=1, r1_length=3, r1_pcrel=0, r1_symbolnum=243), (r2_address=2338, r2_type=0, r2_extern=1, r2_length=3, r2_pcrel=0, r2_symbolnum=237)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

Error during cabal-install bootstrap:
Compiling the Setup script failed.

错误的完整版本是:

$./bootstrap.sh 
mktemp: illegal option -- p
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix 
Using gcc for C compiler. If this is not what you want, set CC.
Using /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld instead.
Checking installed packages for ghc-8.8.3...
deepseq is already installed and the version is ok.
binary is already installed and the version is ok.
time is already installed and the version is ok.
transformers is already installed and the version is ok.
mtl is already installed and the version is ok.
text is already installed and the version is ok.
parsec is already installed and the version is ok.
network-uri-2.6.1.0 will be downloaded and installed.
network-2.7.0.0 will be downloaded and installed.
HTTP-4000.3.12 will be downloaded and installed.
zlib-0.6.2 will be downloaded and installed.
random-1.1 will be downloaded and installed.
stm is already installed and the version is ok.
hashable-1.2.7.0 will be downloaded and installed.
async-2.2.1 will be downloaded and installed.
base16-bytestring-0.1.1.6 will be downloaded and installed.
base64-bytestring-1.0.0.1 will be downloaded and installed.
cryptohash-sha256-0.11.101.0 will be downloaded and installed.
resolv-0.1.1.1 will be downloaded and installed.
mintty-0.1.2 will be downloaded and installed.
echo-0.1.3 will be downloaded and installed.
edit-distance-0.2.2.1 will be downloaded and installed.
ed25519-0.0.5.0 will be downloaded and installed.
tar-0.5.1.0 will be downloaded and installed.
digest-0.0.1.2 will be downloaded and installed.
lukko-0.1.1 will be downloaded and installed.
hackage-security-0.6.0.0 will be downloaded and installed.
Cabal-3.2.0.0 will be downloaded and installed.

Downloading Cabal-3.2.0.0...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  753k    0  753k    0     0  2879k      0 --:--:-- --:--:-- --:--:-- 2888k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 27320    0 27320    0     0   188k      0 --:--:-- --:--:-- --:--:--  189k
[  1 of 236] Compiling Distribution.Compat.Async ( Distribution/Compat/Async.hs, Distribution/Compat/Async.o )
[  2 of 236] Compiling Distribution.Compat.Binary ( Distribution/Compat/Binary.hs, Distribution/Compat/Binary.o )
[  3 of 236] Compiling Distribution.Compat.Directory ( Distribution/Compat/Directory.hs, Distribution/Compat/Directory.o )
[  4 of 236] Compiling Distribution.Compat.Exception ( Distribution/Compat/Exception.hs, Distribution/Compat/Exception.o )
[  5 of 236] Compiling Distribution.Compat.FilePath ( Distribution/Compat/FilePath.hs, Distribution/Compat/FilePath.o )
[  7 of 236] Compiling Distribution.Compat.Internal.TempFile ( Distribution/Compat/Internal/TempFile.hs, Distribution/Compat/Internal/TempFile.o )

( 200 other compiling lines ..)

[230 of 236] Compiling Distribution.Simple.Configure ( Distribution/Simple/Configure.hs, Distribution/Simple/Configure.o )
[231 of 236] Compiling Distribution.Simple.SrcDist ( Distribution/Simple/SrcDist.hs, Distribution/Simple/SrcDist.o )
[232 of 236] Compiling Distribution.Simple.Build ( Distribution/Simple/Build.hs, Distribution/Simple/Build.o )
[233 of 236] Compiling Distribution.Simple.Haddock ( Distribution/Simple/Haddock.hs, Distribution/Simple/Haddock.o )
[234 of 236] Compiling Distribution.Simple.Doctest ( Distribution/Simple/Doctest.hs, Distribution/Simple/Doctest.o )
[235 of 236] Compiling Distribution.Simple ( Distribution/Simple.hs, Distribution/Simple.o )
[236 of 236] Compiling Main             ( Setup.hs, Setup.o )
Linking Setup ...
ld64.lld: warning: ignoring unknown argument: --gc-sections
ld64.lld: warning: ignoring unknown argument: -u

(80 other similar lines..)

ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -u
ld64.lld: warning: ignoring unknown argument: -search_paths_first
ld64.lld: warning: ignoring unknown argument: -dead_strip_dylibs
ld64.lld: warning: -sdk_version is required when emitting min version load command.  Setting sdk version to match provided min version
Cannot open ./Distribution/Compat/Async.o: bad relocation (Invalid pointer diff) in section __TEXT/__text (r1_address=2338, r1_type=5, r1_extern=1, r1_length=3, r1_pcrel=0, r1_symbolnum=243), (r2_address=2338, r2_type=0, r2_extern=1, r2_length=3, r2_pcrel=0, r2_symbolnum=237)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

Error during cabal-install bootstrap:
Compiling the Setup script failed.

还有另一个更新

根据 @bradm 的评论我已经尝试过Haskell Stack http://docs.haskellstack.org/en/stable/README/#how-to-install http://docs.haskellstack.org/en/stable/README/#how-to-install。出现与我问题开始时相同的错误。我仔细检查了堆栈是否是新安装的,并且它显示了现在的时间戳。它在新的虚拟项目中的堆栈设置上失败,并且具有相同的长丑陋错误签名,包括 Main.o bad relocation 上的链接器错误。这是它的核心(与顶部相同):

Cannot open /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.o: bad relocation (Invalid pointer diff) in section __TEXT/__text (r1_address=21c, r1_type=5, r1_extern=1, r1_length=2, r1_pcrel=0, r1_symbolnum=37), (r2_address=21c, r2_type=0, r2_extern=1, r2_length=2, r2_pcrel=0, r2_symbolnum=30)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building simple Setup.hs using:
      /Users/steve/.stack/programs/x86_64-osx/ghc-8.8.3/bin/ghc-8.8.3 
     -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.0.1.0 /Users/steve/.stack/setup-exe-src/setup-mPHDZzAJ.hs /Users/steve/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /Users/steve/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3
    Process exited with code: ExitFailure 1

我刚刚发现这个已知的错误:https://github.com/commercialhaskell/stack/issues/4373 https://github.com/commercialhaskell/stack/issues/4373

这正是我所看到的。

所需的解决方法是更新settings文件深埋在新生成的~/.stack目录https://github.com/commercialhaskell/stack/issues/4373#issuecomment-432726112 https://github.com/commercialhaskell/stack/issues/4373#issuecomment-432726112

这些说明不完整,因此我向该错误添加了注释以进行澄清。该设置位置:~/.stack/programs/x86_64-osx/ghc-8.8.3/lib/ghc-8.8.3/settings

和这个works(注意stack test是一个组合stack build and stack test):

(base) 10:27:09/haskelltest $stack test
Stack has not been tested with GHC versions above 8.6, and using 8.8.3, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
Linking /Users/steve/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_3.0.1.0_ghc-8.8.3 ...
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
Building all executables for `haskelltest' once. After a successful build of all of them, only specified executables will be rebuilt.
haskelltest> configure (lib + exe + test)
Configuring haskelltest-0.1.0.0...
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
haskelltest> build (lib + exe + test)
Preprocessing library for haskelltest-0.1.0.0..
Building library for haskelltest-0.1.0.0..
[1 of 2] Compiling Lib
[2 of 2] Compiling Paths_haskelltest
Preprocessing test suite 'haskelltest-test' for haskelltest-0.1.0.0..
Building test suite 'haskelltest-test' for haskelltest-0.1.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_haskelltest
Linking .stack-work/dist/x86_64-osx/Cabal-3.0.1.0/build/haskelltest-test/haskelltest-test ...
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
Preprocessing executable 'haskelltest-exe' for haskelltest-0.1.0.0..
Building executable 'haskelltest-exe' for haskelltest-0.1.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_haskelltest
Linking .stack-work/dist/x86_64-osx/Cabal-3.0.1.0/build/haskelltest-exe/haskelltest-exe ...
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
haskelltest> copy/register
Installing library in /git/rubytest/haskelltest/.stack-work/install/x86_64-osx/18cf924ea0be80a27100889c349bd98b50cf064de8de23f912f9f822b43a80db/8.8.3/lib/x86_64-osx-ghc-8.8.3/haskelltest-0.1.0.0-48zsyNIR9r7Efmr0ATZ6Im
Installing executable haskelltest-exe in /git/rubytest/haskelltest/.stack-work/install/x86_64-osx/18cf924ea0be80a27100889c349bd98b50cf064de8de23f912f9f822b43a80db/8.8.3/bin
Registering library for haskelltest-0.1.0.0..
haskelltest> test (suite: haskelltest-test)

Progress 1/2: haskelltestTest suite not yet implemented

haskelltest> Test suite haskelltest-test passed
Completed 2 action(s).   
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

macOS 上的堆栈构建 的相关文章

随机推荐