Skip to content

Commit 862fffd

Browse files
committed
[lldb/qemu] Set qemu's "ld prefix" based on the platform sysroot
Both serve the same purpose (finding shared libraries) and allow one to launch a dynamically linked executable by just specifying the platform sysroot.
1 parent ca271f4 commit 862fffd

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ lldb::ProcessSP PlatformQemuUser::DebugProcess(ProcessLaunchInfo &launch_info,
191191
launch_info.SetArguments(args, true);
192192

193193
Environment emulator_env = Host::GetEnvironment();
194+
if (ConstString sysroot = GetSDKRootDirectory())
195+
emulator_env["QEMU_LD_PREFIX"] = sysroot.GetStringRef().str();
194196
for (const auto &KV : GetGlobalProperties().GetEmulatorEnvVars())
195197
emulator_env[KV.first()] = KV.second;
196198
launch_info.GetEnvironment() = ComputeLaunchEnvironment(

lldb/test/API/qemu/TestQemuLaunch.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,11 @@ def test_arg0(self):
249249

250250
self.assertEqual(state["program"], self.getBuildArtifact())
251251
self.assertEqual(state["0"], "ARG0")
252+
253+
def test_sysroot(self):
254+
sysroot = self.getBuildArtifact("sysroot")
255+
self.runCmd("platform select qemu-user --sysroot %s" % sysroot)
256+
state = self._run_and_get_state()
257+
self.assertEqual(state["environ"]["QEMU_LD_PREFIX"], sysroot)
258+
self.assertIn("QEMU_LD_PREFIX",
259+
state["environ"]["QEMU_UNSET_ENV"].split(","))

0 commit comments

Comments
 (0)