Skip to content

Commit 1b4197c

Browse files
committed
Use explicit rustc commit-hash
Required for lldb on mac
1 parent 1ebfe11 commit 1b4197c

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

editors/code/src/debug.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
33
import * as path from 'path';
44
import * as ra from './lsp_ext';
55

6-
import { Cargo, getSysroot } from './toolchain';
6+
import { Cargo, getRustcId, getSysroot } from './toolchain';
77
import { Ctx } from "./ctx";
88
import { prepareEnv } from "./run";
99

@@ -107,9 +107,11 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
107107
let sourceFileMap = debugOptions.sourceFileMap;
108108
if (sourceFileMap === "auto") {
109109
// let's try to use the default toolchain
110+
const commitHash = await getRustcId(wsFolder);
110111
const sysroot = await getSysroot(wsFolder);
111112
const rustlib = path.normalize(sysroot + "/lib/rustlib/src/rust");
112-
sourceFileMap = { "/rustc/*": rustlib };
113+
sourceFileMap = {};
114+
sourceFileMap[`/rustc/${commitHash}/`] = rustlib;
113115
}
114116

115117
const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, sourceFileMap);

editors/code/src/toolchain.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ export function getSysroot(dir: string): Promise<string> {
129129
return execute(`${rustcPath} --print sysroot`, { cwd: dir });
130130
}
131131

132+
export async function getRustcId(dir: string): Promise<string> {
133+
const rustcPath = getPathForExecutable("rustc");
134+
135+
// do not memoize the result because the toolchain may change between runs
136+
const data = await execute(`${rustcPath} -V -v`, { cwd: dir });
137+
const rx = /commit-hash:\s(.*)$/m.compile();
138+
139+
return rx.exec(data)![1];
140+
}
141+
132142
/** Mirrors `toolchain::cargo()` implementation */
133143
export function cargoPath(): string {
134144
return getPathForExecutable("cargo");

editors/code/src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ export function execute(command: string, options: ExecOptions): Promise<string>
159159
resolve(stdout.trimEnd());
160160
});
161161
});
162-
}
162+
}

0 commit comments

Comments
 (0)