bazelbuild / bazel Goto Github PK
View Code? Open in Web Editor NEWa fast, scalable, multi-language and extensible build system
Home Page: https://bazel.build
License: Apache License 2.0
a fast, scalable, multi-language and extensible build system
Home Page: https://bazel.build
License: Apache License 2.0
This code in compile.sh:
JAVAC_VERSION=$($JAVAC -version 2>&1)
[[ "$JAVAC_VERSION" =~ ^"javac 1"\.([89]|[1-9][0-9]).*$ ]] \
|| fail "JDK version is lower than 1.8, please set \$JAVA_HOME."
fails when the output of javac -version
is
$ javac -version
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=utf8
javac 1.8.0_31
This scenario happens when the users env has JAVA_TOOLS_VERSION set to "-Dfile.encoding=utf8". Unfortunately, the "Picked up" line gets outputted to stderr just like the javac section.
Removing the leading ^ in the regexp fixes the issue. A fix that preserves that javac must be first in any line might be to use grep plus some <()
magic.
I tried to get bazel running on Suse SLES 11.3.
I did the following steps (roughly):
zypper addrepo http://download.opensuse.org/repositories/Archiving/SLE_11_SP3/Archiving.repo
zypper refresh
zypper install libarchive
zypper install libarchive-devel
zypper addrepo http://download.opensuse.org/repositories/Java:Factory/SLE_11_SP3/Java:Factory.repo
zypper refresh
zypper install java-1_8_0-openjdk
zypper install java-1_8_0-openjdk-devel
export JAVA_HOME=/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/
./compile.sh
fails
~/bazel>./compile.sh
Compiling Java stubs for protocol buffers...
third_party/protobuf/protoc.amd64: /lib64/libc.so.6: version GLIBC_2.15' not found (required by third_party/protobuf/protoc.amd64) third_party/protobuf/protoc.amd64: /lib64/libc.so.6: version
GLIBC_2.14' not found (required by third_party/protobuf/protoc.amd64)
SLES 11.3 comes with glibc 2.11 ( I updated it)
~/bazel>zypper info glibc
Loading repository data...
Reading installed packages...
Information for package glibc:
Repository: sp3-updates
Name: glibc
Version: 2.11.3-17.82.11
Arch: x86_64
Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
Support Level: Level 3
Installed: Yes
Status: up-to-date
Installed Size: 5.3 MiB
Summary: Standard Shared Libraries (from the GNU C Library)
Description:
The GNU C Library provides the most important standard libraries used
by nearly all programs: the standard C library, the standard math
library, and the POSIX thread library. A system is not functional
without these libraries.
I doubt glibc can be updated, so it would be good if bazel could work with this version of glibc.
I tried to compile a Java project with about 20000 java source code files. When I ran it for the first time it would take quite some time without using much cpu time, I would also get "slow read" messages.
I did a thread dump (see at the end) and apparently there is a global lock in com.google.devtools.build.lib.actions.cache.DigestUtils.getDigestOrFail and 199 threads are waiting on that lock/
do a
grep 0x00000000c02f6570 /tmp/bazel.log
I think the number of threads is a bit high, I don't think it would go any faster especially since the lock is really global.
the thread dump is here:
https://github.com/kohlerm/bazel/blob/issues/global_lock.log
The Build Encyclopedia documentation for objc_proto_library
references proto_library
, which does not seem to have been open sourced yet.
On the same note, objc_proto_library
seems to be the only available rule for building proto libraries. What is the plan for proto_library
rules for other languages?
I'm running Mac OS X 10.10.3. It looks like libtool complains when trying to build header only libraries. Adding an empty cc file to the build rule fixes this, however a warning will be output and it does not feel very clean to have empty cc files littered all over the place.
Sample build rule and output below:
cc_library(
name = "header-only",
hdrs = ["hello-lib.h"],
)
$ output/bazel build examples/cpp:header-only
INFO: Found 1 target...
INFO: From Linking examples/cpp/libheader-only.a:
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: no files specified
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols]
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]
ERROR: /Users/trevorgray/src/github.com/google/bazel/examples/cpp/BUILD:9:1: Linking of rule '//examples/cpp:header-only' failed: libtool failed: error executing command /usr/bin/libtool -static -s -o bazel-out/local_darwin-fastbuild/bin/examples/cpp/libheader-only.a: com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //examples/cpp:header-only failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.232s, Critical Path: 1.10s
$ ./output/bazel info execution_root
/private/var/tmp/_blaze_alexeagle/048dc339e919adf019cd498aa08795ff/bazel
cc_*
rules such as cc_library
and cc_binary
will build pure C binaries if the file extensions of the source files are .c
rather than one of the standard C++ file extensions. While these build rules are listed under "C/C++" in the Build Encyclopedia, it would be helpful to add a note to clarify that these rules will do the right thing when compiling only C code.
It may also be good to provide macros such as c_library
and c_binary
and a CROSSTOOL config for C that set the correct flags for building C binaries.
Allow Bazel to automatically push compiled jars into Maven.
Compiled bazel from source using ./compile.sh
-- resulting binary segfaults moments after starting.
Ubuntu 12.04.5 LTS
java-8-oracle (from the PPA suggested here: http://bazel.io/docs/install.html)
libc6 2.15-0ubuntu10.11
To reproduce:
$ git clone https://github.com/google/bazel
$ cd bazel
$ ./compile.sh
Compiling Java stubs for protocol buffers...
Compiling Bazel Java code...
Extracting helper classes for Bazel Java...
Creating libblaze.jar...
Compiling SingleJar tool code...
Extracting helper classes for SingleJar tool...
Creating SingleJar_deploy.jar...
Compiling JavaBuilder tool code...
Extracting helper classes for JavaBuilder tool...
Creating JavaBuilder_deploy.jar...
Compiling client .cc files...
Linking client...
Compiling ijar .cc files...
Linking ijar...
Compiling JNI libraries...
Linking libunix.so...
Compiling build-runfiles...
Compiling process-wrapper...
Compiling sandbox...
Creating Bazel self-extracting archive...
Creating objc helper tools...
Compiling actoolzip code...
Extracting helper classes for actoolzip...
Creating precomp_actoolzip_deploy.jar...
Compiling ibtoolzip code...
Extracting helper classes for ibtoolzip...
Creating precomp_ibtoolzip_deploy.jar...
Compiling momczip code...
Extracting helper classes for momczip...
Creating precomp_momczip_deploy.jar...
Compiling bundlemerge code...
Extracting helper classes for bundlemerge...
Creating precomp_bundlemerge_deploy.jar...
Compiling plmerge code...
Extracting helper classes for plmerge...
Creating precomp_plmerge_deploy.jar...
Compiling xcodegen code...
Extracting helper classes for xcodegen...
Creating precomp_xcodegen_deploy.jar...
Build successful! Binary is here: (...)/bazel/output/bazel
$ ./output/bazel
Extracting Bazel installation...
Segmentation fault (core dumped)
Inspecting the core:
$gdb ./output/bazel core
...
warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fffe23fe000
Core was generated by `./output/bazel'.
Program terminated with signal 11, Segmentation fault.
(gdb) thread apply all where
Thread 1 (Thread 0x7f51dc60f740 (LWP 26482)):
#0 0x00007f51db7f7ec5 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f51dc1bb842 in std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007f51dc1bbf5c in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x0000000000404d86 in blaze::BlazeStartupOptions::GetJvm (this=0x1383100)
at src/main/cpp/blaze_startup_options.cc:136
#4 0x000000000040f017 in blaze::VerifyJavaVersionAndGetJvm () at src/main/cpp/blaze.cc:443
#5 0x000000000040f434 in blaze::StartServer (socket=6) at src/main/cpp/blaze.cc:489
#6 0x000000000040fd47 in blaze::ConnectToServer (start=true) at src/main/cpp/blaze.cc:637
#7 0x0000000000411f87 in blaze::SendServerRequest () at src/main/cpp/blaze.cc:1150
#8 0x00000000004140be in blaze::main (argc=1, argv=0x7fffe22c7298) at src/main/cpp/blaze.cc:1687
#9 0x000000000041416b in main (argc=1, argv=0x7fffe22c7298) at src/main/cpp/blaze.cc:1694
We should add an entry to github/linguist for BUILD/Skylark so that GitHub can 1) add proper syntax highlighting for displaying BUILD and .bzl files and 2) include them in the language stats for repositories.
It might also be good to add an entry for ASCII protos/CROSSTOOL as well. There is a Linguist entry for Protocol Buffer message definitions but not for ASCII protos.
Bazel currently supports this in Java via the java_import rule but C++ appears to be lacking this kind of feature [1]. Please consider extending the default Bazel build rules to allow C++ builds to integrate third party libraries that consist of header files and precompiled library binaries.
The following links from the page http://bazel.io/docs/FAQ.html all 404:
https://github.com/google/bazel/blob/master/base_workspace/examples/cpp/BUILD
https://github.com/google/bazel/blob/master/base_workspace/tools/build_rules/py_rules.bzl
https://github.com/google/bazel/tree/master/base_workspace/examples/py
Just tried
https://bazel.io/docs/getting-started.html and
http://bazel.io/docs/getting-started.html.
I couldn't open https one.
suppose you want to link against the system jni headers on a Mac that might be a WORKSPACE entry of:
new_local_repository(
name = "jni-local",
build_file = "BUILD.extjni",
path = "/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/include",
)
bind(
name = "jni",
actual = "@jni-local//:headers",
)
---
BUILD.extjni of:
genrule(
name = "empty",
outs = ["empty.cc"],
cmd = "echo -n 'void external_jdk_empty(){}' > $@",
)
cc_library(
name = "headers",
srcs = [":empty"],
hdrs = glob(["**/*.h"]),
includes = [
".",
"darwin",
],
visibility = ["//visibility:public"],
)
When you try and compile a file which has #include <jni.h>
:
ERROR: jni/BUILD:10:1: undeclared inclusion(s) in rule '//jni:libreverse.so':
this rule is missing dependency declarations for the following files included by 'jni/Reverse.cpp':
'/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/include/jni.h'
'/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/include/darwin/jni_md.h'.
Compiling with the java example with SAP JVM (a closed source fork of the Oracle VM) does not work because the SAP JVM does not support the -client option.
replacing the -client option with -server in
src/main/java/com/google/devtools/build/lib/rules/java/JavaConfigurationLoader.java
works around this problem.
Probably -client should not be a baked in default option.
The error message is misleading. It mentions that the --verbose option should be used but that does not seem to exist.
There is also no hint that it fails because of -client option missing. E.g. I only saw when using strace.
While Skylark is a Python subset, there are slight differences between Skylark/BUILD style vs. the Google Python conventions. For example (from the Skylark cookbook:
def macro(name, visibility=None):
# Creating a native genrule.
native.genrule(
name = name,
outs = [name + '.txt'],
cmd = 'echo hello > $@',
visibility = visibility,
)
Rule invocations such as native.genrule()
follow the BUILD style rather than the standard Python function call style.
I think it would be good to write a Skylark Style Guide that defines a convention for Skylark code and lists some best practices.
TLDR - "sudo apt-get install openjdk-8-source" fixes it.
EDIT: Should've waited for the whole test, but this one is not so critical: "bc" also needs to be installed for the sh_tests to pass (so one more "apt-get install bc")
Here is the full story (without the "bc" failure):
(utopic)malkia@localhost:~/p/google/bazel$ ./bootstrap_test.sh test
*** bootstrap ***
INFO: Starting clean (this may take a while). Consider using --expunge_async if the clean takes more than several minutes.
ERROR: /home/malkia/p/google/bazel/tools/jdk/BUILD:50:1: error loading package 'external': Could not access /home/malkia/.cache/bazel/_bazel_malkia/25bda5d738c2f595d569ca82f756ade7/.external-repository/local-jdk/src.zip: /usr/lib/jvm/openjdk-8 (No such file or directory) and referenced by '//tools/jdk:jdk'.
ERROR: Loading failed; build aborted.
INFO: Elapsed time: 0.609s
Bootstrap failed
(utopic)malkia@localhost:/p/google/bazel$ ls -l /home/malkia/.cache/bazel/_bazel_malkia/25bda5d738c2f595d569ca82f756ade7/.external-repository/local-jdk/src.zip/p/google/bazel$ ls -l /usr/lib/jvm/java-8-openjdk-amd64/src.zip
lrwxrwxrwx 1 malkia malkia 41 Mar 27 00:36 /home/malkia/.cache/bazel/_bazel_malkia/25bda5d738c2f595d569ca82f756ade7/.external-repository/local-jdk/src.zip -> /usr/lib/jvm/java-8-openjdk-amd64/src.zip
(utopic)malkia@localhost:
lrwxrwxrwx 1 root root 20 Mar 17 19:18 /usr/lib/jvm/java-8-openjdk-amd64/src.zip -> ../openjdk-8/src.zip
(utopic)malkia@localhost:/p/google/bazel$ ls -l /usr/lib/jvm/openjdk-8/p/google/bazel$ sudo apt-get install openjdk-8-source
ls: cannot access /usr/lib/jvm/openjdk-8: No such file or directory
(utopic)malkia@localhost:
[sudo] password for malkia:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
openjdk-8-source
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 46.0 MB of archives.
After this operation, 51.8 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ vivid/universe openjdk-8-source all 8u40-b27-1 [46.0 MB]
Fetched 46.0 MB in 16s (2783 kB/s)
Selecting previously unselected package openjdk-8-source.
(Reading database ... 98820 files and directories currently installed.)
Preparing to unpack .../openjdk-8-source_8u40-b27-1_all.deb ...
Unpacking openjdk-8-source (8u40-b27-1) ...
Setting up openjdk-8-source (8u40-b27-1) ...
(utopic)malkia@localhost:~/p/google/bazel$ ./bootstrap_test.sh test
*** bootstrap ***
INFO: Starting clean (this may take a while). Consider using --expunge_async if the clean takes more than several minutes.
INFO: Found 2 targets...
INFO: From Building src/main/java/libbazel-core.jar (1171 files):
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
INFO: Elapsed time: 97.663s, Critical Path: 92.35s
==> bootstrap passed
Extracting Bazel installation...
Sending SIGTERM to previous Bazel server (pid=6798)... done.
.............
*** test ***
INFO: Found 69 targets and 19 test targets...
[213 / 323] Still waiting for 54 jobs to complete:
Running (standalone):
action 'CompileProtos src/main/protobuf/libproto_build.jar', 10 s
action 'CompileProtos src/main/protobuf/libproto_bundlemerge.jar', 10 s
action 'CompileProtos src/main/protobuf/libproto_crosstool_config.jar', 10 s
action 'CompileProtos src/main/protobuf/libproto_test_status.jar', 10 s
Scheduling:
action 'CompileProtos src/main/protobuf/libproto_xcodegen.jar', 12 s
action 'CompileProtos src/main/protobuf/libproto_extra_actions_base.jar', 12 s
Executing genrule //examples/gen:genrule, 12 s
Building src/java_tools/buildjar/libjava-langtools-location-lib.jar (1 files), 11 s
Building src/java_tools/buildjar/libjavac-bootclasspath-locations-lib.jar (1 files), 11 s
Extracting interface //third_party:truth, 11 s
Linking src/main/cpp/libmd5.so, 11 s
Building src/main/java/libjava-toolchain-parser.jar (11 files), 11 s
Linking src/main/cpp/libutil.so, 11 s
... 41 more jobs
The CROSSTOOL toolchain config for darwin
has a cxx_builtin_include_directory
for /opt/local/include
but is missing an entry for /usr/local/include
.
Would be awesome if the docs had an example for a complete App with a Java backend (say),
to showcase Bazel's ability to build everything a developer needs.
Maybe cause of some wrong ssl files configuration. But this is causing issue in resolution of links in readme.
On the pages :
when building the example projects it is stated that the following commands should be used :
$ bazel build examples/java:hello-world
respectively
$ $HOME/bazel/output/bazel build //examples/java-native/src/main/java/com/example/myproject:hello-world
but actually the command should look like this :
$ bazel build examples/java-native/src/main/java/com/example/myproject:hello-world
When going through the example in the documentation, I am getting the following error while running bazel build
:
$ bazel build my-project:my-runner --verbose_failuresExtracting Bazel installation...
......
INFO: Found 1 target...
ERROR: /home/rbvermaa/src/bazel/base_workspace/my-project/BUILD:1:1: Creating runfiles tree bazel-out/local_linux-fastbuild/bin/my-project/my-runner.runfiles failed: build-runfiles failed: error executing command
(cd /home/rbvermaa/.cache/bazel/_blaze_rbvermaa/ce51c282b5b9dadfc520c685445c68ce/base_workspace && \
exec env - \
/home/rbvermaa/.cache/bazel/_blaze_rbvermaa/ce51c282b5b9dadfc520c685445c68ce/base_workspace/_bin/build-runfiles bazel-out/local_linux-fastbuild/bin/my-project/my-runner.runfiles_manifest bazel-out/local_linux-fastbuild/bin/my-project/my-runner.runfiles): com.google.devtools.build.lib.shell.ExecFailedException: java.io.IOException: Cannot run program "/home/rbvermaa/.cache/bazel/_blaze_rbvermaa/ce51c282b5b9dadfc520c685445c68ce/base_workspace/_bin/process-wrapper" (in directory "/home/rbvermaa/.cache/bazel/_blaze_rbvermaa/ce51c282b5b9dadfc520c685445c68ce/base_workspace"): error=13, Permission denied: build-runfiles failed: error executing command
(cd /home/rbvermaa/.cache/bazel/_blaze_rbvermaa/ce51c282b5b9dadfc520c685445c68ce/base_workspace && \
exec env - \
/home/rbvermaa/.cache/bazel/_blaze_rbvermaa/ce51c282b5b9dadfc520c685445c68ce/base_workspace/_bin/build-runfiles bazel-out/local_linux-fastbuild/bin/my-project/my-runner.runfiles_manifest bazel-out/local_linux-fastbuild/bin/my-project/my-runner.runfiles): com.google.devtools.build.lib.shell.ExecFailedException: java.io.IOException: Cannot run program "/home/rbvermaa/.cache/bazel/_blaze_rbvermaa/ce51c282b5b9dadfc520c685445c68ce/base_workspace/_bin/process-wrapper" (in directory "/home/rbvermaa/.cache/bazel/_blaze_rbvermaa/ce51c282b5b9dadfc520c685445c68ce/base_workspace"): error=13, Permission denied.
Target //my-project:my-runner failed to build
INFO: Elapsed time: 1.994s, Critical Path: 0.51s
Looking at the files that bazel is failing on, they seem to lack the executable flag, while in the installation prefix of bazel, they are actually executable.
$ ll /home/rbvermaa/.cache/bazel/_blaze_rbvermaa/install/c319309e20c3f37a277f6e599681275a/_embedded_binaries/
total 13488
-rw-r--r-- 1 rbvermaa users 109 Mar 22 2025 build_interface_so
-rw-r--r-- 1 rbvermaa users 64181 Mar 22 2025 build-runfiles
-rw-r--r-- 1 rbvermaa users 0 Mar 22 2025 client_info
-rw-r--r-- 1 rbvermaa users 33 Mar 22 2025 install_base_key
-rw-r--r-- 1 rbvermaa users 4 Mar 22 2025 java.version
-rw-r--r-- 1 rbvermaa users 801 Mar 22 2025 jdk.BUILD
-rw-r--r-- 1 rbvermaa users 820 Mar 22 2025 jdk.WORKSPACE
-rw-r--r-- 1 rbvermaa users 13589089 Mar 22 2025 libblaze.jar
-rw-r--r-- 1 rbvermaa users 94557 Mar 22 2025 libunix.so
-rw-r--r-- 1 rbvermaa users 19486 Mar 22 2025 namespace-sandbox
-rw-r--r-- 1 rbvermaa users 14008 Mar 22 2025 process-wrapper
The bazel installation directory looks like:
$ ls -l /nix/store/wl19f5z591zrmrp66mbdjr1zi5z5kdr6-bazel-20150325.9a0dc1b2/share/bazel/
total 37712
dr-xr-xr-x 3 root nixbld 4096 Jan 1 1970 actoolzip
-r-xr-xr-x 1 root nixbld 12367529 Jan 1 1970 bazel
-r-xr-xr-x 1 root nixbld 167 Jan 1 1970 build_interface_so
dr-xr-xr-x 3 root nixbld 4096 Jan 1 1970 buildjar
-r-xr-xr-x 1 root nixbld 64181 Jan 1 1970 build-runfiles
dr-xr-xr-x 3 root nixbld 4096 Jan 1 1970 bundlemerge
dr-xr-xr-x 8 root nixbld 4096 Jan 1 1970 classes
-r-xr-xr-x 1 root nixbld 307789 Jan 1 1970 client
-r-xr-xr-x 1 root nixbld 0 Jan 1 1970 client_info
dr-xr-xr-x 3 root nixbld 4096 Jan 1 1970 ibtoolzip
dr-xr-xr-x 2 root nixbld 4096 Jan 1 1970 ijar
-r--r--r-- 1 root nixbld 33 Jan 1 1970 install_base_key
-r--r--r-- 1 root nixbld 4 Jan 1 1970 java.version
-r--r--r-- 1 root nixbld 801 Jan 1 1970 jdk.BUILD
-r--r--r-- 1 root nixbld 820 Jan 1 1970 jdk.WORKSPACE
-r--r--r-- 1 root nixbld 13589089 Jan 1 1970 libblaze.jar
-r-xr-xr-x 1 root nixbld 94557 Jan 1 1970 libunix.so
-r--r--r-- 1 root nixbld 58 Jan 1 1970 MANIFEST.MF
dr-xr-xr-x 3 root nixbld 4096 Jan 1 1970 momczip
-r-xr-xr-x 1 root nixbld 19486 Jan 1 1970 namespace-sandbox
dr-xr-xr-x 2 root nixbld 4096 Jan 1 1970 native
dr-xr-xr-x 2 root nixbld 4096 Jan 1 1970 objs
-r--r--r-- 1 root nixbld 12059740 Jan 1 1970 package.zip
dr-xr-xr-x 3 root nixbld 4096 Jan 1 1970 plmerge
-r-xr-xr-x 1 root nixbld 14008 Jan 1 1970 process-wrapper
dr-xr-xr-x 3 root nixbld 4096 Jan 1 1970 singlejar
dr-xr-xr-x 3 root nixbld 4096 Jan 1 1970 src
dr-xr-xr-x 2 root nixbld 4096 Jan 1 1970 test_classes
dr-xr-xr-x 3 root nixbld 4096 Jan 1 1970 xcodegen
One thing that might be different in my setup is the fact that the installation of bazel is readonly, perhaps that is related?
I'm using Ubuntu Vivid Vervet under croutonized chromebook, and found that one dependency (zip) is missing, which this command below fixes:
sudo apt-get install zip
(It might be that under normal ubuntu install it's always present)
I'm hoping the Eclipse support can be open sourced :-) All the open-source build tools I currently use like Maven, Gradle, and SBT have Eclipse support built-in.
Both links referencing examples return 404s.
make the following:
cc_library(name="A", ...)
cc_library(name="B", srcs=["b.cpp"], deps=[":A"], ...)
cc_binary(name="main", ..., deps=[":B"])
bazel build :main works just fine (it correctly puts libA.so and libB.so on the link line)
bazel build :A - same
but bazel build :B will fail with:
From Linking lib/libB.so:
Undefined symbols for architecture x86_64:
"...."
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: lib/BUILD:3:1: Linking of rule '//lib:lib' failed: gcc failed: error executing command /usr/bin/gcc -shared -o bazel-out/local_darwin-fastbuild/bin/lib/libB.so bazel-out/local_darwin-fastbuild/bin/lib/_objs/lib/lib/b.pic.o -lstdc++ -B/usr/bin -Wl,-S: com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
It appears that liba.so is missing from the command
Allow creating projects on Travis which use Bazel to build.
Right now, people landing on the GitHub repo can't know about the full website.
A emphasis on automated testing -> An emphasis on automated testing
"Find more background about Bazel in our FAQ" -- needs a period after FAQ.
"The test environment is described the test encyclopedia." -- described in the test encyclopedia?
We need a better installation process for Bazel. Distributing binaries would be nice. We should make packages for brew and ubuntu/debian, and a minimum, plus binary installers for Linux & OS X.
Did using port to install libarchive, but the compile.sh script failed at link step, complaining about the missing symbols of archive related methods for x86_64 arch.
Creating JavaBuilder_deploy.jar...
Compiling client .cc files...
Linking client...
Undefined symbols for architecture x86_64:
"_archive_entry_pathname", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
blaze::GetInstallBase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_entry_perm", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_errno", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
blaze::GetInstallBase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_error_string", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
blaze::GetInstallBase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_read_data", referenced from:
blaze::GetInstallBase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_read_data_block", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_read_free", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
blaze::GetInstallBase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_read_new", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
blaze::GetInstallBase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_read_next_header", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
blaze::GetInstallBase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_read_open_filename", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
blaze::GetInstallBase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
"_archive_read_support_format_zip", referenced from:
blaze::ActuallyExtractData(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
blaze::GetInstallBase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in blaze.cc.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Build systems such as Autotools and CMake have a mechanism to generate an install target that can be configured via install hooks or rules. It would be good to have a similar mechanism in Bazel.
This is what I get when trying to compile Bazel on my machine.
$ ./compile.sh
Compiling Java stubs for protocol buffers...
./compile.sh: line 355: third_party/protobuf/protoc.amd64: cannot execute binary file: Exec format error
My machine says:
$ uname -a
Linux cowfarm 3.13.0-34-generic #60-Ubuntu SMP Wed Aug 13 15:49:09 UTC 2014 i686 i686 i686 GNU/Linux
I'm guessing all the cool kids run AMD these days. :)
Creating JavaBuilder_deploy.jar...
Compiling client .cc files...
src/main/cpp/blaze.cc:66:10: fatal error: 'archive.h' file not found
Exposing some shell-completion magic such that one could...
bazel my/project/foo:
... then hit tab to get the list of targets at that package would be amazeballz.
The Getting Started guide has you copy base_workspace/
to create a workspace in which to place projects. The workspace contains symlinks into the bazel checkout for examples/
, third_party/
, tools/
.
This works well for a local project, but does not work if I wish to publish a project using Bazel, as the symlinks will almost certainly point to the wrong location. How are projects expected to handle this? I could not find it mentioned in any of the docs. The only obvious solution I see is to do a real copy of the tools/
directory into my project. However, that means that future Bazel changes will effectively need to be merged into my repository.
I mention tools/
specifically, because examples/
and third_party/
don't seem to be required, at least for a basic project, however tools/
is (Without tools/
, I get ERROR: Loading of target '//tools/cpp:toolchain' failed; build aborted: no such package 'tools/cpp': BUILD file not found on package path.
).
When I run with --help
:
/Users/mbolin/src/bazel$ ./output/bazel --help
WARNING: build volume / is nearly full (5235527 inodes remain).
WARNING: build volume / is nearly full (21.4GB remain).
[bazel development version]
Or the version
subcommand:
/Users/mbolin/src/bazel$ ./output/bazel version
WARNING: build volume / is nearly full (5235535 inodes remain).
WARNING: build volume / is nearly full (21.4GB remain).
Unrecognized option: --javabase=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
Bazel's first instinct is to tell me that I only have 21.4GB free. How much disk space do I have to free up to get Bazel to stop belittling my hard drive?
The entire crosstool format is probably too hairy, but we should definitely have examples how to configure embedded toolchains.
Case 1:
foopath/foo.cpp needs to include barpath/bar.h
How do I describe the dependency here?
Case 2:
What about second level header file inclusion? For example
foopath/foo.cpp needs to include barpath/bar.h, which includes bazpath/baz.h
Whether or not Bazel supports Eclipse or Intellij or other tools directly, there are a lot of useful hooks that would permit third-parties to write their own APIs. This especially includes:
That's all I can think of just now, but I wanted this tracking bug in place, more focused on the tooling api.
$ ./compile.sh
...
third_party/ijar/classfile.cc: In function 'devtools_ijar::ClassFile* devtools_ijar::ReadClass(const void*, size_t)':
third_party/ijar/classfile.cc:1393:35: error: expected ')' before 'PRIx32'
third_party/ijar/classfile.cc:1393:60: warning: spurious trailing '%' in format [-Wformat]
Using the following BUILD file:
cc_library(
name = "foo",
srcs = ["foo.cpp"],
hdrs = ["foo.h"],
)
cc_test(
name = "foo_test",
srcs = ["foo_test.cpp"],
deps = [":foo"],
)
where foo.h
is:
int foo(int x);
foo.cpp
is:
#include "foo.h"
int foo(int x) {
return x * x;
}
and foo_test.cpp
is:
#include "foo.h"
#include <iostream>
int main() {
std::cout << "Hello, World " << foo(3) << "\n";
return 0;
}
then bazel test --test_output=streamed :foo_test
produces the output:
WARNING: Streamed test output requested so all tests will be run locally, without sharding, one at a time.
INFO: Found 1 test target...
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
dyld: Library not loaded: bazel-out/local_darwin-fastbuild/bin/libfoo.so
Referenced from: /private/var/tmp/_blaze_beder/28185150b94b8129abda95172b3b0fc5/workspace/bazel-out/local_darwin-fastbuild/bin/foo_test.runfiles/./foo_test
Reason: image not found
tools/test/test-setup.sh: line 16: 1519 Trace/BPT trap: 5 "$@"
FAIL: //:foo_test (see /private/var/tmp/_blaze_beder/28185150b94b8129abda95172b3b0fc5/workspace/bazel-out/local_darwin-fastbuild/testlogs/foo_test/test.log).
Target //:foo_test up-to-date:
bazel-bin/foo_test
INFO: Elapsed time: 0.190s, Critical Path: 0.11s
//:foo_test FAILED
Executed 1 out of 1 tests: 1 fails locally.
If I run bazel build :foo_test
, then it builds correctly, and I can run ./bazel-bin/foo_test
, and it correctly produces the output Hello, World 9
.
I'm running OS X Yosemite, 10.10.2 (14C1514), with gcc --version
:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
clang --version
:
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
I'm synced to bazel's master branch, change 03bad46.
./compile.sh
WARNING: Could not find libarchive installation, proceeding bravely.
Compiling Java stubs for protocol buffers...
Compiling Bazel Java code...
Extracting helper classes for Bazel Java...
Creating libblaze.jar...
Compiling SingleJar tool code...
Extracting helper classes for SingleJar tool...
Creating SingleJar_deploy.jar...
Compiling JavaBuilder tool code...
Extracting helper classes for JavaBuilder tool...
Creating JavaBuilder_deploy.jar...
Compiling client .cc files...
src/main/cpp/blaze.cc:66:10: fatal error: 'archive.h' file not found
#include "archive.h"
^
1 error generated.
I've got the example compiled on Suse 12.3
I only had to install libarchive-devel:
zypper install libarchive-devel
Starting with a fresh checkout of bazel on ubuntu 14.10, I'm running into odd errors while trying to build any of the example targets:
┌─( benley@sunnyside )─( ~/fl/bazel )─( master + )
└─(0)─> $ ./compile.sh
Compiling Java stubs for protocol buffers...
Compiling Bazel Java code...
Extracting helper classes for Bazel Java...
Creating libblaze.jar...
Compiling SingleJar tool code...
Extracting helper classes for SingleJar tool...
Creating SingleJar_deploy.jar...
Compiling JavaBuilder tool code...
Extracting helper classes for JavaBuilder tool...
Creating JavaBuilder_deploy.jar...
Compiling client .cc files...
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
Linking client...
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
Compiling ijar .cc files...
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
Linking ijar...
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
Compiling JNI libraries...
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
Linking libunix.so...
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
Compiling build-runfiles...
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
Compiling process-wrapper...
Compiling sandbox...
Creating Bazel self-extracting archive...
Creating objc helper tools...
Compiling actoolzip code...
Extracting helper classes for actoolzip...
Creating precomp_actoolzip_deploy.jar...
Compiling ibtoolzip code...
Extracting helper classes for ibtoolzip...
Creating precomp_ibtoolzip_deploy.jar...
Compiling momczip code...
Extracting helper classes for momczip...
Creating precomp_momczip_deploy.jar...
Compiling bundlemerge code...
Extracting helper classes for bundlemerge...
Creating precomp_bundlemerge_deploy.jar...
Compiling plmerge code...
Extracting helper classes for plmerge...
Creating precomp_plmerge_deploy.jar...
Compiling xcodegen code...
Extracting helper classes for xcodegen...
Creating precomp_xcodegen_deploy.jar...
Build successful!
┌─( benley@sunnyside )─( ~/fl/bazel )─( master + )
└─(0)─> $ cd base_workspace
┌─( benley@sunnyside )─( ~/fl/bazel/base_workspace )─( master + )
└─(0)─> $ ../output/bazel build //examples/cpp:hello-world --verbose_failures
WARNING: build volume / is nearly full (11.5GB remain).
Extracting Bazel installation...
.....
INFO: Found 1 target...
ERROR: /home/benley/fl/bazel/base_workspace/examples/cpp/BUILD:3:1: C++ compilation of rule '//examples/cpp:hello-lib' failed: gcc failed: error executing command
(cd /home/benley/.cache/bazel/_blaze_benley/bdd2b581bf2e6753f7f2b0e653b181ef/base_workspace && \
exec env - \
INTERCEPT_LOCALLY_EXECUTABLE=1 \
/usr/bin/gcc -iquote . -iquote bazel-out/local_linux-fastbuild/genfiles -isystem tools/cpp/gcc3 '-std=c++0x' '-frandom-seed=bazel-out/local_linux-fastbuild/bin/examples/cpp/_objs/hello-lib/examples/cpp/hello-lib.pic.o' -MD -MF bazel-out/local_linux-fastbuild/bin/examples/cpp/_objs/hello-lib/examples/cpp/hello-lib.pic.d -fPIC -c examples/cpp/hello-lib.cc -o bazel-out/local_linux-fastbuild/bin/examples/cpp/_objs/hello-lib/examples/cpp/hello-lib.pic.o): com.google.devtools.build.lib.shell.ExecFailedException: java.io.IOException: Cannot run program "/home/benley/.cache/bazel/_blaze_benley/bdd2b581bf2e6753f7f2b0e653b181ef/base_workspace/_bin/process-wrapper" (in directory "/home/benley/.cache/bazel/_blaze_benley/bdd2b581bf2e6753f7f2b0e653b181ef/base_workspace"): error=13, Permission denied: gcc failed: error executing command
(cd /home/benley/.cache/bazel/_blaze_benley/bdd2b581bf2e6753f7f2b0e653b181ef/base_workspace && \
exec env - \
INTERCEPT_LOCALLY_EXECUTABLE=1 \
/usr/bin/gcc -iquote . -iquote bazel-out/local_linux-fastbuild/genfiles -isystem tools/cpp/gcc3 '-std=c++0x' '-frandom-seed=bazel-out/local_linux-fastbuild/bin/examples/cpp/_objs/hello-lib/examples/cpp/hello-lib.pic.o' -MD -MF bazel-out/local_linux-fastbuild/bin/examples/cpp/_objs/hello-lib/examples/cpp/hello-lib.pic.d -fPIC -c examples/cpp/hello-lib.cc -o bazel-out/local_linux-fastbuild/bin/examples/cpp/_objs/hello-lib/examples/cpp/hello-lib.pic.o): com.google.devtools.build.lib.shell.ExecFailedException: java.io.IOException: Cannot run program "/home/benley/.cache/bazel/_blaze_benley/bdd2b581bf2e6753f7f2b0e653b181ef/base_workspace/_bin/process-wrapper" (in directory "/home/benley/.cache/bazel/_blaze_benley/bdd2b581bf2e6753f7f2b0e653b181ef/base_workspace"): error=13, Permission denied.
Target //examples/cpp:hello-world failed to build
INFO: Elapsed time: 1.018s, Critical Path: 0.07s
All the symlink targets in that base_workspace/_bin/ directory are indeed non-executable:
┌─( benley@sunnyside )─( ~/fl/bazel/base_workspace )─( master + )
└─(0)─> $ ls -l ~/.cache/bazel/_blaze_benley/install/01ecdad01ce03d4a0dc45e9f98eb8250/_embedded_binaries/
total 13496
-rw-r--r-- 1 benley benley 109 Mar 21 2025 build_interface_so
-rw-r--r-- 1 benley benley 64165 Mar 21 2025 build-runfiles
-rw-r--r-- 1 benley benley 0 Mar 21 2025 client_info
-rw-r--r-- 1 benley benley 33 Mar 21 2025 install_base_key
-rw-r--r-- 1 benley benley 4 Mar 21 2025 java.version
-rw-r--r-- 1 benley benley 801 Mar 21 2025 jdk.BUILD
-rw-r--r-- 1 benley benley 820 Mar 21 2025 jdk.WORKSPACE
-rw-r--r-- 1 benley benley 13595952 Mar 21 2025 libblaze.jar
-rw-r--r-- 1 benley benley 94541 Mar 21 2025 libunix.so
-rw-r--r-- 1 benley benley 19502 Mar 21 2025 namespace-sandbox
-rw-r--r-- 1 benley benley 14008 Mar 21 2025 process-wrapper
I'd love to see Bazel support Scala. I thought it'd be helpful to have an item here where those interested can track the issue and discuss, but feel free to close if this isn't the appropriate venue for such a suggestion.
We'd probably want to use zinc to handle compilation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.