Unable to install agda via nix in macOS M1 - macos

Running
nix-shell -p agda
on macOS M1 (Monterey), compilation seems to run fine but linking fails with a segmentation error
clang-11: error: linker command failed with exit code 139 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 139)
error: builder for '/nix/store/0zli7b0k7mdq3aj9yrfk546vr1a1mb34-Agda-2.6.2.2.drv' failed with exit code 1;
last 10 log lines:
> [399 of 401] Compiling Agda.Compiler.JS.Compiler ( src/full/Agda/Compiler/JS/Compiler.hs, dist/build/Agda/Compiler/JS/Compiler.o, dist/build/Agda/Compiler/JS/Compiler.dyn_o )
> [400 of 401] Compiling Agda.Compiler.Builtin ( src/full/Agda/Compiler/Builtin.hs, dist/build/Agda/Compiler/Builtin.o, dist/build/Agda/Compiler/Builtin.dyn_o )
> [401 of 401] Compiling Agda.Main ( src/full/Agda/Main.hs, dist/build/Agda/Main.o, dist/build/Agda/Main.dyn_o )
> Preprocessing executable 'agda' for Agda-2.6.2.2..
> Building executable 'agda' for Agda-2.6.2.2..
> [1 of 1] Compiling Main ( src/main/Main.hs, dist/build/agda/agda-tmp/Main.o )
> Linking dist/build/agda/agda ...
> /nix/store/l1vm9w0y2fdav63xk2nfrwgzrg30hm5x-clang-wrapper-11.1.0/bin/ld: line 256: 1241 Segmentation fault: 11 /nix/store/gwm9iadcyybh7gc4q6djvaz4fb40i90c-cctools-binutils-darwin-949.0.1/bin/ld ${extraBefore+"${extraBefore[#]}"} ${params+"${params[#]}"} ${extraAfter+"${extraAfter[#]}"}
> clang-11: error: linker command failed with exit code 139 (use -v to see invocation)
> `cc' failed in phase `Linker'. (Exit code: 139)
I did run into linking issues with other Haskell packages in recent versions of macOS, where ghc couldn't find libffi or zlib, and I had to set env variables, eg
export C_INCLUDE_PATH="`xcrun --show-sdk-path`/usr/include/ffi"¬
However, In the case of agda, from the error message it's not obvious to me what the issue is: is it caused by a C lib that the linker cannot locate, and if yes how can i discover which one? is it a problem with M1? is nix-shell -p agda suppose to work on M1?

I've finally managed to find a github issue tracking the problem (it wasn't that easy to find): https://github.com/NixOS/nixpkgs/issues/149692#issuecomment-1177684790
According to the ticket, the only available workaround at the moment is to compile for x86_64 and use Rosetta

Related

golang can't start debug, shows framework not found CoreFoundation

I'm using Macbook pro m1, after data migration or update to monterey(not sure which cause this), golang seems can't debug or go list -compiled. I tried to reinstall/update golang and the result is same
go version: 1.17.3 darwin/arm64
Error msg when I start debug
Build Error: go build -o /var/folders/x8/s3w_s9rj0qj74hs68wvqs1740000gp/T/__debug_bin4251008076 -gcflags all=-N -l .
# runtime/cgo
ld: framework not found CoreFoundation
clang: error: linker command failed with exit code 1 (use -v to see invocation) (exit status 2)
Error msg when go list -compiled
# runtime/cgo
ld: framework not found CoreFoundation
clang: error: linker command failed with exit code 1 (use -v to see invocation)
confcenter
what can i do, any idea?
You need to reinstall the CommandLineTools. xcode-select says everything is up to date, but this information seems to be false.
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

linker command failed when building plugin

