aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Quist <partouf@gmail.com>2022-02-01 08:39:55 +0100
committerGitHub <noreply@github.com>2022-02-01 08:39:55 +0100
commitc28d535c1e31d4a146b8cd553bc2827ba2837ca6 (patch)
treeac32cbea22dd707d700719d3dd5c0c4a85572f35
parent5f0a3a7f23311b4837f4c6e031c992d9306782da (diff)
downloadcompiler-explorer-c28d535c1e31d4a146b8cd553bc2827ba2837ca6.tar.gz
compiler-explorer-c28d535c1e31d4a146b8cd553bc2827ba2837ca6.zip
Changes needed to make dotnet work with nsjail (#3307)gh-1805
-rw-r--r--.nycrc.yml1
-rw-r--r--etc/config/csharp.amazon.properties17
-rw-r--r--etc/config/csharp.defaults.properties15
-rw-r--r--etc/config/fsharp.amazon.properties17
-rw-r--r--etc/config/fsharp.defaults.properties13
-rw-r--r--etc/config/vb.amazon.properties17
-rw-r--r--etc/config/vb.defaults.properties13
-rw-r--r--etc/nsjail/execute.cfg2
-rw-r--r--lib/base-compiler.d.ts12
-rw-r--r--lib/compilers/dotnet.ts (renamed from lib/compilers/dotnet.js)46
10 files changed, 99 insertions, 54 deletions
diff --git a/.nycrc.yml b/.nycrc.yml
index 586a90bca..d93f5ce0f 100644
--- a/.nycrc.yml
+++ b/.nycrc.yml
@@ -5,6 +5,7 @@ include:
exclude:
- lib/asm-docs/generated/asm-docs-*.js
- lib/compilers/fake-for-test.js
+ - lib/**/*.d.ts
report-dir: ./out/coverage
reporter:
- lcov
diff --git a/etc/config/csharp.amazon.properties b/etc/config/csharp.amazon.properties
new file mode 100644
index 000000000..ea20eb967
--- /dev/null
+++ b/etc/config/csharp.amazon.properties
@@ -0,0 +1,17 @@
+compilers=&csharp
+supportsBinary=false
+needsMulti=false
+compilerType=csharp
+defaultCompiler=dotnet601csharp
+
+group.csharp.compilers=dotnet601csharp
+
+compiler.dotnet601csharp.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
+compiler.dotnet601csharp.name=.NET 6.0.101
+compiler.dotnet601csharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
+compiler.dotnet601csharp.runtimeId=linux-x64
+compiler.dotnet601csharp.targetFramework=net6.0
+compiler.dotnet601csharp.buildConfig=Release
+compiler.dotnet601csharp.additionalSources=
+compiler.dotnet601csharp.langVersion=latest
+compiler.dotnet601csharp.nugetPackages=/opt/compiler-explorer/dotnet_nuget-v6.0.0/packages
diff --git a/etc/config/csharp.defaults.properties b/etc/config/csharp.defaults.properties
index fd384aca5..16a0c2cf7 100644
--- a/etc/config/csharp.defaults.properties
+++ b/etc/config/csharp.defaults.properties
@@ -1,10 +1,8 @@
-compilers=&csharp
+compilers=dotnet6csharp
supportsBinary=false
needsMulti=false
compilerType=csharp
-defaultCompiler=dotnet6csharp:dotnettrunkcsharp
-
-group.csharp.compilers=dotnet6csharp:dotnettrunkcsharp
+defaultCompiler=dotnet6csharp
compiler.dotnet6csharp.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
compiler.dotnet6csharp.name=.NET 6.0.101
@@ -14,12 +12,3 @@ compiler.dotnet6csharp.targetFramework=net6.0
compiler.dotnet6csharp.buildConfig=Release
compiler.dotnet6csharp.additionalSources=
compiler.dotnet6csharp.langVersion=latest
-
-compiler.dotnettrunkcsharp.exe=/opt/compiler-explorer/dotnet-trunk/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
-compiler.dotnettrunkcsharp.name=.NET Trunk
-compiler.dotnettrunkcsharp.clrDir=/opt/compiler-explorer/dotnet-trunk/bin/coreclr/Linux.x64.Checked
-compiler.dotnettrunkcsharp.runtimeId=linux-x64
-compiler.dotnettrunkcsharp.targetFramework=net6.0
-compiler.dotnettrunkcsharp.buildConfig=Release
-compiler.dotnettrunkcsharp.additionalSources=
-compiler.dotnettrunkcsharp.langVersion=preview
diff --git a/etc/config/fsharp.amazon.properties b/etc/config/fsharp.amazon.properties
new file mode 100644
index 000000000..acb2d1f45
--- /dev/null
+++ b/etc/config/fsharp.amazon.properties
@@ -0,0 +1,17 @@
+compilers=&fsharp
+supportsBinary=false
+needsMulti=false
+compilerType=fsharp
+defaultCompiler=dotnet601fsharp
+
+group.fsharp.compilers=dotnet601fsharp
+
+compiler.dotnet601fsharp.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
+compiler.dotnet601fsharp.name=.NET 6.0.101
+compiler.dotnet601fsharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
+compiler.dotnet601fsharp.runtimeId=linux-x64
+compiler.dotnet601fsharp.targetFramework=net6.0
+compiler.dotnet601fsharp.buildConfig=Release
+compiler.dotnet601fsharp.additionalSources=
+compiler.dotnet601fsharp.langVersion=latest
+compiler.dotnet601fsharp.nugetPackages=/opt/compiler-explorer/dotnet_nuget-v6.0.0/packages
diff --git a/etc/config/fsharp.defaults.properties b/etc/config/fsharp.defaults.properties
index 26308f360..6b3313a41 100644
--- a/etc/config/fsharp.defaults.properties
+++ b/etc/config/fsharp.defaults.properties
@@ -1,11 +1,9 @@
-compilers=&fsharp
+compilers=dotnet6fsharp
supportsBinary=false
needsMulti=false
compilerType=fsharp
defaultCompiler=dotnet6fsharp
-group.fsharp.compilers=dotnet6fsharp:dotnettrunkfsharp
-
compiler.dotnet6fsharp.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
compiler.dotnet6fsharp.name=.NET 6.0.101
compiler.dotnet6fsharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
@@ -14,12 +12,3 @@ compiler.dotnet6fsharp.targetFramework=net6.0
compiler.dotnet6fsharp.buildConfig=Release
compiler.dotnet6fsharp.additionalSources=
compiler.dotnet6fsharp.langVersion=latest
-
-compiler.dotnettrunkfsharp.exe=/opt/compiler-explorer/dotnet-trunk/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
-compiler.dotnettrunkfsharp.name=.NET Trunk
-compiler.dotnettrunkfsharp.clrDir=/opt/compiler-explorer/dotnet-trunk/bin/coreclr/Linux.x64.Checked
-compiler.dotnettrunkfsharp.runtimeId=linux-x64
-compiler.dotnettrunkfsharp.targetFramework=net6.0
-compiler.dotnettrunkfsharp.buildConfig=Release
-compiler.dotnettrunkfsharp.additionalSources=
-compiler.dotnettrunkfsharp.langVersion=latest
diff --git a/etc/config/vb.amazon.properties b/etc/config/vb.amazon.properties
new file mode 100644
index 000000000..0f96bf19d
--- /dev/null
+++ b/etc/config/vb.amazon.properties
@@ -0,0 +1,17 @@
+compilers=&vb
+supportsBinary=false
+needsMulti=false
+compilerType=vb
+defaultCompiler=dotnet601vb
+
+group.vb.compilers=dotnet601vb
+
+compiler.dotnet601vb.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
+compiler.dotnet601vb.name=.NET 6.0.101
+compiler.dotnet601vb.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
+compiler.dotnet601vb.runtimeId=linux-x64
+compiler.dotnet601vb.targetFramework=net6.0
+compiler.dotnet601vb.buildConfig=Release
+compiler.dotnet601vb.additionalSources=
+compiler.dotnet601vb.langVersion=latest
+compiler.dotnet601vb.nugetPackages=/opt/compiler-explorer/dotnet_nuget-v6.0.0/packages
diff --git a/etc/config/vb.defaults.properties b/etc/config/vb.defaults.properties
index 200e2dd12..608addfc3 100644
--- a/etc/config/vb.defaults.properties
+++ b/etc/config/vb.defaults.properties
@@ -1,11 +1,9 @@
-compilers=&vb
+compilers=dotnet6vb
supportsBinary=false
needsMulti=false
compilerType=vb
defaultCompiler=dotnet6vb
-group.vb.compilers=dotnet6vb:dotnettrunkvb
-
compiler.dotnet6vb.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
compiler.dotnet6vb.name=.NET 6.0.101
compiler.dotnet6vb.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
@@ -14,12 +12,3 @@ compiler.dotnet6vb.targetFramework=net6.0
compiler.dotnet6vb.buildConfig=Release
compiler.dotnet6vb.additionalSources=
compiler.dotnet6vb.langVersion=latest
-
-compiler.dotnettrunkvb.exe=/opt/compiler-explorer/dotnet-trunk/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
-compiler.dotnettrunkvb.name=.NET Trunk
-compiler.dotnettrunkvb.clrDir=/opt/compiler-explorer/dotnet-trunk/bin/coreclr/Linux.x64.Checked
-compiler.dotnettrunkvb.runtimeId=linux-x64
-compiler.dotnettrunkvb.targetFramework=net6.0
-compiler.dotnettrunkvb.buildConfig=Release
-compiler.dotnettrunkvb.additionalSources=
-compiler.dotnettrunkvb.langVersion=latest
diff --git a/etc/nsjail/execute.cfg b/etc/nsjail/execute.cfg
index 6b22182d2..124d56e04 100644
--- a/etc/nsjail/execute.cfg
+++ b/etc/nsjail/execute.cfg
@@ -10,7 +10,7 @@ log_level: FATAL
rlimit_as_type: INF
rlimit_cpu_type: SOFT
rlimit_fsize: 1024 # 1GB
-rlimit_nofile: 100
+rlimit_nofile: 150
uidmap {
inside_id: "10240"
diff --git a/lib/base-compiler.d.ts b/lib/base-compiler.d.ts
new file mode 100644
index 000000000..c6b63d883
--- /dev/null
+++ b/lib/base-compiler.d.ts
@@ -0,0 +1,12 @@
+export declare class BaseCompiler {
+ constructor(compilerInfo, env);
+ public compiler;
+ public lang;
+ public outputFilebase: string;
+ public compilerProps: (key: string) => string;
+ public getOutputFilename(path: string, filename: string): string;
+ public exec(filepath: string, args: string[], execOptions);
+ public parseCompilationOutput(result, filename: string);
+ public getDefaultExecOptions();
+ public runCompiler(compiler: string, args: string[], filename: string, execOptions);
+}
diff --git a/lib/compilers/dotnet.js b/lib/compilers/dotnet.ts
index d84a072db..65d0e9a3a 100644
--- a/lib/compilers/dotnet.js
+++ b/lib/compilers/dotnet.ts
@@ -26,13 +26,29 @@ import path from 'path';
import fs from 'fs-extra';
+/// <reference types="../base-compiler" />
import { BaseCompiler } from '../base-compiler';
class DotNetCompiler extends BaseCompiler {
-
- get rID() { return this.compilerProps(`compiler.${this.compiler.id}.runtimeId`); }
- get targetFramework() { return this.compilerProps(`compiler.${this.compiler.id}.targetFramework`); }
- get buildConfig() { return this.compilerProps(`compiler.${this.compiler.id}.buildConfig`); }
+ private rID: string;
+ private targetFramework: string;
+ private buildConfig: string;
+ private nugetPackagesPath: string;
+ private clrBuildDir: string;
+ private additionalSources: string;
+ private langVersion: string;
+
+ constructor(compilerInfo, env) {
+ super(compilerInfo, env);
+
+ this.rID = this.compilerProps(`compiler.${this.compiler.id}.runtimeId`);
+ this.targetFramework = this.compilerProps(`compiler.${this.compiler.id}.targetFramework`);
+ this.buildConfig = this.compilerProps(`compiler.${this.compiler.id}.buildConfig`);
+ this.nugetPackagesPath = this.compilerProps(`compiler.${this.compiler.id}.nugetPackages`);
+ this.clrBuildDir = this.compilerProps(`compiler.${this.compiler.id}.clrDir`);
+ this.additionalSources = this.compilerProps(`compiler.${this.compiler.id}.additionalSources`);
+ this.langVersion = this.compilerProps(`compiler.${this.compiler.id}.langVersion`);
+ }
get compilerOptions() {
return ['publish', '-c', this.buildConfig, '--self-contained', '--runtime', this.rID, '-v', 'q', '--nologo'];
@@ -55,10 +71,9 @@ class DotNetCompiler extends BaseCompiler {
const programDir = path.dirname(inputFileName);
const sourceFile = path.basename(inputFileName);
- const clrBuildDir = this.compilerProps(`compiler.${this.compiler.id}.clrDir`);
const projectFilePath = path.join(programDir, `CompilerExplorer${this.lang.extensions[0]}proj`);
- const crossgen2Path = path.join(clrBuildDir, 'crossgen2', 'crossgen2.dll');
+ const crossgen2Path = path.join(this.clrBuildDir, 'crossgen2', 'crossgen2.dll');
const programPublishPath = path.join(
programDir,
@@ -70,8 +85,6 @@ class DotNetCompiler extends BaseCompiler {
);
const programDllPath = path.join(programPublishPath, 'CompilerExplorer.dll');
- const additionalSources = this.compilerProps(`compiler.${this.compiler.id}.additionalSources`);
- const langVersion = this.compilerProps(`compiler.${this.compiler.id}.langVersion`);
const projectFileContent =
`<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
@@ -79,11 +92,11 @@ class DotNetCompiler extends BaseCompiler {
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<AssemblyName>CompilerExplorer</AssemblyName>
- <LangVersion>${langVersion}</LangVersion>
+ <LangVersion>${this.langVersion}</LangVersion>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
- <EnablePreviewFeatures>${langVersion === 'preview' ? 'true' : 'false'}</EnablePreviewFeatures>
+ <EnablePreviewFeatures>${this.langVersion === 'preview' ? 'true' : 'false'}</EnablePreviewFeatures>
<RestoreAdditionalProjectSources>
- https://api.nuget.org/v3/index.json;${additionalSources ? additionalSources : ''}
+ https://api.nuget.org/v3/index.json;${this.additionalSources ? this.additionalSources : ''}
</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
@@ -92,6 +105,11 @@ class DotNetCompiler extends BaseCompiler {
</Project>
`;
+ execOptions.env.DOTNET_CLI_TELEMETRY_OPTOUT = 'true';
+ execOptions.env.DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 'true';
+ execOptions.env.NUGET_PACKAGES = this.nugetPackagesPath;
+ execOptions.env.DOTNET_NOLOGO='true';
+
execOptions.customCwd = programDir;
await fs.writeFile(projectFilePath, projectFileContent);
@@ -128,7 +146,7 @@ class DotNetCompiler extends BaseCompiler {
programPublishPath,
programDllPath,
crossgen2Options,
- this.getOutputFilename(programDir, ''),
+ this.getOutputFilename(programDir, this.outputFilebase),
);
if (crossgen2Result.code !== 0) {
@@ -142,10 +160,6 @@ class DotNetCompiler extends BaseCompiler {
return this.compilerOptions;
}
- getOutputFilename(dirPath) {
- return path.join(dirPath, `output.s`);
- }
-
cleanAsm(stdout) {
let cleanedAsm = '';