@@ -635,6 +635,12 @@ public LibraryToLink createLibraryLinkerInput(
635635 "If you pass '%s_library', you must also pass a 'feature_configuration'" , library );
636636 }
637637 }
638+ if (nopicObjects != null && staticLibrary == null ) {
639+ throw Starlark .errorf ("If you pass 'objects' you must also pass a 'static_library'" );
640+ }
641+ if (picObjects != null && picStaticLibrary == null ) {
642+ throw Starlark .errorf ("If you pass 'pic_objects' you must also pass a 'pic_static_library'" );
643+ }
638644 if (notNullArtifactForIdentifier == null ) {
639645 throw Starlark .errorf ("Must pass at least one artifact" );
640646 }
@@ -1798,7 +1804,7 @@ public Tuple createLinkingContextFromCompilationOutputs(
17981804 CcToolchainProvider starlarkCcToolchainProvider ,
17991805 CcCompilationOutputs compilationOutputs ,
18001806 Sequence <?> userLinkFlags , // <String> expected
1801- Sequence <?> linkingContextsObjects , // <CcLinkingContext> expected
1807+ Sequence <?> linkingContexts , // <CcLinkingContext> expected
18021808 String name ,
18031809 String languageString ,
18041810 boolean alwayslink ,
@@ -1808,11 +1814,9 @@ public Tuple createLinkingContextFromCompilationOutputs(
18081814 Object grepIncludes ,
18091815 Object variablesExtension ,
18101816 Object stamp ,
1811- Object linkedDllNameSuffix ,
1812- Object winDefFile ,
18131817 StarlarkThread thread )
18141818 throws InterruptedException , EvalException {
1815- if (checkObjectsBound (stamp , linkedDllNameSuffix , winDefFile )) {
1819+ if (checkObjectsBound (stamp )) {
18161820 CcModule .checkPrivateStarlarkificationAllowlist (thread );
18171821 }
18181822 Language language = parseLanguage (languageString );
@@ -1841,8 +1845,6 @@ public Tuple createLinkingContextFromCompilationOutputs(
18411845 } else {
18421846 staticLinkTargetType = LinkTargetType .OBJC_ARCHIVE ;
18431847 }
1844- List <CcLinkingContext > ccLinkingContexts =
1845- Sequence .cast (linkingContextsObjects , CcLinkingContext .class , "linking_contexts" );
18461848 CcLinkingHelper helper =
18471849 new CcLinkingHelper (
18481850 actions .getActionConstructionContext ().getRuleErrorConsumer (),
@@ -1866,42 +1868,43 @@ public Tuple createLinkingContextFromCompilationOutputs(
18661868 .addNonCodeLinkerInputs (
18671869 Sequence .cast (additionalInputs , Artifact .class , "additional_inputs" ))
18681870 .setShouldCreateStaticLibraries (!disallowStaticLibraries )
1869- .addCcLinkingContexts (ccLinkingContexts )
18701871 .setShouldCreateDynamicLibrary (
18711872 !disallowDynamicLibraries
1872- && (!featureConfiguration
1873- .getFeatureConfiguration ()
1874- .isEnabled (CppRuleClasses .TARGETS_WINDOWS )
1875- || winDefFile != null ))
1873+ && !featureConfiguration
1874+ .getFeatureConfiguration ()
1875+ .isEnabled (CppRuleClasses .TARGETS_WINDOWS ))
18761876 .setStaticLinkType (staticLinkTargetType )
18771877 .setDynamicLinkType (LinkTargetType .NODEPS_DYNAMIC_LIBRARY )
18781878 .emitInterfaceSharedLibraries (true )
1879- .setLinkedDLLNameSuffix (
1880- convertFromNoneable (linkedDllNameSuffix , /* defaultValue= */ "" ))
1881- .setDefFile (convertFromNoneable (winDefFile , /* defaultValue= */ null ))
18821879 .setIsStampingEnabled (isStampingEnabled )
18831880 .addLinkopts (Sequence .cast (userLinkFlags , String .class , "user_link_flags" ));
18841881 if (!asDict (variablesExtension ).isEmpty ()) {
18851882 helper .addVariableExtension (new UserVariablesExtension (asDict (variablesExtension )));
18861883 }
18871884 try {
1885+ CcLinkingOutputs ccLinkingOutputs = CcLinkingOutputs .EMPTY ;
18881886 ImmutableList <LibraryToLink > libraryToLink = ImmutableList .of ();
1889- CcLinkingOutputs ccLinkingOutputs = helper .link (compilationOutputs );
1890- if (!ccLinkingOutputs .isEmpty ()) {
1891- LibraryToLink rewrappedForAlwaysLink =
1892- ccLinkingOutputs .getLibraryToLink ().toBuilder ().setAlwayslink (alwayslink ).build ();
1893- ccLinkingOutputs =
1894- CcLinkingOutputs .builder ()
1895- .setExecutable (ccLinkingOutputs .getExecutable ())
1896- .setLibraryToLink (rewrappedForAlwaysLink )
1897- .addAllLtoArtifacts (ccLinkingOutputs .getAllLtoArtifacts ())
1898- .build ();
1899- libraryToLink = ImmutableList .of (rewrappedForAlwaysLink );
1887+ if (!compilationOutputs .isEmpty ()) {
1888+ ccLinkingOutputs = helper .link (compilationOutputs );
1889+ if (!ccLinkingOutputs .isEmpty ()) {
1890+ libraryToLink =
1891+ ImmutableList .of (
1892+ ccLinkingOutputs .getLibraryToLink ().toBuilder ()
1893+ .setAlwayslink (alwayslink )
1894+ .build ());
1895+ }
19001896 }
19011897 CcLinkingContext linkingContext =
19021898 helper .buildCcLinkingContextFromLibrariesToLink (
19031899 libraryToLink , CcCompilationContext .EMPTY );
1904- return Tuple .of (linkingContext , ccLinkingOutputs );
1900+ return Tuple .of (
1901+ CcLinkingContext .merge (
1902+ ImmutableList .<CcLinkingContext >builder ()
1903+ .add (linkingContext )
1904+ .addAll (
1905+ Sequence .cast (linkingContexts , CcLinkingContext .class , "linking_contexts" ))
1906+ .build ()),
1907+ ccLinkingOutputs );
19051908 } catch (RuleErrorException e ) {
19061909 throw Starlark .errorf ("%s" , e .getMessage ());
19071910 }
@@ -1999,7 +2002,7 @@ protected Tuple compile(
19992002 Object textualHeadersStarlarkObject ,
20002003 Object additionalExportedHeadersObject ,
20012004 Sequence <?> includes , // <String> expected
2002- Object starlarkLooseIncludes ,
2005+ Object starlarkIncludes ,
20032006 Sequence <?> quoteIncludes , // <String> expected
20042007 Sequence <?> systemIncludes , // <String> expected
20052008 Sequence <?> frameworkIncludes , // <String> expected
@@ -2039,15 +2042,15 @@ protected Tuple compile(
20392042 hdrsCheckingModeObject ,
20402043 implementationCcCompilationContextsObject ,
20412044 coptsFilterObject ,
2042- starlarkLooseIncludes )) {
2045+ starlarkIncludes )) {
20432046 CcModule .checkPrivateStarlarkificationAllowlist (thread );
20442047 }
20452048
20462049 StarlarkActionFactory actions = starlarkActionFactoryApi ;
20472050 CcToolchainProvider ccToolchainProvider =
20482051 convertFromNoneable (starlarkCcToolchainProvider , null );
20492052
2050- ImmutableList <String > looseIncludes = asClassImmutableList (starlarkLooseIncludes );
2053+ ImmutableList <String > looseIncludes = asClassImmutableList (starlarkIncludes );
20512054 CppModuleMap moduleMap = convertFromNoneable (moduleMapNoneable , /* defaultValue= */ null );
20522055 ImmutableList <CppModuleMap > additionalModuleMaps =
20532056 asClassImmutableList (additionalModuleMapsNoneable );
0 commit comments