aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/cpp
Commit message (Collapse)AuthorAge
* Add a 'fdo_optimize' feature to the auto-configured crosstool.Gravatar Benjamin Peterson2017-12-05
| | | | | | | | | | | Bazel's fallback action config for PGO optimization uses Google-internal compiler flags. Here, we provide a 'fdo_optimize' feature without these internal flags, so --fdo_optimize can work out of the box. This fixes https://github.com/bazelbuild/bazel/issues/1171. Change-Id: I1d40eb72211e7c5bea213de7d2c237ac2877b3a1 PiperOrigin-RevId: 177947264
* Add an open-source version of find_cpp_toolchain, to allow open-source users ofGravatar cpeyser2017-12-04
| | | | | | | | the CppConfiguration Skylark API to migrate to platforms and toolchains. For more details on toolchains, please see https://docs.google.com/document/d/1-G-VPRLEj9VyfC6VrQBiR8To-dZjnBSQS66Y4nargGM/edit#heading=h.al54v2ddwqzv PiperOrigin-RevId: 177811908
* Windows: Expose find_vc_path and find_msvc_tool functionGravatar Yun Peng2017-12-01
| | | | | | | | | | | | | | | find_vc_path and find_msvc_tool are now visible from windows_cc_configure.bzl, users can do: load("@bazel_tools//tools/cpp:windows_cc_configure.bzl", "find_vc_path" "find_msvc_tool") to get Visual C++ path and find Visual C++ tools detected by Bazel in their repository rule. Change-Id: Ifb6d1f412e64251f413a59d3149d44ca2f8bc5d7 PiperOrigin-RevId: 177589321
* Windows CROSSTOOL: Define DEBUG in fastbuild and dbg modeGravatar pcloudy2017-11-22
| | | | | RELNOTES: None PiperOrigin-RevId: 176646230
* Windows CROSSTOOL: Define NDEBUG in opt modeGravatar pcloudy2017-11-22
| | | | | | | Fixed https://github.com/bazelbuild/bazel/issues/4144 RELNOTES: None PiperOrigin-RevId: 176642833
* Update/Add license header to cc auto-configure templates.Gravatar xingao2017-11-21
| | | | PiperOrigin-RevId: 176510846
* Add 'assemble' action_config for Windows.Gravatar Seth Greenstein2017-11-17
| | | | | | | | | | | Allows .asm files to be included in srcs. ml64.exe is used to create .o files which can later be linked. However, this change will not allow custom flags to be passed to ml64.exe other than /I and /D. Fixes #3648 Closes #3887. Change-Id: I42b6ff76d526abed440bb7f0e0ed4cc3812b4893 PiperOrigin-RevId: 176085382
* msvc_cl.py: Remove code for adding /MT /MD options from wrapper script.Gravatar pcloudy2017-11-14
| | | | | | | | The wrapper script is now only necessary for TensorFlow GPU build. Since the link option for MSVCRT is controlled by CROSSTOOL, we should remove the hack in wrapper script to avoid conflict. RELNOTES: None PiperOrigin-RevId: 175664202
* Add win_def_file attribute to cc rules.Gravatar Yun Peng2017-11-14
| | | | | | | | RELNOTES[NEW]: Users can use win_def_file attribute to specify a DEF file for exporting symbols when build a shared library on Windows. Change-Id: Ifa28d8b7b24eaefcefc9640d8dc56fd2931e9688 PiperOrigin-RevId: 175651203
* Introduce cc_toolchain_type, which exports c++ make variables. UseGravatar cpeyser2017-11-07
| | | | | | //tools/cpp:toolchain_type as the canonical c++ toolchain. PiperOrigin-RevId: 174759558
* Windows: genenrate a fake CROSSTOOL when VC not foundGravatar Yun Peng2017-10-18
| | | | | | | | | | | | | | | | When Visual C++ build tools are not found on Windows, we generating a fake CROSSTOOL so that users can still build for other languages. In the fake CROSSTOOL, we point all tools to a batch script which prints error messages to notify users when they try to build any cc targets. Also, added an extra default_toolchain specification for x64_windows cpu value, so that users can use this cpu in select on non-Windows platforms. Fixed https://github.com/bazelbuild/bazel/issues/3853 Change-Id: Ib4d7a38fd4d98075f6b73ce310c28822e58af4e2 PiperOrigin-RevId: 172341985
* Fix osx_cc_wrapper to also update dylibsGravatar hlopko2017-10-13
| | | | | | | | | | | | | | | In https://github.com/bazelbuild/bazel/commit/f426544e67170d31b9d228ecf4cdc4b6ce1ba00d I updated osx_cc_wrapper to work correctly in case both precompiled .so and cc_library-made .so are linked into a single binary. This cl makes osx_cc_wrapper work also when a precompiled .dylib is provided. This is roll-forward of https://github.com/bazelbuild/bazel/commit/0257c29f496719bb8414d012334155de6bbefa11. Fixes #3450 again for dylibs Fixes #407 One step closer to finishing #1576 RELNOTES: None. PiperOrigin-RevId: 171969333
* Automated rollback of commit 0257c29f496719bb8414d012334155de6bbefa11.Gravatar hlopko2017-10-11
| | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** I broke http://ci.bazel.io/view/Dashboard/job/bazel-tests/1079/testReport/junit/(root)/(empty)/test_osx_cc_wrapper_rpaths_handling/ *** Original change description *** Fix osx_cc_wrapper to also update dylibs In https://github.com/bazelbuild/bazel/commit/f426544e67170d31b9d228ecf4cdc4b6ce1ba00d I updated osx_cc_wrapper to work correctly in case both precompiled .so and cc_library-made .so are linked into a single binary. This cl makes osx_cc_wrapper work also when a precompiled .dylib is provided. Fixes #3450 again for dylibs Fixes #407 One step closer to finishing #1576 RELNOTES: None. PiperOrigin-RevId: 171806769
* Fix osx_cc_wrapper to also update dylibsGravatar hlopko2017-10-11
| | | | | | | | | | | | | In https://github.com/bazelbuild/bazel/commit/f426544e67170d31b9d228ecf4cdc4b6ce1ba00d I updated osx_cc_wrapper to work correctly in case both precompiled .so and cc_library-made .so are linked into a single binary. This cl makes osx_cc_wrapper work also when a precompiled .dylib is provided. Fixes #3450 again for dylibs Fixes #407 One step closer to finishing #1576 RELNOTES: None. PiperOrigin-RevId: 171683650
* Windows CROSSTOOL: remove c++-link-executable from ↵Gravatar pcloudy2017-09-29
| | | | | | | | | interface_library_output_path flag set We shouldn't apply this flag set to c++-link-executable action, it will only add a /IMPLIB:ignore option. RELNOTES: None. PiperOrigin-RevId: 170459781
* Windows: Add static_link_msvcrt and related featuresGravatar Yun Peng2017-09-26
| | | | | | | | | | | | | | | This is to replace using USE_DYNAMIC_CRT env variable to configure msvcrt linking in CROSSTOOL. If user applies static_link_msvcrt feature to a specific target, Bazel will choose the correct options for statically linking msvcrt. If static_link_msvcrt is not specified, Bazel uses options for dynamically linking msvcrt by default. https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx Change-Id: Ia078dfb528de9ffdd8a11d392db9eb3f34463b09 PiperOrigin-RevId: 170021927
* Windows: Make dynamic libraries available to binary at runtimeGravatar Yun Peng2017-09-20
| | | | | | | | | | | When copy_dynamic_libraries_to_binary is enabled, we copy the shared libraries required by the binary to the binary's directory. Bazel will throw errors if there are confilct actions generating the same artifacts. Change-Id: I09a5a599ca0ec7a67efd49d5aa89481450fa4e90 PiperOrigin-RevId: 169364498
* Toolchain type labels for c++ are filegroups instead of toolchain_type.Gravatar cpeyser2017-09-18
| | | | PiperOrigin-RevId: 168835640
* Automated rollback of commit f26e8694ae78599b3e2004e3360eaf3443fa53a6.Gravatar hlopko2017-09-18
| | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks clang_tidy. *** Original change description *** Introduce -c source_file -o output_file build variables Prior to this cl CompileCommandLine would (almost) unconditionally emit -c and -o flags. This cl removes this logic and relies on crosstool to emit these flags. This is another small step towards platform independent C++ rules. Memory use is not affected, since the build variables used by this cl are already exposed, this cl just forces crosstools to use it. RELNOTES: None. PiperOrigin-RevId: 168834576
* Bazel now can build dynamic library from cc_libraryGravatar Yun Peng2017-09-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Working towards: https://github.com/bazelbuild/bazel/issues/3311 When building dynamic library on Windows, Bazel builds an import library and a DLL. Bazel provides a feature called windows_export_all_symbols, if this feature is enabled(and no_windows_export_all_symbols is not) for a cc_library, then Bazel parses object files of that cc_library to generate a DEF file that will be used during linking time to export symbols from DLL. This feature can be specified at crosstool, package, target and command line level. A few differences from Unix platforms: 1. We don't build the shared library on Windows by default, users have to specifiy --output_groups=dynamic_library for building dynamic libraries. This output group is also available on other platforms. 2. By default, cc_test is dynamically linked on Unix, but it will be statically linked on Windows by default. (meaning the default value of linkstatic in cc_test is 1 on Windows, and 0 on other platforms) 3. For global data symbols, __declspec(dllimport) must still be used in source files. Remaining issues: 1. Extensions for import library and DLL are not correct yet. 2. DLLs are not guaranteed to be available during runtime yet. 3. Diamond problem If a cc_library A is specified as linkstatic=0, then no dynamic library will be built for it, so if another cc_library B depends on it, A will be statically linked into B, and if a cc_binary C depends on B, A will also be statically linked into C and B will be dynamically linked to C. This is wrong because A is duplicated in both B and C. It is essentially a diamond problem describled in C++ Transitive Library. (https://docs.google.com/document/d/1-tv0_79zGyBoDmaP_pYWaBVUwHUteLpAs90_rUl-VY8/edit?usp=sharing) Hopefully, we can avoid this by using cc_shared_library rule in future. Change-Id: I23640d4caf8afe65d60b1522af6368536d7a8408 PiperOrigin-RevId: 168829958
* Automated rollback of commit ca216f5eb4b1f1892219db0f578495bbbdbaa875.Gravatar philwo2017-09-15
| | | | | | | | | | | | | | | *** Reason for rollback *** Breaks Bazel building itself on FreeBSD, also #3739. *** Original change description *** Introduce empty "toolchain_category" rule for labels that will be used as categories of toolchains for the purpose of toolchain selection. Up to now, we've used the native toolchain_type rule for this purpose. That rule depends on a number of configuration fragments that supply build variables - we don't want toolchains to need to depend on those fragments as well. E.g. toolchain_type depends on JvmConfiguration, but we would like toolchains to work with --experimental_disable_jvm. PiperOrigin-RevId: 168810566
* Introduce -c source_file -o output_file build variablesGravatar hlopko2017-09-14
| | | | | | | | | | | | Prior to this cl CompileCommandLine would (almost) unconditionally emit -c and -o flags. This cl removes this logic and relies on crosstool to emit these flags. This is another small step towards platform independent C++ rules. Memory use is not affected, since the build variables used by this cl are already exposed, this cl just forces crosstools to use it. RELNOTES: None. PiperOrigin-RevId: 168671507
* Introduce empty "toolchain_category" rule for labels that will be used asGravatar cpeyser2017-09-14
| | | | | | | | categories of toolchains for the purpose of toolchain selection. Up to now, we've used the native toolchain_type rule for this purpose. That rule depends on a number of configuration fragments that supply build variables - we don't want toolchains to need to depend on those fragments as well. E.g. toolchain_type depends on JvmConfiguration, but we would like toolchains to work with --experimental_disable_jvm. PiperOrigin-RevId: 168577759
* Expose sysroot as a build variableGravatar hlopko2017-09-12
| | | | | | | | | This cl removes hardcoded --sysroot flag generation from bazel when constructing command line for C++ actions. The hardcoded flag is still exposed to Skylark (to stay backwards compatible). RELNOTES: None. PiperOrigin-RevId: 168346711
* Introduce unfiltered_compile_flags build variable, rename copts variable to ↵Gravatar hlopko2017-09-11
| | | | | | | | | | | | | user_compile_flags Also add magic to a feature named 'unfiltered_compile_flags' so the flags expanded from it are not subject to nocopt filtering. This is encore of https://github.com/bazelbuild/bazel/commit/268c0bcbf79f9f3f72d95fa51af0f1b18c5ce29e that was rolled back because it regressed memory. RELNOTES: None. PiperOrigin-RevId: 167989075
* 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 8328dc9e3b0d473756ec94508744afefe4d8eaf2.Gravatar pcloudy2017-09-07
| | | | | | | | | *** Reason for rollback *** Rollback since this change is based on https://github.com/bazelbuild/bazel/commit/268c0bcbf79f9f3f72d95fa51af0f1b18c5ce29e, which is rollbacked due to a performance reason RELNOTES: None. PiperOrigin-RevId: 167836715
* Fix windows crosstools after ↵Gravatar hlopko2017-09-06
| | | | | | | | | https://github.com/bazelbuild/bazel/commit/268c0bcbf79f9f3f72d95fa51af0f1b18c5ce29e Fixes #3693 RELNOTES: None. PiperOrigin-RevId: 167704700
* 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
* Automated rollback of commit 363413110f3a63a11d900864be1852adbaed2899.Gravatar cpeyser2017-08-29
| | | | | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks //src/test/shell/bazel:bazel_bootstrap_distfile_test: INFO: You can skip this first step by providing a path to the bazel binary as second argument: INFO: ./compile.sh compile /path/to/bazel 🍃 Building Bazel from scratch...... 🍃 Building Bazel with Bazel. .WARNING: /tmp/bazel_cHivhPBc/out/external/bazel_tools/WORKSPACE:1: Workspace name in /tmp/bazel_cHivhPBc/out/external/bazel_tools/WORKSPACE (@io_bazel) does not match the name given in the repository's definition (@bazel_tools); this will cause a build error in future versions. ERROR: in target '//external:cc_toolchain': error loading package '@local_config_cc//': Extension file not found. Unable to load file '@local_config_cc//:dummy_toolchain.bzl': file doesn't exist or isn't a file. INFO: Elapsed time: 3.343s ERROR: Could not build Bazel Found by git bisect. *** Original change description *** Add a new toolchain type for c++. In order to do this, 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: 166750885
* Add a new toolchain type for c++. In order to do this, ↵Gravatar cpeyser2017-08-28
| | | | | | | | 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: 166509298
* Fix osx_cc_wrapper.sh for multiple rpathsGravatar Marcel Hlopko2017-08-18
| | | | | | | | | | | | | | osx_cc_wrapper.sh was not working correctly in cases when multiple rpaths were specified on linking command line. This cl modifies the wrapper to record all rpaths, and use the rpath that corresponds to a particular library when updating libraries install name. Fixes #3450 RELNOTES: None. Change-Id: I614694a792b6724a1db9814ee25af1802560c463 PiperOrigin-RevId: 165618946
* windows_cc_configure.bzl: Clear PATH, INCLUDE, LIB envsGravatar Yun Peng2017-08-04
| | | | | | | | | | | | | This change prevents leaking irrelevant envs to C++ actions. Before running VCVARSALL.BAT, we set PATH=<system root> INCLUDE= LIB= See https://github.com/bazelbuild/bazel/issues/3500 Change-Id: I767a36a3be3c8c01ad5cac2a7762edd34047e1bf PiperOrigin-RevId: 164242012
* Add no_stripping feature to MSVC CROSSTOOLGravatar Yun Peng2017-08-04
| | | | | | | | | | | | If no_stripping feature is enabled, then strip action config is not necessary, building stripped binary will just copy the orignial binary. Fix https://github.com/bazelbuild/bazel/issues/3482 Also fixed CI breakage: https://github.com/bazelbuild/bazel/issues/3505 Change-Id: Ie78fe174c42248c9b3e930008eef96dcd1864741 PiperOrigin-RevId: 164237588
* Simplify copts handling and expose them as a build variableGravatar hlopko2017-08-02
| | | | | | | | | | | This cl changes copts to be immutable (and changes addCopts methods into setCopts, so it's simpler to reason about copts) and exposes copts as a build variable. It also introduces CompileBuildVariablesTest, similar to LinkBuildVariablesTest, to test that right build variables are exposed for right actions. RELNOTES: None. PiperOrigin-RevId: 163876774
* Fix UNIX linker detection (was erroneously disabling ld.gold)Gravatar Allen Lavoie2017-08-01
| | | | | | | | | | Adds back a compiler test empty .cc file. Seems to be an omission in https://github.com/bazelbuild/bazel/commit/65cda4f219e564ccb190b2992151658dfae9904 The _is_gold_supported check in unix_cc_configure.bzl always fails without this change, since the file it's checking with isn't created. Looks like there may be other effects through _add_option_if_supported, although I only noticed because apparently I have written linker-specific code. Closes #3484. PiperOrigin-RevId: 163832465
* MSVC CROSSTOOL: Stop adding -g in debug modeGravatar pcloudy2017-07-31
| | | | | | | Fix https://github.com/bazelbuild/bazel/issues/3473 RELNOTES: None PiperOrigin-RevId: 163686215
* MSVC CROSSTOOL: Remove some legacy featuresGravatar pcloudy2017-07-31
| | | | | RELNOTES: None PiperOrigin-RevId: 163679651
* Add preprocessor_defines feature for MSVC CROSSTOOLGravatar pcloudy2017-07-31
| | | | | | | | Fix https://github.com/bazelbuild/bazel/issues/3474 Fix https://github.com/bazelbuild/bazel/issues/3472 RELNOTES: None PiperOrigin-RevId: 163677371
* windows_cc_configure.bzl: Set maxsplit to 1 when parsing environment variablesGravatar pcloudy2017-07-25
| | | | | | | fix https://github.com/bazelbuild/bazel/issues/3442 RELNOTES: PiperOrigin-RevId: 163039890
* Windows, CROSSTOOL: add subsystem flag feature in theGravatar Laszlo Csomor2017-07-20
| | | | | | | | | BUILD file. They must use "-" instead of "/" otherwise Bazel believes the linkopts entry declares a (invalid) label. Change-Id: I6ad33c3f51c37f59e7d3b92be872fc4e2b27d434 PiperOrigin-RevId: 162597691
* Add support for Visual Studio 2017 in cc_configure auto-detection and our ↵Gravatar Philipp Wollermann2017-07-14
| | | | | | | | | Python tests. RELNOTES: None. Change-Id: I76c4f11323b1c0690e20d54f129abd671275acb0 PiperOrigin-RevId: 161934858
* Remove /DOS_WINDOWS from Windows CROSSTOOLGravatar pcloudy2017-07-14
| | | | | | | Fixed https://github.com/bazelbuild/bazel/issues/3366 RELNOTES: None PiperOrigin-RevId: 161926642
* Add *_alias rules to @bazel_tools so that people don't have to keep writing ↵Gravatar lberki2017-07-14
| | | | | | | | | | their own. The alias_rules.bzl hack is required because Bazel at HEAD needs to be able to be built with released Bazel, which doesn't know these rules yet. RELNOTES: None. PiperOrigin-RevId: 161808672
* 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
* Windows: Switch wrapper-less CROSSTOOL to defaultGravatar pcloudy2017-07-12
| | | | | | | | | set USE_MSVC_WRAPPER=1 if you still want to use wrapper script. RELNOTES: Windows: Wrapper-less CROSSTOOL becomes default now. set USE_MSVC_WRAPPER=1 if you still want to use wrapper script. PiperOrigin-RevId: 161654018
* Add /DNOMINMAX back to CROSSTOOLGravatar pcloudy2017-07-10
| | | | | | | | | /DNOMINMAX is a very common use and no one has complained about it yet, so keep it in CROSSTOOL Fixed https://github.com/bazelbuild/bazel/issues/3347 RELNOTES: None. PiperOrigin-RevId: 161381862