make build_envoy
#BUILD_WITH_CONTAINER=1 make build_envoy
#dry run
make -n build
#log
make V=1 build
make build BAZEL_STARTUP_ARGS='' BAZEL_BUILD_ARGS='-s --explain=explain.txt --config=debug' BAZEL_TARGETS='//src/envoy:envoy'
make build BAZEL_STARTUP_ARGS='' BAZEL_BUILD_ARGS='-s --explain=explain.txt --config=debug --sandbox_debug' BAZEL_TARGETS='//src/envoy:envoy'
make build BAZEL_STARTUP_ARGS='' BAZEL_BUILD_ARGS='-s --explain=explain.txt --config=debug --cxxopt="-fno-stack-protector" --copt="-fno-stack-protector"' BAZEL_TARGETS='//src/envoy:envoy' 2>&1 | tee bazel-log.log
Makefile.core.mk
build_envoy:
export PATH=$(PATH) CC=$(CC) CXX=$(CXX) && \
bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) $(BAZEL_CONFIG_REL) @com_googlesource_chromium_v8//:build && \
bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) $(BAZEL_CONFIG_REL) //src/envoy:envoy
bazel info //src/envoy:envoy
bazel build //src/envoy:envoy
bazel query 'deps(//src/envoy:envoy)'
bazel query --notool_deps --noimplicit_deps 'deps(//src/envoy:envoy)' --output graph
show_args#
show_args:
/bin/echo \
export PATH=$(PATH) CC=$(CC) CXX=$(CXX) \
bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) $(BAZEL_CONFIG_REL) @com_googlesource_chromium_v8//:build \
bazel $(BAZEL_STARTUP_ARGS) build $(BAZEL_BUILD_ARGS) $(BAZEL_CONFIG_REL) //src/envoy:envoy
make show_args
export PATH=/usr/lib/llvm-10/bin:/root/.vscode-server/bin/6cba118ac49a1b88332f312a8f67186f7f3c1643/bin:/root/.vscode-server/bin/6cba118ac49a1b88332f312a8f67186f7f3c1643/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin CC=clang CXX=clang++
bazel build --config=libc++ --config=release @com_googlesource_chromium_v8//:build
bazel build --config=libc++ --config=release //src/envoy:envoy
.bazelrc#
strip#
build:release --strip=always
build:release-symbol -c opt
https://docs.bazel.build/versions/main/user-manual.html#flag–strip
--strip (always|never|sometimes)#
This option determines whether Bazel will strip debugging information from all binaries and shared libraries, by invoking the linker with the -Wl,--strip-debug option. --strip=always means always strip debugging information. --strip=never means never strip debugging information. The default value of --strip=sometimes means strip if the --compilation_mode is fastbuild.
% bazel build --strip=always //foo:bar
will compile the target while stripping debugging information from all generated binaries.
Note that if you want debugging information, it’s not enough to disable stripping; you also need to make sure that the debugging information was generated by the compiler, which you can do by using either -c dbg or --copt -g.
Note also that Bazel’s --strip option corresponds with ld’s --strip-debug option: it only strips debugging information. If for some reason you want to strip all symbols, not just debug symbols, you would need to use ld’s --strip-all option, which you can do by passing --linkopt=-Wl,--strip-all to Bazel. Also be aware that setting Bazel’s --strip flag will override --linkopt=-Wl,--strip-all, so you should only set one or the other. If you are only building a single binary and want all symbols stripped, you could also pass --stripopt=--strip-all and explicitly build the //foo:bar.stripped version of the target. As described in the section on --stripopt, this applies a strip action after the final binary is linked rather than including stripping in all of the build’s link actions.
--stripopt=strip-option#
This is an additional option to pass to the strip command when generating a *.stripped binary. The default is -S -p. This option can be used multiple times.
Note that --stripopt does not apply to the stripping of the main binary with [--strip](https://docs.bazel.build/versions/main/user-manual.html#flag--strip)=(always|sometimes)
compilation_mode#
--compilation_mode (fastbuild|opt|dbg) (-c)#
The --compilation_mode option (often shortened to -c, especially -c opt) takes an argument of fastbuild, dbg or opt, and affects various C/C++ code-generation options, such as the level of optimization and the completeness of debug tables. Bazel uses a different output directory for each different compilation mode, so you can switch between modes without needing to do a full rebuild every time.
fastbuildmeans build as fast as possible: generate minimal debugging information (-gmlt -Wl,-S), and don’t optimize. This is the default. Note:-DNDEBUGwill not be set.dbgmeans build with debugging enabled (-g), so that you can use gdb (or another debugger).optmeans build with optimization enabled and withassert()calls disabled (-O2 -DNDEBUG). Debugging information will not be generated inoptmode unless you also pass--copt -g.
misc#
/usr/lib/llvm/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -g '-stdlib=libc++' '-DG3_BUILD_TARGET="bazel-out/k8-dbg/bin/src/envoy/envoy"' '-DG3_TARGET_NAME="//src/envoy:envoy"' '-DBUILD_COVERAGE_ENABLED=0' '-DGPLATFORM="local"' -include bazel-out/k8-dbg/include/build-info-nonvolatile.h -include bazel-out/k8-dbg/include/build-info-volatile.h -I. -fPIC -DNULL_PLUGIN '-std=c++17' -Wnon-virtual-dtor -Wformat -Wformat-security -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/envoy/source/common/version/version_linkstamp.cc -o bazel-out/k8-dbg/bin/src/envoy/_objs/envoy/source/common/version/version_linkstamp.o)
ls -lh ./bazel-bin/src/envoy/envoy
/usr/lib/llvm/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -g '-stdlib=libc++' '-DG3_BUILD_TARGET="bazel-out/k8-dbg/bin/src/envoy/envoy"' '-DG3_TARGET_NAME="//src/envoy:envoy"' '-DBUILD_COVERAGE_ENABLED=0' '-DGPLATFORM="local"' -include bazel-out/k8-dbg/include/build-info-nonvolatile.h -include bazel-out/k8-dbg/include/build-info-volatile.h -I. -fPIC -DNULL_PLUGIN -fno-stack-protector -fno-stack-protector -fno-stack-protector '-std=c++17' -fno-stack-protector -Wnon-virtual-dtor -Wformat -Wformat-security -fno-stack-protector -fno-stack-protector -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/envoy/source/common/version/version_linkstamp.cc -o bazel-out/k8-dbg/bin/src/envoy/_objs/envoy/source/common/version/version_linkstamp.o)
SUBCOMMAND: # //src/envoy:envoy [action 'Linking src/envoy/envoy', configuration: f5ecda082602d21e6681cd558254477f2008e75bb608ae4c9a8a3fcc2aa44de8, execution platform: @local_config_platform//:host]
(cd /home/.cache/bazel/_bazel_root/9fdd49e4743c3f8ee04d8f2b39e01600/execroot/io_istio_proxy && \