Skip to content

Commit

Permalink
executionType/sandBoxType no longer stored per compiler (compiler-exp…
Browse files Browse the repository at this point in the history
…lorer#7381)

.. as they're uniform execution options


Note the removal of `(compiler as any).executionType = 'nsjail'` from
tests - seems it didn't do anything.

But better test execution in staging, as I'm having trouble using nsjail
locally.
  • Loading branch information
OfekShilon authored Feb 8, 2025
1 parent ea1c667 commit 7409194
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
7 changes: 0 additions & 7 deletions lib/base-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ import type {IAsmParser} from './parsers/asm-parser.interfaces.js';
import {AsmParser} from './parsers/asm-parser.js';
import {LlvmPassDumpParser} from './parsers/llvm-pass-dump-parser.js';
import type {PropertyGetter} from './properties.interfaces.js';
import {propsFor} from './properties.js';
import {HeaptrackWrapper} from './runtime-tools/heaptrack-wrapper.js';
import {LibSegFaultHelper} from './runtime-tools/libsegfault-helper.js';
import {SentryCapture} from './sentry.js';
Expand Down Expand Up @@ -212,8 +211,6 @@ export class BaseCompiler {
protected externalparser: null | ExternalParserBase;
protected supportedLibraries?: Record<string, OptionsHandlerLibrary>;
protected packager: Packager;
protected executionType: string;
protected sandboxType: string;
protected defaultRpathFlag = '-Wl,-rpath,';
private static objdumpAndParseCounter = new PromClient.Counter({
name: 'ce_objdumpandparsetime_total',
Expand Down Expand Up @@ -258,10 +255,6 @@ export class BaseCompiler {
this.compiler.disabledFilters = (this.compiler.disabledFilters as any).split(',');
}

const execProps = propsFor('execution');
this.executionType = execProps('executionType', 'none');
this.sandboxType = execProps('sandboxType', 'none');

this.asm = new AsmParser(this.compilerProps);
const irDemangler = new LLVMIRDemangler(this.compiler.demangler, this);
this.llvmIr = new LlvmIrParser(this.compilerProps, irDemangler);
Expand Down
4 changes: 3 additions & 1 deletion lib/compilers/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import fs from 'fs-extra';
import type {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import {BaseCompiler} from '../base-compiler.js';
import {propsFor} from '../properties.js';
import * as utils from '../utils.js';

export class CleanCompiler extends BaseCompiler {
Expand Down Expand Up @@ -114,7 +115,8 @@ export class CleanCompiler extends BaseCompiler {
await fs.mkdir(execOptions.env.CLEANABCPATH);
await fs.mkdir(execOptions.env.CLEANOPATH);

if (this.executionType === 'nsjail') {
const execProps = propsFor('execution');
if (execProps<string>('executionType') === 'nsjail') {
execOptions.env.CLEANABCPATH = '/app/Clean System Files';
execOptions.env.CLEANOPATH = '/app/obj';
}
Expand Down
18 changes: 2 additions & 16 deletions test/library-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('Library directories (c++)', () => {
} as unknown as ClientOptionsType);
});

it('should add libpaths and link to libraries', () => {
it('should add libpaths and link to libraries 1', () => {
const links = compiler.getSharedLibraryLinks([{id: 'fmt', version: '10'}]);
expect(links).toContain('-lfmtd');

Expand All @@ -133,9 +133,7 @@ describe('Library directories (c++)', () => {
expect(qtpaths).toContain('-L' + path.normalize('/tmp/compiler-explorer-compiler-123/qt/lib'));
});

it('should add libpaths and link to libraries when using nsjail', () => {
(compiler as any).executionType = 'nsjail';

it('should add libpaths and link to libraries 2', () => {
const fmtpaths = (compiler as any).getSharedLibraryPathsAsArguments(
[{id: 'fmt', version: '10'}],
undefined,
Expand All @@ -156,8 +154,6 @@ describe('Library directories (c++)', () => {
});

it('should add extra include paths when using packagedheaders', () => {
(compiler as any).executionType = 'nsjail';

const fmtpaths = (compiler as any).getIncludeArguments(
[{id: 'fmt', version: '10'}],
'/tmp/compiler-explorer-compiler-123',
Expand All @@ -176,8 +172,6 @@ describe('Library directories (c++)', () => {
});

it('should set LD_LIBRARY_PATH when executing', () => {
(compiler as any).sandboxType = 'nsjail';

const qtpaths = (compiler as BaseCompiler).getSharedLibraryPathsAsLdLibraryPathsForExecution(
{
libraries: [{id: 'qt', version: '660'}],
Expand All @@ -195,8 +189,6 @@ describe('Library directories (c++)', () => {
});

it('should add libpaths and link when statically linking', () => {
(compiler as any).executionType = 'nsjail';

const staticlinks = compiler.getStaticLibraryLinks([{id: 'cpptrace', version: '030'}], []);
expect(staticlinks).toContain('-lcpptrace');
expect(staticlinks).toContain('-ldwarf');
Expand Down Expand Up @@ -272,8 +264,6 @@ describe('Library directories (fortran)', () => {
});

it('should not add libpaths and link to libraries when they dont exist', async () => {
(compiler as any).executionType = 'nsjail';

const dirPath = await compiler.newTempDir();

const libPath = path.join(dirPath, 'json_fortran/lib');
Expand All @@ -289,8 +279,6 @@ describe('Library directories (fortran)', () => {
});

it('should add libpaths and link to libraries', async () => {
(compiler as any).executionType = 'nsjail';

const dirPath = await compiler.newTempDir();
const libPath = path.join(dirPath, 'json_fortran/lib');
await fs.mkdir(libPath, {recursive: true});
Expand All @@ -315,7 +303,6 @@ describe('Library directories (fortran)', () => {
});

it('should add includes for packaged libraries', async () => {
(compiler as any).executionType = 'nsjail';
(compiler as any).compiler.includeFlag = '-isystem';

const dirPath = await compiler.newTempDir();
Expand All @@ -328,7 +315,6 @@ describe('Library directories (fortran)', () => {
});

it('should add includes for non-packaged C libraries', async () => {
(compiler as any).executionType = 'nsjail';
(compiler as any).compiler.includeFlag = '-isystem';

const dirPath = await compiler.newTempDir();
Expand Down

0 comments on commit 7409194

Please sign in to comment.