Flip -iree-llvm-link-embedded to true by default. (#7372)

Tying up loose ends on https://github.com/google/iree/issues/4717.

The system linking path is more flexible for debugging and integration with platform-specific tooling, while the embedded linking path is more portable and is likely to have better performance.

Summary of changes:

* Remove explicit `--iree-llvm-link-embedded=true` from targets using `dylib-sync`
* Remove test suites that were testing the embedded path explicitly (now duplicates of the default test suites)
* Disambiguate `iree-llvm-system-linker-path`/`IREE_LLVMAOT_SYSTEM_LINKER_PATH` and `iree-llvm-embedded-linker-path`/`IREE_LLVMAOT_EMBEDDED_LINKER_PATH` flags/env-vars
  * Also remove docs referencing them. If the automatic discovery fails, error messages should give enough context for developers to debug on their own.
* Include source build of `lld` in test targets that now depend on it
* Smooth out linker tool discovery in `EmbeddedLinkerTool.cpp`
diff --git a/benchmarks/TFLite/CMakeLists.txt b/benchmarks/TFLite/CMakeLists.txt
index e63ba22..358f117 100644
--- a/benchmarks/TFLite/CMakeLists.txt
+++ b/benchmarks/TFLite/CMakeLists.txt
@@ -98,7 +98,6 @@
     "--iree-llvm-target-triple=aarch64-none-linux-android29"
     "--iree-flow-inline-constants-max-byte-length=2048"
     "--iree-llvm-loop-unrolling=true"
-    "--iree-llvm-link-embedded=true"
   DRIVER
     "dylib-sync"
 )
diff --git a/benchmarks/TensorFlow/CMakeLists.txt b/benchmarks/TensorFlow/CMakeLists.txt
index 5076e16..11ce458 100644
--- a/benchmarks/TensorFlow/CMakeLists.txt
+++ b/benchmarks/TensorFlow/CMakeLists.txt
@@ -121,7 +121,6 @@
     "--iree-llvm-target-triple=aarch64-none-linux-android29"
     "--iree-flow-inline-constants-max-byte-length=2048"
     "--iree-llvm-loop-unrolling=true"
-    "--iree-llvm-link-embedded=true"
   DRIVER
     "dylib-sync"
 )
@@ -337,7 +336,6 @@
     "--iree-input-type=mhlo"
     "--iree-llvm-target-triple=aarch64-none-linux-android29"
     "--iree-flow-inline-constants-max-byte-length=2048"
-    "--iree-llvm-link-embedded=true"
   DRIVER
     "dylib-sync"
 )
diff --git a/build_tools/bazel/build_core.sh b/build_tools/bazel/build_core.sh
index 0147c6c..98fab39 100755
--- a/build_tools/bazel/build_core.sh
+++ b/build_tools/bazel/build_core.sh
@@ -35,7 +35,8 @@
 declare -a test_env_args=(
   --test_env=IREE_LLVMAOT_DISABLE=$IREE_LLVMAOT_DISABLE
   --test_env=IREE_VULKAN_DISABLE=$IREE_VULKAN_DISABLE
-  --action_env=IREE_LLVMAOT_LINKER_PATH=$IREE_LLVMAOT_LINKER_PATH
+  --action_env=IREE_LLVMAOT_SYSTEM_LINKER_PATH=$IREE_LLVMAOT_SYSTEM_LINKER_PATH
+  --action_env=IREE_LLVMAOT_EMBEDDED_LINKER_PATH=$IREE_LLVMAOT_EMBEDDED_LINKER_PATH
 )
 
 declare -a default_build_tag_filters=("-nokokoro")
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
index bbfc8e3..f5bc2e8 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -19,6 +19,7 @@
 
     # LLVM
     "@llvm-project//llvm:IPO": ["LLVMipo"],
+    "@llvm-project//lld:lld": ["lld"],
     # MLIR
     "@llvm-project//mlir:AllPassesAndDialects": ["MLIRAllDialects"],
     "@llvm-project//mlir:AffineToStandardTransforms": ["MLIRAffineToStandard"],
diff --git a/build_tools/kokoro/gcp_ubuntu/cmake/linux/riscv64/test.sh b/build_tools/kokoro/gcp_ubuntu/cmake/linux/riscv64/test.sh
index 2925954..f24a75d 100755
--- a/build_tools/kokoro/gcp_ubuntu/cmake/linux/riscv64/test.sh
+++ b/build_tools/kokoro/gcp_ubuntu/cmake/linux/riscv64/test.sh
@@ -38,6 +38,7 @@
 "${BUILD_HOST_DIR?}/install/bin/iree-translate" \
   -iree-input-type=mhlo \
   -iree-mlir-to-vm-bytecode-module -iree-hal-target-backends=dylib-llvm-aot \
+  -iree-llvm-link-embedded=false \
   -iree-llvm-target-triple=riscv64 \
   -iree-llvm-target-cpu=generic-rv64 \
   -iree-llvm-target-cpu-features="+m,+a,+f,+d,+c" \
