cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30k stars 3.79k forks source link

build: building from source failed on ARM64 platform #86646

Open odidev opened 2 years ago

odidev commented 2 years ago

Describe the problem

I am trying to build cockroachdb from source on ARM64 platform via bazel 5.2.0, by using this documentation.

Command: - bazel build pkg/cmd/cockroach-short

While building with bazel, the build is failing.


$ bazel build pkg/cmd/cockroach-short 

Extracting Bazel installation... 

Starting local Bazel server and connecting to it... 

INFO: Analyzed target //pkg/cmd/cockroach-short:cockroach-short (1424 packages loaded, 23185 targets configured). 

INFO: Found 1 target... 

INFO: From GoCompilePkg pkg/ccl/gssapiccl/gssapiccl.a: 

external/archived_cdep_libkrb5_linuxarm/lib/libkrb5.a(dnsglue.o):dnsglue.c:function krb5int_dns_init: error: undefined reference to '__res_nsearch' 

collect2: error: ld returned 1 exit status 

ERROR: /home/avi/cockroach/pkg/cmd/cockroach-short/BUILD.bazel:15:10: GoLink pkg/cmd/cockroach-short/cockroach-short_/cockroach-short failed: (Exit 1): builder failed: error executing command bazel-out/aarch64-opt-exec-2B5CBBC6/bin/external/go_sdk/builder '-param=bazel-out/aarch64-fastbuild/bin/pkg/cmd/cockroach-short/cockroach-short_/cockroach-short-0.params' -- -extld /usr/bin/gcc ... (remaining 3 arguments skipped) 

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging 

external/go_sdk/pkg/tool/linux_arm64/link: running /usr/bin/gcc failed: exit status 1 

external/archived_cdep_libkrb5_linuxarm/lib/libkrb5.a(dnsglue.o):dnsglue.c:function krb5int_dns_init: error: undefined reference to '__res_nsearch' 

collect2: error: ld returned 1 exit status 

link: error running subcommand external/go_sdk/pkg/tool/linux_arm64/link: exit status 2 

Target //pkg/cmd/cockroach-short:cockroach-short failed to build 

Use --verbose_failures to see the command lines of failed build steps. 

INFO: Elapsed time: 501.823s, Critical Path: 129.64s 

INFO: 3152 processes: 336 internal, 2816 linux-sandbox. 

FAILED: Build did NOT complete successfully 

Expected behavior Building on ARM64 Platform should succeed.

Environment:


$ uname -a 

Linux ip-172-31-43-167 5.15.0-1017-aws #21-Ubuntu SMP Fri Aug 5 11:14:45 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux 

$ cat /etc/os-release 

PRETTY_NAME="Ubuntu 22.04 LTS" 

NAME="Ubuntu" 

VERSION_ID="22.04" 

VERSION="22.04 LTS (Jammy Jellyfish)" 

VERSION_CODENAME=jammy 

ID=ubuntu 

ID_LIKE=debian 

HOME_URL="https://www.ubuntu.com/" 

SUPPORT_URL="https://help.ubuntu.com/" 

BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" 

PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" 

UBUNTU_CODENAME=jammy 

Please suggest if there is any specific documentation to follow to build for arm64 platform.

Jira issue: CRDB-18851

blathers-crl[bot] commented 2 years ago

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I was unable to automatically find someone to ping.

If we have not gotten back to your issue within a few business days, you can try the following:

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

rickystewart commented 2 years ago

Hi @odidev, a couple questions:

  1. Do you have the libresolv-wrapper library installed? res_nsearch is provided by that library so you need to have it installed.
  2. What configuration are you using for building/what are the contents of your .bazelrc.user? You should probably be building in the dev configuration, if you're not already.
odidev commented 2 years ago

Yes, I have installed libresolv-wrapper library, but still it was not working, so I have updated BUILD.bazel file.


cockroach$ git diff 

diff --git a/pkg/ccl/gssapiccl/BUILD.bazel b/pkg/ccl/gssapiccl/BUILD.bazel 

index b5f0a1c8f7..07a651a527 100644 

--- a/pkg/ccl/gssapiccl/BUILD.bazel 

+++ b/pkg/ccl/gssapiccl/BUILD.bazel 

@@ -20,7 +20,7 @@ go_library( 

         # NB: On Ubuntu, res_nsearch is found in the resolv_wrapper library, 

         # found in the libresolv-wrapper package. 

         "//build/toolchains:is_dev_linux": ["-ldl -lresolv -lresolv_wrapper"], 

-        "@io_bazel_rules_go//go/platform:linux": ["-ldl -lresolv"], 

+        "@io_bazel_rules_go//go/platform:linux": ["-ldl -lresolv -lresolv_wrapper"], 

         "//conditions:default": [], 

     }), 

     importpath = "github.com/cockroachdb/cockroach/pkg/ccl/gssapiccl", 

And I have successfully built cockroachDB binary on ARM64.

Can I raise PR with the above code?

rickystewart commented 2 years ago

As I mentioned -- you should probably be building with the dev config (--config dev). If you had, you would have been building with -lresolv_wrapper either way. Is there a reason the dev config didn't work for you?

odidev commented 2 years ago

Thanks @rickystewart for your valuable suggestion. Yes, I have successfully built cockroachDB binary on ARM64 using ./dev build pkg/cmd/cockroach-short command. But before running this command I had to run ./dev doctor command. So as ./dev doctor command suggested, I have created .bazelrc.user file and added


build --config lintonbuild 

build --config dev 

test --test_tmpdir=/PATH/TO/TMPDIR 

Just a query, to use inbuild-sql of cockroach, we need libgeos.so and libgeos_c.so files. So, after building with bazel, there are no .so files created. Do we need to build these files separately?

rickystewart commented 2 years ago

Yes, you have to build them separately. bazel build c-deps:libgeos. Depending on which platform you're on this may download a pre-built version, but you can force building it from scratch with bazel build c-deps:libgeos --config force_build_cdeps.

github-actions[bot] commented 7 months ago

We have marked this issue as stale because it has been inactive for 18 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to CockroachDB!