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

Commit

Permalink
buck/rust: remove support for --extern-location
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jsgf authored and facebook-github-bot committed Apr 20, 2022
1 parent 4d3809b commit fd0ddba
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
public class PrebuiltRustLibraryDescription
implements DescriptionWithTargetGraph<PrebuiltRustLibraryDescriptionArg>,
VersionPropagator<PrebuiltRustLibraryDescriptionArg> {
private final RustBuckConfig rustBuckConfig;

public PrebuiltRustLibraryDescription(RustBuckConfig rustBuckConfig) {
this.rustBuckConfig = rustBuckConfig;
}

@Override
public Class<PrebuiltRustLibraryDescriptionArg> getConstructorArgType() {
Expand Down Expand Up @@ -88,8 +83,7 @@ public com.facebook.buck.rules.args.Arg getLinkerArg(
ruleFlags,
args.getRlib(),
directDependent,
dependentFilesystem.relativize(rlibAbsolutePath).toString(),
rustBuckConfig.getExternLocations());
dependentFilesystem.relativize(rlibAbsolutePath).toString());
}

@Override
Expand Down
13 changes: 0 additions & 13 deletions src/com/facebook/buck/features/rust/RustBuckConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class RustBuckConfig {
private static final String PREFER_STATIC_LIBS = "prefer_static_libs";
private static final String RUSTC_INCREMENTAL = "incremental";
private static final String DEFAULT_EDITION = "default_edition";
private static final String EXTERN_LOCATIONS = "extern_locations";
private static final String RUSTC_PLUGIN_PLATFORM = "rustc_plugin_platform";
private static final String NATIVE_UNBUNDLE_DEPS = "native_unbundle_deps";

Expand Down Expand Up @@ -230,18 +229,6 @@ boolean getUnflavoredBinaries() {
return delegate.getBooleanValue(SECTION, UNFLAVORED_BINARIES, false);
}

/**
* Get extern_locations option. This controls whether to pass `--extern-location` to rustc for
* each `--extern` so that when it reports an unused dependency it can refer to the actual Buck
* target and dependency in question. The location is a json object with `target` (unflavored
* build target) and `dep` (unflavored dependency for target) keys.
*
* @return Boolean of whether to pass --extern-location to rustc.
*/
boolean getExternLocations() {
return delegate.getBooleanValue(SECTION, EXTERN_LOCATIONS, false);
}

/**
* Get source path remapping option. This controls whether we ask rustc to remap source paths in
* all output (ie, compiler messages, file!() macros, debug info, etc).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public Collection<Description<?>> getDescriptions(DescriptionCreationContext con
new RustBinaryDescription(toolchainProvider, rustBuckConfig, downwardApiConfig),
new RustLibraryDescription(toolchainProvider, rustBuckConfig, downwardApiConfig),
new RustTestDescription(toolchainProvider, rustBuckConfig, downwardApiConfig),
new PrebuiltRustLibraryDescription(rustBuckConfig));
new PrebuiltRustLibraryDescription());
}
}
23 changes: 2 additions & 21 deletions src/com/facebook/buck/features/rust/RustLibraryArg.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
* referenced by. Indirect dependencies are not explicitly enumerated; instead the `-Ldependency`
* option adds a search directory in which dependencies can be found (in practice with Buck builds,
* there's one directory per dependency).
*
* <p>We also keep the target name we're adding the dependency for, and the target a dependent crate
* comes from. This is so we can pass an `--extern-location` option to rustc which allows compiler
* diagnostics for unused dependencies to directly reference the dependency which needs to be
* removed.
*/
@BuckStyleValue
public abstract class RustLibraryArg implements Arg, HasSourcePath {
Expand Down Expand Up @@ -70,20 +65,15 @@ public abstract class RustLibraryArg implements Arg, HasSourcePath {
@AddToRuleKey
public abstract String getRlibRelativePath();

/// True if the `extern_locations` option is set.
@AddToRuleKey
public abstract boolean getExternLoc();

public static RustLibraryArg of(
BuildTarget target,
String crate,
ImmutableList<String> flags,
SourcePath rlib,
Optional<BuildTarget> directDependent,
String rlibRelativePath,
boolean extern_loc) {
String rlibRelativePath) {
return ImmutableRustLibraryArg.ofImpl(
target, crate, flags, rlib, directDependent, rlibRelativePath, extern_loc);
target, crate, flags, rlib, directDependent, rlibRelativePath);
}

@Override
Expand All @@ -108,15 +98,6 @@ public void appendToCommandLine(

consumer.accept(
String.format("--extern=%s%s=%s", externQualifiers, crate, getRlibRelativePath()));
if (getExternLoc()) {
// assume targets never need json string quoting
consumer.accept(
String.format(
"--extern-location=%s=json:{\"target\":\"%s\",\"dep\":\"%s\"}",
crate,
directDep.get().withoutFlavors().getFullyQualifiedName(),
getTarget().getFullyQualifiedName()));
}
} else {
consumer.accept(
String.format("-Ldependency=%s", Paths.get(getRlibRelativePath()).getParent()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ public Arg getLinkerArg(
ruleFlags,
rlib,
directDependent,
dependentFilesystem.relativize(rlibAbsolutePath).toString(),
rustBuckConfig.getExternLocations());
dependentFilesystem.relativize(rlibAbsolutePath).toString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.facebook.buck.features.rust;

import com.facebook.buck.core.config.FakeBuckConfig;
import com.facebook.buck.core.model.BuildTarget;
import com.facebook.buck.core.model.BuildTargetFactory;
import com.facebook.buck.core.model.targetgraph.AbstractNodeBuilder;
Expand All @@ -37,9 +36,8 @@ private PrebuiltRustLibraryBuilder(
}

public static PrebuiltRustLibraryBuilder from(String target) {
RustBuckConfig config = new RustBuckConfig(FakeBuckConfig.builder().build());
return new PrebuiltRustLibraryBuilder(
new PrebuiltRustLibraryDescription(config), BuildTargetFactory.newInstance(target));
new PrebuiltRustLibraryDescription(), BuildTargetFactory.newInstance(target));
}

public PrebuiltRustLibraryBuilder setRlib(SourcePath rlib) {
Expand Down

0 comments on commit fd0ddba

Please sign in to comment.