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

git_repository target doesn't build, but build's on its own when local. #8811

Closed
mikewiacek opened this issue Jul 7, 2019 · 6 comments
Closed
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: bug

Comments

@mikewiacek
Copy link

mikewiacek commented Jul 7, 2019

Description of the problem / feature request:

https://github.com/VirusTotal/yara includes a WORKSPACE and bazel BUILD files. If you clone this repository, I can successfully bazel build :all without issue. However if another workspace references this repository via git_repository, it will not build successfully.

Included here is a complete walk through to reproduce...

[mike@filer 16:29:16 ~]$ bazel info release
Starting local Bazel server and connecting to it...
release 0.25.3

[mike@filer 16:33:32 ~]$ git clone https://github.com/VirusTotal/yara.git
Cloning into 'yara'...
remote: Enumerating objects: 14681, done.
remote: Total 14681 (delta 0), reused 0 (delta 0), pack-reused 14681
Receiving objects: 100% (14681/14681), 17.98 MiB | 6.80 MiB/s, done.
Resolving deltas: 100% (10568/10568), done.
Checking out files: 100% (268/268), done.
[mike@filer 16:33:49 ~]$ cd yara

[mike@filer 16:34:09 ~/yara]$ bazel build :libyara
INFO: Analyzed target //:libyara (11 packages loaded, 613 targets configured).
INFO: Found 1 target...
Target //:libyara up-to-date:
  bazel-bin/liblibyara.a
  bazel-bin/liblibyara.so
INFO: Elapsed time: 6.241s, Critical Path: 1.81s
INFO: 301 processes: 301 linux-sandbox.
INFO: Build completed successfully, 304 total actions
[mike@filer 16:34:18 ~/yara]$

All looks good? Now let's try this as a remote git repository in a clean workspace.

[mike@filer 16:35:21 ~]$ mkdir new_workspace
[mike@filer 16:35:43 ~/new_workspace]$ vi WORKSPACE

WORKSPACE contains the following...

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
    name = "boringssl",
    commit = "863837047be74b20f59369b5256c39ad00f015b3",
    remote = "https://boringssl.googlesource.com/boringssl",
)

git_repository(
    name = "yara_ext",
    commit = "305ba7afa48d3fced5dfd324789d5c795bcc47b2",
    remote = "https://github.com/VirusTotal/yara",
)
[mike@filer 16:39:08 ~/new_workspace]$ bazel build @yara_ext//:all
INFO: Analyzed 5 targets (0 packages loaded, 0 targets configured).
INFO: Found 5 targets...
ERROR: /tmp/bazel_out_mike/d40b1fcf1140a86564738a571d7f7f49/external/yara_ext/BUILD.bazel:108:1: C++ compilation of rule '@yara_ext//:libyara' failed (Exit 1) gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -MD -MF ... (remaining 61 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
In file included from hex_lexer.l:56:0:
external/yara_ext/libyara/include/yara/hex_lexer.h:79:10: fatal error: hex_grammar.h: No such file or directory
 #include <hex_grammar.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
INFO: Elapsed time: 0.667s, Critical Path: 0.23s
INFO: 19 processes: 19 linux-sandbox.
FAILED: Build did NOT complete successfully
@mikewiacek
Copy link
Author

This might be a bug with the build rules in yara, it looks like the cc_library target for yara needs some extract includes = [...] paths set.

I'll leave this bug open though, just in case there is something weird with bazel here as it's unclear if it should have compiled at all in the first place.

@aiuto aiuto added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. untriaged labels Jul 8, 2019
@laurentlb laurentlb added team-Rules-CPP Issues for C++ rules and removed team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. labels Jul 26, 2019
@laurentlb
Copy link
Contributor

I'm surprised that it doesn't find hex_grammar.h. It might be an issue with cc_ rules, but I haven't investigated.

@scentini
Copy link
Contributor

This is a known issue with the cc_rules, we're working on it.
The reason why this happens is because currently there is no other way to specify nontransitive include paths in a cc_library except through the copts attribute.

The libryara actually passes the include directive for the private headers here.
However, when building it as an external repository, the headers end up in a slightly different location, thus the "-Ilibyara" doesn't work, see #4463.

This will be fixed as part of #6790.

@scentini scentini added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Jul 31, 2019
@scentini scentini self-assigned this Jul 31, 2019
@meisterT
Copy link
Member

This is still an issue with current Bazel.

@oquenchil oquenchil added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) type: bug and removed P2 We'll consider working on this in future. (Assignee optional) labels Nov 19, 2020
@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Apr 12, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: bug
Projects
None yet
Development

No branches or pull requests

6 participants