сборка стека на macOS - PullRequest
       21

сборка стека на macOS

4 голосов
/ 04 апреля 2020

Я новичок в 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

Я пытался найти их, но не столкнулся с очевидными совпадениями / решениями. Советы?

Обновление haskell и stack были установлены следующим образом:

brew install haskell-stack

Другое обновление Я пытаюсь перейти к установить с haskell platform.

Запрашивающий не выключен в левом поле, но вместо этого следует указаниям, предоставленным Haskell platform https://www.haskell.org/platform/

enter image description here

Там есть нет ссылка для скачивания, поэтому мы прибегаем к поиску в Google для загрузки ghcup , что приводит нас к https://www.haskell.org/ghcup/

Затем выполните команду

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

enter image description here

Результат:

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

Это установило ghcup правильно

 $ghcup
ghcup 0.0.8
GHC up toolchain installer

USAGE:
    ghcup [FLAGS] <SUBCOMMAND>

Следующее в строке: cabal. Поиск Google привел меня к: https://hackage.haskell.org/package/cabal-install

enter image description here

Я скачал tar-файл с установкой cabal 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 . Появляются те же ошибки, что и в начале моего вопроса. Я дважды проверил, что стек был недавно установлен, и сейчас он показывает метку времени. Он завершается неудачно при установке стека в новом фиктивном проекте и имеет такую ​​же сигнатуру из-за длинных уродливых ошибок, включая ошибку компоновщика при неправильном перемещении Main.o. Вот его ядро ​​(так же, как и наверху):

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

1 Ответ

0 голосов
/ 04 апреля 2020

Я только что нашел эту известную ошибку: https://github.com/commercialhaskell/stack/issues/4373

Это именно то, что я вижу.

enter image description here

Обходной путь - обновить файл settings, который находится глубоко под недавно созданным каталогом ~/.stack https://github.com/commercialhaskell/stack/issues/4373#issuecomment -432726112

enter image description here

Эти инструкции неполные, поэтому я добавил комментарий к этой ошибке, чтобы уточнить. Это расположение настроек: ~/.stack/programs/x86_64-osx/ghc-8.8.3/lib/ghc-8.8.3/settings

enter image description here

И это работает (обратите внимание, что stack test является комбинацией stack build и 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).   
...