]> git.lizzy.rs Git - rust.git/commitdiff
Use explicit rustc commit-hash
authorvsrs <vit@conrlab.com>
Thu, 22 Apr 2021 15:30:44 +0000 (18:30 +0300)
committervsrs <vit@conrlab.com>
Thu, 22 Apr 2021 15:59:03 +0000 (18:59 +0300)
Required for lldb on mac

editors/code/src/debug.ts
editors/code/src/toolchain.ts
editors/code/src/util.ts

index 8c6969dc670e9f4b4a1c573b7c72cba32c6123db..830980f968c5bb92f69ee41cc13151db9721ae3e 100644 (file)
@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
 import * as path from 'path';
 import * as ra from './lsp_ext';
 
-import { Cargo, getSysroot } from './toolchain';
+import { Cargo, getRustcId, getSysroot } from './toolchain';
 import { Ctx } from "./ctx";
 import { prepareEnv } from "./run";
 
@@ -107,9 +107,11 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
     let sourceFileMap = debugOptions.sourceFileMap;
     if (sourceFileMap === "auto") {
         // let's try to use the default toolchain
+        const commitHash = await getRustcId(wsFolder);
         const sysroot = await getSysroot(wsFolder);
         const rustlib = path.normalize(sysroot + "/lib/rustlib/src/rust");
-        sourceFileMap = { "/rustc/*": rustlib };
+        sourceFileMap = {};
+        sourceFileMap[`/rustc/${commitHash}/`] = rustlib;
     }
 
     const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, sourceFileMap);
index 5725bcafe2f895b73a164902c990e1751535b442..68826c478d37248cb5ca0a2123aa1d74932b483c 100644 (file)
@@ -129,6 +129,16 @@ export function getSysroot(dir: string): Promise<string> {
     return execute(`${rustcPath} --print sysroot`, { cwd: dir });
 }
 
+export async function getRustcId(dir: string): Promise<string> {
+    const rustcPath = getPathForExecutable("rustc");
+
+    // do not memoize the result because the toolchain may change between runs
+    const data = await execute(`${rustcPath} -V -v`, { cwd: dir });
+    const rx = /commit-hash:\s(.*)$/m.compile();
+
+    return rx.exec(data)![1];
+}
+
 /** Mirrors `toolchain::cargo()` implementation */
 export function cargoPath(): string {
     return getPathForExecutable("cargo");
index fc5c9e94e5e49bc40730a858f31e3c0abea89b66..56e0e439e980e46a87c86ec5a2387ad6adf2d233 100644 (file)
@@ -159,4 +159,4 @@ export function execute(command: string, options: ExecOptions): Promise<string>
             resolve(stdout.trimEnd());
         });
     });
-}
\ No newline at end of file
+}