diff --git a/docs/developers/get_started/getting_started_android_cmake.md b/docs/developers/get_started/getting_started_android_cmake.md
index c5c7ee0..df64baa 100644
--- a/docs/developers/get_started/getting_started_android_cmake.md
+++ b/docs/developers/get_started/getting_started_android_cmake.md
@@ -72,8 +72,6 @@
 ```
 
 Debugging note:
-  * If `IREE_LLVMAOT_LINKER_PATH` is set for targeting Android then
-the build above will fail, and you should run `unset IREE_LLVMAOT_LINKER_PATH`.
   * If you experience the build error similar to issue [#4915](https://github.com/google/iree/issues/4915), update the cmake configuration CLI to
 ```shell
 $ cmake -G Ninja -B ../iree-build-host/ \
diff --git a/docs/developers/get_started/getting_started_linux_cmake.md b/docs/developers/get_started/getting_started_linux_cmake.md
index 7010b1e..0c78030 100644
--- a/docs/developers/get_started/getting_started_linux_cmake.md
+++ b/docs/developers/get_started/getting_started_linux_cmake.md
@@ -109,13 +109,6 @@
 
 ### LLVM Ahead-of-Time (AOT) backend
 
-If you want to manually specify the linker used, set the
-`IREE_LLVMAOT_LINKER_PATH` environment variable to the path of the linker:
-
-```shell
-$ export IREE_LLVMAOT_LINKER_PATH=ld.lld-10
-```
-
 Translate a source MLIR into an IREE module:
 
 ```shell
diff --git a/docs/developers/get_started/getting_started_riscv_cmake.md b/docs/developers/get_started/getting_started_riscv_cmake.md
index 84e6c23..e863d3d 100644
--- a/docs/developers/get_started/getting_started_riscv_cmake.md
+++ b/docs/developers/get_started/getting_started_riscv_cmake.md
@@ -60,9 +60,6 @@
 $ cmake --build ../iree-build-host/ --target install
 ```
 
-Debugging note: if `IREE_LLVMAOT_LINKER_PATH` is set for targeting RISC-V then
-the build above will fail, and you should run `unset IREE_LLVMAOT_LINKER_PATH`.
-
 ### Target configuration
 
 The following instruction shows how to build for the RISC-V 64-bit Linux machine
diff --git a/docs/developers/get_started/getting_started_windows_cmake.md b/docs/developers/get_started/getting_started_windows_cmake.md
index e405456..bd02798 100644
--- a/docs/developers/get_started/getting_started_windows_cmake.md
+++ b/docs/developers/get_started/getting_started_windows_cmake.md
@@ -102,13 +102,6 @@
 [the Microsoft documentation](https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019)
 for details on configuring the toolchain.
 
