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

question: how to fix bazel errors when cross-compiling for arm64? #11446

Closed
errordeveloper opened this issue Jun 4, 2020 · 8 comments
Closed

Comments

@errordeveloper
Copy link
Contributor

errordeveloper commented Jun 4, 2020

There had been a few issue regarding arm64 (#10512, #7686 & #1861), but this one is not a feature request.
I have attempted to configure Bazel to cross-compile for arm64, but I am facing a roadblock.

Here is what I did:

When I test my changes, I get this:

$ bazel build --config=cross_aarch64  //source/exe:envoy-static
INFO: Build options --cpu, --crosstool_top, and --host_crosstool_top have changed, discarding analysis cache.
ERROR: /root/.cache/bazel/_bazel_root/f8087e59fd95af1ae29e8fcb7ff1a3dc/external/envoy/bazel/foreign_cc/BUILD:40:1: in configure_make rule @envoy//bazel/foreign_cc:luajit: 
Traceback (most recent call last):
	File "/root/.cache/bazel/_bazel_root/f8087e59fd95af1ae29e8fcb7ff1a3dc/external/envoy/bazel/foreign_cc/BUILD", line 40
		configure_make(name = 'luajit')
	File "/root/.cache/bazel/_bazel_root/f8087e59fd95af1ae29e8fcb7ff1a3dc/external/rules_foreign_cc/tools/build_defs/configure.bzl", line 29, in _configure_make
		cc_external_rule_impl(ctx, <1 more arguments>)
	File "/root/.cache/bazel/_bazel_root/f8087e59fd95af1ae29e8fcb7ff1a3dc/external/rules_foreign_cc/tools/build_defs/framework.bzl", line 252, in cc_external_rule_impl
		attrs.create_configure_script(<1 more arguments>)
	File "/root/.cache/bazel/_bazel_root/f8087e59fd95af1ae29e8fcb7ff1a3dc/external/rules_foreign_cc/tools/build_defs/configure.bzl", line 43, in attrs.create_configure_script
		create_configure_script(<12 more arguments>)
	File "/root/.cache/bazel/_bazel_root/f8087e59fd95af1ae29e8fcb7ff1a3dc/external/rules_foreign_cc/tools/build_defs/configure_script.bzl", line 17, in create_configure_script
		get_env_vars(workspace_name, <5 more arguments>)
	File "/root/.cache/bazel/_bazel_root/f8087e59fd95af1ae29e8fcb7ff1a3dc/external/rules_foreign_cc/tools/build_defs/configure_script.bzl", line 71, in get_env_vars
		vars["LDFLAGS"]
key "LDFLAGS" not found in dictionary
INFO: Repository boringssl instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule http_archive defined at:
  /root/.cache/bazel/_bazel_root/f8087e59fd95af1ae29e8fcb7ff1a3dc/external/bazel_tools/tools/build_defs/repo/http.bzl:336:16: in <toplevel>
ERROR: Analysis of target '//source/exe:envoy-static' failed; build aborted: Analysis of target '@envoy//bazel/foreign_cc:luajit' failed
INFO: Elapsed time: 26.319s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (454 packages loaded, 12661 targets configured)
    Fetching @com_github_gperftools_gperftools; Patching repository 9s
    Fetching @org_golang_x_tools; Cloning c9f9432ec4b21a28c4d47f172513698febb68e9c of https://go.googlesource.com/tools 5s
    Fetching @com_github_golang_protobuf; Cloning 6c65a5562fc06764971b7c5d05c76c75e84bdbf7 of https://github.com/golang/protobuf
$

I'm using a container image for this, so anyone should be able to reproduce easily:

git remote add errordeveloper https://github.com/errordeveloper/envoy
git fetch errordeveloper
git checkout errordeveloper/cross-aarch64 -b cross-aarch64

docker run \
  --volume "$(pwd):/src" \
  --workdir "/src" \
  --rm --tty --interactive \
    docker.io/cilium/image-compilers:ac609e4c5a77e9c4c92e096b8c96a49b78d5c869 \
      bazel build --config=cross_aarch64  //source/exe:envoy-static

I'd love some help here, would be happy to contribute back once I have it working!

@errordeveloper
Copy link
Contributor Author

I have looked into rules_foreign_cc, but I fail to understand what is really going on there really.

@errordeveloper errordeveloper changed the title cross-compilation for arm64 question: how to fix bazel errors when cross-compiling for arm64 Jun 4, 2020
@errordeveloper errordeveloper changed the title question: how to fix bazel errors when cross-compiling for arm64 question: how to fix bazel errors when cross-compiling for arm64? Jun 4, 2020
@errordeveloper
Copy link
Contributor Author

More specifically, what I don't get is:

  • what exactly rules_foreign_cc is trying to do?
  • how is vars["LDFLAGS"] set normally and why it doesn't get set in my case?

@errordeveloper

This comment has been minimized.

@errordeveloper
Copy link
Contributor Author

I have managed to overcome the LDFLAGS issue with a fairly simple fix (bazel-contrib/rules_foreign_cc#407). I'll share an update if I run into anything else, or will be sure to close the issue otherwise.

@errordeveloper

This comment has been minimized.

@errordeveloper

This comment has been minimized.

@errordeveloper
Copy link
Contributor Author

For the record, bazel-contrib/rules_foreign_cc#407 has been merged and I'll open a PR here to update the dependency.

@errordeveloper
Copy link
Contributor Author

Good news: I have built Envoy successfully now, yet with quite a few tweaks, which can be found in my branch. I'd like to open a PR at some point, but it would help if someone could help me to resolve some of the underlying issues that I've managed to bypass.

errordeveloper added a commit to errordeveloper/envoy that referenced this issue Jun 9, 2020
The aim is to fix one of the issues encountered while cross-compiling
Envoy (see envoyproxy#11446 and bazel-contrib/rules_foreign_cc#407).

Signed-off-by: Ilya Dmitrichenko <errordeveloper@gmail.com>
errordeveloper added a commit to errordeveloper/envoy that referenced this issue Jun 9, 2020
The aim is to fix one of the issues encountered while cross-compiling
Envoy (see envoyproxy#11446 and bazel-contrib/rules_foreign_cc#407).

Signed-off-by: Ilya Dmitrichenko <errordeveloper@gmail.com>
lizan pushed a commit that referenced this issue Jun 11, 2020
The aim is to fix one of the issues encountered while cross-compiling
Envoy (see #11446 and bazel-contrib/rules_foreign_cc#407).

Signed-off-by: Ilya Dmitrichenko <errordeveloper@gmail.com>
yashwant121 pushed a commit to yashwant121/envoy that referenced this issue Jun 24, 2020
The aim is to fix one of the issues encountered while cross-compiling
Envoy (see envoyproxy#11446 and bazel-contrib/rules_foreign_cc#407).

Signed-off-by: Ilya Dmitrichenko <errordeveloper@gmail.com>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
songhu pushed a commit to songhu/envoy that referenced this issue Jun 25, 2020
The aim is to fix one of the issues encountered while cross-compiling
Envoy (see envoyproxy#11446 and bazel-contrib/rules_foreign_cc#407).

Signed-off-by: Ilya Dmitrichenko <errordeveloper@gmail.com>
yashwant121 pushed a commit to yashwant121/envoy that referenced this issue Jul 24, 2020
The aim is to fix one of the issues encountered while cross-compiling
Envoy (see envoyproxy#11446 and bazel-contrib/rules_foreign_cc#407).

Signed-off-by: Ilya Dmitrichenko <errordeveloper@gmail.com>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants