}.
*/
public String getSolibDirectory() {
return toolchainInfo.getSolibDirectory();
}
/**
* Returns the compilation mode.
*/
@Nullable
public CompilationMode getCompilationMode() {
return cppConfiguration == null ? null : cppConfiguration.getCompilationMode();
}
/**
* Returns whether the toolchain supports the gold linker.
*/
public boolean supportsGoldLinker() {
return toolchainInfo.supportsGoldLinker();
}
/**
* Returns whether the toolchain supports dynamic linking.
*/
public boolean supportsDynamicLinker() {
return toolchainInfo.supportsDynamicLinker();
}
/**
* Returns whether the toolchain supports linking C/C++ runtime libraries
* supplied inside the toolchain distribution.
*/
public boolean supportsEmbeddedRuntimes() {
return toolchainInfo.supportsEmbeddedRuntimes();
}
/**
* Returns whether the toolchain supports EXEC_ORIGIN libraries resolution.
*/
public boolean supportsExecOrigin() {
// We're rolling out support for this in the same release that also supports embedded runtimes.
return toolchainInfo.supportsEmbeddedRuntimes();
}
/** Returns whether the toolchain supports the --start-lib/--end-lib options. */
public boolean supportsStartEndLib() {
return toolchainInfo.supportsStartEndLib();
}
/**
* Returns whether this toolchain supports interface shared objects.
*
* Should be true if this toolchain generates ELF objects.
*/
public boolean supportsInterfaceSharedObjects() {
return toolchainInfo.supportsInterfaceSharedObjects();
}
@Nullable
public CppConfiguration getCppConfiguration() {
return cppConfiguration;
}
/** Returns build variables to be templated into the crosstool. */
public Variables getBuildVariables() {
return buildVariables;
}
/**
* Return the set of include files that may be included even if they are not mentioned in the
* source file or any of the headers included by it.
*/
public ImmutableList getBuiltinIncludeFiles() {
return builtinIncludeFiles;
}
/**
* Returns the environment variables that need to be added to tests that collect code coverage.
*/
public NestedSet> getCoverageEnvironment() {
return coverageEnvironment;
}
public ImmutableMap getEnvironment() {
return environment;
}
/**
* Returns the tool which should be used for linking dynamic libraries, or in case it's not
* specified by the crosstool this will be @tools_repository/tools/cpp:link_dynamic_library
*/
public Artifact getLinkDynamicLibraryTool() {
return linkDynamicLibraryTool;
}
/**
* Returns the tool that builds interface libraries from dynamic libraries.
*/
public Artifact getInterfaceSoBuilder() {
return interfaceSoBuilder;
}
@SkylarkCallable(
name = "sysroot",
structField = true,
doc =
"Returns the sysroot to be used. If the toolchain compiler does not support "
+ "different sysroots, or the sysroot is the same as the default sysroot, then "
+ "this method returns None
."
)
public PathFragment getSysroot() {
return sysroot;
}
/**
* Returns the path fragment that is either absolute or relative to the execution root that can be
* used to execute the given tool.
*/
public PathFragment getToolPathFragment(CppConfiguration.Tool tool) {
return toolchainInfo.getToolPathFragment(tool);
}
/**
* Returns the abi we're using, which is a gcc version. E.g.: "gcc-3.4". Note that in practice we
* might be using gcc-3.4 as ABI even when compiling with gcc-4.1.0, because ABIs are backwards
* compatible.
*/
// TODO(bazel-team): The javadoc should clarify how this is used in Blaze.
public String getAbi() {
return toolchainInfo.getAbi();
}
/**
* Returns the glibc version used by the abi we're using. This is a glibc version number (e.g.,
* "2.2.2"). Note that in practice we might be using glibc 2.2.2 as ABI even when compiling with
* gcc-4.2.2, gcc-4.3.1, or gcc-4.4.0 (which use glibc 2.3.6), because ABIs are backwards
* compatible.
*/
// TODO(bazel-team): The javadoc should clarify how this is used in Blaze.
public String getAbiGlibcVersion() {
return toolchainInfo.getAbiGlibcVersion();
}
/**
* Returns a label that references the library files needed to statically
* link the C++ runtime (i.e. libgcc.a, libgcc_eh.a, libstdc++.a) for the
* target architecture.
*/
public Label getStaticRuntimeLibsLabel() {
return toolchainInfo.getStaticRuntimeLibsLabel();
}
/**
* Returns a label that references the library files needed to dynamically
* link the C++ runtime (i.e. libgcc_s.so, libstdc++.so) for the target
* architecture.
*/
public Label getDynamicRuntimeLibsLabel() {
return toolchainInfo.getDynamicRuntimeLibsLabel();
}
/** Returns the compiler version string (e.g. "gcc-4.1.1"). */
@SkylarkCallable(name = "compiler", structField = true, doc = "C++ compiler.",
allowReturnNones = true)
public String getCompiler() {
return toolchainInfo == null ? null : toolchainInfo.getCompiler();
}
/** Returns the libc version string (e.g. "glibc-2.2.2"). */
@SkylarkCallable(name = "libc", structField = true, doc = "libc version string.",
allowReturnNones = true)
public String getTargetLibc() {
return toolchainInfo == null ? null : toolchainInfo.getTargetLibc();
}
/** Returns the target architecture using blaze-specific constants (e.g. "piii"). */
@SkylarkCallable(name = "cpu", structField = true, doc = "Target CPU of the C++ toolchain.",
allowReturnNones = true)
public String getTargetCpu() {
return toolchainInfo == null ? null : toolchainInfo.getTargetCpu();
}
/**
* Returns a map of additional make variables for use by {@link BuildConfiguration}. These are to
* used to allow some build rules to avoid the limits on stack frame sizes and variable-length
* arrays.
*
* The returned map must contain an entry for {@code STACK_FRAME_UNLIMITED}, though the entry
* may be an empty string.
*/
public ImmutableMap getAdditionalMakeVariables() {
return toolchainInfo.getAdditionalMakeVariables();
}
/**
* Returns whether the toolchain supports "Fission" C++ builds, i.e. builds where compilation
* partitions object code and debug symbols into separate output files.
*/
public boolean supportsFission() {
return toolchainInfo.supportsFission();
}
@SkylarkCallable(
name = "unfiltered_compiler_options_do_not_use",
doc =
"Returns the default list of options which cannot be filtered by BUILD "
+ "rules. These should be appended to the command line after filtering."
)
public ImmutableList getUnfilteredCompilerOptionsWithSysroot(Iterable features) {
return cppConfiguration.getUnfilteredCompilerOptionsDoNotUse(features, sysroot);
}
public ImmutableList getUnfilteredCompilerOptions(Iterable features) {
return cppConfiguration.getUnfilteredCompilerOptionsDoNotUse(features, /* sysroot= */ null);
}
@SkylarkCallable(
name = "link_options_do_not_use",
structField = true,
doc =
"Returns the set of command-line linker options, including any flags "
+ "inferred from the command-line options."
)
public ImmutableList getLinkOptionsWithSysroot() {
return cppConfiguration == null
? ImmutableList.of()
: cppConfiguration.getLinkOptionsDoNotUse(sysroot);
}
public ImmutableList getLinkOptions() {
return cppConfiguration.getLinkOptionsDoNotUse(/* sysroot= */ null);
}
/**
* Returns test-only link options such that certain test-specific features can be configured
* separately (e.g. lazy binding).
*/
public ImmutableList getTestOnlyLinkOptions() {
return toolchainInfo.getTestOnlyLinkOptions();
}
/** Returns the system name which is required by the toolchain to run. */
public String getHostSystemName() {
return toolchainInfo.getHostSystemName();
}
/**
* Returns the list of options to be used with 'objcopy' when converting binary files to object
* files, or {@code null} if this operation is not supported.
*/
public ImmutableList getObjCopyOptionsForEmbedding() {
return toolchainInfo.getObjCopyOptionsForEmbedding();
}
/**
* Returns the list of options to be used with 'ld' when converting binary files to object files,
* or {@code null} if this operation is not supported.
*/
public ImmutableList getLdOptionsForEmbedding() {
return toolchainInfo.getLdOptionsForEmbedding();
}
/**
* Returns link options for the specified flag list, combined with universal options for all
* shared libraries (regardless of link staticness).
*/
ImmutableList getSharedLibraryLinkOptions(FlagList flags, Iterable features) {
return toolchainInfo.getSharedLibraryLinkOptions(flags, features);
}
/** Returns compiler flags arising from the {@link CToolchain}. */
ImmutableList getToolchainCompilerFlags() {
return toolchainInfo.getCompilerFlags();
}
/** Returns additional compiler flags for C++ arising from the {@link CToolchain} */
ImmutableList getToolchainCxxFlags() {
return toolchainInfo.getCxxFlags();
}
/**
* Returns compiler flags arising from the {@link CToolchain} for C compilation by compilation
* mode.
*/
ImmutableListMultimap getCFlagsByCompilationMode() {
return toolchainInfo.getCFlagsByCompilationMode();
}
/**
* Returns compiler flags arising from the {@link CToolchain} for C++ compilation by compilation
* mode.
*/
ImmutableListMultimap getCxxFlagsByCompilationMode() {
return toolchainInfo.getCxxFlagsByCompilationMode();
}
/** Returns compiler flags arising from the {@link CToolchain} for C compilation by lipo mode. */
ImmutableListMultimap getLipoCFlags() {
return toolchainInfo.getLipoCFlags();
}
/**
* Returns compiler flags arising from the {@link CToolchain} for C++ compilation by lipo mode.
*/
ImmutableListMultimap getLipoCxxFlags() {
return toolchainInfo.getLipoCxxFlags();
}
/** Returns optional compiler flags arising from the {@link CToolchain}. */
ImmutableList getOptionalCompilerFlags() {
return toolchainInfo.getOptionalCompilerFlags();
}
/** Returns optional compiler flags for C++ arising from the {@link CToolchain}. */
ImmutableList getOptionalCxxFlags() {
return toolchainInfo.getOptionalCxxFlags();
}
/** Returns linker flags for fully statically linked outputs. */
FlagList getFullyStaticLinkFlags(CompilationMode compilationMode, LipoMode lipoMode) {
return new FlagList(
configureLinkerOptions(
compilationMode, lipoMode, LinkingMode.FULLY_STATIC),
FlagList.convertOptionalOptions(toolchainInfo.getOptionalLinkerFlags()),
ImmutableList.of());
}
/** Returns linker flags for mostly static linked outputs. */
FlagList getMostlyStaticLinkFlags(CompilationMode compilationMode, LipoMode lipoMode) {
return new FlagList(
configureLinkerOptions(
compilationMode, lipoMode, LinkingMode.MOSTLY_STATIC),
FlagList.convertOptionalOptions(toolchainInfo.getOptionalLinkerFlags()),
ImmutableList.of());
}
/** Returns linker flags for mostly static shared linked outputs. */
FlagList getMostlyStaticSharedLinkFlags(CompilationMode compilationMode, LipoMode lipoMode) {
return new FlagList(
configureLinkerOptions(
compilationMode,
lipoMode,
LinkingMode.MOSTLY_STATIC_LIBRARIES),
FlagList.convertOptionalOptions(toolchainInfo.getOptionalLinkerFlags()),
ImmutableList.of());
}
/** Returns linker flags for artifacts that are not fully or mostly statically linked. */
FlagList getDynamicLinkFlags(CompilationMode compilationMode, LipoMode lipoMode) {
return new FlagList(
configureLinkerOptions(
compilationMode, lipoMode, LinkingMode.DYNAMIC),
FlagList.convertOptionalOptions(toolchainInfo.getOptionalLinkerFlags()),
ImmutableList.of());
}
ImmutableList configureLinkerOptions(
CompilationMode compilationMode,
LipoMode lipoMode,
LinkingMode linkingMode) {
return toolchainInfo.configureLinkerOptions(
compilationMode, lipoMode, linkingMode);
}
/** Returns the GNU System Name */
@SkylarkCallable(
name = "target_gnu_system_name",
structField = true,
doc = "The GNU System Name.",
allowReturnNones = true
)
public String getTargetGnuSystemName() {
return toolchainInfo == null ? null : toolchainInfo.getTargetGnuSystemName();
}
/** Returns the architecture component of the GNU System Name */
public String getGnuSystemArch() {
return toolchainInfo.getGnuSystemArch();
}
public final boolean isLLVMCompiler() {
return toolchainInfo.isLLVMCompiler();
}
// Not all of CcToolchainProvider is exposed to Skylark, which makes implementing deep equality
// impossible: if Java-only parts are considered, the behavior is surprising in Skylark, if they
// are not, the behavior is surprising in Java. Thus, object identity it is.
@Override
public boolean equals(Object other) {
return other == this;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
}