Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Compiler Explorer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
Compiler Explorer
Commits
4f1bbcf5
Unverified
Commit
4f1bbcf5
authored
2 years ago
by
Patrick Quist
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
.net - compileToBinary fix (#4353)
parent
df607d5f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
etc/nsjail/execute.cfg
+1
-1
1 addition, 1 deletion
etc/nsjail/execute.cfg
lib/compilers/dotnet.ts
+41
-23
41 additions, 23 deletions
lib/compilers/dotnet.ts
with
42 additions
and
24 deletions
etc/nsjail/execute.cfg
+
1
−
1
View file @
4f1bbcf5
...
@@ -28,7 +28,7 @@ cgroup_net_cls_parent: "ce-compile"
...
@@ -28,7 +28,7 @@ cgroup_net_cls_parent: "ce-compile"
cgroup_cpu_parent:
"ce-compile"
cgroup_cpu_parent:
"ce-compile"
cgroup_mem_max:
1342177280
# 1.25 GiB
cgroup_mem_max:
1342177280
# 1.25 GiB
cgroup_pids_max:
64
# go uses a bunch (probably one per CPU, on my desktop)
cgroup_pids_max:
72
cgroup_cpu_ms_per_sec:
1000
cgroup_cpu_ms_per_sec:
1000
mount
{
mount
{
...
...
This diff is collapsed.
Click to expand it.
lib/compilers/dotnet.ts
+
41
−
23
View file @
4f1bbcf5
...
@@ -46,7 +46,6 @@ class DotNetCompiler extends BaseCompiler {
...
@@ -46,7 +46,6 @@ class DotNetCompiler extends BaseCompiler {
private
buildConfig
:
string
;
private
buildConfig
:
string
;
private
clrBuildDir
:
string
;
private
clrBuildDir
:
string
;
private
langVersion
:
string
;
private
langVersion
:
string
;
private
compileToBinary
=
false
;
constructor
(
compilerInfo
,
env
)
{
constructor
(
compilerInfo
,
env
)
{
super
(
compilerInfo
,
env
);
super
(
compilerInfo
,
env
);
...
@@ -94,6 +93,44 @@ class DotNetCompiler extends BaseCompiler {
...
@@ -94,6 +93,44 @@ class DotNetCompiler extends BaseCompiler {
];
];
}
}
async
writeProjectfile
(
programDir
:
string
,
compileToBinary
:
boolean
,
sourceFile
:
string
)
{
const
projectFileContent
=
`<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>
${
this
.
targetFramework
}
</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>CompilerExplorer</AssemblyName>
<LangVersion>
${
this
.
langVersion
}
</LangVersion>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Nullable>enable</Nullable>
<OutputType>
${
compileToBinary
?
'
Exe
'
:
'
Library
'
}
</OutputType>
</PropertyGroup>
<ItemGroup>
<Compile Include="
${
sourceFile
}
" />
</ItemGroup>
</Project>
`
;
const
projectFilePath
=
path
.
join
(
programDir
,
`CompilerExplorer
${
this
.
lang
.
extensions
[
0
]}
proj`
);
await
fs
.
writeFile
(
projectFilePath
,
projectFileContent
);
}
override
async
buildExecutable
(
compiler
,
options
,
inputFilename
,
execOptions
)
{
const
dirPath
=
path
.
dirname
(
inputFilename
);
const
inputFilenameSafe
=
this
.
filename
(
inputFilename
);
const
sourceFile
=
path
.
basename
(
inputFilenameSafe
);
await
this
.
writeProjectfile
(
dirPath
,
true
,
sourceFile
);
return
super
.
buildExecutable
(
compiler
,
options
,
inputFilename
,
execOptions
);
}
override
async
doCompilation
(
inputFilename
,
dirPath
,
key
,
options
,
filters
,
backendOptions
,
libraries
,
tools
)
{
const
inputFilenameSafe
=
this
.
filename
(
inputFilename
);
const
sourceFile
=
path
.
basename
(
inputFilenameSafe
);
await
this
.
writeProjectfile
(
dirPath
,
filters
.
binary
,
sourceFile
);
return
super
.
doCompilation
(
inputFilename
,
dirPath
,
key
,
options
,
filters
,
backendOptions
,
libraries
,
tools
);
}
override
async
runCompiler
(
override
async
runCompiler
(
compiler
:
string
,
compiler
:
string
,
options
:
string
[],
options
:
string
[],
...
@@ -105,29 +142,15 @@ class DotNetCompiler extends BaseCompiler {
...
@@ -105,29 +142,15 @@ class DotNetCompiler extends BaseCompiler {
}
}
const
programDir
=
path
.
dirname
(
inputFilename
);
const
programDir
=
path
.
dirname
(
inputFilename
);
const
sourceFile
=
path
.
basename
(
inputFilename
);
const
projectFilePath
=
path
.
join
(
programDir
,
`CompilerExplorer
${
this
.
lang
.
extensions
[
0
]}
proj`
);
const
crossgen2Path
=
path
.
join
(
this
.
clrBuildDir
,
'
crossgen2
'
,
'
crossgen2.dll
'
);
const
crossgen2Path
=
path
.
join
(
this
.
clrBuildDir
,
'
crossgen2
'
,
'
crossgen2.dll
'
);
const
nugetConfigPath
=
path
.
join
(
programDir
,
'
nuget.config
'
);
const
nugetConfigPath
=
path
.
join
(
programDir
,
'
nuget.config
'
);
const
programOutputPath
=
path
.
join
(
programDir
,
'
bin
'
,
this
.
buildConfig
,
this
.
targetFramework
);
const
programOutputPath
=
path
.
join
(
programDir
,
'
bin
'
,
this
.
buildConfig
,
this
.
targetFramework
);
const
programDllPath
=
path
.
join
(
programOutputPath
,
'
CompilerExplorer.dll
'
);
const
programDllPath
=
path
.
join
(
programOutputPath
,
'
CompilerExplorer.dll
'
);
const
projectFileContent
=
`<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
const
sdkBaseDir
=
path
.
join
(
path
.
dirname
(
compiler
),
'
sdk
'
);
<TargetFramework>
${
this
.
targetFramework
}
</TargetFramework>
const
sdkVersions
=
await
fs
.
readdir
(
sdkBaseDir
);
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>CompilerExplorer</AssemblyName>
<LangVersion>
${
this
.
langVersion
}
</LangVersion>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Nullable>enable</Nullable>
<OutputType>
${
this
.
compileToBinary
?
'
Exe
'
:
'
Library
'
}
</OutputType>
</PropertyGroup>
<ItemGroup>
<Compile Include="
${
sourceFile
}
" />
</ItemGroup>
</Project>
`
;
const
nugetConfigFileContent
=
`<?xml version="1.0" encoding="utf-8"?>
const
nugetConfigFileContent
=
`<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configuration>
...
@@ -158,7 +181,6 @@ class DotNetCompiler extends BaseCompiler {
...
@@ -158,7 +181,6 @@ class DotNetCompiler extends BaseCompiler {
execOptions
.
env
.
DOTNET_NOLOGO
=
'
true
'
;
execOptions
.
env
.
DOTNET_NOLOGO
=
'
true
'
;
execOptions
.
customCwd
=
programDir
;
execOptions
.
customCwd
=
programDir
;
await
fs
.
writeFile
(
projectFilePath
,
projectFileContent
);
await
fs
.
writeFile
(
nugetConfigPath
,
nugetConfigFileContent
);
await
fs
.
writeFile
(
nugetConfigPath
,
nugetConfigFileContent
);
const
crossgen2Options
:
string
[]
=
[];
const
crossgen2Options
:
string
[]
=
[];
...
@@ -211,10 +233,6 @@ class DotNetCompiler extends BaseCompiler {
...
@@ -211,10 +233,6 @@ class DotNetCompiler extends BaseCompiler {
}
}
override
optionsForFilter
(
filters
:
ParseFiltersAndOutputOptions
)
{
override
optionsForFilter
(
filters
:
ParseFiltersAndOutputOptions
)
{
if
(
filters
.
binary
)
{
this
.
compileToBinary
=
true
;
}
return
this
.
compilerOptions
;
return
this
.
compilerOptions
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment