aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/cpp/CROSSTOOL.tpl
Commit message (Collapse)AuthorAge
* Unify action_configs for static librariesGravatar hlopko2018-03-12
| | | | | | | | | | | We don't need to separate them into 4 different flavours, all crosstools define them identically anyway. RELNOTES: CppRules: Unified action_configs for static libraries From now on only c++-link-static-library is read. PiperOrigin-RevId: 188726352
* CROSSTOOLS: Fix comment for /EHsc compiler flagGravatar Samer Masterson2018-03-02
| | | | | | | | The previous comment referred to the option `/EHa`, but `/EHsc` is the option to only catch C++ standards (which seems to be what we want, according to this doc: https://msdn.microsoft.com/en-us/library/1deeycx5.aspx) Closes #4739. PiperOrigin-RevId: 187593737
* Introduce a specific action_config for linking nodeps dynamic librariesGravatar hlopko2018-03-01
| | | | | | | | | | | | | With this cl toolchain author can specify different flags for linking shared library produced by cc_library and a shared library produced by cc_binary. This is what is needed to remove linking_mode_flags - MOSTLY_STATIC_LIBRARIES from the crosstool. What this linking mode was used for was to separate when we link transitive shared library from cc_binary and when we link this little-and-not-really-useful-outside-of-bazel nodeps shared library in cc_library. RELNOTES: CcToolchain: Introduced action_config for "c++-link-transitive-dynamic-library" PiperOrigin-RevId: 187523334
* Automated rollback of commit c7e343ad314aeab6283b5939bc8126a112140a11.Gravatar plf2018-02-16
| | | | | | | | | | | | | | | *** Reason for rollback *** Rolling back after having come up with a more principled solution in b/73047818 that will add a more generic attribute called additional_linker_inputs so that users can depend on any file of any type and reference it from linkopts. *** Original change description *** C++: Allows adding linkopts through file. The file can be generated during execution by a different rule. RELNOTES:none PiperOrigin-RevId: 185977745
* C++: Allows adding linkopts through file.Gravatar plf2018-02-12
| | | | | | | The file can be generated during execution by a different rule. RELNOTES:none PiperOrigin-RevId: 185361140
* Introduce -c source_file -o output_file build variablesGravatar hlopko2018-02-08
| | | | | | | | | | | | | | 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. Encore of https://github.com/bazelbuild/bazel/commit/f26e8694ae78599b3e2004e3360eaf3443fa53a6. RELNOTES: None. PiperOrigin-RevId: 184981106
* Automated rollback of commit 2aeaeba66857c561dd6d63c79a213f1cabc3650d.Gravatar dslomov2018-01-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks C++ on gcc 4.8.4 (specifically, TensorFlow: https://github.com/bazelbuild/bazel/issues/4474) Fixes #4474 *** Original change description *** When linking mostly-static Linux binaries, link libstdc++.a explicitly. This allows libstdc++ to be statically linked, which is normally only possible when invoking GCC as `g++` with the `-static-libstdc++` flag. Fixes https://github.com/bazelbuild/bazel/issues/2840 See https://github.com/envoyproxy/envoy/issues/415 for additional background and context. cc @htuch (for Envoy) and @calpeyser @hlopko (who I talked to earlier about this)... *** RELNOTES: None. PiperOrigin-RevId: 182519445
* Refactor Windows C++ toolchain selectionGravatar Yun Peng2018-01-03
| | | | | | | | | | | | | | | | | | | We used to have --cpu=x64_windows_msys for selecting msys gcc toolchain, this is a misuse of --cpu flag. Instead, we should use --compiler flag to select C++ toolchain. For example, --compiler=msvc-cl, --compiler=msys-gcc, --compiler=mingw-gcc After this change, we can use mingw gcc toolchain by following steps: 1. In MSYS, install mingw by `pacman -S mingw-w64-x86_64-gcc` 2. Add /mingw64:/mingw64/bin into PATH 3. build with --compiler=mingw-gcc Related: https://github.com/bazelbuild/rules_go/issues/736 Change-Id: I4b5f77ce0698cfcafefe5d2ab17657f9c9e295d3 PiperOrigin-RevId: 180678829
* When linking mostly-static Linux binaries, link libstdc++.a explicitly.Gravatar John Millikin2017-12-12
| | | | | | | | | | | | | | | | | | This allows libstdc++ to be statically linked, which is normally only possible when invoking GCC as `g++` with the `-static-libstdc++` flag. Fixes https://github.com/bazelbuild/bazel/issues/2840 See https://github.com/envoyproxy/envoy/issues/415 for additional background and context. cc @htuch (for Envoy) and @calpeyser @hlopko (who I talked to earlier about this) I'm only doing this in the Linux toolchain because MacOS doesn't do static linking of system libs anyway, and I don't know enough about Windows or FreeBSD to test on those platforms. Closes #4031. PiperOrigin-RevId: 178762357
* Windows MSVC CROSSTOOL: Don't pass /DEBUG:FASTLINK to linker if it doesn't ↵Gravatar Yun Peng2017-12-11
| | | | | | | | | | | | | | support it This makes Bazel work nicer with VC++ version prior to VC++ 2015, but it doesn't mean we fully support them. For example, /WHOLEARCHIVE doesn't work with versions older that VC++ 2015, either. Fixed https://github.com/bazelbuild/bazel/issues/3109 Fixed https://github.com/bazelbuild/bazel/issues/4240 Change-Id: Iab7280bea241a203cb04dc9ca0a7b3bce518fb64 PiperOrigin-RevId: 178615516
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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, 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
* Remove /DOS_WINDOWS from Windows CROSSTOOLGravatar pcloudy2017-07-14
| | | | | | | Fixed https://github.com/bazelbuild/bazel/issues/3366 RELNOTES: None PiperOrigin-RevId: 161926642
* 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
* Remove some unnecessary compiler_flags from Windows CROSSTOOLGravatar pcloudy2017-07-07
| | | | | | | After reviewing these options' meanings, I don't think we need to put them in CROSSTOOL. Users can add them in their own BUILD files if needed, so that they don't have to undefine them. See https://github.com/bazelbuild/bazel/pull/3310 RELNOTES: None PiperOrigin-RevId: 161177879
* Assume crosstools that don't have 'no_legacy_features' feature need patchingGravatar hlopko2017-07-06
| | | | | | | | | | | | | Right now there are 2 ways how to control crosstool patches. If there is 'no_legacy_features' feature defined, no patching will be performed. If there is not, then depending on whether any c++ action_config is defined one set of patches is applied, or other set of patches is applied. It's a mess, and in the most cases, crosstools that do not define 'no_legacy_features' need the full patching. This cl fixes the crosstools that need the partial patching. RELNOTES: Crosstool patches are only applied if the toolchain doesn't define 'no_legacy_features' feature. PiperOrigin-RevId: 160979463
* Remove implicit iteration from CrosstoolGravatar hlopko2017-07-05
| | | | | | | | | | | | | | | | | Up until now we allowed implicit iteration, e.g.: flag_group { flag: '%{some_sequence_variable}' } From now on, snippet above will raise an error. We require explicit 'iterate_over' message, e.g.: flag_group { iterate_over: 'some_sequence_variable' flag: '%{some_sequence_variable}' } RELNOTES: Implicit iteration in the CROSSTOOL has been removed, use explicit 'iterate_over' message. PiperOrigin-RevId: 160871888
* Get rid of batch script in MSVC CROSSTOOLGravatar Yun Peng2017-06-26
| | | | | | | Now the MSVC CROSSTOOL can truly be wrapper-free! \o/ RELNOTES: None. PiperOrigin-RevId: 159962674
* Also add TEMP into msvc_env featureGravatar Yun Peng2017-06-12
| | | | | Change-Id: Ia2510a2b8df728c02f77e2df4effff3232cfe3a2 PiperOrigin-RevId: 158685074
* 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
* Remove /W3 from compiler_flag from MSVC CROSSTOOLGravatar pcloudy2017-05-24
| | | | | | | | | The default warning level will become /W1 which only display severe warnings. https://msdn.microsoft.com/en-us/library/thxezb7y.aspx RELNOTES: None PiperOrigin-RevId: 156972872
* 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
* Reformat Bazel crosstools to have consistent 2 spaces indentGravatar hlopko2017-04-28
| | | | | RELNOTES: None. PiperOrigin-RevId: 154426101
* Parse /showIncludes output for MSVC compilerGravatar Yun Peng2017-04-25
| | | | | | | | Instead of parsing .d file generated by wrapper script, we directly parse the output of /showIncludes option. Change-Id: Id94e20a5cb05a494a793fd6a43756d44d27cea8a PiperOrigin-RevId: 154161939
* Clean up more things in MSVC wrapper scriptsGravatar Yun Peng2017-04-24
| | | | | | | | | | | 1. Moved /nologo flag into feature 2. No need to specify -m64, adding /MACHINVE:X64 as linker flag 3. Still use wrapper script to add /MT or /MD for now, because our users are depending on it: https://github.com/bazelbuild/bazel/issues/2120 We need a plan first before move them into CROSSTOOL Change-Id: If5e4c01a900fcf9e93877e04a893879897bff3a3 PiperOrigin-RevId: 154036870
* Generating PDB files on WindowsGravatar Yun Peng2017-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | 1. Add /Z7 as compiler flag in CROSSTOOL, this causes full debugging infomation built into object files, no PDB file is generated. 2. Add /DEBUG as linker flag so that a PDB file will be generated for executable or dll. * /DEBUG:FULL for dbg mode. the full PDB can be used to debug the executable when no other build products are available, such as when the executable is deployed. * /DEBUG:FASTLINK for fastbuild mode. object files are still needed when debugging the executable, but linking speed can be two to four times faster that full PDB generation. * No option is added for opt mode. More detailed info: https://msdn.microsoft.com/en-us/library/xe4t6fc1.aspx 3. Add an empty feature in MSVC CROSSTOOL to tell Bazel we need PDB file 4. Add PDB file artifact in an output named pdb_file of cc_binary, then you can build the pdb file by bazel build //foo/bar:bin --output_groups=pdb_file 5. Add test for PDB file generation Change-Id: Ia5096470187ebca72f2c804f32d5b723f40c0b85 PiperOrigin-RevId: 153449059
* 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