11{
2+ binutils ,
23 lib ,
3- stdenv ,
4+ clangStdenv ,
45 fetchFromGitHub ,
56 cmake ,
67 openssl ,
78 zlib ,
89} :
910
10- stdenv . mkDerivation rec {
11+ let
12+ # HACK: work around https://github.com/NixOS/nixpkgs/issues/177129
13+ # Though this is an issue between Clang and GCC,
14+ # so it may not get fixed anytime soon...
15+ empty-libgcc_eh = clangStdenv . mkDerivation {
16+ pname = "empty-libgcc_eh" ;
17+ version = "0" ;
18+ dontUnpack = true ;
19+ installPhase = ''
20+ mkdir -p "$out"/lib
21+ "${ binutils } "/bin/ar r "$out"/lib/libgcc_eh.a
22+ '' ;
23+ } ;
24+ in
25+
26+ # NOTE: This must be `clang` because `gcc` is known to miscompile or ICE while
27+ # compiling `capnproto` coroutines.
28+ #
29+ # See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102051
30+ # See: https://gerrit.lix.systems/c/lix/+/1874
31+ clangStdenv . mkDerivation rec {
1132 pname = "capnproto" ;
1233 version = "1.1.0" ;
1334
@@ -23,8 +44,27 @@ stdenv.mkDerivation rec {
2344 propagatedBuildInputs = [
2445 openssl
2546 zlib
47+ ] ++ lib . optional ( clangStdenv . cc . isClang && clangStdenv . targetPlatform . isStatic ) empty-libgcc_eh ;
48+
49+ # FIXME: separate the binaries from the stuff that user systems actually use
50+ # This runs into a terrible UX issue in Lix and I just don't want to debug it
51+ # right now for the couple MB of closure size:
52+ # https://git.lix.systems/lix-project/lix/issues/551
53+ # outputs = [ "bin" "dev" "out" ];
54+
55+ cmakeFlags = [
56+ ( lib . cmakeBool "BUILD_SHARED_LIBS" true )
57+ # Take optimization flags from CXXFLAGS rather than cmake injecting them
58+ ( lib . cmakeFeature "CMAKE_BUILD_TYPE" "None" )
2659 ] ;
2760
61+ env = {
62+ # Required to build the coroutine library
63+ CXXFLAGS = "-std=c++20" ;
64+ } ;
65+
66+ separateDebugInfo = true ;
67+
2868 meta = with lib ; {
2969 homepage = "https://capnproto.org/" ;
3070 description = "Cap'n Proto cerealization protocol" ;
@@ -35,6 +75,6 @@ stdenv.mkDerivation rec {
3575 '' ;
3676 license = licenses . mit ;
3777 platforms = platforms . all ;
38- maintainers = [ ] ;
78+ maintainers = lib . teams . lix . members ;
3979 } ;
4080}
0 commit comments