aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/ada.js
diff options
context:
space:
mode:
authorMarc Poulhiès <dkm@kataplop.net>2022-05-25 16:09:08 +0200
committerGitHub <noreply@github.com>2022-05-25 16:09:08 +0200
commitb006d4ac92916d5d1db027b96bd20108a019b388 (patch)
tree8cf1fb08b8fcd8ee344a3e940c98d27ec88c8a49 /lib/compilers/ada.js
parent4dc3e56d957604b685cd73785d924170218ba415 (diff)
downloadcompiler-explorer-b006d4ac92916d5d1db027b96bd20108a019b388.tar.gz
compiler-explorer-b006d4ac92916d5d1db027b96bd20108a019b388.zip
Ada: fix compile to binary/execute within jail (#3716)gh-3090
Need to jump in the dedicated directory, but then GNAT may write some files that may conflict with ours: create a dedicated temp subdir to run GNAT. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'lib/compilers/ada.js')
-rw-r--r--lib/compilers/ada.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/compilers/ada.js b/lib/compilers/ada.js
index 11de78ea1..b8dc3b786 100644
--- a/lib/compilers/ada.js
+++ b/lib/compilers/ada.js
@@ -24,6 +24,7 @@
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
+import fs from 'fs-extra';
import {BaseCompiler} from '../base-compiler';
import * as utils from '../utils';
@@ -51,7 +52,7 @@ export class AdaCompiler extends BaseCompiler {
getOutputFilename(dirPath) {
// The basename here must match the value used in the pragma Source_File
// in the user provided source.
- return path.join(dirPath, 'example.o');
+ return path.join(dirPath, 'example.out');
}
prepareArguments(userOptions, filters, backendOptions, inputFilename, outputFilename, libraries) {
@@ -147,6 +148,14 @@ export class AdaCompiler extends BaseCompiler {
execOptions = this.getDefaultExecOptions();
}
+ // create a subdir so that files automatically created by GNAT don't
+ // conflict with anything else in parent dir.
+ const temp_dir = path.join(path.dirname(inputFilename), 'tempsub');
+ await fs.mkdir(temp_dir);
+
+ // Set the working directory to be the temp directory that has been created
+ execOptions.customCwd = temp_dir;
+
const result = await this.exec(compiler, options, execOptions);
result.inputFilename = inputFilename;