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

"Using cargo-raze through Bazel" documentation example doesn't compile anymore #423

Open
sayrer opened this issue Jul 2, 2021 · 9 comments

Comments

@sayrer
Copy link
Contributor

sayrer commented Jul 2, 2021

If you update close to the main branch, something like this works:

#
# Use "cargo raze" through Bazel to download Cargo dependencies.
#
git_repository(
    name = "cargo_raze",
    commit = "ee2effee5b6c95cfcfd5e496677ce61dcd35c472",
    remote = "https://github.com/google/cargo-raze"
)

load("@cargo_raze//:repositories.bzl", "cargo_raze_repositories")

cargo_raze_repositories()

load("@cargo_raze//:transitive_deps.bzl", "cargo_raze_transitive_deps")

cargo_raze_transitive_deps()
@depthwise
Copy link

This works, BTW:

http_archive(
    name = "cargo_raze",
    sha256 = "0a7986b1a8ec965ee7aa317ac61e82ea08568cfdf36b7ccc4dd3d1aff3b36e0b",
    strip_prefix = "cargo-raze-0.12.0",
    url = "https://github.com/google/cargo-raze/archive/refs/tags/v0.12.0.tar.gz",
)

@rbtcollins

This comment has been minimized.

@photex
Copy link

photex commented Sep 15, 2021

This is also failing for me on Linux and afaik MacOS. SSL failing in multiple ways depending the crates I've tried, but libgit, libssh, and openssl are all apparently quite a hassle. No problems with cargo and the libs living in the system however.

@photex
Copy link

photex commented Sep 15, 2021

Also seems to fail on Windows.

On MacOS, cloning this repo and running bazel build //impl/... does work however.

@cfrantz
Copy link

cfrantz commented Nov 11, 2021

I'm experiencing this issue wrt the pcre dependency. ftp.pcre.org seems to be down and the the copy on mirror.bazel.build no longer seems to be present.

Is there a more reliable or stable URL for pcre-8.44?

@UebelAndre
Copy link
Collaborator

I'm experiencing this issue wrt the pcre dependency. ftp.pcre.org seems to be down and the the copy on mirror.bazel.build no longer seems to be present.

Is there a more reliable or stable URL for pcre-8.44?

this seems unrelated to cargo-raze but maybe this would help: https://github.com/bazelbuild/rules_foreign_cc/blob/0.6.0/examples/third_party/pcre/pcre_repositories.bzl

If you need 8.44 specifically I'd first try to open a PR there for that version and maintainers can go request it gets added to the mirror if it's not there.

@cfrantz
Copy link

cfrantz commented Nov 11, 2021

@UebelAndre The linked pcre_repositories.bzl file would appear to suffer from the same issue in this repo: it depends on ftp.pcre.org and mirror.bazel.build. I don't have any visibility into mirror.bazel.build, but I imagine that it used to host pcre-8.44 and the file expired some time after ftp.pcre.org went down and its only a matter of time until pcre-8.43 expires (just conjecture on my part).

I did find a rather complete historical mirror of pcre on https://ftp.exim.org/pub/pcre/. I can't vouch for its reliability.

I also found that the openresty project apparently also suffered this problem. They changed their (non-bazel) build scripts to download pcre from sourceforge.

@cfrantz
Copy link

cfrantz commented Nov 11, 2021

Next problem: after resolving the pcre dependency in my local sandbox, I'm getting a failure compiling libgit2:

/home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/2/execroot/cargo_raze/external/cargo_raze__libgit2/src/transports/ssh.c:11:10: fatal error: libssh2.h: No such file or directory
   11 | #include <libssh2.h>
      |          ^~~~~~~~~~~
compilation terminated.

At first, I though this was caused by the use of $(execpath ...) in a dict passed to cache_entries, which appears to not be subject to bazel's "make variable" expansion (you can see that EMBED_SSH_PATH gets assigned an empty value):

