Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake.nix: explicitly add libcxx as dependency #4107

Merged
merged 1 commit into from
Jan 31, 2024
Merged

Conversation

eliasnaur
Copy link
Contributor

@eliasnaur eliasnaur commented Jan 31, 2024

Without this change, my tinygo builds crash with

SIGSEGV: segmentation violation
PC=0x10884f87c m=16 sigcode=2
signal arrived during cgo execution

goroutine 378 [syscall]:
runtime.cgocall(0x100631e44, 0x1401755be88)
	/nix/store/4hf287252ilsdf2w36mfm8fa0rvbf33w-go-1.21.4/share/go/src/runtime/cgocall.go:157 +0x44 fp=0x1401755be50 sp=0x1401755be10 pc=0x1002a5084
tinygo.org/x/go-llvm._Cfunc_LLVMGoWriteThinLTOBitcodeToMemoryBuffer(0x123614160)
	_cgo_gotypes.go:6078 +0x34 fp=0x1401755be80 sp=0x1401755be50 pc=0x1004b66b4
...

and reports using LLVM 16:

$ tinygo version
tinygo version 0.31.0-dev darwin/arm64 (using go version go1.21.4 and LLVM version 16.0.6)

I don't know why libcxx-16 is being included, but explicitly specifying llvmPackages_17.libcxx fixes the crash and version skew.

Without this change, my tinygo builds crash with

SIGSEGV: segmentation violation
PC=0x10884f87c m=16 sigcode=2
signal arrived during cgo execution

goroutine 378 [syscall]:
runtime.cgocall(0x100631e44, 0x1401755be88)
	/nix/store/4hf287252ilsdf2w36mfm8fa0rvbf33w-go-1.21.4/share/go/src/runtime/cgocall.go:157 +0x44 fp=0x1401755be50 sp=0x1401755be10 pc=0x1002a5084
tinygo.org/x/go-llvm._Cfunc_LLVMGoWriteThinLTOBitcodeToMemoryBuffer(0x123614160)
	_cgo_gotypes.go:6078 +0x34 fp=0x1401755be80 sp=0x1401755be50 pc=0x1004b66b4
...

and reports using LLVM 16:

$ tinygo version
tinygo version 0.31.0-dev darwin/arm64 (using go version go1.21.4 and LLVM version 16.0.6)

I don't know why libcxx-16 is being included, but explicitly specifying
llvmPackages_17.libcxx fixes the crash and version skew.
@aykevl
Copy link
Member

aykevl commented Jan 31, 2024

Huh that's very odd. Normally Nix is supposed to only make explicit dependencies available. Perhaps it picked up libcxx from the host somehow? I think you can check using ldd.

In any case, this seems harmless so I'll merge it.

@aykevl aykevl merged commit 7b8ae2d into tinygo-org:dev Jan 31, 2024
15 checks passed
@eliasnaur
Copy link
Contributor Author

ldd doesn't work on macOS, but:

$ DYLD_PRINT_LIBRARIES=1 DYLD_PRINT_LIBRARIES_POST_LAUNCH=1 DYLD_PRINT_RPATHS=1 tinygo
dyld[43805]: <no uuid> /Users/a/go/bin/tinygo
dyld[43805]: <no uuid> /nix/store/pa45hr057y8q677ic3mx3m2w147p4ghz-llvm-17.0.6-lib/lib/libLLVM.dylib
dyld[43805]: <no uuid> /nix/store/a377d66g1rgsd4vkzxdhkza5g55fkmky-zlib-1.3/lib/libz.dylib
dyld[43805]: <no uuid> /nix/store/j1f6nc90w2lj3a9ffhlh3swj09rx52vm-clang-17.0.6-lib/lib/libclang.dylib
dyld[43805]: <no uuid> /nix/store/x622mzi1g7v7nh7zq5r8d0nxbhrg9px3-libcxxabi-16.0.6/lib/libc++abi.1.0.dylib
dyld[43805]: <no uuid> /nix/store/vf7k7l7ny35g1nmninaqjbryl2xqkag5-libcxx-16.0.6/lib/libc++.1.0.dylib
dyld[43805]: <no uuid> /nix/store/lb9b1yj8l0zqgj5f28m4k1lw9wcj8d1m-libffi-3.4.4/lib/libffi.8.dylib
dyld[43805]: <no uuid> /nix/store/knf3077k6fhm0g5qw2z51m22afzhz279-ncurses-6.4/lib/libncursesw.6.dylib
dyld[43805]: <no uuid> /nix/store/al2fcmdcsxlx9zv5nsr4464dmrypf2bk-libxml2-2.11.5/lib/libxml2.2.dylib
dyld[43805]: <no uuid> /nix/store/g5r20rs0qhcjcbf9dhbnbd9ksg0h0jmx-libiconv-50/lib/libiconv.dylib
...

