Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit fd0ddba

Browse files
jsgffacebook-github-bot
authored andcommitted
buck/rust: remove support for --extern-location
Summary: `--extern-location` was an experimental option in rustc to pass tool diagnostic information through rustc. It was used to pass location information for unused dependencies from Buck via rustc for consumption by rustfixdeps. This was removed in upstream rust in rust-lang/rust#96086 so remove support for it here. Reviewed By: cjhopman fbshipit-source-id: 3509c3b2680a3a86fc782839f2a12312674f9d52
1 parent 4d3809b commit fd0ddba

File tree

6 files changed

+6
-47
lines changed

6 files changed

+6
-47
lines changed

src/com/facebook/buck/features/rust/PrebuiltRustLibraryDescription.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
public class PrebuiltRustLibraryDescription
4343
implements DescriptionWithTargetGraph<PrebuiltRustLibraryDescriptionArg>,
4444
VersionPropagator<PrebuiltRustLibraryDescriptionArg> {
45-
private final RustBuckConfig rustBuckConfig;
46-
47-
public PrebuiltRustLibraryDescription(RustBuckConfig rustBuckConfig) {
48-
this.rustBuckConfig = rustBuckConfig;
49-
}
5045

5146
@Override
5247
public Class<PrebuiltRustLibraryDescriptionArg> getConstructorArgType() {
@@ -88,8 +83,7 @@ public com.facebook.buck.rules.args.Arg getLinkerArg(
8883
ruleFlags,
8984
args.getRlib(),
9085
directDependent,
91-
dependentFilesystem.relativize(rlibAbsolutePath).toString(),
92-
rustBuckConfig.getExternLocations());
86+
dependentFilesystem.relativize(rlibAbsolutePath).toString());
9387
}
9488

9589
@Override

