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?
Related
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
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
creating a build getting this error
ld: library not found for -lPods-Swan
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Deleted -lPods-Swan.a in main project and now works.
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.
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.