libcxx-16 is also in the environment:

$ export |rg libcxx
declare -x NIX_CFLAGS_COMPILE=" -frandom-seed=6hlh4ydiqz -isystem /nix/store/kn42w75jaxn67cwasjc8bamvqvvmwj4j-libcxx-16.0.6-dev/include -isystem /nix/store/x26rhb948xf8jxqcrrm431qda6pgpjn1-libcxxabi-16.0.6-dev/include -isystem /nix/store/vlajrml5iynvz4b6g1hivjdwa7614g8q-compiler-rt-libc-16.0.6-dev/include -isystem /nix/store/2rzyj3jrv6ywzbah7kiffa15gj9bd46k-llvm-17.0.6-dev/include -isystem /nix/store/965d26wgfh9rjzlf5b29lvbdzz29pjnb-ncurses-6.4-dev/include -isystem /nix/store/68289cwrk5pjj6nmlb7r76qqpw99s011-zlib-1.3-dev/include -isystem /nix/store/6achz4yvzls6d3piy9jyw0bwqj71xlqz-clang-17.0.6-dev/include -isystem /nix/store/q4k0b3g6fvm3jxcdqfpxxza0hja0blgc-libcxx-17.0.6-dev/include -isystem /nix/store/299c96xpcifgymyzx3ixdmhx2w03hhc3-lld-17.0.6-dev/include -isystem /nix/store/29rm05dhznyf3ha47ra6qjgc4vhbpsia-avrdude-7.2/include -isystem /nix/store/dnmdcw3mf1yi98mvxzx8iml0pkhf8fmq-binaryen-116/include -iframework /nix/store/7aiqcq3qjyy3cx3c2qafcv1q559hgbbc-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -isystem /nix/store/bj25mj5bpvbx03gqzf7hbpk6n7w4khr6-libobjc-11.0.0/include -iframework /nix/store/cpdysjy53rjmmmrfd7pz4b7kmvaskmph-apple-framework-Foundation-11.0.0/Library/Frameworks -iframework /nix/store/y12dx8cmpj68i10w72cijccflnhg1ad7-apple-framework-ApplicationServices-11.0.0/Library/Frameworks -iframework /nix/store/803jnyznlw514dz1fcbasgh69m76pxyv-apple-framework-ColorSync-11.0.0/Library/Frameworks -iframework /nix/store/18n978qvmqs5rlxv5wb5mhrrdbsi06l7-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -iframework /nix/store/mxn3cnq7hhh4qy6mnwhnwrn5qks1cs18-apple-framework-CoreGraphics-11.0.0/Library/Frameworks -iframework /nix/store/7nc6wi6swdc8hcxwf2al3r0nzvbgqs4m-apple-framework-IOKit-11.0.0/Library/Frameworks -iframework /nix/store/g8f2sg1a14x4axx9x7ji4hlll2r933k6-apple-framework-SystemConfiguration-11.0.0/Library/Frameworks -iframework /nix/store/h0x77jf3ix0x2jkjs9imsngk8kws94la-apple-framework-Security-11.0.0/Library/Frameworks -isystem /nix/store/7y81azvimmhqrk0mia4qzyxwzhdx5rdv-apple-lib-libDER/include -iframework /nix/store/2a37hj2yxfpyc3f6gzvafnlh91lzigsp-apple-framework-CoreServices-11.0.0/Library/Frameworks -iframework /nix/store/lbnn0f8m05d7vkqrwx6b47mc7wy9wxf9-apple-framework-CFNetwork-11.0.0/Library/Frameworks -iframework /nix/store/yr4bxvf9d5xz7lp9p7wig5fk9m6a0l99-apple-framework-CoreAudio-11.0.0/Library/Frameworks -iframework /nix/store/wd6jngfywj1d60dcx24afwgc92zcxypr-apple-framework-CoreAudioTypes-11.0.0/Library/Frameworks -iframework /nix/store/pvslgd1gpl5vfpmhg0zrr91ws090jfv9-apple-framework-DiskArbitration-11.0.0/Library/Frameworks -iframework /nix/store/ch84dx65aix6hrdj91qiadxndp3f6l65-apple-framework-NetFS-11.0.0/Library/Frameworks -iframework /nix/store/02487zak2xyyppwrvq7ik6lpa04340ca-apple-framework-ServiceManagement-11.0.0/Library/Frameworks -iframework /nix/store/4pwbyf74gg6vk9pycic5w0c9pz86yjjz-apple-framework-CoreText-11.0.0/Library/Frameworks -iframework /nix/store/fidyspdqrpyhkv2bs9523prw5v39n646-apple-framework-ImageIO-11.0.0/Library/Frameworks -iframework /nix/store/wshv41iccz36yfb5bjmqfwvldzd8id5v-apple-framework-Combine-11.0.0/Library/Frameworks -isystem /nix/store/4h8sj7pmid71vgkflx4wxyvmj6mghz39-Toolchains/XcodeDefault.xctoolchain/include -isystem /nix/store/kn42w75jaxn67cwasjc8bamvqvvmwj4j-libcxx-16.0.6-dev/include -isystem /nix/store/x26rhb948xf8jxqcrrm431qda6pgpjn1-libcxxabi-16.0.6-dev/include -isystem /nix/store/vlajrml5iynvz4b6g1hivjdwa7614g8q-compiler-rt-libc-16.0.6-dev/include -isystem /nix/store/2rzyj3jrv6ywzbah7kiffa15gj9bd46k-llvm-17.0.6-dev/include -isystem /nix/store/965d26wgfh9rjzlf5b29lvbdzz29pjnb-ncurses-6.4-dev/include -isystem /nix/store/68289cwrk5pjj6nmlb7r76qqpw99s011-zlib-1.3-dev/include -isystem /nix/store/6achz4yvzls6d3piy9jyw0bwqj71xlqz-clang-17.0.6-dev/include -isystem /nix/store/q4k0b3g6fvm3jxcdqfpxxza0hja0blgc-libcxx-17.0.6-dev/include -isystem /nix/store/299c96xpcifgymyzx3ixdmhx2w03hhc3-lld-17.0.6-dev/include -isystem /nix/store/29rm05dhznyf3ha47ra6qjgc4vhbpsia-avrdude-7.2/include -isystem /nix/store/dnmdcw3mf1yi98mvxzx8iml0pkhf8fmq-binaryen-116/include -iframework /nix/store/7aiqcq3qjyy3cx3c2qafcv1q559hgbbc-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -isystem /nix/store/bj25mj5bpvbx03gqzf7hbpk6n7w4khr6-libobjc-11.0.0/include -iframework /nix/store/cpdysjy53rjmmmrfd7pz4b7kmvaskmph-apple-framework-Foundation-11.0.0/Library/Frameworks -iframework /nix/store/y12dx8cmpj68i10w72cijccflnhg1ad7-apple-framework-ApplicationServices-11.0.0/Library/Frameworks -iframework /nix/store/803jnyznlw514dz1fcbasgh69m76pxyv-apple-framework-ColorSync-11.0.0/Library/Frameworks -iframework /nix/store/18n978qvmqs5rlxv5wb5mhrrdbsi06l7-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -iframework /nix/store/mxn3cnq7hhh4qy6mnwhnwrn5qks1cs18-apple-framework-CoreGraphics-11.0.0/Library/Frameworks -iframework /nix/store/7nc6wi6swdc8hcxwf2al3r0nzvbgqs4m-apple-framework-IOKit-11.0.0/Library/Frameworks -iframework /nix/store/g8f2sg1a14x4axx9x7ji4hlll2r933k6-apple-framework-SystemConfiguration-11.0.0/Library/Frameworks -iframework /nix/store/h0x77jf3ix0x2jkjs9imsngk8kws94la-apple-framework-Security-11.0.0/Library/Frameworks -isystem /nix/store/7y81azvimmhqrk0mia4qzyxwzhdx5rdv-apple-lib-libDER/include -iframework /nix/store/2a37hj2yxfpyc3f6gzvafnlh91lzigsp-apple-framework-CoreServices-11.0.0/Library/Frameworks -iframework /nix/store/lbnn0f8m05d7vkqrwx6b47mc7wy9wxf9-apple-framework-CFNetwork-11.0.0/Library/Frameworks -iframework /nix/store/yr4bxvf9d5xz7lp9p7wig5fk9m6a0l99-apple-framework-CoreAudio-11.0.0/Library/Frameworks -iframework /nix/store/wd6jngfywj1d60dcx24afwgc92zcxypr-apple-framework-CoreAudioTypes-11.0.0/Library/Frameworks -iframework /nix/store/pvslgd1gpl5vfpmhg0zrr91ws090jfv9-apple-framework-DiskArbitration-11.0.0/Library/Frameworks -iframework /nix/store/ch84dx65aix6hrdj91qiadxndp3f6l65-apple-framework-NetFS-11.0.0/Library/Frameworks -iframework /nix/store/02487zak2xyyppwrvq7ik6lpa04340ca-apple-framework-ServiceManagement-11.0.0/Library/Frameworks -iframework /nix/store/4pwbyf74gg6vk9pycic5w0c9pz86yjjz-apple-framework-CoreText-11.0.0/Library/Frameworks -iframework /nix/store/fidyspdqrpyhkv2bs9523prw5v39n646-apple-framework-ImageIO-11.0.0/Library/Frameworks -iframework /nix/store/wshv41iccz36yfb5bjmqfwvldzd8id5v-apple-framework-Combine-11.0.0/Library/Frameworks -isystem /nix/store/4h8sj7pmid71vgkflx4wxyvmj6mghz39-Toolchains/XcodeDefault.xctoolchain/include"
declare -x NIX_LDFLAGS=" -L/nix/store/vf7k7l7ny35g1nmninaqjbryl2xqkag5-libcxx-16.0.6/lib -L/nix/store/x622mzi1g7v7nh7zq5r8d0nxbhrg9px3-libcxxabi-16.0.6/lib -L/nix/store/l92ls1vba62zsywdj81hlgmgx5adn6bn-compiler-rt-libc-16.0.6/lib -L/nix/store/knf3077k6fhm0g5qw2z51m22afzhz279-ncurses-6.4/lib -L/nix/store/a377d66g1rgsd4vkzxdhkza5g55fkmky-zlib-1.3/lib -L/nix/store/pa45hr057y8q677ic3mx3m2w147p4ghz-llvm-17.0.6-lib/lib -L/nix/store/j1f6nc90w2lj3a9ffhlh3swj09rx52vm-clang-17.0.6-lib/lib -L/nix/store/vv6jrgnyi4av0wqc471y7yy9k4p8yjnc-libcxx-17.0.6/lib -L/nix/store/idnlzhm9nga5lixs6pz5y56bjkajbmqm-lld-17.0.6-lib/lib -L/nix/store/29rm05dhznyf3ha47ra6qjgc4vhbpsia-avrdude-7.2/lib -L/nix/store/dnmdcw3mf1yi98mvxzx8iml0pkhf8fmq-binaryen-116/lib -L/nix/store/bj25mj5bpvbx03gqzf7hbpk6n7w4khr6-libobjc-11.0.0/lib -L/nix/store/vf7k7l7ny35g1nmninaqjbryl2xqkag5-libcxx-16.0.6/lib -L/nix/store/x622mzi1g7v7nh7zq5r8d0nxbhrg9px3-libcxxabi-16.0.6/lib -L/nix/store/l92ls1vba62zsywdj81hlgmgx5adn6bn-compiler-rt-libc-16.0.6/lib -L/nix/store/knf3077k6fhm0g5qw2z51m22afzhz279-ncurses-6.4/lib -L/nix/store/a377d66g1rgsd4vkzxdhkza5g55fkmky-zlib-1.3/lib -L/nix/store/pa45hr057y8q677ic3mx3m2w147p4ghz-llvm-17.0.6-lib/lib -L/nix/store/j1f6nc90w2lj3a9ffhlh3swj09rx52vm-clang-17.0.6-lib/lib -L/nix/store/vv6jrgnyi4av0wqc471y7yy9k4p8yjnc-libcxx-17.0.6/lib -L/nix/store/idnlzhm9nga5lixs6pz5y56bjkajbmqm-lld-17.0.6-lib/lib -L/nix/store/29rm05dhznyf3ha47ra6qjgc4vhbpsia-avrdude-7.2/lib -L/nix/store/dnmdcw3mf1yi98mvxzx8iml0pkhf8fmq-binaryen-116/lib -L/nix/store/bj25mj5bpvbx03gqzf7hbpk6n7w4khr6-libobjc-11.0.0/lib"
declare -x buildInputs="/nix/store/4hf287252ilsdf2w36mfm8fa0rvbf33w-go-1.21.4 /nix/store/2rzyj3jrv6ywzbah7kiffa15gj9bd46k-llvm-17.0.6-dev /nix/store/6achz4yvzls6d3piy9jyw0bwqj71xlqz-clang-17.0.6-dev /nix/store/q4k0b3g6fvm3jxcdqfpxxza0hja0blgc-libcxx-17.0.6-dev /nix/store/299c96xpcifgymyzx3ixdmhx2w03hhc3-lld-17.0.6-dev /nix/store/29rm05dhznyf3ha47ra6qjgc4vhbpsia-avrdude-7.2 /nix/store/dnmdcw3mf1yi98mvxzx8iml0pkhf8fmq-binaryen-116"

I tried nix why-depends .# nixpkgs#libcxx after hacking the flake.nix to specify a default package, but it reported no dependency. I'm guessing libcxx-16 bleeds through because of an artifact in how clang is bootstrapped on Nix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants