aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/cpp/cc_configure.bzl
Commit message (Collapse)AuthorAge
* 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
* 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
* 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
* 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
* 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
* 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
* Add toolchain definitions for autoconfigured cc_toolchain entries.Gravatar jcater2018-03-27
| | | | PiperOrigin-RevId: 190611069
* Consult BAZEL_LINKOPTS env variable when detecting linker flags in ↵Gravatar hlopko2018-02-27
| | | | | | | | | | | | | | | | | | | autogenerated cc toolchain Relevant to #4031, fixes #4524. Does not affect the osx + xcode toolchain that supports both C++ and ObjC! RELNOTES: BAZEL_LINKOPTS is now consulted when autoconfiguring c++ toolchain Now linker flags for the autogenerated C++ toolchain can be controlled by BAZEL_LINKOPTS environment variable (using colon as a flag separator): BAZEL_LINKOPTS=-lc++ bazel build //... The default value is "-lstdc++:-lm". PiperOrigin-RevId: 187173297
* Make cc_configure script more extensibleGravatar Ilya Biryukov2017-12-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a few extension points to cc_configure script with the ultimate goal to allow downloading the compiler and other tools used for C++ build before generating the crosstool. Specifically, we make the following changes: - Expose the implementation of a cc_autoconf repository rule under a name of cc_autoconf_impl. - Extend cc_autoconf_impl to allow overriding paths to build tools (i.e. compilers, linkers, etc.) - Allow to put any extra artifacts into the generated crosstool repository. All files inside 'extra_tools' folder are added into compiler_files, all_files and linker_files properties of the generated crosstool, so that they are available for the crosstool. With these extension one can do the following to download the compilers used for the build and configure the crosstool: - Create a repository_rule for the toolchain with a custom implementation. - In the implementation function of the repository rule: + Download the compilers and put them into `extra_tools` folder. + Run cc_autoconf_impl with overriden_tools set to relative paths of the compiler and other build tools in the extra_tools folder. Change-Id: I51af6b504578963b3e97bcdd1ccb6d0a5fed1c3e PiperOrigin-RevId: 179675911
* Use C++-only toolchain on darwin when BAZEL_USE_CPP_ONLY_TOOLCHAIN env var ↵Gravatar hlopko2017-12-12
| | | | | | | | | | | | | is set to "1" By default when xcode is installed on darwin bazel will pick a toolchain that supports both C++ and ObjC. This cl allows the user to pick C++ only toolchain even when Xcode is installed. Fixes #4231. RELNOTES: None. PiperOrigin-RevId: 178745218
* Add a new toolchain type for c++. In order to do this, ↵Gravatar cpeyser2017-09-08
| | | | | | | | PlatformConfiguration is made a legal configuration fragment for every rule class. Add a default "dummy" c++ toolchain to prevent resolution errors when legacy toolchain selection logic is used. Add toolchain mocks to java and shell tests. PiperOrigin-RevId: 167901210
* Automated rollback of commit 2b983bdf508e010a3d4ee9dbaf446b7666749799.Gravatar cpeyser2017-09-01
| | | | | | | | | | | | *** Reason for rollback *** Breaks rules_go CI *** Original change description *** Rollforward of c++ toolchain-relevant BUILD file and Bazel mocking changes. That is, a c++ toolchain is added, but a Bazel dependency on that toolchain is not. PiperOrigin-RevId: 167198874
* Rollforward of c++ toolchain-relevant BUILD file and Bazel mocking changes. ↵Gravatar cpeyser2017-08-31
| | | | | | That is, a c++ toolchain is added, but a Bazel dependency on that toolchain is not. PiperOrigin-RevId: 167006332
* Automated rollback of commit 9d5bce66280094c0531ddfde2752e596d0d78c79.Gravatar plf2017-08-30
| | | | PiperOrigin-RevId: 166966182
* Add a new toolchain type for c++. In order to do this, ↵Gravatar cpeyser2017-08-29
| | | | | | | | PlatformConfiguration is made a legal configuration fragment for every rule class. Add a default "dummy" c++ toolchain to prevent resolution errors when legacy toolchain selection logic is used. Add toolchain mocks to java and shell tests. PiperOrigin-RevId: 166854893
* Correct environment variable name local_config_cc depends onGravatar pcloudy2017-07-13
| | | | | | | Should be USE_MSVC_WRAPPER instead NO_MSVC_WRAPPER now. RELNOTES: None PiperOrigin-RevId: 161668110
* Output more debug information when running python testsGravatar Yun Peng2017-06-28
| | | | | | | This is for debugging https://github.com/bazelbuild/bazel/issues/3273 Change-Id: I84e260ae1a22147fed0cffc2960352c77af2cf58 PiperOrigin-RevId: 160399209
* Refactor cc_configure.bzlGravatar Yun Peng2017-06-22
| | | | | | | | | | | | Split original cc_configure.bzl into 4 different files: lib_cc_configure.bzl: base library for C++ toolchain configuration unix_cc_configure.bzl: For Unix platforms osx_cc_configure.bzl: For macOS windows_cc_configure.bzl: For Windows Change-Id: I76fa44294c6ca4304f0a94f3a1c57d6e76141667 PiperOrigin-RevId: 159801973
* Make cc_configure on Windows simpler and more robustGravatar Yun Peng2017-06-13
| | | | | | | | | | | | | The previous registry value we are querying only exists when Visual Studio is installed. If user only has VC build tools installed and doesn't set env vars like BAZEL_VS, VS140COMNTOOLS, VC won't be detected. HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7 exists in both situations and works for all VS versions. Change-Id: I07b5593e882e23fa9e0079e082e6d357b905736d PiperOrigin-RevId: 158841618
* Use a wrapper-free MSVC toolchain when NO_MSVC_WRAPPER=1Gravatar Yun Peng2017-06-06
| | | | | | | | | | | | | | | | | | | To enable a wrapper free MSVC CROSSTOOL, set NO_MSVC_WRAPPER=1 or add --action_env=NO_MSVC_WRAPPER=1 flag. Note that we still use windows_cc_wrapper.bat to invoke cl.exe and link.exe for different actions. Result for bazel build src/main/cpp:client : NO_WRAPPER: INFO: Elapsed time: 76.833s, Critical Path: 16.70s WRAPPER: INFO: Elapsed time: 138.517s, Critical Path: 27.78s Change-Id: Iaf6b67fc791ae1f8b62d332e47f96f719510bda1 PiperOrigin-RevId: 158118110
* Make C++ archiving use action_configs instead of hardcoded flagsGravatar hlopko2017-06-01
| | | | | RELNOTES: Use action_config in crosstool for static library archiving, remove ar_flag. PiperOrigin-RevId: 157685703
* Fix typo: s/exists/exist/ where needed.Gravatar philwo2017-05-31
| | | | | RELNOTES: None. PiperOrigin-RevId: 157572063
* Reverts non-xcode-available darwin crosstool generation.Gravatar cparsons2017-05-31
| | | | | RELNOTES: None. PiperOrigin-RevId: 157529642
* Wrap ar invocations for osx bazel crosstool.Gravatar cparsons2017-05-23
| | | | | | | | | This: 1. Forces ar invocations to go through xcrunwrapper (thus having the environment variables set correctly so that the appropriate xcode is used) 2. Institutes a fix for non-hermeticism around object file timestamps. RELNOTES: None. PiperOrigin-RevId: 156759530
* Fixes compilation on Power8Gravatar davideleoni902017-05-15
| | | | | | | | This fixes #3000 Closes #3002. PiperOrigin-RevId: 156046356
* Adding feature for linking C Run-Time library on WindowsGravatar Yun Peng2017-05-12
| | | | | | | | | | | | | | | By default, we use /MT(/MTd for debug mode) and link to libcmt.lib(libcmtd.lib). Users can set USE_DYNAMIC_CRT=1 or add --action_env=USE_DYNAMIC_CRT=1 to switch to /MD and msvcrt.lib (/MDd and msvcrtd.lib for debug mode) Reference: https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx Fixed https://github.com/bazelbuild/bazel/issues/2120 Change-Id: I61e65ace82163acd456bf82f2b108c5fe8d8a8ce PiperOrigin-RevId: 155850886
* Escape % in strings that will appear in CrosstoolGravatar hlopko2017-05-10
| | | | | | | | | | %foo% syntax is not allowed in Crosstool, but some Windows environment variables that we read in cc_configure.bzl can reference other variables, therefore in order not to crash, we need to escape them before putting the values into the Crosstool. RELNOTES: None. PiperOrigin-RevId: 155602425
* Rollforward #2 of: Basic open-source crosstool to support targeting apple ↵Gravatar cparsons2017-05-04
| | | | | | | platform types. RELNOTES: None. PiperOrigin-RevId: 154993630
* Automated g4 rollback of commit 5038016e6573962d2554fcf9c10faa0cca8714e2.Gravatar dmarting2017-05-02
| | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Broke rules_go and all its dependencies: http://ci.bazel.io/job/rules_web/BAZEL_VERSION=HEAD,PLATFORM_NAME=darwin-x86_64/464/console http://ci.bazel.io/job/rules_go/BAZEL_VERSION=HEAD,PLATFORM_NAME=darwin-x86_64/823/console http://ci.bazel.io/job/buildifier/BAZEL_VERSION=HEAD,PLATFORM_NAME=darwin-x86_64/557/console Bisected with `bazel build ...` in rules_go The error message is still -whole-archive appearing in rules_go. *** Original change description *** Rollforward of: Basic open-source crosstool to support targeting apple platform types. RELNOTES: None. PiperOrigin-RevId: 154825240
* Rollforward of: Basic open-source crosstool to support targeting apple ↵Gravatar cparsons2017-04-28
| | | | | | | platform types. RELNOTES: None. PiperOrigin-RevId: 154547417
* Automated g4 rollback of commit 501b62716af12ba42c019bd9f231468b3c144757.Gravatar aehlig2017-04-18
| | | | | | | | | | | | | | | *** Reason for rollback *** Broke //src/test/shell/bazel:cc_inc_library_test on darwin see http://ci.bazel.io/job/bazel-tests/BAZEL_VERSION=HEAD,PLATFORM_NAME=darwin-x86_64/704/console *** Original change description *** Basic open-source crosstool to support targetting apple platform types. RELNOTES: None. PiperOrigin-RevId: 153460334
* Basic open-source crosstool to support targetting apple platform types.Gravatar cparsons2017-04-18
| | | | | RELNOTES: None. PiperOrigin-RevId: 153360877
* Automated g4 rollback of commit 045104899738594d85f9ab9b0b9ccbde320b8055.Gravatar jfield2017-04-18
| | | | | | | | | | | | | *** Reason for rollback *** Breaks internal tests that use nonstandard crosstools *** Original change description *** Make C++ archiving use action_configs instead of hardcoded flags RELNOTES: Use action_config in crosstool for static library archiving, remove ar_flag. PiperOrigin-RevId: 153344597
* Make C++ archiving use action_configs instead of hardcoded flagsGravatar hlopko2017-04-13
| | | | | RELNOTES: Use action_config in crosstool for static library archiving, remove ar_flag. PiperOrigin-RevId: 153046587
* Do not add a build id to C++ binaries by default.Gravatar lberki2017-04-13
| | | | | | | Fixes #2805. RELNOTES: None. PiperOrigin-RevId: 153039178
* cc_configure: stricter error checks in _executeGravatar laszlocsomor2017-04-11
| | | | | | | | | | | | | | | | | Add stricter error checks in hopes of catching occasional CI flakiness where the stdout of a command seems to get lost. It's now an error if the command returns a non-zero exit code (or a zero one if it's expected to fail) or if its stdout is empty. Previously we only checked if stderr was empty to consider the action successful. See https://github.com/bazelbuild/bazel/issues/2675 RELNOTES: none PiperOrigin-RevId: 152685220
* Provide more information regarding compilerGravatar Eric Cousineau2017-04-10
| | | | | | | | | | | | | | | | | | | | This addresses #2761, to provide a minor improvement if neither `gcc` or `CC` are found on the path. Let me know if you would like anything changed! Local qualification steps: ``` $ cd bazel $ git rebase 0.4.5 # Did not want to spend too much time synchronizing derived stuff in master $ ln -s ~/Downloads/bazel-0.4.5-dist/derived . $ ./compile.sh $ export PATH=~+/output/bazel;$PATH $ cd .../someproject $ CC=clang-9000 bazel build //package:test Cannot find gcc or CC (clang-9000), either correct your path or set the CC environment variable. ``` Closes #2773. PiperOrigin-RevId: 152658002
* Suppress some warning messages from cc_configure.bzlGravatar Yun Peng2017-04-06
| | | | | | | Fixed https://github.com/bazelbuild/bazel/issues/2775 Change-Id: I4f5bab56ab961fd5310d62c7eee70abf9c98f9d9 PiperOrigin-RevId: 152359801
* Windows MSVC toolchain: Move environment variables setup from wrapper script ↵Gravatar Yun Peng2017-04-06
| | | | | | | to CROSSTOOL Change-Id: Ic6ee5a22412281743267a40623f4a8514a2e70f6 PiperOrigin-RevId: 152252048
* adding more env vars to invalidation listGravatar Nicolas Lopez2017-04-04
| | | | | | | | | It seems several env vars that are used by cc_configure are not in the invalidation list and not included in the bootstrap compile. Adding them. Change-Id: I67f73ae09abbe9033bcbbcb4026dab04d225b699 PiperOrigin-RevId: 152139948
* Replacing hardcoded use of 'local' for env variables in cc autoconfigGravatar Nicolas Lopez2017-03-28
| | | | | | | | -- Change-Id: Ic1632229e67bf82b69983f9614258c5fd54c12d8 Reviewed-on: https://cr.bazel.build/9390 PiperOrigin-RevId: 151422502 MOS_MIGRATED_REVID=151422502
* cc_configure: more generic msys_root discovery Gravatar László Csomor2017-03-23
| | | | | | | | | | | See https://github.com/bazelbuild/bazel/issues/2725 Related to https://github.com/bazelbuild/bazel/issues/2447 -- Change-Id: I5cc7fba43ae46bc9ef47bcaf9efaf2a0b9911bc4 Reviewed-on: https://cr.bazel.build/9468 PiperOrigin-RevId: 150881196 MOS_MIGRATED_REVID=150881196
* Make MSVC CROSSTOOL default on Windows Gravatar Yun Peng2017-03-08
| | | | | | | | | | | | | | | | The default C++ CROSSTOOL on Windows now becomes MSVC, --cpu=x64_windows_msvc is still supported To use MSYS toolcahin, add --cpu=x64_windows_msys and --host_cpu=x64_windows_msys for host compilation See https://github.com/bazelbuild/bazel/issues/2627 -- Change-Id: Ie788a39cb5ffbc9fc956ccfd51a3cc816c74543a Reviewed-on: https://cr.bazel.build/9292 PiperOrigin-RevId: 149530250 MOS_MIGRATED_REVID=149530250
* Make gold autodetection more robust on macosGravatar Marcel Hlopko2017-03-08
| | | | | | | | | | | | | | Some macos clang versions don't fail when setting -fuse-ld=gold, which makes cc_configure.bzl think gold linker is available, when it is actually not. The sideeffect of this cl is that we will not autodetect gold when only a very old (year 2010 and older) is present. I assume this is fine. Fixes #2502 -- PiperOrigin-RevId: 149521872 MOS_MIGRATED_REVID=149521872
* Fix coverage section in the autodetected crosstool for windowsGravatar Marcel Hlopko2017-02-24
| | | | | | | | Fixes https://github.com/bazelbuild/bazel/issues/2582 -- PiperOrigin-RevId: 148455784 MOS_MIGRATED_REVID=148455784
* Fix autodetection of c++ coverage on osxGravatar Marcel Hlopko2017-02-24
| | | | | | | | | | | | | Fixes #2275. The logic that adds 'coverage' feature to the toolchain if not present in CppConfiguration only works for linux targets. This cl teaches cc_configure.bzl about this feature so it can be autodetected on osx correctly (although the autodetection logic in this cl is rather naive). -- PiperOrigin-RevId: 148336592 MOS_MIGRATED_REVID=148336592
* cc_configure: declare environment variables for invalidation Gravatar Damien Martin-Guillerez2017-02-15
| | | | | | | | | | And stop setting the local flag -- Change-Id: I97c76cf78a191a5f37c8bb3cd32e78df5aeeb885 Reviewed-on: https://cr.bazel.build/8223 PiperOrigin-RevId: 147591728 MOS_MIGRATED_REVID=147591728
* Make Bazel work with Visual Studio 2017 Gravatar Yun Peng2017-02-14
| | | | | | | | | | | | | | | Now Bazel can detect MSVC from Visual Studio 2017 or Visual C++ build tools 2017. Also modified build_windows_jni.sh to make it work with VS 2017. Fixed: https://github.com/bazelbuild/bazel/issues/2440 -- Change-Id: I4afbce809ff74634f32fab87efe5e7f0b3f60c95 Reviewed-on: https://cr.bazel.build/8890 PiperOrigin-RevId: 147467993 MOS_MIGRATED_REVID=147467993
* Detect Visual C++ build tools through vcvarsqueryregistry.bat Gravatar Yun Peng2017-02-08
| | | | | | | | | | | See: https://github.com/bazelbuild/bazel/issues/2434 Fixed https://github.com/bazelbuild/bazel/issues/2448 -- Change-Id: I12b109af81e0eb8948fd1d7a7d2bbfcf6baa7ca4 Reviewed-on: https://cr.bazel.build/8693 PiperOrigin-RevId: 146886981 MOS_MIGRATED_REVID=146886981
* Windows, cc_configure: use BAZEL_SH, not cygpathGravatar Laszlo Csomor2017-02-01
| | | | | | | | | | | | | | Use the BAZEL_SH envvar while creating the Windows CROSSTOOL file, instead of calling "cygpath -m /". The latter is based on the assumption that we are running under MSYS. Fixes https://github.com/bazelbuild/bazel/issues/2463 See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 146227581 MOS_MIGRATED_REVID=146227581