Repository: compiler-explorer/compiler-explorer
Pull request #7740 (2025-05-30 02:48:53)

fixes for windows execution


Patch:
diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts
index ba95a2602..90938867f 100644
--- a/lib/base-compiler.ts
+++ b/lib/base-compiler.ts
@@ -960,6 +960,19 @@ export class BaseCompiler {
         });
     }
 
+    getSharedLibraryBinPaths(libraries: SelectedLibraryVersion[], dirPath?: string): string[] {
+        return libraries.flatMap(selectedLib => {
+            const foundVersion = this.findLibVersion(selectedLib);
+            if (!foundVersion) return [];
+
+            const paths: string[] = [];
+            if (this.buildenvsetup && !this.buildenvsetup.extractAllToRoot && dirPath) {
+                paths.push(path.join(dirPath, selectedLib.id, 'bin'));
+            }
+            return paths;
+        });
+    }
+
     protected getSharedLibraryPathsAsArguments(
         libraries: SelectedLibraryVersion[],
         libDownloadPath: string | undefined,
@@ -2168,6 +2181,13 @@ export class BaseCompiler {
             );
         }
 
+        executeParameters.env.PATH = [
+            ...this.getSharedLibraryBinPaths(key.libraries, buildResult.dirPath),
+            executeParameters.env.PATH,
+        ]
+            .filter(Boolean)
+            .join(path.delimiter);
+
         const execTriple = await RemoteExecutionQuery.guessExecutionTripleForBuildresult(buildResult);
         if (!this.compiler.emulated && !matchesCurrentHost(execTriple)) {
             if (await RemoteExecutionQuery.isPossible(execTriple)) {
diff --git a/lib/binaries/win-utils.ts b/lib/binaries/win-utils.ts
index 44a28025a..722488cb6 100644
--- a/lib/binaries/win-utils.ts
+++ b/lib/binaries/win-utils.ts
@@ -101,9 +101,13 @@ export async function copyNeededDlls(
     execoptions: ExecutionOptionsWithEnv,
 ): Promise<void> {
     const winutils = new WinUtils(execFunction, objdumper, execoptions);
-    const dlls = await winutils.get_dlls_used(executableFilename);
-    for (const dll of dlls) {
-        const infolder = path.join(dirPath, path.basename(dll));
-        await fs.copyFile(dll, infolder);
+    try {
+        const dlls = await winutils.get_dlls_used(executableFilename);
+        for (const dll of dlls) {
+            const infolder = path.join(dirPath, path.basename(dll));
+            await fs.copyFile(dll, infolder);
+        }
+    } catch (e) {
+        logger.error(`Error while retreiving or copying dll dependencies of ${executableFilename}`);
     }
 }


Test patch:
diff --git a/test/filter-tests.ts b/test/filter-tests.ts
index 4b3706392..06eda3d95 100644
--- a/test/filter-tests.ts
+++ b/test/filter-tests.ts
@@ -71,7 +71,7 @@ function testFilter(filename: string, suffix: string, filters: ParseFiltersAndOu
 }
 
 describe('Filter test cases', () => {
-    if (process.platform === 'win32') {
+    if (process.platform === 'win32' || process.platform === 'darwin') {
         it('should skip filter-tests on Windows', () => {
             expect(true).toBe(true);
         });
@@ -93,7 +93,7 @@ describe('Filter test cases', () => {
         }
     });
     describe('Binary, directives, labels and comments', () => {
-        if (process.platform !== 'win32') {
+        if (process.platform !== 'win32' && process.platform !== 'darwin') {
             for (const x of cases) {
                 testFilter(x, '.binary.directives.labels.comments', {
                     binary: true,
@@ -105,7 +105,7 @@ describe('Filter test cases', () => {
         }
     });
     describe('Binary, directives, labels, comments and library code', () => {
-        if (process.platform !== 'win32') {
+        if (process.platform !== 'win32' && process.platform !== 'darwin') {
             for (const x of cases) {
                 if (!x.endsWith('-bin.asm')) continue;
 
@@ -120,7 +120,7 @@ describe('Filter test cases', () => {
         }
     });
     describe('Binary, directives, labels, comments and library code with dontMaskFilenames', () => {
-        if (process.platform !== 'win32') {
+        if (process.platform !== 'win32' && process.platform !== 'darwin') {
             for (const x of cases) {
                 if (!x.endsWith('-bin.asm')) continue;