++ execpath @cargo_raze__libssh2//:libssh2
bazel-out/k8-fastbuild/bin/external/cargo_raze__libgit2/libgit2_foreign_cc/build_script.sh: line 161: execpath: command not found
+ /home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/8/execroot/cargo_raze/external/cmake-3.21.2-linux-x86_64/bin/cmake -DBUILD_CLAR=off -DBUILD_EXAMPLES=off -DBUILD_FUZZERS=off -DBUILD_SHARED_LIBS=off -DEMBED_SSH_PATH= -DUSE_HTTPS=on -DREGEX_BACKEND=pcre -DCMAKE_TOOLCHAIN_FILE=crosstool_bazel.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/8/execroot/cargo_raze/bazel-out/k8-fastbuild/bin/external/cargo_raze__libgit2/libgit2 '-DCMAKE_PREFIX_PATH=/home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/8/execroot/cargo_raze/bazel-out/k8-fastbuild/bin/external/cargo_raze__libgit2/libgit2.ext_build_deps;external/cargo_raze__zlib/zlib/include;bazel-out/k8-fastbuild/bin/external/cargo_raze__zlib/zlib/include;/home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/8/execroot/cargo_raze/bazel-out/k8-fastbuild/bin/external/cargo_raze__libgit2/libgit2.ext_build_deps/pcre;/home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/8/execroot/cargo_raze/bazel-out/k8-fastbuild/bin/external/cargo_raze__libgit2/libgit2.ext_build_deps/openssl;/home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/8/execroot/cargo_raze/bazel-out/k8-fastbuild/bin/external/cargo_raze__libgit2/libgit2.ext_build_deps/libssh2;/home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/8/execroot/cargo_raze/bazel-out/k8-fastbuild/bin/external/cargo_raze__libgit2/libgit2.ext_build_deps/zlib' -DCMAKE_RANLIB= -DCMAKE_MAKE_PROGRAM=/home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/8/execroot/cargo_raze/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make/bin/make -G 'Unix Makefiles' /home/cfrantz/.cache/bazel/_bazel_cfrantz/46ab4e084a8cc38b5692291265c54fb0/sandbox/linux-sandbox/8/execroot/cargo_raze/external/cargo_raze__libgit2

However, after playing around with this for a bit and attempting a bunch of different ways to assign a value to EMBED_SSH_PATH (ie: I used $EXT_BUILD_DEPS/libssh2 which seemed to expand to a valid path with include, lib and share dirs), I'm not really sure whether that is problem or not.

@DhashS
Copy link

DhashS commented Nov 12, 2021

I did this to fix it.

http_archive(
    name = "cargo_raze",
    patch_args = [
        "-p1",
    ],
    patches = ["//tools:0001-patch-pcre-to-use-additional-URL.patch"],
    sha256 = "e04a1982ce4f81ffe42066256cfcfc03732e4f1d646fd3253bcf3eabf45f45be",
    strip_prefix = "cargo-raze-0.13.0",
    url = "https://github.com/google/cargo-raze/archive/refs/tags/v0.13.0.tar.gz",
)
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: dhash <[email protected]>
Date: Fri, 12 Nov 2021 12:22:11 -0800
Subject: patch pcre to use additional URL


diff --git a/third_party/pcre/pcre_repositories.bzl b/third_party/pcre/pcre_repositories.bzl
index 6aaf32b9..7d1a2d58 100644
--- a/third_party/pcre/pcre_repositories.bzl
+++ b/third_party/pcre/pcre_repositories.bzl
@@ -13,5 +13,6 @@ def pcre_repositories():
         urls = [
             "https://mirror.bazel.build/ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz",
             "https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz",
+            "https://downloads.sourceforge.net/project/pcre/pcre/8.44/pcre-8.44.tar.gz"
         ],
     )
-- 
2.27.0

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

No branches or pull requests

7 participants