-If you want to manually specify the linker used, set the
-`IREE_LLVMAOT_LINKER_PATH` environment variable to the path of the linker:
-
-```powershell
-> set IREE_LLVMAOT_LINKER_PATH="C:\Tools\LLVM\bin\lld-link.exe"
-```
-
 Translate a source MLIR file into an IREE module:
 
 ```powershell
diff --git a/docs/website/docs/deployment-configurations/bare-metal.md b/docs/website/docs/deployment-configurations/bare-metal.md
index 0934807..498e8ba 100644
--- a/docs/website/docs/deployment-configurations/bare-metal.md
+++ b/docs/website/docs/deployment-configurations/bare-metal.md
@@ -27,11 +27,10 @@
 The model can be compiled with the following command from the IREE compiler
 build directory
 
-``` shell hl_lines="3 4 5 6"
+``` shell hl_lines="3 4 5"
 iree/tools/iree-translate \
     -iree-mlir-to-vm-bytecode-module \
     -iree-hal-target-backends=dylib-llvm-aot \
-    -iree-llvm-link-embedded=true \
     -iree-llvm-target-triple=x86_64-pc-linux-elf \
     -iree-llvm-debug-symbols=false \
     iree/samples/models/simple_abs.mlir \
@@ -43,10 +42,6 @@
 
 * `iree-hal-target-backends=dylib-llvm-aot`: Build the model for the dynamic
 library CPU HAL driver
-* `iree-llvm-link-embedded=true`: Generate the dynamic library with
-[LLD](https://lld.llvm.org/) and the artifact can be loaded with the
-[embedded library loader](https://github.com/google/iree/blob/main/iree/hal/local/loaders/embedded_library_loader.h)
-without invoking the dynamic library support
 * `iree-llvm-target-triple`: Use the `<arch>-pc-linux-elf` LLVM target triple so
 the artifact has a fixed ABI to be rendered by the
 [elf_module library](https://github.com/google/iree/tree/main/iree/hal/local/elf)
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp
index 25abad6..ed514fe 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp
@@ -385,7 +385,7 @@
       return mlir::emitError(variantOp.getLoc())
              << "failed to link executable and generate target dylib using "
                 "linker toolchain "
-             << linkerTool->getToolPath();
+             << linkerTool->getSystemToolPath();
     }
     auto &linkArtifacts = linkArtifactsOr.getValue();
     if (options_.keepLinkerArtifacts) {
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.cpp
index e027925..768fb80 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.cpp
@@ -132,16 +132,17 @@
   targetOptions.debugSymbols = clDebugSymbols;
 
   static llvm::cl::opt<std::string> clLinkerPath(
-      "iree-llvm-linker-path",
-      llvm::cl::desc("Tool used to link shared libraries produced by IREE."),
+      "iree-llvm-system-linker-path",
+      llvm::cl::desc("Tool used to link system shared libraries produced by "
+                     "IREE (for -iree-llvm-link-embedded=false)."),
       llvm::cl::init(""));
   targetOptions.linkerPath = clLinkerPath;
 
   static llvm::cl::opt<std::string> clEmbeddedLinkerPath(
       "iree-llvm-embedded-linker-path",
       llvm::cl::desc("Tool used to link embedded ELFs produced by IREE (for "
-                     "-iree-llvm-link-embedded)."),
-      llvm::cl::init("ld.lld"));
+                     "-iree-llvm-link-embedded=true)."),
+      llvm::cl::init(""));
   targetOptions.embeddedLinkerPath = clEmbeddedLinkerPath;
 
   static llvm::cl::opt<bool> clLinkEmbedded(
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.h b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.h
index 0a0124f..f1e9fe5 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.h
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.h
@@ -49,7 +49,7 @@
   std::string embeddedLinkerPath;
 
   // Build for the IREE embedded platform-agnostic ELF loader.
-  bool linkEmbedded = false;
+  bool linkEmbedded = true;
 
   // Link any required runtime libraries into the produced binaries statically.
   // This increases resulting binary size but enables the binaries to be used on
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.cpp
index aede2a6..d42d539 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.cpp
@@ -106,15 +106,15 @@
   }
 }
 
-std::string LinkerTool::getToolPath() const {
-  // Always use the -iree-llvm-linker-path flag when specified as it's
+std::string LinkerTool::getSystemToolPath() const {
+  // Always use the -iree-llvm-system-linker-path flag when specified as it's
   // explicitly telling us what to use.
   if (!targetOptions.linkerPath.empty()) {
     return targetOptions.linkerPath;
   }
 
   // Allow users to override the automatic search with an environment variable.
-  char *linkerPath = std::getenv("IREE_LLVMAOT_LINKER_PATH");
+  char *linkerPath = std::getenv("IREE_LLVMAOT_SYSTEM_LINKER_PATH");
   if (linkerPath) {
     return std::string(linkerPath);
   }
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.h b/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.h
index 7039c14..2fb402f 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.h
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.h
@@ -84,8 +84,9 @@
 
   virtual ~LinkerTool() = default;
 
-  // Returns the path to the linker tool binary.
-  virtual std::string getToolPath() const;
+  // Returns the path to the system linker tool binary, or empty string if none
+  // was discovered.
+  virtual std::string getSystemToolPath() const;
 
   // Configures a module prior to compilation with any additional
   // functions/exports it may need, such as shared object initializer functions.
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/AndroidLinkerTool.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/internal/AndroidLinkerTool.cpp
index 60ed5ce..f07e930 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/AndroidLinkerTool.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/internal/AndroidLinkerTool.cpp
@@ -24,7 +24,7 @@
 //   https://developer.android.com/ndk/guides/other_build_systems
 //
 // If we want to support self-built variants we'll need an env var (or just make
-// the user set IREE_LLVMAOT_LINKER_PATH).
+// the user set IREE_LLVMAOT_SYSTEM_LINKER_PATH).
 static const char *getNDKHostPlatform() {
   auto hostTriple = Triple(llvm::sys::getProcessTriple());
   if (hostTriple.isOSLinux() && hostTriple.getArch() == Triple::x86_64) {
@@ -68,8 +68,8 @@
  public:
   using LinkerTool::LinkerTool;
 
-  std::string getToolPath() const override {
-    auto toolPath = LinkerTool::getToolPath();
+  std::string getSystemToolPath() const override {
+    auto toolPath = LinkerTool::getSystemToolPath();
     if (!toolPath.empty()) return toolPath;
 
     // ANDROID_NDK must be set for us to infer the tool path.
@@ -114,7 +114,7 @@
     artifacts.libraryFile.close();
 
     SmallVector<std::string, 8> flags = {
-        getToolPath(),
+        getSystemToolPath(),
 
         // Avoids including any libc/startup files that initialize the CRT as
         // we don't use any of that. Our shared libraries must be freestanding.
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/EmbeddedLinkerTool.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/internal/EmbeddedLinkerTool.cpp
index cda219e..315ce3c 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/EmbeddedLinkerTool.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/internal/EmbeddedLinkerTool.cpp
@@ -40,7 +40,7 @@
  public:
   using LinkerTool::LinkerTool;
 
-  std::string getToolPath() const override {
+  std::string getEmbeddedToolPath() const {
     // Always try to use the tool specified for this exact configuration first.
     // Hopefully some day soon we'll be able to statically link LLD in and call
     // a C function to do the linking instead of needing a separate tool.
@@ -49,18 +49,18 @@
     }
 
     // Fall back to check for setting the linker explicitly via environment
-    // variables or flags. Users may do this to use their own lld with custom
-    // architectures built in.
-    auto toolPath = LinkerTool::getToolPath();
-    if (!toolPath.empty()) return toolPath;
+    // variables.
+    char *envVarPath = std::getenv("IREE_LLVMAOT_EMBEDDED_LINKER_PATH");
+    if (envVarPath && envVarPath[0] != '\0') return std::string(envVarPath);
 
     // No explicit linker specified, search the environment for common tools.
-    toolPath = findToolInEnvironment({"ld.lld"});
-    if (!toolPath.empty()) return toolPath;
+    std::string environmentPath =
+        findToolInEnvironment({"iree-lld", "lld", "ld.lld", "lld-link"});
+    if (!environmentPath.empty()) return environmentPath;
 
     llvm::errs() << "LLD (ld.lld) not found on path; specify with the "
-                    "IREE_LLVMAOT_LINKER_PATH environment variable or "
-                    "-iree-llvm-linker-path=\n";
+                    "IREE_LLVMAOT_EMBEDDED_LINKER_PATH environment variable or "
+                    "-iree-llvm-embedded-linker-path=\n";
     return "";
   }
 
@@ -89,7 +89,7 @@
     artifacts.libraryFile.close();
 
     SmallVector<std::string, 8> flags = {
-        getToolPath(),
+        getEmbeddedToolPath(),
 
         // Forces LLD to act like gnu ld and produce ELF files.
         // If not specified then lld tries to figure out what it is by progname
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/RiscvLinkerTool.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/internal/RiscvLinkerTool.cpp
index b54a98e..1cbb730 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/RiscvLinkerTool.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/internal/RiscvLinkerTool.cpp
@@ -25,9 +25,9 @@
  public:
   using LinkerTool::LinkerTool;
 
-  std::string getToolPath() const override {
+  std::string getSystemToolPath() const override {
     // First check for setting the linker explicitly.
-    auto toolPath = LinkerTool::getToolPath();
+    auto toolPath = LinkerTool::getSystemToolPath();
     if (!toolPath.empty()) return toolPath;
 
     char *riscvToolchainRoot = std::getenv("RISCV_TOOLCHAIN_ROOT");
@@ -61,7 +61,7 @@
     artifacts.libraryFile.close();
 
     SmallVector<std::string, 8> flags = {
-        getToolPath(),
+        getSystemToolPath(),
         "-o " + artifacts.libraryFile.path,
     };
 
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/UnixLinkerTool.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/internal/UnixLinkerTool.cpp
index cdc1b21..375ffbd 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/UnixLinkerTool.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/internal/UnixLinkerTool.cpp
@@ -22,9 +22,9 @@
  public:
   using LinkerTool::LinkerTool;
 
-  std::string getToolPath() const override {
+  std::string getSystemToolPath() const override {
     // First check for setting the linker explicitly.
-    auto toolPath = LinkerTool::getToolPath();
+    auto toolPath = LinkerTool::getSystemToolPath();
     if (!toolPath.empty()) return toolPath;
 
     // No explicit linker specified, search the environment for common tools.
@@ -50,7 +50,7 @@
     artifacts.libraryFile.close();
 
     SmallVector<std::string, 8> flags = {
-        getToolPath(),
+        getSystemToolPath(),
         "-o " + artifacts.libraryFile.path,
     };
 
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/WasmLinkerTool.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/internal/WasmLinkerTool.cpp
index fa92479..2e5eab1 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/WasmLinkerTool.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/internal/WasmLinkerTool.cpp
@@ -36,9 +36,9 @@
  public:
   using LinkerTool::LinkerTool;
 
-  std::string getToolPath() const override {
+  std::string getSystemToolPath() const override {
     // First check for setting the linker explicitly.
-    auto toolPath = LinkerTool::getToolPath();
+    auto toolPath = LinkerTool::getSystemToolPath();
     if (!toolPath.empty()) return toolPath;
 
     // No explicit linker specified, search the environment for common tools.
@@ -77,7 +77,7 @@
     artifacts.libraryFile.close();
 
     SmallVector<std::string, 8> flags = {
-        getToolPath(),
+        getSystemToolPath(),
 
         // entry symbol not defined (pass --no-entry to suppress): _start
         "--no-entry",
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/internal/WindowsLinkerTool.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/internal/WindowsLinkerTool.cpp
index 8405a04..41e2894 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/internal/WindowsLinkerTool.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/internal/WindowsLinkerTool.cpp
@@ -21,9 +21,9 @@
  public:
   using LinkerTool::LinkerTool;
 
-  std::string getToolPath() const override {
+  std::string getSystemToolPath() const override {
     // First check for setting the linker explicitly.
-    auto toolPath = LinkerTool::getToolPath();
+    auto toolPath = LinkerTool::getSystemToolPath();
     if (!toolPath.empty()) return toolPath;
 
     // No explicit linker specified, search the environment for common tools.
@@ -101,7 +101,7 @@
     llvm::sys::path::replace_extension(pdbPath, "pdb");
 
     SmallVector<std::string, 8> flags = {
-        getToolPath(),
+        getSystemToolPath(),
 
         // Hide the linker banner message printed each time.
         "/nologo",
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/test/BUILD b/iree/compiler/Dialect/HAL/Target/LLVM/test/BUILD
index 5a93026..1a77b77 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/test/BUILD
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/test/BUILD
@@ -24,5 +24,6 @@
     data = [
         "//iree/tools:IreeFileCheck",
         "//iree/tools:iree-opt",
+        "@llvm-project//lld:lld",
     ],
 )
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt b/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt
index 21398e9..9120ed7 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/test/CMakeLists.txt
@@ -18,6 +18,7 @@
   DATA
     iree::tools::IreeFileCheck
     iree::tools::iree-opt
+    lld
 )
 
 ### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/test/smoketest.mlir b/iree/compiler/Dialect/HAL/Target/LLVM/test/smoketest.mlir
index 10b74e4..91a4ff5 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/test/smoketest.mlir
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/test/smoketest.mlir
@@ -1,4 +1,5 @@
 // RUN: iree-opt -split-input-file -iree-hal-transformation-pipeline %s | IreeFileCheck %s
+// RUN: iree-opt -split-input-file -iree-hal-transformation-pipeline -iree-llvm-link-embedded=false %s | IreeFileCheck %s
 
 #map = affine_map<(d0) -> (d0)>
 
diff --git a/iree/hal/local/elf/testdata/generate.sh b/iree/hal/local/elf/testdata/generate.sh
index 7ccee79..078b2fb 100644
--- a/iree/hal/local/elf/testdata/generate.sh
+++ b/iree/hal/local/elf/testdata/generate.sh
@@ -40,7 +40,6 @@
       -o=simple_embedding_test_dylib_llvm_scratch.vmfb
 
       -iree-hal-target-backends=dylib-llvm-aot
-      -iree-llvm-link-embedded=true
       -iree-llvm-debug-symbols=false
 
       "${translate_args[@]}"
diff --git a/iree/hal/local/executable_library_benchmark.md b/iree/hal/local/executable_library_benchmark.md
index 3ba507d..77b32f5 100644
--- a/iree/hal/local/executable_library_benchmark.md
+++ b/iree/hal/local/executable_library_benchmark.md
@@ -58,7 +58,6 @@
     iree/samples/simple_embedding/simple_embedding_test.mlir \
     -o=module.vmfb \
     -iree-hal-target-backends=dylib-llvm-aot \
-    -iree-llvm-link-embedded=true \
     -iree-llvm-debug-symbols=false \
     -iree-llvm-target-triple=x86_64-pc-linux-elf \
     -print-ir-after-all \
diff --git a/iree/samples/simple_embedding/BUILD b/iree/samples/simple_embedding/BUILD
index 9688702..43d6125 100644
--- a/iree/samples/simple_embedding/BUILD
+++ b/iree/samples/simple_embedding/BUILD
@@ -104,7 +104,6 @@
         "-iree-mlir-to-vm-bytecode-module",
         "-iree-hal-target-backends=dylib-llvm-aot",
         "-iree-llvm-target-triple=x86_64-pc-linux-elf",
-        "-iree-llvm-link-embedded=true",
         "-iree-llvm-debug-symbols=false",
         "-iree-vm-bytecode-module-strip-source-map=true",
         "-iree-vm-emit-polyglot-zip=false",
@@ -123,7 +122,6 @@
         "-iree-llvm-target-cpu=generic-rv32",
         "-iree-llvm-target-cpu-features=+m,+f",
         "-iree-llvm-target-abi=ilp32",
-        "-iree-llvm-link-embedded=true",
         "-iree-llvm-debug-symbols=false",
         "-iree-vm-bytecode-module-strip-source-map=true",
         "-iree-vm-emit-polyglot-zip=false",
@@ -142,7 +140,6 @@
         "-iree-llvm-target-cpu=generic-rv64",
         "-iree-llvm-target-cpu-features=+m,+a,+f,+d,+c",
         "-iree-llvm-target-abi=lp64d",
-        "-iree-llvm-link-embedded=true",
         "-iree-llvm-debug-symbols=false",
         "-iree-vm-bytecode-module-strip-source-map=true",
         "-iree-vm-emit-polyglot-zip=false",
@@ -159,7 +156,6 @@
         "-iree-hal-target-backends=dylib-llvm-aot",
         "-iree-llvm-target-triple=armv7a-pc-linux-elf",
         "-iree-llvm-target-float-abi=hard",
-        "-iree-llvm-link-embedded=true",
         "-iree-llvm-debug-symbols=false",
         "-iree-vm-bytecode-module-strip-source-map=true",
         "-iree-vm-emit-polyglot-zip=false",
@@ -175,7 +171,6 @@
         "-iree-mlir-to-vm-bytecode-module",
         "-iree-hal-target-backends=dylib-llvm-aot",
         "-iree-llvm-target-triple=aarch64-pc-linux-elf",
-        "-iree-llvm-link-embedded=true",
         "-iree-llvm-debug-symbols=false",
         "-iree-vm-bytecode-module-strip-source-map=true",
         "-iree-vm-emit-polyglot-zip=false",
diff --git a/iree/samples/simple_embedding/CMakeLists.txt b/iree/samples/simple_embedding/CMakeLists.txt
index 670169b..dedb908 100644
--- a/iree/samples/simple_embedding/CMakeLists.txt
+++ b/iree/samples/simple_embedding/CMakeLists.txt
@@ -91,7 +91,6 @@
     "-iree-mlir-to-vm-bytecode-module"
     "-iree-hal-target-backends=dylib-llvm-aot"
     "-iree-llvm-target-triple=x86_64-pc-linux-elf"
-    "-iree-llvm-link-embedded=true"
     "-iree-llvm-debug-symbols=false"
     "-iree-vm-bytecode-module-strip-source-map=true"
     "-iree-vm-emit-polyglot-zip=false"
@@ -113,7 +112,6 @@
     "-iree-llvm-target-cpu=generic-rv32"
     "-iree-llvm-target-cpu-features=+m,+f"
     "-iree-llvm-target-abi=ilp32"
-    "-iree-llvm-link-embedded=true"
     "-iree-llvm-debug-symbols=false"
     "-iree-vm-bytecode-module-strip-source-map=true"
     "-iree-vm-emit-polyglot-zip=false"
@@ -135,7 +133,6 @@
     "-iree-llvm-target-cpu=generic-rv64"
     "-iree-llvm-target-cpu-features=+m,+a,+f,+d,+c"
     "-iree-llvm-target-abi=lp64d"
-    "-iree-llvm-link-embedded=true"
     "-iree-llvm-debug-symbols=false"
     "-iree-vm-bytecode-module-strip-source-map=true"
     "-iree-vm-emit-polyglot-zip=false"
@@ -155,7 +152,6 @@
     "-iree-hal-target-backends=dylib-llvm-aot"
     "-iree-llvm-target-triple=armv7a-pc-linux-elf"
     "-iree-llvm-target-float-abi=hard"
-    "-iree-llvm-link-embedded=true"
     "-iree-llvm-debug-symbols=false"
     "-iree-vm-bytecode-module-strip-source-map=true"
     "-iree-vm-emit-polyglot-zip=false"
@@ -174,7 +170,6 @@
     "-iree-mlir-to-vm-bytecode-module"
     "-iree-hal-target-backends=dylib-llvm-aot"
     "-iree-llvm-target-triple=aarch64-pc-linux-elf"
-    "-iree-llvm-link-embedded=true"
     "-iree-llvm-debug-symbols=false"
     "-iree-vm-bytecode-module-strip-source-map=true"
     "-iree-vm-emit-polyglot-zip=false"
diff --git a/iree/samples/static_library/CMakeLists.txt b/iree/samples/static_library/CMakeLists.txt
index 3b9f54e..3c9a4a2 100644
--- a/iree/samples/static_library/CMakeLists.txt
+++ b/iree/samples/static_library/CMakeLists.txt
@@ -17,6 +17,7 @@
 set(_TRANSLATE_ARGS)
 list(APPEND _TRANSLATE_ARGS "-iree-mlir-to-vm-bytecode-module")
 list(APPEND _TRANSLATE_ARGS "-iree-hal-target-backends=dylib-llvm-aot")
+list(APPEND _TRANSLATE_ARGS "-iree-llvm-link-embedded=false")
 list(APPEND _TRANSLATE_ARGS "-iree-llvm-link-static")
 list(APPEND _TRANSLATE_ARGS "-iree-llvm-static-library-output-path=simple_mul.o")
 list(APPEND _TRANSLATE_ARGS "${CMAKE_CURRENT_SOURCE_DIR}/simple_mul.mlir")
diff --git a/iree/test/e2e/linalg_ext_ops/BUILD b/iree/test/e2e/linalg_ext_ops/BUILD
index 9752101..fc0b0e6 100644
--- a/iree/test/e2e/linalg_ext_ops/BUILD
+++ b/iree/test/e2e/linalg_ext_ops/BUILD
@@ -37,24 +37,6 @@
 )
 
 iree_check_single_backend_test_suite(
-    name = "check_dylib_embedded-llvm-aot_dylib",
-    srcs = enforce_glob(
-        # keep sorted
-        [
-            "reverse.mlir",
-        ],
-        include = ["*.mlir"],
-        exclude = [
-        ],
-    ),
-    compiler_flags = [
-        "-iree-llvm-link-embedded=true",
-    ],
-    driver = "dylib",
-    target_backend = "dylib-llvm-aot",
-)
-
-iree_check_single_backend_test_suite(
     name = "check_dylib-llvm-aot_dylib",
     srcs = enforce_glob(
         # keep sorted
diff --git a/iree/test/e2e/linalg_ext_ops/CMakeLists.txt b/iree/test/e2e/linalg_ext_ops/CMakeLists.txt
index 78b49f4..7d46dba 100644
--- a/iree/test/e2e/linalg_ext_ops/CMakeLists.txt
+++ b/iree/test/e2e/linalg_ext_ops/CMakeLists.txt
@@ -29,19 +29,6 @@
 
 iree_check_single_backend_test_suite(
   NAME
-    check_dylib_embedded-llvm-aot_dylib
-  SRCS
-    "reverse.mlir"
-  TARGET_BACKEND
-    "dylib-llvm-aot"
-  DRIVER
-    "dylib"
-  COMPILER_FLAGS
-    "-iree-llvm-link-embedded=true"
-)
-
-iree_check_single_backend_test_suite(
-  NAME
     check_dylib-llvm-aot_dylib
   SRCS
     "reverse.mlir"
diff --git a/iree/test/e2e/models/BUILD b/iree/test/e2e/models/BUILD
index be8a453..9d140ec 100644
--- a/iree/test/e2e/models/BUILD
+++ b/iree/test/e2e/models/BUILD
@@ -41,6 +41,7 @@
     data = [
         "//iree/tools:IreeFileCheck",
         "//iree/tools:iree-run-mlir",
+        "@llvm-project//lld:lld",
     ],
     tags = [
         "hostonly",
diff --git a/iree/test/e2e/models/CMakeLists.txt b/iree/test/e2e/models/CMakeLists.txt
index 5cef709..ad94da2 100644
--- a/iree/test/e2e/models/CMakeLists.txt
+++ b/iree/test/e2e/models/CMakeLists.txt
@@ -24,6 +24,7 @@
   DATA
     iree::tools::IreeFileCheck
     iree::tools::iree-run-mlir
+    lld
   LABELS
     "hostonly"
     "optonly"
diff --git a/iree/test/e2e/tensor_ops/BUILD b/iree/test/e2e/tensor_ops/BUILD
index 4b2a1ce..2fd0fcf 100644
--- a/iree/test/e2e/tensor_ops/BUILD
+++ b/iree/test/e2e/tensor_ops/BUILD
@@ -35,7 +35,7 @@
 )
 
 iree_check_single_backend_test_suite(
-    name = "check_dylib_embedded-llvm-aot_dylib",
+    name = "check_dylib-llvm-aot_dylib",
     srcs = enforce_glob(
         # keep sorted
         [
@@ -47,9 +47,6 @@
             "tensor_cast.mlir",
         ],
     ),
-    compiler_flags = [
-        "-iree-llvm-link-embedded=true",
-    ],
     driver = "dylib",
     target_backend = "dylib-llvm-aot",
 )
@@ -67,9 +64,6 @@
             "tensor_cast.mlir",
         ],
     ),
-    compiler_flags = [
-        "-iree-llvm-link-embedded=true",
-    ],
     driver = "cuda",
     tags = [
         "noasan",
@@ -94,9 +88,6 @@
             "tensor_cast.mlir",
         ],
     ),
-    compiler_flags = [
-        "-iree-llvm-link-embedded=true",
-    ],
     driver = "vulkan",
     target_backend = "vulkan-spirv",
 )
diff --git a/iree/test/e2e/tensor_ops/CMakeLists.txt b/iree/test/e2e/tensor_ops/CMakeLists.txt
index 325e859..4eceb38 100644
--- a/iree/test/e2e/tensor_ops/CMakeLists.txt
+++ b/iree/test/e2e/tensor_ops/CMakeLists.txt
@@ -26,7 +26,7 @@
 
 iree_check_single_backend_test_suite(
   NAME
-    check_dylib_embedded-llvm-aot_dylib
+    check_dylib-llvm-aot_dylib
   SRCS
     "extract_slice.mlir"
     "tensor_insert_slice.mlir"
@@ -34,8 +34,6 @@
     "dylib-llvm-aot"
   DRIVER
     "dylib"
-  COMPILER_FLAGS
-    "-iree-llvm-link-embedded=true"
 )
 
 iree_check_single_backend_test_suite(
@@ -48,8 +46,6 @@
     "cuda"
   DRIVER
     "cuda"
-  COMPILER_FLAGS
-    "-iree-llvm-link-embedded=true"
   LABELS
     "noasan"
     "nomsan"
@@ -68,8 +64,6 @@
     "vulkan-spirv"
   DRIVER
     "vulkan"
-  COMPILER_FLAGS
-    "-iree-llvm-link-embedded=true"
 )
 
 ### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/iree/test/e2e/xla_ops/BUILD b/iree/test/e2e/xla_ops/BUILD
index 3cf26c8..b43fb72 100644
--- a/iree/test/e2e/xla_ops/BUILD
+++ b/iree/test/e2e/xla_ops/BUILD
@@ -98,7 +98,7 @@
 )
 
 iree_check_single_backend_test_suite(
-    name = "check_dylib_embedded-llvm-aot_dylib",
+    name = "check_dylib-llvm-aot_dylib",
     srcs = enforce_glob(
         # keep sorted
         [
@@ -164,79 +164,6 @@
             "round.mlir",
         ],
     ),
-    compiler_flags = [
-        "-iree-input-type=mhlo",
-        "-iree-llvm-link-embedded=true",
-    ],
-    driver = "dylib",
-    target_backend = "dylib-llvm-aot",
-)
-
-iree_check_single_backend_test_suite(
-    name = "check_dylib-llvm-aot_dylib",
-    srcs = enforce_glob(
-        # keep sorted
-        [
-            "abs.mlir",
-            "add.mlir",
-            "batch_norm_inference.mlir",
-            "bitcast_convert.mlir",
-            "broadcast.mlir",
-            "broadcast_add.mlir",
-            "broadcast_in_dim.mlir",
-            "clamp.mlir",
-            "compare.mlir",
-            "concatenate.mlir",
-            "constant.mlir",
-            "convert.mlir",
-            "convolution.mlir",
-            "cosine.mlir",
-            "divide.mlir",
-            "dot.mlir",
-            "dot_general.mlir",
-            "dynamic_slice.mlir",
-            "dynamic_update_slice.mlir",
-            "exponential.mlir",
-            "exponential_minus_one.mlir",
-            "fft.mlir",
-            "finite.mlir",
-            "floor.mlir",
-            "gather.mlir",
-            "iota.mlir",
-            "log.mlir",
-            "log_plus_one.mlir",
-            "maximum.mlir",
-            "minimum.mlir",
-            "multiply.mlir",
-            "negate.mlir",
-            "pad.mlir",
-            "pow.mlir",
-            "reduce.mlir",
-            "reduce_window.mlir",
-            "remainder.mlir",
-            "reshape.mlir",
-            "reverse.mlir",
-            "rng_normal.mlir",
-            "rng_uniform.mlir",
-            "rsqrt.mlir",
-            "scatter.mlir",
-            "scatter_dynamic.mlir",
-            "select.mlir",
-            "sine.mlir",
-            "slice.mlir",
-            "sort.mlir",
-            "sqrt.mlir",
-            "subtract.mlir",
-            "tanh.mlir",
-            "torch_index_select.mlir",
-            "transpose.mlir",
-            "while.mlir",
-        ],
-        include = ["*.mlir"],
-        exclude = [
-            "round.mlir",
-        ],
-    ),
     compiler_flags = ["-iree-input-type=mhlo"],
     driver = "dylib",
     target_backend = "dylib-llvm-aot",
diff --git a/iree/test/e2e/xla_ops/CMakeLists.txt b/iree/test/e2e/xla_ops/CMakeLists.txt
index cc22a75..ab355a6 100644
--- a/iree/test/e2e/xla_ops/CMakeLists.txt
+++ b/iree/test/e2e/xla_ops/CMakeLists.txt
@@ -84,73 +84,6 @@
 
 iree_check_single_backend_test_suite(
   NAME
-    check_dylib_embedded-llvm-aot_dylib
-  SRCS
-    "abs.mlir"
-    "add.mlir"
-    "batch_norm_inference.mlir"
-    "bitcast_convert.mlir"
-    "broadcast.mlir"
-    "broadcast_add.mlir"
-    "broadcast_in_dim.mlir"
-    "clamp.mlir"
-    "compare.mlir"
-    "concatenate.mlir"
-    "constant.mlir"
-    "convert.mlir"
-    "convolution.mlir"
-    "cosine.mlir"
-    "divide.mlir"
-    "dot.mlir"
-    "dot_general.mlir"
-    "dynamic_slice.mlir"
-    "dynamic_update_slice.mlir"
-    "exponential.mlir"
-    "exponential_minus_one.mlir"
-    "fft.mlir"
-    "finite.mlir"
-    "floor.mlir"
-    "gather.mlir"
-    "iota.mlir"
-    "log.mlir"
-    "log_plus_one.mlir"
-    "maximum.mlir"
-    "minimum.mlir"
-    "multiply.mlir"
-    "negate.mlir"
-    "pad.mlir"
-    "pow.mlir"
-    "reduce.mlir"
-    "reduce_window.mlir"
-    "remainder.mlir"
-    "reshape.mlir"
-    "reverse.mlir"
-    "rng_normal.mlir"
-    "rng_uniform.mlir"
-    "rsqrt.mlir"
-    "scatter.mlir"
-    "scatter_dynamic.mlir"
-    "select.mlir"
-    "sine.mlir"
-    "slice.mlir"
-    "sort.mlir"
-    "sqrt.mlir"
-    "subtract.mlir"
-    "tanh.mlir"
-    "torch_index_select.mlir"
-    "transpose.mlir"
-    "while.mlir"
-  TARGET_BACKEND
-    "dylib-llvm-aot"
-  DRIVER
-    "dylib"
-  COMPILER_FLAGS
-    "-iree-input-type=mhlo"
-    "-iree-llvm-link-embedded=true"
-)
-
-iree_check_single_backend_test_suite(
-  NAME
     check_dylib-llvm-aot_dylib
   SRCS
     "abs.mlir"
diff --git a/iree/tools/test/BUILD b/iree/tools/test/BUILD
index 41489e0..2c10883 100644
--- a/iree/tools/test/BUILD
+++ b/iree/tools/test/BUILD
@@ -35,6 +35,7 @@
         "//iree/tools:iree-run-mlir",
         "//iree/tools:iree-run-module",
         "//iree/tools:iree-translate",
+        "@llvm-project//lld:lld",
     ],
     tags = [
         "hostonly",
diff --git a/iree/tools/test/CMakeLists.txt b/iree/tools/test/CMakeLists.txt
index bf6581f..aca8f33 100644
--- a/iree/tools/test/CMakeLists.txt
+++ b/iree/tools/test/CMakeLists.txt
@@ -27,6 +27,7 @@
     iree::tools::iree-run-mlir
     iree::tools::iree-run-module
     iree::tools::iree-translate
+    lld
   LABELS
     "hostonly"
 )