Skip to content

Commit b07549d

Browse files
comiuscopybara-github
authored andcommitted
Remove native C++ linking code
Remove the flag and native code paths. Remove testComputeKeyStatic that were covering only native code. Move LinkBuildVariables into the LinkBuildVariablesTest. The only remaining use. Substitute dummy-exec-requirement with supports-exec-requirement. Stalark actions filter exec requirements that don't start with a set of predefined strings. PiperOrigin-RevId: 747737688 Change-Id: I425c0f7aec4205ef6027eb690840293d2f45fc04
1 parent 5d53bf6 commit b07549d

19 files changed

+133
-3216
lines changed

src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppSemantics.java

-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import com.google.devtools.build.lib.rules.cpp.CppCompileActionBuilder;
3535
import com.google.devtools.build.lib.rules.cpp.CppConfiguration;
3636
import com.google.devtools.build.lib.rules.cpp.CppFileTypes;
37-
import com.google.devtools.build.lib.rules.cpp.CppLinkActionBuilder;
3837
import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;
3938
import net.starlark.java.eval.EvalException;
4039
import net.starlark.java.eval.Sequence;
@@ -120,10 +119,6 @@ public void finalizeCompileActionBuilder(
120119
}
121120
}
122121

123-
@Override
124-
public void finalizeLinkActionBuilder(
125-
CppConfiguration configuration, CppLinkActionBuilder actionBuilder) throws EvalException {}
126-
127122
@Override
128123
public boolean allowIncludeScanning() {
129124
return true;

src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java

-977
This file was deleted.

src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java

-263
Large diffs are not rendered by default.

src/main/java/com/google/devtools/build/lib/rules/cpp/CcStarlarkInternal.java

+63-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static com.google.devtools.build.lib.skyframe.BzlLoadValue.keyForBuild;
1919

2020
import com.google.common.base.Ascii;
21+
import com.google.common.base.Preconditions;
2122
import com.google.common.collect.ImmutableList;
2223
import com.google.common.collect.ImmutableMap;
2324
import com.google.common.collect.ImmutableSet;
@@ -38,6 +39,7 @@
3839
import com.google.devtools.build.lib.cmdline.Label;
3940
import com.google.devtools.build.lib.collect.nestedset.Depset;
4041
import com.google.devtools.build.lib.collect.nestedset.Depset.TypeException;
42+
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
4143
import com.google.devtools.build.lib.packages.Attribute.ComputedDefault;
4244
import com.google.devtools.build.lib.packages.AttributeMap;
4345
import com.google.devtools.build.lib.packages.Info;
@@ -709,18 +711,71 @@ public Args getArgs(
709711
@Param(name = "supports_dynamic_linker")
710712
})
711713
public StarlarkList<LibraryInput> convertLibraryToLinkListToLinkerInputList(
712-
Depset librariesToLink,
714+
Depset librariesToLinkDepset,
713715
boolean staticMode,
714716
boolean forDynamicLibrary,
715717
boolean supportsDynamicLinker)
716718
throws TypeException {
717-
return StarlarkList.copyOf(
718-
Mutability.IMMUTABLE,
719-
CcLinkingHelper.convertLibraryToLinkListToLinkerInputList(
720-
librariesToLink.getSet(LibraryToLink.class),
721-
staticMode,
722-
forDynamicLibrary,
723-
supportsDynamicLinker));
719+
// LINT.IfChange
720+
NestedSet<LibraryToLink> librariesToLink = librariesToLinkDepset.getSet(LibraryToLink.class);
721+
722+
ImmutableList.Builder<LibraryInput> libraryInputsBuilder = ImmutableList.builder();
723+
for (LibraryToLink libraryToLink : librariesToLink.toList()) {
724+
LibraryInput staticLibraryInput =
725+
libraryToLink.getStaticLibrary() == null ? null : libraryToLink.getStaticLibraryInput();
726+
LibraryInput picStaticLibraryInput =
727+
libraryToLink.getPicStaticLibrary() == null
728+
? null
729+
: libraryToLink.getPicStaticLibraryInput();
730+
LibraryInput libraryInputToUse = null;
731+
if (staticMode) {
732+
if (forDynamicLibrary) {
733+
if (picStaticLibraryInput != null) {
734+
libraryInputToUse = picStaticLibraryInput;
735+
} else if (staticLibraryInput != null) {
736+
libraryInputToUse = staticLibraryInput;
737+
}
738+
} else {
739+
if (staticLibraryInput != null) {
740+
libraryInputToUse = staticLibraryInput;
741+
} else if (picStaticLibraryInput != null) {
742+
libraryInputToUse = picStaticLibraryInput;
743+
}
744+
}
745+
if (libraryInputToUse == null) {
746+
if (libraryToLink.getInterfaceLibrary() != null) {
747+
libraryInputToUse = libraryToLink.getInterfaceLibraryInput();
748+
} else if (libraryToLink.getDynamicLibrary() != null) {
749+
libraryInputToUse = libraryToLink.getDynamicLibraryInput();
750+
}
751+
}
752+
} else {
753+
if (libraryToLink.getInterfaceLibrary() != null) {
754+
libraryInputToUse = libraryToLink.getInterfaceLibraryInput();
755+
} else if (libraryToLink.getDynamicLibrary() != null) {
756+
libraryInputToUse = libraryToLink.getDynamicLibraryInput();
757+
}
758+
if (libraryInputToUse == null || !supportsDynamicLinker) {
759+
if (forDynamicLibrary) {
760+
if (picStaticLibraryInput != null) {
761+
libraryInputToUse = picStaticLibraryInput;
762+
} else if (staticLibraryInput != null) {
763+
libraryInputToUse = staticLibraryInput;
764+
}
765+
} else {
766+
if (staticLibraryInput != null) {
767+
libraryInputToUse = staticLibraryInput;
768+
} else if (picStaticLibraryInput != null) {
769+
libraryInputToUse = picStaticLibraryInput;
770+
}
771+
}
772+
}
773+
}
774+
Preconditions.checkNotNull(libraryInputToUse);
775+
libraryInputsBuilder.add(libraryInputToUse);
776+
}
777+
return StarlarkList.copyOf(Mutability.IMMUTABLE, libraryInputsBuilder.build());
778+
// LINT.ThenChange(//src/main/starlark/builtins_bzl/common/cc/link/convert_linker_inputs.bzl)
724779
}
725780

726781
@StarlarkMethod(

src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java

-9
Original file line numberDiff line numberDiff line change
@@ -1020,13 +1020,4 @@ public boolean experimentalStarlarkCompiling(StarlarkThread thread) throws EvalE
10201020
CcModule.checkPrivateStarlarkificationAllowlist(thread);
10211021
return cppOptions.experimentalStarlarkCompiling;
10221022
}
1023-
1024-
@StarlarkMethod(
1025-
name = "experimental_starlark_linking",
1026-
documented = false,
1027-
useStarlarkThread = true)
1028-
public boolean experimentalStarlarkLinking(StarlarkThread thread) throws EvalException {
1029-
CcModule.checkPrivateStarlarkificationAllowlist(thread);
1030-
return cppOptions.experimentalStarlarkLinking;
1031-
}
10321023
}

src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java

-141
This file was deleted.

0 commit comments

Comments
 (0)