From fd0ddbafe681fc5ac87095079ca4bb1dc6d9e96a Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Tue, 19 Apr 2022 20:23:23 -0700 Subject: [PATCH] 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 https://github.com/rust-lang/rust/pull/96086 so remove support for it here. Reviewed By: cjhopman fbshipit-source-id: 3509c3b2680a3a86fc782839f2a12312674f9d52 --- .../rust/PrebuiltRustLibraryDescription.java | 8 +------ .../buck/features/rust/RustBuckConfig.java | 13 ----------- .../rust/RustDescriptionsProvider.java | 2 +- .../buck/features/rust/RustLibraryArg.java | 23 ++----------------- .../features/rust/RustLibraryDescription.java | 3 +-- .../rust/PrebuiltRustLibraryBuilder.java | 4 +--- 6 files changed, 6 insertions(+), 47 deletions(-) diff --git a/src/com/facebook/buck/features/rust/PrebuiltRustLibraryDescription.java b/src/com/facebook/buck/features/rust/PrebuiltRustLibraryDescription.java index 5c67c7e4e35..adca706b364 100644 --- a/src/com/facebook/buck/features/rust/PrebuiltRustLibraryDescription.java +++ b/src/com/facebook/buck/features/rust/PrebuiltRustLibraryDescription.java @@ -42,11 +42,6 @@ public class PrebuiltRustLibraryDescription implements DescriptionWithTargetGraph, VersionPropagator { - private final RustBuckConfig rustBuckConfig; - - public PrebuiltRustLibraryDescription(RustBuckConfig rustBuckConfig) { - this.rustBuckConfig = rustBuckConfig; - } @Override public Class getConstructorArgType() { @@ -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 diff --git a/src/com/facebook/buck/features/rust/RustBuckConfig.java b/src/com/facebook/buck/features/rust/RustBuckConfig.java index 44c10f18524..12bdc8224a0 100644 --- a/src/com/facebook/buck/features/rust/RustBuckConfig.java +++ b/src/com/facebook/buck/features/rust/RustBuckConfig.java @@ -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"; @@ -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). diff --git a/src/com/facebook/buck/features/rust/RustDescriptionsProvider.java b/src/com/facebook/buck/features/rust/RustDescriptionsProvider.java index 0a40080f995..065f86d50e9 100644 --- a/src/com/facebook/buck/features/rust/RustDescriptionsProvider.java +++ b/src/com/facebook/buck/features/rust/RustDescriptionsProvider.java @@ -40,6 +40,6 @@ public Collection> getDescriptions(DescriptionCreationContext con new RustBinaryDescription(toolchainProvider, rustBuckConfig, downwardApiConfig), new RustLibraryDescription(toolchainProvider, rustBuckConfig, downwardApiConfig), new RustTestDescription(toolchainProvider, rustBuckConfig, downwardApiConfig), - new PrebuiltRustLibraryDescription(rustBuckConfig)); + new PrebuiltRustLibraryDescription()); } } diff --git a/src/com/facebook/buck/features/rust/RustLibraryArg.java b/src/com/facebook/buck/features/rust/RustLibraryArg.java index f5b04607ba1..03765e8a17e 100644 --- a/src/com/facebook/buck/features/rust/RustLibraryArg.java +++ b/src/com/facebook/buck/features/rust/RustLibraryArg.java @@ -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). - * - *

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 { @@ -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 flags, SourcePath rlib, Optional 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 @@ -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())); diff --git a/src/com/facebook/buck/features/rust/RustLibraryDescription.java b/src/com/facebook/buck/features/rust/RustLibraryDescription.java index 829cd0960b3..5e9f8bb06a7 100644 --- a/src/com/facebook/buck/features/rust/RustLibraryDescription.java +++ b/src/com/facebook/buck/features/rust/RustLibraryDescription.java @@ -357,8 +357,7 @@ public Arg getLinkerArg( ruleFlags, rlib, directDependent, - dependentFilesystem.relativize(rlibAbsolutePath).toString(), - rustBuckConfig.getExternLocations()); + dependentFilesystem.relativize(rlibAbsolutePath).toString()); } @Override diff --git a/test/com/facebook/buck/features/rust/PrebuiltRustLibraryBuilder.java b/test/com/facebook/buck/features/rust/PrebuiltRustLibraryBuilder.java index 50af3f60428..e420b679d35 100644 --- a/test/com/facebook/buck/features/rust/PrebuiltRustLibraryBuilder.java +++ b/test/com/facebook/buck/features/rust/PrebuiltRustLibraryBuilder.java @@ -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; @@ -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) {