From c7b7989e26672521a333fc2b032504c394050f80 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Thu, 23 May 2024 10:38:19 -0400 Subject: [PATCH] vscode-extensions.ms-vscode.cpptools: Use the bundled interpreter for binaries Previously autoPatchelfHook would stomp on the interpreter for the bundled cpptools* executables. Here we manually run the hook and then explicitly patch the interpreter. (cherry picked from commit 5b6363538b631542725244c1f9012529f446c4d0) --- .../extensions/ms-vscode.cpptools/default.nix | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/editors/vscode/extensions/ms-vscode.cpptools/default.nix b/pkgs/applications/editors/vscode/extensions/ms-vscode.cpptools/default.nix index 76112cd46efc..61b079b190b7 100644 --- a/pkgs/applications/editors/vscode/extensions/ms-vscode.cpptools/default.nix +++ b/pkgs/applications/editors/vscode/extensions/ms-vscode.cpptools/default.nix @@ -73,6 +73,8 @@ vscode-utils.buildVscodeMarketplaceExtension { stdenv.cc.cc.lib ]; + dontAutoPatchelf = true; + postPatch = '' mv ./package.json ./package_orig.json @@ -92,13 +94,22 @@ vscode-utils.buildVscodeMarketplaceExtension { find "${clang-tools}" -mindepth 1 -maxdepth 1 | xargs ln -s -t "./LLVM" # Patching binaries - chmod +x bin/cpptools bin/cpptools-srv bin/cpptools-wordexp debugAdapters/bin/OpenDebugAD7 + chmod +x bin/cpptools bin/cpptools-srv bin/cpptools-wordexp bin/libc.so debugAdapters/bin/OpenDebugAD7 patchelf --replace-needed liblttng-ust.so.0 liblttng-ust.so.1 ./debugAdapters/bin/libcoreclrtraceptprovider.so ''; - postFixup = lib.optionalString gdbUseFixed '' - wrapProgram $out/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7 --prefix PATH : ${lib.makeBinPath [ gdb ]} - ''; + postFixup = + '' + autoPatchelf $out/share/vscode/extensions/ms-vscode.cpptools/debugAdapters + + # cpptools* are distributed by the extension and need to be run through the distributed musl interpretter + patchelf --set-interpreter $out/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so $out/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools + patchelf --set-interpreter $out/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so $out/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools-srv + patchelf --set-interpreter $out/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so $out/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools-wordexp + '' + + lib.optionalString gdbUseFixed '' + wrapProgram $out/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7 --prefix PATH : ${lib.makeBinPath [ gdb ]} + ''; meta = { description = "The C/C++ extension adds language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging.";