grpc: work around clang limitations#253530
Conversation
|
Retargeting staging due to the number of rebuilds. |
There was a problem hiding this comment.
I get the same error on this branch and the staging commit it's based on.
On the staging commit without including the fix:
nix-build --pure --no-out-link --argstr system x86_64-darwin -E 'with import ./. {}; grpc.override { stdenv = llvmPackages_16.stdenv.override (let dMV = { darwinMinVersion = "10.13"; }; in old: { }); }'
error: builder for '/nix/store/mqd8c7qlz7kj8kgzn1q69daygw18d6r6-grpc-1.57.0.drv' failed with exit code 2;
last 10 log lines:
> make[2]: *** [CMakeFiles/grpcpp_channelz.dir/build.make:77: gens/src/proto/grpc/channelz/channelz.grpc.pb.cc] Error 1
> make[1]: *** [CMakeFiles/Makefile2:550: CMakeFiles/grpcpp_channelz.dir/all] Error 2
> 1 warning generated.
> [ 99%] Linking CXX shared library libgrpc++_error_details.dylib
> 1 warning generated.
> [ 99%] Built target grpc++_error_details
> 1 warning generated.
> [ 99%] Linking CXX shared library libgrpc++_alts.dylib
> [ 99%] Built target grpc++_alts
> make: *** [Makefile:136: all] Error 2
And then "including" the fix:
nix-build --pure --no-out-link --argstr system x86_64-darwin -E 'with import ./. {}; grpc.override { stdenv = llvmPackages_16.stdenv.override (let dMV = { darwinMinVersion = "10.13"; }; in old: { hostPlatform = old.hostPlatform // dMV; buildPlatform = old.buildPlatform // dMV; targetPlatform = old.targetPlatform // dMV;}); }'
error: builder for '/nix/store/m343grlp9xd0z4i9ssyp5jj3gqsbic1y-grpc-1.57.0.drv' failed with exit code 2;
last 10 log lines:
> make[1]: *** Waiting for unfinished jobs....
> make[1]: *** [CMakeFiles/Makefile2:550: CMakeFiles/grpcpp_channelz.dir/all] Error 2
> 1 warning generated.
> [ 99%] Linking CXX shared library libgrpc++_error_details.dylib
> 1 warning generated.
> [ 99%] Built target grpc++_error_details
> 1 warning generated.
> [ 99%] Linking CXX shared library libgrpc++_alts.dylib
> [ 99%] Built target grpc++_alts
> make: *** [Makefile:136: all] Error 2
Seems like this happens from LLVM 15 onwards.
EDIT: I think passing --argstr and then using -E with another nixpkgs import is flawed.
Fix not included:
In file included from /tmp/nix-build-grpc-1.57.0.drv-0/source/src/core/[26/1825]
el/channelz.cc:21:
In file included from /tmp/nix-build-grpc-1.57.0.drv-0/source/src/core/lib/chann
el/channelz.h:28:
In file included from /nix/store/0gxf0bjxkyx3mp7x1syxl5vh7fkj54sw-libcxx-16.0.6-
dev/include/c++/v1/map:543:
In file included from /nix/store/0gxf0bjxkyx3mp7x1syxl5vh7fkj54sw-libcxx-16.0.6-dev/include/c++/v1/__node_handle:65:
In file included from /nix/store/0gxf0bjxkyx3mp7x1syxl5vh7fkj54sw-libcxx-16.0.6-
dev/include/c++/v1/optional:1583:
In file included from /nix/store/0gxf0bjxkyx3mp7x1syxl5vh7fkj54sw-libcxx-16.0.6-
dev/include/c++/v1/memory:898: In file included from /nix/store/0gxf0bjxkyx3mp7x1syxl5vh7fkj54sw-libcxx-16.0.6-dev/include/c++/v1/__memory/shared_ptr.h:31:
/nix/store/0gxf0bjxkyx3mp7x1syxl5vh7fkj54sw-libcxx-16.0.6-dev/include/c++/v1/__m
emory/unique_ptr.h:91:5: error: aligned deallocation function of type 'void (voi
d *, std::align_val_t) noexcept' is only available on macOS 10.13 or newer
delete[] __ptr; ^
/nix/store/0gxf0bjxkyx3mp7x1syxl5vh7fkj54sw-libcxx-16.0.6-dev/include/c++/v1/__m
emory/unique_ptr.h:504:7: note: in instantiation of function template specialization 'std::default_delete<grpc_core::channelz::PerCpuCallCountingHelper::PerCpuD
ata[]>::operator()<grpc_core::channelz::PerCpuCallCountingHelper::PerCpuData>' r
equested here __ptr_.second()(__tmp);
^
/nix/store/0gxf0bjxkyx3mp7x1syxl5vh7fkj54sw-libcxx-16.0.6-dev/include/c++/v1/__m
emory/unique_ptr.h:460:75: note: in instantiation of member function 'std::uniqu
e_ptr<grpc_core::channelz::PerCpuCallCountingHelper::PerCpuData[]>::reset' reque
sted here
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(
); }
^
/tmp/nix-build-grpc-1.57.0.drv-0/source/src/core/lib/gprpp/per_cpu.h:55:7: note:
in instantiation of member function 'std::unique_ptr<grpc_core::channelz::PerCp
uCallCountingHelper::PerCpuData[]>::~unique_ptr' requested here
class PerCpu {
^
/nix/store/0gxf0bjxkyx3mp7x1syxl5vh7fkj54sw-libcxx-16.0.6-dev/include/c++/v1/__m
emory/unique_ptr.h:91:5: note: if you supply your own aligned allocation functio
ns, use -faligned-allocation to silence this diagnostic
delete[] __ptr;
^
I believe that's the actual failure you're fixing here.
However, with the fix "included":
nix-build --pure --no-out-link -E 'with import ./. { system = "x86_64-darwin"; }; grpc.override { stdenv = llvmPackages_16.stdenv.override (let dMV = { darwinMinVersion = "10.13"; }; in old: { hostPlatform = old.hostPlatform // dMV; buildPlatform = old.buildPlatform // dMV; targetPlatform = old.targetPlatform // dMV;}); }'
error: builder for '/nix/store/kgqrg5zz36ncr6b52dnxr1lvl6vv3ygy-grpc-1.57.0.drv' failed with exit code 2;
last 10 log lines:
> --grpc_out: protoc-gen-grpc: Plugin killed by signal 11.
> make[1]: *** [CMakeFiles/Makefile2:437: CMakeFiles/grpc++_reflection.dir/all] Error 2
> make[1]: *** Waiting for unfinished jobs....
> make[2]: *** [CMakeFiles/grpcpp_channelz.dir/build.make:77: gens/src/proto/grpc/channelz/channelz.grpc.pb.cc] Error 1
> make[1]: *** [CMakeFiles/Makefile2:550: CMakeFiles/grpcpp_channelz.dir/all] Error 2
> [ 99%] Linking CXX shared library libgrpc++_error_details.dylib
> [ 99%] Built target grpc++_error_details
> [ 99%] Linking CXX shared library libgrpc++_alts.dylib
> [ 99%] Built target grpc++_alts
> make: *** [Makefile:136: all] Error 2
gRPC has dependencies written in C++, so the crash is probably due to mixing different versions of libc++ in the same process. gRPC and its dependencies all need to be built against the same libc++ (which currently means with the same clang version). |
Clang checks for a deployment target of at least 10.13 when using aligned allocations even though it has an implementation using `posix_memalign`, which is available in the 10.12 SDK. Work around this check by lying to clang about what the deployment target is.
toonn
left a comment
There was a problem hiding this comment.
Couldn't work out the proper override so I just merged in the LLVM bump. Reproduced both failure and success with that. So looks good to me.
I fixed a couple typos in the commit.
Description of changes
Clang checks for a deployment target of at least 10.13 when using aligned allocations even though it has an implementaiton using
posix_memalign, which is available in the 10.12 SDK. Work around this check by lying to clang about what the deployment target is.Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)