}.
*/
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 CcToolchainVariables 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;
}
/**
* 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;
}
@Override
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"). */
@Override
public String getCompiler() {
return toolchainInfo == null ? null : toolchainInfo.getCompiler();
}
/** Returns the libc version string (e.g. "glibc-2.2.2"). */
@Override
public String getTargetLibc() {
return toolchainInfo == null ? null : toolchainInfo.getTargetLibc();
}
/** Returns the target architecture using blaze-specific constants (e.g. "piii"). */
@Override
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();
}
@Override
// TODO(b/24373706): Remove this method once new C++ toolchain API is available
public ImmutableList getUnfilteredCompilerOptionsWithSysroot(
Iterable featuresNotUsedAnymore) {
return toolchainInfo.getUnfilteredCompilerOptions(sysroot);
}
public ImmutableList getUnfilteredCompilerOptions() {
return toolchainInfo.getUnfilteredCompilerOptions(/* sysroot= */ null);
}
/**
* Unused, for compatibility with things internal to Google.
*
* Deprecated: Use platforms.
*/
@Deprecated
public String getTargetOS() {
return toolchainInfo.getTargetOS();
}
@Override
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(ImmutableList flags) {
return toolchainInfo.getSharedLibraryLinkOptions(flags);
}
/** 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 linker flags for fully statically linked outputs. */
ImmutableList getLegacyFullyStaticLinkFlags(
CompilationMode compilationMode, LipoMode lipoMode) {
return configureAllLegacyLinkOptions(
compilationMode, lipoMode, LinkingMode.LEGACY_FULLY_STATIC);
}
/** Returns linker flags for mostly static linked outputs. */
ImmutableList getLegacyMostlyStaticLinkFlags(
CompilationMode compilationMode, LipoMode lipoMode) {
return configureAllLegacyLinkOptions(compilationMode, lipoMode, LinkingMode.STATIC);
}
/** Returns linker flags for mostly static shared linked outputs. */
ImmutableList getLegacyMostlyStaticSharedLinkFlags(
CompilationMode compilationMode, LipoMode lipoMode) {
return configureAllLegacyLinkOptions(
compilationMode, lipoMode, LinkingMode.LEGACY_MOSTLY_STATIC_LIBRARIES);
}
/** Returns linker flags for artifacts that are not fully or mostly statically linked. */
ImmutableList getLegacyDynamicLinkFlags(
CompilationMode compilationMode, LipoMode lipoMode) {
return configureAllLegacyLinkOptions(compilationMode, lipoMode, LinkingMode.DYNAMIC);
}
/**
* Return all flags coming from naked {@code linker_flag} fields in the crosstool. {@code
* linker_flag}s coming from linking_mode_flags and compilation_mode_flags are not included. If
* you need all possible linker flags, use {@link #configureAllLegacyLinkOptions(CompilationMode,
* LipoMode, LinkingMode)}.
*/
public ImmutableList getLegacyLinkOptions() {
return toolchainInfo.getLegacyLinkOptions();
}
/**
* Return all flags coming from {@code compiler_flag} crosstool fields excluding flags coming from
* --copt options and copts attribute.
*/
public ImmutableList getLegacyCompileOptions() {
ImmutableList.Builder coptsBuilder =
ImmutableList.builder()
.addAll(getToolchainCompilerFlags())
.addAll(getCFlagsByCompilationMode().get(cppConfiguration.getCompilationMode()))
.addAll(getLipoCFlags().get(cppConfiguration.getLipoMode()));
if (cppConfiguration.isOmitfp()) {
coptsBuilder.add("-fomit-frame-pointer");
coptsBuilder.add("-fasynchronous-unwind-tables");
coptsBuilder.add("-DNO_FRAME_POINTER");
}
return coptsBuilder.build();
}
public ImmutableList getLegacyCompileOptionsWithCopts() {
return ImmutableList.builder()
.addAll(getLegacyCompileOptions())
.addAll(cppConfiguration.getCopts())
.build();
}
/** Return all possible {@code linker_flag} flags from the crosstool. */
ImmutableList configureAllLegacyLinkOptions(
CompilationMode compilationMode, LipoMode lipoMode, LinkingMode linkingMode) {
return toolchainInfo.configureAllLegacyLinkOptions(compilationMode, lipoMode, linkingMode);
}
/** Returns the GNU System Name */
@Override
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();
}
public FdoMode getFdoMode() {
return fdoMode;
}
/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*/
@Override
public ImmutableList getCompilerOptions() {
return getLegacyCompileOptionsWithCopts();
}
/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* Returns the list of additional C-specific options to use for compiling C. These should be go
* on the command line after the common options returned by {@link
* CcToolchainProvider#getLegacyCompileOptionsWithCopts()}.
*/
@Override
public ImmutableList getCOptions() {
return cppConfiguration.getCOptions();
}
/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* Returns the list of additional C++-specific options to use for compiling C++. These should
* be on the command line after the common options returned by {@link #getCompilerOptions}.
*/
@Override
@Deprecated
public ImmutableList getCxxOptionsWithCopts() {
return ImmutableList.builder()
.addAll(getLegacyCxxOptions())
.addAll(cppConfiguration.getCxxopts())
.build();
}
public ImmutableList getLegacyCxxOptions() {
return ImmutableList.builder()
.addAll(getToolchainCxxFlags())
.addAll(getCxxFlagsByCompilationMode().get(cppConfiguration.getCompilationMode()))
.addAll(getLipoCxxFlags().get(cppConfiguration.getLipoMode()))
.build();
}
/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* Returns the immutable list of linker options for fully statically linked outputs. Does not
* include command-line options passed via --linkopt or --linkopts.
*
* @param sharedLib true if the output is a shared lib, false if it's an executable
*/
@Override
@Deprecated
public ImmutableList getFullyStaticLinkOptions(Boolean sharedLib) throws EvalException {
if (!sharedLib) {
throw new EvalException(
Location.BUILTIN, "fully_static_link_options is deprecated, new uses are not allowed.");
}
return CppHelper.getFullyStaticLinkOptions(cppConfiguration, this, sharedLib);
}
/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* Returns the immutable list of linker options for mostly statically linked outputs. Does not
* include command-line options passed via --linkopt or --linkopts.
*
* @param sharedLib true if the output is a shared lib, false if it's an executable
*/
@Override
@Deprecated
public ImmutableList getMostlyStaticLinkOptions(Boolean sharedLib) {
return CppHelper.getMostlyStaticLinkOptions(
cppConfiguration, this, sharedLib, /* shouldStaticallyLinkCppRuntimes= */ true);
}
/**
* WARNING: This method is only added to allow incremental migration of existing users. Please do
* not use in new code. Will be removed soon as part of the new Skylark API to the C++ toolchain.
*
* Returns the immutable list of linker options for artifacts that are not fully or mostly
* statically linked. Does not include command-line options passed via --linkopt or --linkopts.
*
* @param sharedLib true if the output is a shared lib, false if it's an executable
*/
@Override
@Deprecated
public ImmutableList getDynamicLinkOptions(Boolean sharedLib) {
return CppHelper.getDynamicLinkOptions(cppConfiguration, this, sharedLib);
}
// 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);
}
public boolean useLLVMCoverageMapFormat() {
return useLLVMCoverageMapFormat;
}
public boolean isCodeCoverageEnabled() {
return codeCoverageEnabled;
}
public boolean isHostConfiguration() {
return isHostConfiguration;
}
public boolean getForcePic() {
return forcePic;
}
public boolean getShouldStripBinaries() {
return shouldStripBinaries;
}
}