aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
Commit message (Collapse)AuthorAge
* Pull out useful parts of discoverInputs into findAdditionalInputs so that it ↵Gravatar Googler2018-02-14
| | | | | | | can also be called by getInputFilesForExtraAction rather than duplicating the logic. RELNOTES: None PiperOrigin-RevId: 185757663
* Add a CODEC for CppCompileAction.Gravatar cpeyser2018-02-14
| | | | PiperOrigin-RevId: 185733313
* Set extra action tool path to the value that crosstool will actually use ↵Gravatar Googler2018-02-13
| | | | | | based on feature configuration PiperOrigin-RevId: 185600940
* Replaces InjectingObjectCodec with dependencies threaded through ↵Gravatar shahan2018-02-13
| | | | | | (Des|S)erializationContext. PiperOrigin-RevId: 185547740
* Ensure that RuleContext is not referenced after analysis by objc_library.Gravatar cparsons2018-02-12
| | | | | | Previously, RuleContext was referenced via the objc implementation of CppSemantics. Objects of that class are no longer held by CppCompileAction post-analysis. PiperOrigin-RevId: 185446320
* 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
* Split CppIncludeScanningContext out of CppCompileActionContextGravatar ulfjack2018-02-08
| | | | | | Rename IncludeScanningContext to CppIncludeExtractionContext, which more closely matches its semantics. PiperOrigin-RevId: 184974810
* Add a CODEC for some dependencies of CppCompileAction: CompileCommandLine andGravatar cpeyser2018-02-07
| | | | | | | | CcToolchainFeatures.Variables. We rephrase the nocopts filter from a Predicate<String> to a custom class, since AutoCodec cannot serialize a Predicate. PiperOrigin-RevId: 184902162
* Generate a CODEC for CppCompilationContext using AutoCodec. This is ↵Gravatar cpeyser2018-02-06
| | | | | | | | required in order to serialize CppCompileAction. Rephrase CppCompilationContext's pregreppedHeaders field as its own value class instead of Pair<Artifact, Artifact>. We do this because NestedSet support in AutoCodec cannot serialize a NestedSet of a generic type. PiperOrigin-RevId: 184740075
* Remove the CppConfiguration field from CppCompileAction. MakingGravatar cpeyser2018-01-30
| | | | | | CppCompileAction smaller improves serialization. PiperOrigin-RevId: 183871454
* Drop CppCompileAction.actionContextGravatar ulfjack2018-01-30
| | | | | | It always set to the same value. PiperOrigin-RevId: 183843518
* C++: Refactors CLIF rule to go through CcLibraryHelper.Gravatar plf2018-01-26
| | | | | | | | | | | TBD: finish pulling out CLIF logic from the C++ rules implementation. This involves refactoring ArtifactCategory and CppSource.Type. CLIF does PIC compilation now. This detail should be irrelevant to users since CLIF only cares about the matched protobuf output file. SKIP_KOKORO=flakes RELNOTES:none PiperOrigin-RevId: 183396902
* Make experimental_inmemory_dotd_files not fail with local executionGravatar ulfjack2018-01-26
| | | | | | If actions are executed locally, silently fall back to reading the on-disk .d file. PiperOrigin-RevId: 183376432
* Add CommandLineItem interface.Gravatar tomlu2018-01-25
| | | | | | | | This interface makes it clearer in the type system exactly how items that go into a CustomCommandLine are turned into strings. It is a preparatory change to allow command line fingerprints to be more cheaply calculated, but it is valuable in itself from a code quality standpoint. PiperOrigin-RevId: 183274022
* Fix usages of PathFragment segments that will become inefficient.Gravatar tomlu2018-01-19
| | | | | | | An upcoming replacement to PathFragment will not have efficient segment semantics, causing code to become unnecessarily inefficient. RELNOTES: None PiperOrigin-RevId: 182553098
* Introduce Root class.Gravatar tomlu2018-01-17
| | | | | | | | | | | This class represents a root (such as a package path or an output root) used for file lookups and artifacts. It is meant to be as opaque as possible in order to hide the user's environment from sky keys and sky functions. Roots are used by RootedPaths and ArtifactRoots. This CL attempts to make the minimum number of modifications necessary to change RootedPath and ArtifactRoot to use these fields. Deprecated methods and invasive accessors are permitted to minimise the risk of any observable changes. RELNOTES: None PiperOrigin-RevId: 182271759
* Change the mnemonic of C++ link stamp compile actions so that extra actions ↵Gravatar lberki2018-01-16
| | | | | | | can be attached to C++ compile actions without tickling the bug that makes Blaze crash when extra actions are attached to shared actions that do input discovery. RELNOTES: None. PiperOrigin-RevId: 182044169
* Convert ActionLookupKey implementations to directly implement SkyKey, ↵Gravatar janakr2018-01-11
| | | | | | removing the layer of indirection of getting SkyKey out of ActionLookupKey, which uses more memory for no reason. PiperOrigin-RevId: 181658615
* Redo FileType to reduce generated garbage.Gravatar tomlu2017-12-22
| | | | | | | | | | | | | * Change FileType to no longer assume it operates on just the base name (it can now be given a full path). * Move the responsibility to specific classes (Artifact, Path, PathFragment) to decide how they want to offer up a string that includes the file name. * Flip the order in which users are expected to check Artifact type, from FileType#matches(Artifact) to Artifact#isFileType(FileType). This looks natural and should encourage developers to use efficient file type checking methods. * Change CppCompileAction to use the new API. RELNOTES: None PiperOrigin-RevId: 179903239
* Automated rollback of commit 367f704e71f352b404df38161f4c367b9ff506c9.Gravatar hlopko2017-12-12
| | | | | | | | | | | | | | *** Reason for rollback *** Rollforward of https://github.com/bazelbuild/bazel/commit/c861c0afd9a4df283936218b9e5b33c452b07c95 after fixing fake link actions. *** Original change description *** Rollback of 178106899. RELNOTES: Linkstamping is now a separate and full-blown CppCompileAction, it's no longer a part of linking command. PiperOrigin-RevId: 178760072
* Rollback of 178106899.Gravatar cpeyser2017-12-08
| | | | PiperOrigin-RevId: 178384991
* Register separate linkstamp compile actionGravatar hlopko2017-12-06
| | | | | | | | | | | | | | | | | This cl replaces entire hardcoded linkstamping command line generation with a separate action. Instead of generating bash command to compile linkstamp and prepending it to the standard link command line, this cl creates a special action that link action depends on. I kept linkstamp action registration in the CppLinkActionBuilder (and GoCompilationHelper internally) to keep the cl shorter and change more localized. I also didn't remove linkstamps and buildInfoHeaderArtifacts from CppLinkAction to stay compatible with extra actions api. Both issues and corresponding cleanups will be addressed in separate cls. RELNOTES: Linkstamping is now a separate and full-blown CppCompileAction, it's no longer a part of linking command. PiperOrigin-RevId: 178106899
* Add ActionKeyContext to Action#getKey.Gravatar tomlu2017-11-29
| | | | | | | This key context can be used by actions to share partial key computations, for instance when computing MD5s for nested sets. RELNOTES: None PiperOrigin-RevId: 177359607
* Remove some unused extension points.Gravatar Googler2017-11-29
| | | | | RELNOTES: None. PiperOrigin-RevId: 177326265
* Return SpawnResults using a List instead of a Set.Gravatar ruperts2017-11-21
| | | | | | | | | Currently we don't care about the list order of SpawnResults. However, we may care about the list order later. Also, if the equals() method for SpawnResults is ever changed then it may be problematic to return SpawnResults in a Set. Aside: ActionResults use SpawnResults to calculate cumulative execution times for Actions, and may provide other metrics in future. RELNOTES: None. PiperOrigin-RevId: 176579460
* 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
* Thread FileSystem through to a single Path#delete call site.Gravatar tomlu2017-10-30
| | | | | | This requires a fairly large amount of changes to fundamental objects like BlazeRuntime, Executor, and so on, as well as changing a lot of test code to thread the file system through. I expect future CLs to be much smaller. PiperOrigin-RevId: 173678144
* Actions now have the option of returning an ActionResult, containing a ↵Gravatar ruperts2017-10-18
| | | | | | | (possibly empty) set of SpawnResults created during execution of the Action. RELNOTES: None. PiperOrigin-RevId: 172529328
* Migrate usage of CppConfiguration#getToolPathFragment andGravatar cpeyser2017-10-11
| | | | | | CppConfiguration#getLdExecutable to CcToolchainProvider. PiperOrigin-RevId: 171818406
* More SpawnResult-related plumbing changes to Actions, Strategies, ↵Gravatar ruperts2017-10-07
| | | | | | | | | ActionContexts, etc., so that SpawnResult metadata is returned upwards. Note that the TODOs mostly refer to changes that will appear in a subsequent CL (a CL to return SpawnResults, contained in ActionResults, from Actions/AbstractActions). I split off the remaining SpawnResult-related changes into this CL and kept the ActionResult-related changes separate. RELNOTES: None. PiperOrigin-RevId: 171355611
* Use FeatureConfiguration to compute linkstamping compile command lineGravatar hlopko2017-09-25
| | | | | | | | | Before, linkstamping compile actions were hardcoded in bazel and assumed gcc/clang and bash. This cl removes gcc/clang assumptions by using feature configuration. RELNOTES: None. PiperOrigin-RevId: 169685949
* 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
* 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
* Make per-file-copts part of the user_compile_flagsGravatar hlopko2017-09-12
| | | | | | | | | This cl adds flags from --per_file_copts option to 'user_compile_flags' build variable. This changes the flag order, before they appeared after unfiltered flags, now they appear before. RELNOTES: None. PiperOrigin-RevId: 168221663
* Automated rollback of commit 70f84252a0f1669564ef3c92c4adeda9b5a22f50.Gravatar ulfjack2017-09-12
| | | | | | | | | | | | | | | | *** Reason for rollback *** Introduced a UI regression. See #3534. *** Original change description *** Avoid relying on System.out/err going to the terminal Use an appropriate EventHandler instead. PiperOrigin-RevId: 168218216
* 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
* Internal changeGravatar kush2017-09-07
| | | | PiperOrigin-RevId: 167751263
* Introduce unfiltered_compile_flags build variable, rename copts variable to ↵Gravatar hlopko2017-09-06
| | | | | | | | | | 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. RELNOTES: None. PiperOrigin-RevId: 167587189
* Allow CommandLine expansion to throw an exception.Gravatar tomlu2017-08-24
| | | | | | | | | | | | | | | | | | | This paves the way for Skylark-side compact command lines that can fail during expansion. In general, expansion happens in these scenarios: * Action execution expands the command line to execute it. This is fine since we are well equipped already to handle failing actions. * In the analysis phase we expand command lines to investigate whether we need a params file. This could be moved to the execution phase, which would have the benefit of getting params files out of the action graph and saving memory. * Key computation expands the command line. This could be fixed by allowing command lines to compute their own keys (which wouldn't try to expand the command line). This could have the benefit of being more efficient. * Extra actions expand the command line to construct the extra action proto. This could maybe be deferred to the execution phase (writing the extra action), which would also be more memory efficient. For failed key computations, we return a singleton "error" key. This means multiple actions that will fail will map to the same key. These actions will necessarily fail if executed, so we should not need to worry about these ending up in the action cache. If we do manage to make the command line compute its own keys then this will become moot in the future. RELNOTES: None PiperOrigin-RevId: 166266385
* 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
* 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
* Avoid relying on System.out/err going to the terminalGravatar ulfjack2017-07-07
| | | | | | Use an appropriate EventHandler instead. PiperOrigin-RevId: 161189061
* Rewrite the Executor/ActionExecutionContext splitGravatar ulfjack2017-06-19
| | | | | | | Move everything to ActionExecutionContext, and drop Executor whereever possible. This clarifies the API, makes it simpler to test, and simplifies the code. PiperOrigin-RevId: 159414816
* Also filter stderr when parse_showincludes feature is enabledGravatar Yun Peng2017-06-13
| | | | | | | | | | On Windows, cl.exe generates include information to stdout. But when using the cuda compiler(nvcc.exe) to invoke cl.exe, it's redirected to stderr. So we need to parse the output of stderr as well. Change-Id: I9a763a6eefa531932bf1077ef4155f6bda934240 PiperOrigin-RevId: 158842448
* Introduce CompileCommandLineBuilder and CompileCommandLineTestGravatar hlopko2017-06-12
| | | | | RELNOTES: NONE. PiperOrigin-RevId: 158703123
* 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
* Use FeatureConfiguration to compute value of CC_FLAGS make variableGravatar hlopko2017-05-26
| | | | | | | | | | | | | | | | | | | | | | | | | This cl introduces new action_config type for Crosstool named 'generic'. This can be used to set the value of CC_FLAGS make variable using much more expressive mechanism (action_configs + features) than previous make_variable Crosstool messages. This has been requested by the C++ LPT. However, as FeatureConfiguration needs RuleContext, CC_FLAGS cannot be computed using configuration only anymore. Also, FeatureConfiguration is C++ rules specific class, and Bazel build-base cannot depend on it. Therefore we cannot use FeatureConfiguration for ExtraActions, for example. Because it cannot be made perfect, this cl is not updating all the possible places that expand make variables but limits the scope to: * genrule (the only widely used rule that often expands make variables) * *_test (CC_FLAGS is used by Tensorflow in the 'args' attribute) * cc_rules (people sometimes set 'copts' to something like: "-DCC_STRING=\\\"$(CC)\\\" -DCC_FLAGS_STRING=\"$(CC_FLAGS)\"" The long term plan is to use Skylark C++ API to get C++ command lines, so CC_FLAGS together with this inconsistent solution will be removed. RELNOTES: CC_FLAGS can be defined using 'generic' action_config in CROSSTOOL PiperOrigin-RevId: 157202883
* 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