aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/cpp
Commit message (Collapse)AuthorAge
* Windows: add //tools/... tests to test suiteGravatar Laszlo Csomor2018-08-09
| | | | | | | | | | | | Add all tests under //tools/... to //src:all_windows_tests, to run them on Bazel CI. See https://github.com/bazelbuild/bazel/issues/4292 Closes #5839. Change-Id: Iae647f561683cc50ef62416c4b834576ae918486 PiperOrigin-RevId: 208167743
* Disable the correct warningGravatar Loo Rong Jie2018-08-03
| | | | | | | | | | | | | | | I realized that I wrote the wrong warning code when I use Bazel from master branch and build something with MSVC. For the curious: - C4117: https://msdn.microsoft.com/en-us/library/9d2szxf8.aspx - C4177: https://msdn.microsoft.com/en-us/library/s4becxs9.aspx /cc @meteorcloudy Closes #5631. PiperOrigin-RevId: 207235606
* Improve MSVC CrosstoolGravatar Loo Rong Jie2018-07-10
| | | | | | | | | | | | | | | | | | | | - Remove `/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS`: it disables warnings for deprecated C++ headers (`<stdext/*>`, `<hash_map>` etc.). Only useful for legacy codebase. - Remove `/J`: `char` is signed according to ISO C++. There is no reason to make `char` unsigned by default. - Remove default `/Gy`: moved to feature (`smaller_binary`). - Remove default `/GF`: string pooling, enabled by default with `/O2`. - Remove `/DDEBUG` in `dbg` mode: conflict with macros defined in some OSS projects such as LLVM. User should use standard `NDEBUG` to detect debug mode. Implements a few general `feature` to abstract away details about the compiler: - `treat_warnings_as_errors`: aka `-Werror`. - `frame_pointer`: aka `-fno-omit-frame-pointer'. - `determinism`: redact `__TIME__` macros etc. - `disable_assertions`: allow user to have `assert/DCHECK` back even in `opt` mode. - `smaller_binary`: common optimization enabled in `opt` mode. Still allow user to disable it in `opt` (such as when using ASAN). - `ignore_noisy_warnings`: suppress a bunch of warnings most people don't care. If users want to be pedantic, they can still get those warnings back with `--features=-ignore_noisy_warnings`. Closes #5519. PiperOrigin-RevId: 203959555
* When using find_cpp_toolchain, make sure the relevant attribute, ↵Gravatar juliexxia2018-07-10
| | | | | | | '_cc_toolchain' exists on the ctx being passed to this function. (I broke TAP once because I forgot to add the attribute. Perhaps not that helpful this late in the migration but doesn't hurt.) RELNOTES: None. PiperOrigin-RevId: 203947282
* Set INCLUDE and LIB env var for actions that actually need themGravatar Loo Rong Jie2018-07-10
| | | | | | | | | | This makes console output of `bazel build -s` shorter when debugging `CROSSTOOL`. /cc @meteorcloudy Closes #5539. PiperOrigin-RevId: 203899866
* Windows, CROSSTOOL: Fix feature for linking interface library and dynamic ↵Gravatar pcloudy2018-07-09
| | | | | | | | | | library 1. Do not apply /WHOLEARCHIVE to interface library 2. On Windows, we cannot link dll directly, so remove related flag_groups RELNOTES: None PiperOrigin-RevId: 203752406
* Windows, CROSSTOOL: Remove MSVC wrapper scripts from Bazel completelyGravatar Yun Peng2018-07-06
| | | | | | | | | | | The only reason that those python wrapper scripts still exists is for TensorFlow's Windows GPU build. As we will create a custom GPU CROSSTOOL in TF repo, we can finally remove wrapper scripts from Bazel. Closes #5526. RELNOTES: Python wrapper scripts for MSVC are removed. PiperOrigin-RevId: 203472223
* Fix autodetection of -z linker flagsGravatar hlopko2018-07-06
| | | | | | | | | | Clang reports missing -Wl,-z,relro as "ld: unknwon option: -z"). This cl fixes the autodetection to expect the short variant. Fixes #5468. RELNOTES: NONE. PiperOrigin-RevId: 203449206
* Remove stub toolchains for iosGravatar hlopko2018-07-05
| | | | | | | Should not be needed anymore since we have dynamic configurations for a while. RELNOTES: None. PiperOrigin-RevId: 203435557
* Fix autodetection of linker flagsGravatar hlopko2018-07-05
| | | | | | | | | | | Flags passed through clang to linker get -Wl, stripped in the error message (e.g. -Wl,-no-as-needed will be reported as "ld: unknwon option: -no-as-needed"). This cl fixes the autodetection to expect the stripped variant. Fixes #5468. RELNOTES: None. PiperOrigin-RevId: 203341563
* windows_cc_configure.bzl: Check default VC installation directoriesGravatar pcloudy2018-07-04
| | | | | | | See https://github.com/bazelbuild/bazel/issues/5254#issuecomment-402131986 RELNOTES: None PiperOrigin-RevId: 203273587
* add more support for ArmGravatar Bin Lu2018-07-04
| | | | | | | | Signed-off-by: Bin Lu <bin.lu@arm.com> Closes #5477. PiperOrigin-RevId: 203241216
* Windows CROSSTOOL: Add action_config for preprocess-assembleGravatar pcloudy2018-07-02
| | | | | | | Fixed https://github.com/bazelbuild/bazel/issues/5495 RELNOTES: None PiperOrigin-RevId: 202929359
* Add aliases for current_cc_host_toolchain, current_libc_top and filegroupGravatar dbabkin2018-06-28
| | | | | | | crosstool to agregate all its together. RELNOTES:none PiperOrigin-RevId: 202470052
* runfiles libraries: fix tests and commentsGravatar Laszlo Csomor2018-06-27
| | | | | | | | | | | | | | | | | | | | | | | | | | - Update all runfiles libraries to have the same header comment format, including the build rule to depend on the namespace / header / module to import - Fix runfiles_test.cc to include the right files (recent refactoring commit has split src/main/cpp/util/path.cc from file_[platform].cc) - Change exported variable _rlocation_isabs_pattern in runfiles.bash to be upper-case, so it is visibly a variable and not a function. See https://github.com/bazelbuild/bazel/issues/4460 Change-Id: I17e18308506ab9f5c9f410ef6bc6b9df912d42a9 Closes #5481. Change-Id: I17e18308506ab9f5c9f410ef6bc6b9df912d42a9 PiperOrigin-RevId: 202291629
* Remove support for header preprocessingGravatar hlopko2018-06-26
| | | | | | | This was never used. We thought it will be useful, but it's not. RELNOTES: None. PiperOrigin-RevId: 202143524
* Add Arm64 supportGravatar Arielle Albon2018-06-20
| | | | | | | | Based on work of Sun Zhiyi <zhiyisun@gmail.com>. Closes #5360. PiperOrigin-RevId: 201339882
* Remove usage of COMPILER_MSVC in Bazel and ijarGravatar Loo Rong Jie2018-06-11
| | | | | | | | | | | | | Convert most `COMPILER_MSVC` to `_WIN32` (as they apply to Windows platform, not MSVC compiler). Only `src/tools/singlejar/zip_headers.h` and `src/main/cpp/util/md5.h` actually need `_MSC_VER`. `COMPILER_MSVC` in `third_party/protobuf` are not removed. They can be fixed by updating dependency to newer version. /cc @meteorcloudy Closes #5350. Change-Id: Ibc131abfaf34a0cb2bd338549983ea9d28eaabfe PiperOrigin-RevId: 200019793
* Move path-manipulation functions to own library file.Gravatar ccalvarin2018-06-05
| | | | | | | | | | | Leave functions that make file accesses in the file library, and general blaze utilities in the blaze_util file, but move the functions that boil down to string manipulation and path formatting to their own file. (With the exception of getCWD, since absolute path syntax is relevant here.) Doing this largely to consolidate all Windows path control into a single place, so that it's easier to notice inconsistencies. For instance, ConvertPath currently makes Windows paths absolute, but not Posix paths, and MakeAbsolute relies on this behavior. In addition, JoinPath assumes Posix path syntax, which leads to some odd looking paths. These will be fixed in a followup change. (Found these issues while working on #4502, trying to fix the windows-specific system bazelrc.) RELNOTES: None. PiperOrigin-RevId: 199368226
* Fix broken flag existence check for linking flags in unix_cc_configure.Gravatar hlopko2018-06-01
| | | | | | | Fixes #5090 RELNOTES: NONE. PiperOrigin-RevId: 198870918
* Format all bzl files with buildifierGravatar vladmos2018-06-01
| | | | | | This CL aslo enables a presubmit check for correct formatting of all bzl files in //third_party/bazel. PiperOrigin-RevId: 198857055
* Update tools/cpp/toolchain_utils.bzl to return the proper C++ toolchainGravatar hlopko2018-05-30
| | | | | RELNOTES: None PiperOrigin-RevId: 198676014
* runfiles,cc: C++ runfiles library in @bazel_toolsGravatar Laszlo Csomor2018-05-30
| | | | | | | | | | | | | | Add the C++ runfiles library to @bazel_tools//tools/cpp/runfiles:runfiles. RELNOTES[NEW]: C++,runfiles: to access data-dependencies (runfiles) in C++ programs, use the runfiles library built into Bazel. For usage info, see https://github.com/bazelbuild/bazel/blob/master/tools/cpp/runfiles/runfiles.h Change-Id: I5057a9f477289eea7244c60105e77fc71652a817 Closes #5293. Change-Id: I90cba6fa4c6595c838ae42f9d2c17548c8387e5d PiperOrigin-RevId: 198531849
* Minimize the cost of Skyframe restarts during CC autoconfiguration.Gravatar jmmv2018-05-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Repository functions restart whenever they have to resolve a label due to the way Skyframe currently works. This is problematic because such functions are often costly: they try to detect features of the host system by building and running tools, and they touch the file system. To minimize the cost of these restarts, which are unavoidable, resolve the paths to all necessary labels upfront. This way, while the restarts still happen, they have no side-effects and thus are cheap. As a side-effect of this work, remove the strange and undocumented "tpl" function, which only made things more cryptic and harder to refactor. This cuts down Bazel's own analysis time on macOS on my Mac Pro 2013 from 14 seconds to 6 seconds by trimming about 15 unnecessary rebuilds and executions of the xcode-locator-bin tool to just 1. In other words: one fewer awkward pause during analysis time. Additionally, there is the hope that this will fix the problems users observe where Bazel writes persistent garbage during autoconfiguration (needing "clean --expunge" to recover) when Visual Studio Code is running and Santa is enabled on macOS; see https://github.com/bazelbuild/bazel/issues/4603. This is most likely a bug in Santa (see https://github.com/google/santa/issues/260) but we were tickling it due to our apparently-abusive behavior of building, executing, and then removing the same thing over and over again. Fixes https://github.com/bazelbuild/bazel/issues/5196 and should also fix https://github.com/bazelbuild/bazel/issues/4603. RELNOTES: None. PiperOrigin-RevId: 198434395
* Change uses of cc_toolchain_type back to plain toolchain_type.Gravatar jcater2018-05-29
| | | | | | This is a prequisite to removing cc_toolchain_type entirely. PiperOrigin-RevId: 198402472
* Add a compiler_flag rule that exposes the value of the "compiler" field of ↵Gravatar rosica2018-05-28
| | | | | | | CROSSTOOL RELNOTES: None PiperOrigin-RevId: 198295290
* runfiles,cc: merge strategies into RunfilesGravatar Laszlo Csomor2018-05-24
| | | | | | | | | | | | | | Merge the manifest- and directory-based runfiles strategies into the Runfiles class. The resulting Runfiles object can look up runfiles from the manifest or from the filesystem, as needed. Change-Id: Ifff4b76849ce67248bb9152901024e241aaea800 Closes #5251. Change-Id: Ifff4b76849ce67248bb9152901024e241aaea800 PiperOrigin-RevId: 197863872
* runfiles,cc: Runfiles uses manifest AND directoryGravatar Laszlo Csomor2018-05-23
| | | | | | | | | | | | | | | | | | | | | | | | Change the C++ runfiles library so it can use the runfiles manifest (if present) and the runfiles directory (if present) simultaneously. If the Runfiles object fails to look up a runfile from the manifest (or the manifest didn't exist or wasn't found) then it looks it up from the runfiles directory. This change allows using the same binary with and without a runfiles tree, which is often what sets local and remote runs apart. https://github.com/bazelbuild/bazel/issues/4460 Change-Id: Iae879ff084ba084fcd7c111638ddeae4c6754f4f Closes #5235. Change-Id: Iae879ff084ba084fcd7c111638ddeae4c6754f4f PiperOrigin-RevId: 197726412
* CROSSTOOL: Make C++ compiled and linked artifact name pattern configurableGravatar Yun Peng2018-05-22
| | | | | | | | | | | | This change makes Bazel respect artifact name patterns specified in CROSSTOOL. Users cannot specify any arbitrary name pattern, it must ends with allowed extensions. For example, for dynamic library, it can only ends with .so, .dylib or .dll, otherwise Bazel throws an error. Change-Id: I21d9e6fa7c3a282e1a9b8ff29679b00925cddb33 PiperOrigin-RevId: 197553413
* cpp runfiles library: precompute envvars mapGravatar Laszlo Csomor2018-05-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compute the list of environment variables when creating the runfiles library instead of computing it on-demand. Since we already have the manifest and directory path from Runfiles::PathsFrom, creating the vector is cheap, though we have to store it even if we don't use it later. In a subsequent change I'll merge the manifest- and directory-based implementations into RunfilesImpl, and collapse RunfilesImpl into the Runfiles base class. The point of that is to make the runfiles library be able to handle both the directory-based and the manifest-based case simultaneously, dependening on what is available to it in the filesystem. See https://github.com/bazelbuild/bazel/issues/4460 Change-Id: I56310423528df2d0f7494f45904150193368e2d6 Closes #5218. Change-Id: I73d1f44611c4b0a73c41162319d0ba7a8a4ae6d7 PiperOrigin-RevId: 197543865
* cpp runfiles library: compute manifest/dir pathsGravatar Laszlo Csomor2018-05-18
| | | | | | | | | | | | | | | | | | | Use the new codepath (Runfiles::PathsFrom) to compute the paths of the runfiles manifest file and runfiles directory. This method considers the RUNFILES_* envvars but also the argv0 value, and tries hard to discover where the runfiles manifest or directory is. See https://github.com/bazelbuild/bazel/issues/4460 Change-Id: I041b9d12f5c4138853fac1c2bf48873af8e2bd93 Closes #5216. Change-Id: I041b9d12f5c4138853fac1c2bf48873af8e2bd93 PiperOrigin-RevId: 197146764
* Split user_link_flags from legacy_link_flagsGravatar hlopko2018-05-16
| | | | | | | | The difference between them is that user_link_flags will stay after we remove legacy fields from the crosstool. RELNOTES: None. PiperOrigin-RevId: 196940832
* Replace use of output_object_file with output_file in CROSSTOOLS.Gravatar hlopko2018-05-16
| | | | | RELNOTES: None. PiperOrigin-RevId: 196870840
* Do not autodetect C++ toolchain when BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 is ↵Gravatar hlopko2018-05-16
| | | | | | | | | | | | present This is useful e.g. when all C++ builds happen remotely and there's no C++ toolchain installed on the host machine. Fixes #5133. RELNOTES: None. PiperOrigin-RevId: 196798471
* runfiles,cc: add a method to discover runfilesGravatar Laszlo Csomor2018-05-02
| | | | | | | | | | | | | | | | | The new method discovers the runfiles manifest and runfiles directory using the values of the RUNFILES_MANIFEST_FILE and RUNFILES_DIR envvars (if specified), and if needed, also looks for them next to argv[0]. See https://github.com/bazelbuild/bazel/issues/4460 Change-Id: Ie9af0a92aa6879b1d9afdee2789f625de1b0d595 Closes #5140. Change-Id: Ie9af0a92aa6879b1d9afdee2789f625de1b0d595 PiperOrigin-RevId: 195093387
* Change -lgcov with --coverageGravatar Irina Iancu2018-05-02
| | | | | | | | `-lgcov` is not supported on macOS. Closes #5138. PiperOrigin-RevId: 195081921
* Fix targets broken by ↵Gravatar laszlocsomor2018-04-30
| | | | | | | https://github.com/bazelbuild/bazel/commit/819bf38d97e6eef3c823bdae3ffcdb013d6d83e3. RELNOTES: none PiperOrigin-RevId: 194770938
* c++,runfiles: move runfiles libraryGravatar Laszlo Csomor2018-04-30
| | | | | | | | | | | | | | | | Move the half-done C++ runfiles library to `//tools/cpp/runfiles`. (The Python and Bash runfiles libraries are already under `//tools/<language>/runfiles`.) See https://github.com/bazelbuild/bazel/issues/4460 Change-Id: I1006f7f81462ea0e4b1de1adcdba89e386d4f9e7 Closes #5107. Change-Id: I1006f7f81462ea0e4b1de1adcdba89e386d4f9e7 PiperOrigin-RevId: 194763392
* Prototype support for llvm coverageGravatar Ulf Adams2018-04-26
| | | | | | | | | | | | | | | https://clang.llvm.org/docs/SourceBasedCodeCoverage.html Closes #5036. Usage with statically linked tests (works with clang 3.9 or later): BAZEL_USE_LLVM_NATIVE_COVERAGE=1 GCOV=llvm-profdata-3.9 CC=clang-3.9 /tmp/bazel coverage --instrumentation_filter=src/main/cpp --dynamic_mode=off src/test/cpp:option_processor_test (LLVM_COV_CMD="llvm-cov-3.9 show -format=html -output-dir=$(pwd)/report/ -instr-profile bazel-out/k8-fastbuild/testlogs/src/test/cpp/option_processor_test/coverage.dat bazel-out/k8-fastbuild/bin/src/test/cpp/option_processor_test" && cd bazel-os-bazel && $LLVM_COV_CMD) Usage with dynamically linked tests (requires clang 4.0 or later): BAZEL_USE_LLVM_NATIVE_COVERAGE=1 GCOV=llvm-profdata-4.0 CC=clang-4.0 bazel coverage --instrumentation_filter=src/main/cpp src/test/cpp:option_processor_test (LLVM_COV_CMD="llvm-cov-4.0 show -format=html -output-dir=$(pwd)/report/ -instr-profile bazel-out/k8-fastbuild/testlogs/src/test/cpp/option_processor_test/coverage.dat bazel-out/k8-fastbuild/bin/src/test/cpp/option_processor_test $(cat bazel-out/k8-fastbuild/bin/src/test/cpp/option_processor_test.runfiles_manifest | cut -d' ' -f 2 | egrep "\.so$" | xargs -n 1 -I xxx echo -n "-object xxx ")" && cd bazel-os-bazel && $LLVM_COV_CMD) PiperOrigin-RevId: 194357292
* Only print a warning if gcov cannot be found, not an errorGravatar ulfjack2018-04-25
| | | | | | | | We have some cases where clang is installed, but not gcc, and there is no convenience symlink for gcov to point to the corresponding clang tool. In this case, coverage won't work, but let's not error out. We can't tell here whether coverage is enabled or not. Fixes #5066. PiperOrigin-RevId: 194245346
* Detect build-in include directories for C and C++, not only for C++Gravatar hlopko2018-04-25
| | | | | | | Ping #3977 RELNOTES: None PiperOrigin-RevId: 194240625
* Add a workaround for gcov-based coverage with clangGravatar Ulf Adams2018-04-19
| | | | | | | | | | | | | | | | | | - Allow overriding the gcov tool with the GCOV env variable in cc_configure - Symlink the GCOV tool in collect-coverage.sh to a temporary location with the name "gcov" This allows the user to specify GCOV=llvm-cov in the environment of a bazel build, which then leads to cc_configure picking up llvm-cov in the crosstool, which the collect-coverage.sh script then uses as "gcov". On linux distributions, the gcov tool does not generally work with clang coverage output, so this provides at least a workaround for running coverage with clang (by setting the GCOV env variable). Closes #5040. PiperOrigin-RevId: 193487773
* Pass --coverage to all compile and link stepsGravatar Ulf Adams2018-04-17
| | | | | | | | | | | | | | I get failing tests without this flag in coverage mode. Workaround is to pass --linkopt=-fprofile-arcs in Bazel. Here are the steps that work at this time (with this change): bazel coverage --strategy=TestRunner=standalone //my/funky:test genhtml -o report-output-directory/ path/to/coverage.dat Some progress on #1118. PiperOrigin-RevId: 193193164
* Remove c++-link-interface-dynamic-library from crosstools, it's not usedGravatar hlopko2018-04-05
| | | | | RELNOTES: None. PiperOrigin-RevId: 191713379
* Fix crosstool target cpu to match local.Gravatar John Cater2018-04-03
| | | | | | | | | The entries in BUILD.tpl specify cpu "local", so CROSSTOOL.tpl needs to match. Closes #4957. Change-Id: I68d7148fa6cb73cd83ef99eab76e0fd2f6227580 PiperOrigin-RevId: 191444915
* Create proguard.txt in android_library AAR output.Gravatar ajmichael2018-04-02
| | | | | | | | | The proguard.txt is the concatenation of the proguard_specs on the android_library rule itself. Note that it does not include transitively defined proguard_specs. Fixes https://github.com/bazelbuild/bazel/issues/4467 RELNOTES: android_library AAR output now contains proguard.txt PiperOrigin-RevId: 191302610
* Fix toolchain CPU identifiers to match what's in the BUILD.tpl file.Gravatar John Cater2018-04-02
| | | | Change-Id: If9d641445dc8c6520b5f4c53eab438e44486b5ac
* Add toolchain definitions for autoconfigured cc_toolchain entries.Gravatar jcater2018-03-27
| | | | PiperOrigin-RevId: 190611069
* Windows: Expose setup_vc_env_vars function from windows_cc_configure.bzlGravatar Yun Peng2018-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | `setup_vc_env_vars` runs vcvarsall.bat to setup environment varibles for Visuall C++ build tools. It returns the values of PATH, LIB, INCLUDE and WINDOWSSDKDIR. Expose this function so that users can use load("@bazel_tools/tools/cpp:windows_cc_configure.bzl", "setup_vc_env_vars") to access this function. Fixed https://github.com/bazelbuild/bazel/issues/4542 RELNOTES[NEW]: Now you can access three functions in windows_cc_configure.bzl by: load("@bazel_tools/tools/cpp:windows_cc_configure.bzl", "<function_name>") 1. find_vc_path(repository_ctx): Detect the VC installation path on your machine, respect BAZEL_VC first, return None if VC not found. 2. setup_vc_env_vars(repository_ctx, vc_path): Get PATH, LIB, INCLUDE, WINDOWSSDKDIR env vars set by VCVARSALL.bat, return None if VCVARSALL.bat not found. 3. find_msvc_tool(repository_ctx, vc_path, tool): Find a certain VC build tool (eg. cl.exe, lib.exe, link.exe), return None if tool not found. Change-Id: Iec5770165aaa4766470bb3b4d818a2cf90678586 Closes #4892. Change-Id: Iec5770165aaa4766470bb3b4d818a2cf90678586 PiperOrigin-RevId: 190039950
* Automated rollback of commit 67549a752c2316234b19d7b50ea84a8ae80d3669.Gravatar hlopko2018-03-21
| | | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks on windows: https://www.google.com/url?sa=D&q=https%3A%2F%2Fbuildkite.com%2Fbazel%2Fgoogle-bazel-presubmit%2Fbuilds%2F624%234a68440b-948b-437b-a633-4f0595721bab *** Original change description *** Automated rollback of commit 3c5a1098af0c5ae80d4e3b1fc52dd1fef6027d43. *** Reason for rollback *** Breaks bazel ci: https://github.com/bazelbuild/bazel/issues/4894#event-1533040075 *** Original change description *** Add crosstool_lib.bzl and crosstool_utils.bzl These will be used to rewrite current crosstool autoconfiguration into action_configs and features. RELNOTES: None. PiperOrigin-RevId: 189906675