When I try to build a golang plugin on macOS Catalina using go 1.13.4, the build process breaks with the following error:
$ make buildPlugin
env GOOS=linux go build -buildmode=plugin -o bin/common common/*.go
# command-line-arguments
/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [buildPlugin] Error 2
✘ $ go tool cgo -V
cgo version go1.13.4
Removing env GOOS=linux helps but it is not a solution. Any ideas about the reason for this problem?

Haskell Stack doesnt work correctly on OSX Sierra

I can't get haskell's stack to work on my Mac.
I installed haskell by:
brew cask install haskell-platform
Which is specified here: https://www.haskell.org/platform/mac.html#osx-homebrewcask
I've also tried installing via the downloadable package at the same site.
I do the following commands:
stack new my-project
cd my-project
stack setup
stack build
stack exec my-project-exe
Per the documentation here:
https://docs.haskellstack.org/en/stable/README/#quick-start-guide
And I immediately see this:
[1] 43017 killed stack exec my-project-exe
I've also tried many other ways of installing haskell. I've actually been able to get something compiled and executed just using cabal, but I can't then get hlint, hindent, or ghc-mod to work, they all return a similar message to the one above. I'd love to be able to work with HaskForce in IntelliJ on my Mac, but I've never had luck getting haskell to work.
System Specs
macOS 10.12.6 (16G29) (Sierra)
Fresh uninstall/reinstall of XCode (accepted terms)
brew as package manager
Here's a gif of what happens as well: https://imgur.com/gallery/afYym7m
UPDATE
I blew away all stuff related to ghc, stack, and cabal and then installed this way
https://haskell-lang.org/get-started
Writing the little HelloWorld.hs script worked fine and showed Hello, World
However, doing
stack new someproj
cd someproj
stack build
Resulted in this:
➜ someproj stack build
[1 of 2] Compiling Main ( /Users/trevord2/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /Users/trevord2/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim ( /Users/trevord2/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /Users/trevord2/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /Users/trevord2/.stack/setup-exe-cache/x86_64-osx/tmp-Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 ...
someproj-0.1.0.0: configure (lib + exe)
Configuring someproj-0.1.0.0...
someproj-0.1.0.0: build (lib + exe)
Preprocessing library someproj-0.1.0.0...
[1 of 1] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Lib.o )
Preprocessing executable 'someproj-exe' for someproj-0.1.0.0...
[1 of 1] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/someproj-exe/someproj-exe-tmp/Main.o )
Linking .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/someproj-exe/someproj-exe ...
ld: warning: ignoring file /Users/trevord2/someproj/.stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/libHSsomeproj-0.1.0.0-6corWoTDCA69pE1sqNF8Id.a, file was built for archive which is not the architecture being linked (x86_64): /Users/trevord2/someproj/.stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/libHSsomeproj-0.1.0.0-6corWoTDCA69pE1sqNF8Id.a
Undefined symbols for architecture x86_64:
"_someprojzm0zi1zi0zi0zm6corWoTDCA69pE1sqNF8Id_Lib_someFunc1_closure", referenced from:
_Main_main1_info in Main.o
_S39Z_srt in Main.o
"_someprojzm0zi1zi0zi0zm6corWoTDCA69pE1sqNF8Id_Lib_someFunc1_info", referenced from:
_Main_main_info in Main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
-- While building package someproj-0.1.0.0 using:
/Users/trevord2/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build lib:someproj exe:someproj-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Which I've seen before and was actually one of my initial problems
UPDATE 2: Created GitHub Issue
Here's the issue: https://github.com/commercialhaskell/stack/issues/3487
After talking with folks on #haskell IRC they recommended I create an issue as this is very peculiar behaviour from what I understand. I'll try make sure whatever we find out here is pushed up there too.

linker command failed with exit code 1 (while importing and compiling a new project)

I have imported a project of cocos2dx, whenever i tried to run the project it shows me following error.
ld: library not found for -lcocos2d libraries
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I dont know what to do.

GODI-Batteries: Installation problems

I am trying to install godi-batteries using GODI console. I seem to have all dependencies sorted (like Camomile). I get the following error within Godi's interface:
> ocamlfind ocamlopt -shared -linkall -package camomile,num,str -o src/batteries_uni.cmxs src/batteries_uni.cmxa
> + ocamlfind ocamlopt -shared -linkall -package camomile,num,str -o src/batteries_uni.cmxs src/batteries_uni.cmxa
> ld: warning: -read_only_relocs cannot be used with x86_64
> ld: codegen problem, can't use rel32 to external symbol _caml_negf_mask in .L101 from src/batteries_uni.a(batFloat.o)
> collect2: ld returned 1 exit status
> File "caml_startup", line 1, characters 0-1:
> Error: Error during linking
> Command exited with code 2.
> make[7]: *** [all] Error 10
> Error: Exec error: File /Users/surikator/godi/build/godi/godi-batteries/./../../mk/bsd.pkg.mk, line 1039: Command returned with non-zero exit code
> Error: Exec error: File /Users/surikator/godi/build/godi/godi-batteries/./../../mk/bsd.pkg.mk, line 1378: Command returned with non-zero exit code
I'm using Mac OS X 10.6.4. and I have a 64 bit machine.
Any ideas on how to go around this?
Thanks,
Surikator.
For some reason, OSX OCaml can't build shared libraries. You'll have to disable batteries' building of shared libraries with
BATTERIES_NATIVE_SHLIB=no make
This problem has been fixed in git commit 92b323, and will be included in the next release.

Resources