src/com/facebook/buck/features/rust/RustBuckConfig.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class RustBuckConfig {
5050
private static final String PREFER_STATIC_LIBS = "prefer_static_libs";
5151
private static final String RUSTC_INCREMENTAL = "incremental";
5252
private static final String DEFAULT_EDITION = "default_edition";
53-
private static final String EXTERN_LOCATIONS = "extern_locations";
5453
private static final String RUSTC_PLUGIN_PLATFORM = "rustc_plugin_platform";
5554
private static final String NATIVE_UNBUNDLE_DEPS = "native_unbundle_deps";
5655

@@ -230,18 +229,6 @@ boolean getUnflavoredBinaries() {
230229
return delegate.getBooleanValue(SECTION, UNFLAVORED_BINARIES, false);
231230
}
232231

233-
/**
234-
* Get extern_locations option. This controls whether to pass `--extern-location` to rustc for
235-
* each `--extern` so that when it reports an unused dependency it can refer to the actual Buck
236-
* target and dependency in question. The location is a json object with `target` (unflavored
237-
* build target) and `dep` (unflavored dependency for target) keys.
238-
*
239-
* @return Boolean of whether to pass --extern-location to rustc.
240-
*/
241-
boolean getExternLocations() {
242-
return delegate.getBooleanValue(SECTION, EXTERN_LOCATIONS, false);
243-
}
244-
245232
/**
246233
* Get source path remapping option. This controls whether we ask rustc to remap source paths in
247234
* all output (ie, compiler messages, file!() macros, debug info, etc).

src/com/facebook/buck/features/rust/RustDescriptionsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public Collection<Description<?>> getDescriptions(DescriptionCreationContext con
4040
new RustBinaryDescription(toolchainProvider, rustBuckConfig, downwardApiConfig),
4141
new RustLibraryDescription(toolchainProvider, rustBuckConfig, downwardApiConfig),
4242
new RustTestDescription(toolchainProvider, rustBuckConfig, downwardApiConfig),
43-
new PrebuiltRustLibraryDescription(rustBuckConfig));
43+
new PrebuiltRustLibraryDescription());
4444
}
4545
}

src/com/facebook/buck/features/rust/RustLibraryArg.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@
3636
* referenced by. Indirect dependencies are not explicitly enumerated; instead the `-Ldependency`
3737
* option adds a search directory in which dependencies can be found (in practice with Buck builds,
3838
* there's one directory per dependency).
39-
*
40-
* <p>We also keep the target name we're adding the dependency for, and the target a dependent crate
41-
* comes from. This is so we can pass an `--extern-location` option to rustc which allows compiler
42-
* diagnostics for unused dependencies to directly reference the dependency which needs to be
43-
* removed.
4439
*/
4540
@BuckStyleValue
4641
public abstract class RustLibraryArg implements Arg, HasSourcePath {
@@ -70,20 +65,15 @@ public abstract class RustLibraryArg implements Arg, HasSourcePath {
7065
@AddToRuleKey
7166
public abstract String getRlibRelativePath();
7267

73-
/// True if the `extern_locations` option is set.
74-
@AddToRuleKey
75-
public abstract boolean getExternLoc();
76-
7768
public static RustLibraryArg of(
7869
BuildTarget target,
7970
String crate,
8071
ImmutableList<String> flags,
8172
SourcePath rlib,
8273
Optional<BuildTarget> directDependent,
83-
String rlibRelativePath,
84-
boolean extern_loc) {
74+
String rlibRelativePath) {
8575
return ImmutableRustLibraryArg.ofImpl(
86-
target, crate, flags, rlib, directDependent, rlibRelativePath, extern_loc);
76+
target, crate, flags, rlib, directDependent, rlibRelativePath);
8777
}
8878

8979
@Override
@@ -108,15 +98,6 @@ public void appendToCommandLine(
10898

10999
consumer.accept(
110100
String.format("--extern=%s%s=%s", externQualifiers, crate, getRlibRelativePath()));
111-
if (getExternLoc()) {
112-
// assume targets never need json string quoting
113-
consumer.accept(
114-
String.format(
115-
"--extern-location=%s=json:{\"target\":\"%s\",\"dep\":\"%s\"}",
116-
crate,
117-
directDep.get().withoutFlavors().getFullyQualifiedName(),
118-
getTarget().getFullyQualifiedName()));
119-
}
120101
} else {
121102
consumer.accept(
122103
String.format("-Ldependency=%s", Paths.get(getRlibRelativePath()).getParent()));

src/com/facebook/buck/features/rust/RustLibraryDescription.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ public Arg getLinkerArg(
357357
ruleFlags,
358358
rlib,
359359
directDependent,
360-
dependentFilesystem.relativize(rlibAbsolutePath).toString(),
361-
rustBuckConfig.getExternLocations());
360+
dependentFilesystem.relativize(rlibAbsolutePath).toString());
362361
}
363362

364363
@Override

test/com/facebook/buck/features/rust/PrebuiltRustLibraryBuilder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.facebook.buck.features.rust;
1818

19-
import com.facebook.buck.core.config.FakeBuckConfig;
2019
import com.facebook.buck.core.model.BuildTarget;
2120
import com.facebook.buck.core.model.BuildTargetFactory;
2221
import com.facebook.buck.core.model.targetgraph.AbstractNodeBuilder;
@@ -37,9 +36,8 @@ private PrebuiltRustLibraryBuilder(
3736
}
3837

3938
public static PrebuiltRustLibraryBuilder from(String target) {
40-
RustBuckConfig config = new RustBuckConfig(FakeBuckConfig.builder().build());
4139
return new PrebuiltRustLibraryBuilder(
42-
new PrebuiltRustLibraryDescription(config), BuildTargetFactory.newInstance(target));
40+
new PrebuiltRustLibraryDescription(), BuildTargetFactory.newInstance(target));
4341
}
4442

4543
public PrebuiltRustLibraryBuilder setRlib(SourcePath rlib) {

0 commit comments

Comments
 (0)