aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
Commit message (Collapse)AuthorAge
* Save dwoFile on LTOBackendArtifacts objectGravatar Googler2017-11-14
| | | | | | | | | This is some clean up pulled out of unknown commit. It avoids needing to reconstruct the dwoFile, which will be harder when we move to using shared LTO backends in some cases. RELNOTES: None PiperOrigin-RevId: 175692708
* 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
* Replace all usages of Blaze's Preconditions class with guava.Gravatar tomlu2017-11-09
| | | | | | | | Blaze had its own class to avoid GC from varargs array creation for the precondition happy path. Guava now (mostly) implements these, making it unnecessary to maintain our own. This change was almost entirely automated by search-and-replace. A few BUILD files needed fixing up since I removed an export of preconditions from lib:util, which was all done by add_deps. There was one incorrect usage of Preconditions that was caught by error prone (which checks Guava's version of Preconditions) that I had to change manually. PiperOrigin-RevId: 175033526
* Don't keep set of LTO backend artifacts on link actionGravatar Googler2017-11-06
| | | | | | | | | | Small cleanup to avoid saving a set of the LTOBackendArtifact objects on the CppLinkAction. They can be accessed from the CppLinkActionBuilder, and keeping them on the CppLinkAction prevents them from being GC'ed when the builder is destroyed. RELNOTES: None PiperOrigin-RevId: 174469228
* Migrate CppConfiguration#supportsGoldLinker, supportsDynamicLinker,Gravatar cpeyser2017-10-31
| | | | | | supportsEmbeddedRuntimes, supportsExecOrigin to CcToolchainProvider. PiperOrigin-RevId: 173928009
* Replace all tool getters in CppConfiguration with corresponding calls toGravatar cpeyser2017-10-12
| | | | | | CcToolchainProvider#getToolPathFragment. PiperOrigin-RevId: 171837541
* Pass CppSemantics down to the CppLinkActionBuilderGravatar hlopko2017-09-29
| | | | | | | | | Currently CppLinkActionBuilder is not using CppSemantics, but it will when we use full CppCompileAction for linkstamp compiles. This cl is a preparation for that. RELNOTES: None. PiperOrigin-RevId: 170467826
* Make windows_export_all_symbols feature work for cc_binaryGravatar Yun Peng2017-09-28
| | | | | | | | | | | | | | | Now Bazel can also export symbols when building dynamic library from cc_binary. The interface library generated can be accessed by interface_library output group. The DEF file can still be accessed by def_file output group even when windows_export_all_symbols feature is not specified. This is useful when users want to filter symbols in DEF file before using it, for example, working around the 64K symbols number limit. Change-Id: I5b4dae0840e20037c00d500181c40b5faedfdcd8 PiperOrigin-RevId: 170330409
* Make the state in RuleContext explicitGravatar ulfjack2017-09-28
| | | | | | | | | | | | | | | | | | | | | This isn't ideal - RuleContext should not have state, but this ended up happening between adding a cache and refactoring how make variables are discovered. I have carefully traced back all callers that provide custom make variable suppliers and added an init call to their rule initialization. Note that the ConfigurationMakeVariableContext is _cached_, so callers that call in without any make variable suppliers and then call again with them would get the context from the previous call. We now enforce that the ConfigurationMakeVariableContext is only initialized once, and that this happens before any usage, which is slightly better than the previous state, where initialization was silently ignored on any subsequent call. Progress on #2475. PiperOrigin-RevId: 170312285
* Simplify CcLinkParams#addCcLibraryGravatar hlopko2017-09-25
| | | | | | | Some of the arguments are not used or are always passed blank. RELNOTES: None. PiperOrigin-RevId: 169899161
* 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
* Move RuleConfiguredTarget to lib.analysis.configuredtargets.Gravatar gregce2017-09-19
| | | | | | This is a trivial change with a large file footprint. PiperOrigin-RevId: 169169864
* Support multiple command lines / params files in SpawnAction.Gravatar tomlu2017-09-15
| | | | | | This is necessary for the upcoming Skylark implementation of param files. PiperOrigin-RevId: 168744486
* Don't attempt LTO indexing of cc_binary if there are no bitcode inputs to link.Gravatar Googler2017-09-12
| | | | | | | | | | | The problem is that the linker will not produce the expected .params file output if there are no inputs, and there is no need for this step in that case. This required adding a method to check if there are any bitcode inputs to the link either directly or indirectly via a library. This is the same walk done by createLtoArtifacts once we decide to do an LTO indexing step. RELNOTES: NONE PiperOrigin-RevId: 168281516
* Ensure ThinLTO backend actions always generate debug info when fission enabledGravatar Googler2017-08-29
| | | | | | | | | While we don't generate .dwp files for shared libraries, the link still expects the object files to contain split debug info. Enhanced tests to ensure the cc_library LTO backend actions always have the expected outputs/build variable, regardless of linking static or not. RELNOTES: NONE PiperOrigin-RevId: 166853630
* Use CustomCommandLine directly instead of via SpawnAction.Builder.Gravatar tomlu2017-08-24
| | | | | | | | | | | | | This change forces use of CustomCommandLine.Builder, which has a richer interface for constructing memory-efficient command lines. It will also permit surveying the code base for inefficient patterns using an IDE. This change was done by hand and split using Rosie to assist with rollbacks in case of bugs. Reviewers, please pay particular attention to: * Each all to addInputArgument/addOutputArgument should come with a corresponding matching pair to SpawnAction.Builder#addInput and CustomCommandLine.Builder#addExecPath (eg.). * The commandLine must be set on the SpawnAction using SpawnAction.Builder#setCommandLine. Note that most calls to addPrefixed("arg=", val) should be more idiomatically expressed as add("arg", val), but this involves changing tests and making sure that the command line tools can accept the format. PiperOrigin-RevId: 166205304
* Rename some of native declared providers according to the new naming scheme.Gravatar dslomov2017-08-21
| | | | | RELNOTES: None PiperOrigin-RevId: 165910455
* Simplify RunfilesSupport interface by having it call ↵Gravatar Googler2017-08-21
| | | | | | | RuleContext.shouldCreateRunfilesSymlinks() itself. RELNOTES: None. PiperOrigin-RevId: 165774395
* Move core test classes to lib.analysis.testGravatar ulfjack2017-08-11
| | | | | | | | These are depended upon by analysis code, so need to live in the same library as lib.analysis. Moving them here makes it possible to split the build-base library into separate libraries for analysis, execution, and rules. PiperOrigin-RevId: 164847161
* Move RuleConfiguredTargetFactory to lib.analysisGravatar ulfjack2017-08-07
| | | | | | | This is part of splitting up the build-base library into separate libraries for analysis, exec, and rules. PiperOrigin-RevId: 164446955
* Use feature configuration to construct command line for 'strip' actionGravatar hlopko2017-08-03
| | | | | | | | | | This cl introduces new action_config named 'strip' for the strip action. While at it, it fixes support for executionRequirements. Fixed #209 RELNOTES: 'strip' action is now configured via feature configuration PiperOrigin-RevId: 164110478
* Use camel case in names that included "LTO".Gravatar Googler2017-08-02
| | | | | | As suggested in readability review for https://github.com/bazelbuild/bazel/commit/2789c97149a1f253b659aa0f2401f44705a3258f. Ended up being a fair number of changes, but I think I got them all. PiperOrigin-RevId: 163975846
* Platform -> ApplePlatform, to avoid ambiguity with the newly introducedGravatar cpeyser2017-07-07
| | | | | | Platform rule. PiperOrigin-RevId: 161203491
* Do not NPE crash when C++ actions are not configured in crosstoolGravatar hlopko2017-07-07
| | | | | | | Show meaningful message instead. RELNOTES: None. PiperOrigin-RevId: 161196096
* Move ExecutionRequirements to the lib.actions packageGravatar ulfjack2017-06-06
| | | | | | | | | It was previously the odd-one out in lib.analysis.actions, due to other code that wanted to depend on it without pulling in all of analysis. However, it's needed to interpret Spawn instances, and Spawn lives in lib.actions, so it makes more sense to move it there, and remove the special-casing. PiperOrigin-RevId: 158116684
* Automated g4 rollback of commit 6879d7ceff0e118fdecb0cabe5134979030b7cb8.Gravatar Googler2017-05-11
| | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Fixes memory issue that caused this CL to be rolled back. *** Original change description *** Automated g4 rollback of commit cbbb423663b154d82e3dfa5e9a56839583987999. *** Reason for rollback *** Need to roll this back as part of http://b/38171368 *** Original change description *** RELNOTES: Effectively remove sysroot from CppConfiguration and allow it to use select statements. PiperOrigin-RevId: 155651879
* Automated g4 rollback of commit cbbb423663b154d82e3dfa5e9a56839583987999.Gravatar Googler2017-05-10
| | | | | | | | | | | *** Reason for rollback *** Need to roll this back as part of http://b/38171368 *** Original change description *** RELNOTES: Effectively remove sysroot from CppConfiguration and allow it to use select statements. PiperOrigin-RevId: 155547813
* RELNOTES: Effectively remove sysroot from CppConfiguration and allow it to ↵Gravatar Googler2017-05-09
| | | | | | use select statements. PiperOrigin-RevId: 155480011
* 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
* Refactor all ctor callsites of PathFragment to instead call a static ↵Gravatar nharmata2017-04-05
| | | | | | | | | | | | 'create' method. This paves the way for changing PathFragment to e.g. an abstract class with multiple subclasses. This way we can split out the windows-specific stuff into one of these concrete classes, making the code more readable and also saving memory (since the shallow heap size of the NonWindowsPathFragment subclass will hopefully be smaller than that of the current PathFragment). This also lets us pursue gc churn optimizations. We can now do interning in PathFragment#create and can also get rid of unnecessary intermediate PathFragment allocations. RELNOTES: None PiperOrigin-RevId: 152145768
* Refactor scheduling of LTO Backend actions into CppLinkActionBuilderGravatar Googler2017-03-14
| | | | | | | | | | | | This was suggested in the review for unknown commit, which adds ThinLTO support to another client of CppLinkActionBuilder. The change required changing the constructor to take a FdoSupportProvider object instead of a FdoSupport object, so required changes to all callers. -- PiperOrigin-RevId: 150060046 MOS_MIGRATED_REVID=150060046
* Stop retrieving FdoSupport statically from hard-coded attribute ↵Gravatar Rumou Duan2017-02-14
| | | | | | | | | | ":cc_toolchain" in RuleContext, instead take the provider from users and pass it around to where it is used. This gives J2ObjcAspect the ability to specify the C++ toolchain attribute under a different name to avoid attribute conflicts with attached rules that have already declared attribute ":cc_toolchain". -- PiperOrigin-RevId: 147358325 MOS_MIGRATED_REVID=147358325
* Stop retrieving CcToolChainProvider statically from hard-coded attribute ↵Gravatar Rumou Duan2017-02-08
| | | | | | | | | | ":cc_toolchain" in RuleContext, instead take the provider from users and pass it around to where it is used. This gives J2ObjcAspect the ability to specify the C++ toolchain attribute under a different name to avoid attribute conflicts with attached rules that have already declared attribute ":cc_toolchain". -- PiperOrigin-RevId: 146920294 MOS_MIGRATED_REVID=146920294
* Description redacted.Gravatar Googler2017-01-23
| | | | | | -- PiperOrigin-RevId: 145091484 MOS_MIGRATED_REVID=145091484
* Fix bug in --experimental_link_dynamic_binaries_separately.Gravatar Googler2017-01-11
| | | | | | | | | | | | | | | If linkstatic was explicitly set to 0 for a non-test target, we didn't set CcLibraryHelper to create CcLinkOutputs, but would still try to link those in instead of the compile output. Instead, pull out a variable that puts this logic into a single spot. Also rename the flag to --experimental_link_compile_output_separately, which IMO makes slightly more sense. Not too important as I don't think we should keep this flag long-term anyway. -- PiperOrigin-RevId: 144194903 MOS_MIGRATED_REVID=144194903
* Use ExecutionRequirements.REQUIRES_DARWIN instead of hard-coding the stringGravatar Ulf Adams2017-01-09
| | | | | | -- PiperOrigin-RevId: 143933349 MOS_MIGRATED_REVID=143933349
* Update call sites to FileWriteAction to use the ↵Gravatar Jon Brandvein2016-12-20
| | | | | | | | | | --experimental_transparent_compression flag Also add test to ensure lazy strings aren't forced. -- PiperOrigin-RevId: 142496520 MOS_MIGRATED_REVID=142496520
* Fix bug introduced when pulling out test sources into their own library forGravatar Googler2016-12-19
| | | | | | | | | | linking. This can lead to conflicts if done for non-test binary targets. -- PiperOrigin-RevId: 142441056 MOS_MIGRATED_REVID=142441056
* Rollback of commit 52b34308428cfd117470c966d8df329f686fb9ed.Gravatar Marcel Hlopko2016-12-16
| | | | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Rolling forward, cl fixing underlying issue is uploaded, will land this one as soon as I get lgtm to the fix from emscripten crosstool owners. *** Original change description *** Automated [] rollback of commit 2d87bf1937c81ef84358fd5f6a372875f6c6fabf. *** Reason for rollback *** We have to roll back unknown commit, on which this one depends. Will resubmit after I fix the underlying issue. *** Original change description *** Support versioned shared library targets for cc_binary linkshared=1 This change allows versioned shared libraries (e.g. "libfoo.so.1.2") to be built and linked. -- PiperOrigin-RevId: 142263653 MOS_MIGRATED_REVID=142263653
* Add option to dynamically link in the compilation output of cc_test andGravatar Googler2016-12-16
| | | | | | | | | | | | | | | | | | | cc_binary if we are doing dynamic linking anyway. The additional option is only for a smooth rollout and will go away once everything works as expected. The benefit is in an incremental save-build-test-cycle. When editing a test (or any of it's transitive headers), the linker input currently changes, meaning we need to do the full link again before the test can run. However, in conjunction with the option --interface_shared_objects, this actually isn't necessary. With this new option, the test source gets compiled into a .so file and while that file changes with each source change, the .ifso file often does not change. Thus, the costly link linking to gether all the .so and .ifso files can be retrieved from cache. Thus, this change should remove this linking step from the critical path of many save-build-test-cycles. -- PiperOrigin-RevId: 142244352 MOS_MIGRATED_REVID=142244352
* Rollback of commit 2d87bf1937c81ef84358fd5f6a372875f6c6fabf.Gravatar Marcel Hlopko2016-12-16
| | | | | | | | | | | | | | | | | *** Reason for rollback *** We have to roll back unknown commit, on which this one depends. Will resubmit after I fix the underlying issue. *** Original change description *** Support versioned shared library targets for cc_binary linkshared=1 This change allows versioned shared libraries (e.g. "libfoo.so.1.2") to be built and linked. -- PiperOrigin-RevId: 142240145 MOS_MIGRATED_REVID=142240145
* Support versioned shared library targets for cc_binary linkshared=1Gravatar Googler2016-12-16
| | | | | | | | | This change allows versioned shared libraries (e.g. "libfoo.so.1.2") to be built and linked. -- PiperOrigin-RevId: 142193230 MOS_MIGRATED_REVID=142193230
* Add a testing Skylark module that exposes an ExecutionInfoProvider constructor.Gravatar Sergio Campama2016-12-12
| | | | | | -- PiperOrigin-RevId: 141594768 MOS_MIGRATED_REVID=141594768
* Move ThinLTO indexing and backend options to Crosstool feature configurationGravatar Googler2016-09-20
| | | | | -- MOS_MIGRATED_REVID=133609638
* Fix a bug that leads to unnecessary compiles of .pic.o files (and possibly)Gravatar Googler2016-09-12
| | | | | | | | | | | | | | | | | | | | | | others in opt compiles. A while back, we added a HIDDEN_TOP_LEVEL output group to CcBinary targets to ensure that --process_headers_in_dependencies works as expected for them. However, adding all HIDDEN_TOP_LEVEL files is actually too much and e.g. also contains .pic.o files which are expensive to build but not actually needed for the compile. The fundamental difference between CcLibrary and CcBinary targets here is that a CcBinary already declares most of its inputs as it needs all of them to link the binary. In contrast, CcLibraries wouldn't need any of they dependent .o files and thus wouldn't even try to build them. This changes splits out the header token files which are required to make --process_headers_in_dependencies work correctly and only adds those to HIDDEN_TOP_LEVEL outputs of binaries files. Also removing some unused code that was producing warnings. -- MOS_MIGRATED_REVID=132883722
* Remove the "cc_*.includes attribute must refer to the third_party directory" ↵Gravatar Lukacs Berki2016-08-31
| | | | | | | | | | | warning from Bazel. This behavior doesn't really make sense except within Google. Fixes #1286. -- MOS_MIGRATED_REVID=131813322
* Fix nocompile tests after commit b6fd4ed25b6201eaaabb14c389c02819184ad4a6. I ↵Gravatar Googler2016-08-24
| | | | | | | | | | | | | can't say that I fully know what I am doing, but this basically reinstantiates the old behavior. Before commit b6fd4ed25b6201eaaabb14c389c02819184ad4a6, transitive modules were added in getAdditionalInputs() (by adding both topLevelHeaderModules and impliedHeaderModules). I removed that, but we still need to create the corresponding symlinks, so adding transitiveModules outside of getAdditionalInputs now. -- MOS_MIGRATED_REVID=131139735
* Prune .pcm files based on the results of include scanning.Gravatar Googler2016-08-23
| | | | | | | Basically, take the set of headers found by #include scanning and check what modules they are coming from. If a module provides at least one of the required headers, it is required as are all of its dependent modules (because of the way modules are implemented). Only use the actually required modules as compilation inputs and as flags handed in on the command line. Also move the logic to calculate top-level modules from the analysis phase into the execution phase. In the long run, we might be able to completely remove this logic now, but for now, we want to be able to quickly switch between the old and the new behavior. Thus, pruning of modules is now guarded on a feature prune_module_headers. -- MOS_MIGRATED_REVID=131058820
* Set the LibraryIdentifier before building the LTO Indexing link actionGravatar Googler2016-08-18
| | | | | | | | | | Otherwise we fail the Precondition check added at the start of CppLinkAction build() for a shared library target's indexing action. Added a test which reproduces the issue without the fix. -- MOS_MIGRATED_REVID=130513291
* Differentiate between regular and alwayslink static libraries in ↵Gravatar Lukacs Berki2016-08-17
| | | | | | | LinkerInput#getArtifactCategory() and use this information to remove one use of LINK_LIBRARY_FILETYPES. -- MOS_MIGRATED_REVID=130400793