From 810a1d091858adc3563504224b9c48f15eda03ed Mon Sep 17 00:00:00 2001 From: Mats Larsen Date: Wed, 15 Dec 2021 18:10:50 +0000 Subject: [PATCH 01/14] Describe which opcode and arch was not found (#3175) --- lib/handlers/assembly-documentation/router.js | 5 +- .../base-assembly-documentation-handler.js | 2 +- test/handlers/api-tests.js | 12 --- .../assembly-documentation/amd64-tests.js | 12 +-- .../assembly-documentation/api-tests.js | 73 +++++++++++++++++++ .../assembly-documentation/arm32-tests.js | 14 +--- .../assembly-documentation/java-tests.js | 12 +-- 7 files changed, 81 insertions(+), 49 deletions(-) create mode 100644 test/handlers/assembly-documentation/api-tests.js diff --git a/lib/handlers/assembly-documentation/router.js b/lib/handlers/assembly-documentation/router.js index 9e0db4b36..b13592a68 100644 --- a/lib/handlers/assembly-documentation/router.js +++ b/lib/handlers/assembly-documentation/router.js @@ -46,9 +46,10 @@ export const setup = (router) => router.get('/asm/:arch/:opcode', (req, res) => if (MAX_STATIC_AGE > 0) { res.setHeader('Cache-Control', `public, max-age=${MAX_STATIC_AGE}`); } - const handler = ASSEMBLY_DOCUMENTATION_HANDLERS[req.params.arch]; + const architecture = req.params.arch; + const handler = ASSEMBLY_DOCUMENTATION_HANDLERS[architecture]; if (handler !== undefined) { return handler.handle(req, res); } - res.status(404).send({ error: 'Unknown architecture '}); + res.status(404).json({ error: `No documentation for '${architecture}'` }).send(); }); diff --git a/lib/handlers/base-assembly-documentation-handler.js b/lib/handlers/base-assembly-documentation-handler.js index ccd47a23f..c3a1b1c17 100644 --- a/lib/handlers/base-assembly-documentation-handler.js +++ b/lib/handlers/base-assembly-documentation-handler.js @@ -57,7 +57,7 @@ export class BaseAssemblyDocumentationHandler { const instruction = (request.params.opcode || '__UNKNOWN_OPCODE').toUpperCase(); const information = this.getInstructionInformation(instruction); if (information === null) { - return response.status(404).send({ error: 'Unknown opcode' }); + return response.status(404).send({ error: `Unknown opcode '${instruction}'` }); } // Accept either JSON or Plaintext Content-Type const requestedContentType = request.accepts(['text', 'json']); diff --git a/test/handlers/api-tests.js b/test/handlers/api-tests.js index 816bf04b3..6c1757ba6 100644 --- a/test/handlers/api-tests.js +++ b/test/handlers/api-tests.js @@ -166,18 +166,6 @@ describe('API handling', () => { throw err; }); }); - it('should respond to ASM doc requests', () => { - return chai.request(app) - .get('/api/asm/MOV') - .set('Accept', 'application/json') - .then(res => { - res.should.have.status(200); - res.should.be.json; - }) - .catch(err => { - throw err; - }); - }); it('should respond to JSON compilers requests with c++ filter', () => { return chai.request(app) .get('/api/compilers/c++') diff --git a/test/handlers/assembly-documentation/amd64-tests.js b/test/handlers/assembly-documentation/amd64-tests.js index c6a057704..78945d45a 100644 --- a/test/handlers/assembly-documentation/amd64-tests.js +++ b/test/handlers/assembly-documentation/amd64-tests.js @@ -40,7 +40,7 @@ describe('amd64 assembly documentation', () => { .then(res => { res.should.have.status(404); res.should.be.json; - res.body.should.deep.equal({ error: 'Unknown opcode' }); + res.body.should.deep.equal({ error: 'Unknown opcode \'MOV_OH_WAIT\'' }); }).catch(e => { throw e; }); }); @@ -65,16 +65,6 @@ describe('amd64 assembly documentation', () => { }).catch(e => { throw e; }); }); - it('should respond to json for unknown opcodes', () => { - return chai.request(app) - .get('/asm/NOANOPCODE') - .set('Accept', 'application/json') - .then(res => { - res.should.have.status(404); - res.should.be.json; - }).catch(e => { throw e; }); - }); - it('should return 406 on bad accept type', () => { return chai.request(app).get('/asm/mov') .set('Accept', 'application/pdf') diff --git a/test/handlers/assembly-documentation/api-tests.js b/test/handlers/assembly-documentation/api-tests.js new file mode 100644 index 000000000..8b617d483 --- /dev/null +++ b/test/handlers/assembly-documentation/api-tests.js @@ -0,0 +1,73 @@ +// Copyright (c) 2021, Compiler Explorer Authors +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +import express, { Router } from 'express'; + +import { setup } from '../../../lib/handlers/assembly-documentation/router'; +import { chai } from '../../utils'; + +describe('Assembly Documentation API', () => { + let app; + + before(() => { + app = express(); + /** @type {e.Router} */ + const router = Router(); + setup(router); + app.use('/api', router); + }); + + it('should accept requests to the api', () => { + return chai.request(app) + .get('/api/asm/amd64/mov') + .set('Accept', 'application/json') + .then(res => { + res.should.have.status(200); + res.should.be.json; + }) + .catch(err => { + throw err; + }); + }); + + it('should return opcode not found', () => { + return chai.request(app).get('/api/asm/amd64/notexistingop') + .set('Accept', 'application/json') + .then((res) => { + res.should.have.status(404); + res.should.be.json; + res.body.should.deep.equals({ error: `Unknown opcode 'NOTEXISTINGOP'` }); + }).catch(e => { throw e; }); + }); + + it('should return architecture not found', () => { + return chai.request(app).get('/api/asm/notarch/mov') + .set('Accept', 'application/json') + .then((res) => { + res.should.have.status(404); + res.should.be.json; + res.body.should.deep.equals({ error: `No documentation for 'notarch'` }); + }).catch(e => { throw e; }); + }); +}); diff --git a/test/handlers/assembly-documentation/arm32-tests.js b/test/handlers/assembly-documentation/arm32-tests.js index e76ca01f6..899e28e38 100644 --- a/test/handlers/assembly-documentation/arm32-tests.js +++ b/test/handlers/assembly-documentation/arm32-tests.js @@ -40,7 +40,7 @@ describe('arm32 assembly documentation', () => { .then(res => { res.should.have.status(404); res.should.be.json; - res.body.should.deep.equal({ error: 'Unknown opcode' }); + res.body.should.deep.equal({ error: 'Unknown opcode \'MOV_OH_WAIT\'' }); }).catch(e => { throw e; }); }); @@ -65,16 +65,6 @@ describe('arm32 assembly documentation', () => { }).catch(e => { throw e; }); }); - it('should respond to json for unknown opcodes', () => { - return chai.request(app) - .get('/asm/NOANOPCODE') - .set('Accept', 'application/json') - .then(res => { - res.should.have.status(404); - res.should.be.json; - }).catch(e => { throw e; }); - }); - it('should return 406 on bad accept type', () => { return chai.request(app).get('/asm/mov') .set('Accept', 'application/pdf') @@ -109,7 +99,7 @@ describe('arm32 assembly documentation', () => { .then(res => { res.should.have.status(404); res.should.be.json; - res.body.should.deep.equal({ error: 'Unknown opcode' }); + res.body.should.deep.equal({ error: 'Unknown opcode \'JNE\'' }); }).catch(e => { throw e; }); }); }); diff --git a/test/handlers/assembly-documentation/java-tests.js b/test/handlers/assembly-documentation/java-tests.js index 33f1f53f7..09b7ba4b9 100644 --- a/test/handlers/assembly-documentation/java-tests.js +++ b/test/handlers/assembly-documentation/java-tests.js @@ -40,7 +40,7 @@ describe('jvm assembly documentation', () => { .then(res => { res.should.have.status(404); res.should.be.json; - res.body.should.deep.equal({ error: 'Unknown opcode' }); + res.body.should.deep.equal({ error: 'Unknown opcode \'MOV_OH_WAIT\'' }); }).catch(e => { throw e; }); }); @@ -65,16 +65,6 @@ describe('jvm assembly documentation', () => { }).catch(e => { throw e; }); }); - it('should respond to json for unknown opcodes', () => { - return chai.request(app) - .get('/asm/NOANOPCODE') - .set('Accept', 'application/json') - .then(res => { - res.should.have.status(404); - res.should.be.json; - }).catch(e => { throw e; }); - }); - it('should return 406 on bad accept type', () => { return chai.request(app).get('/asm/iload_0') .set('Accept', 'application/pdf') From 28440e737cf0a7abd6bd7f7d9d5b4785d3618273 Mon Sep 17 00:00:00 2001 From: tpambor <1379478+tpambor@users.noreply.github.com> Date: Wed, 15 Dec 2021 19:16:07 +0100 Subject: [PATCH 02/14] Add xtensa compilers for ESP32, ESP32-S2, ESP32-S3 (#3145) --- etc/config/c.amazon.properties | 67 +++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/etc/config/c.amazon.properties b/etc/config/c.amazon.properties index bc0dd110d..159dce0f5 100644 --- a/etc/config/c.amazon.properties +++ b/etc/config/c.amazon.properties @@ -515,7 +515,7 @@ compiler.cicx202112.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 ############################### # Cross GCC -group.ccross.compilers=&cppc:&cmips:&cmsp:&cgccarm:&cavr:&rvcgcc:&cplatspec:&ckalray +group.ccross.compilers=&cppc:&cmips:&cmsp:&cgccarm:&cavr:&rvcgcc:&cxtensaesp32:&cxtensaesp32s2:&cxtensaesp32s3:&cplatspec:&ckalray group.ccross.supportsBinary=false group.ccross.groupName=Cross GCC @@ -848,6 +848,71 @@ compiler.rv32-cgcc1020.semver=10.2.0 compiler.rv32-cgcc1020.objdumper=/opt/compiler-explorer/riscv32/gcc-10.2.0/riscv32-unknown-elf/bin/riscv32-unknown-elf-objdump compiler.rv32-cgcc1020.supportsBinary=true +################################ +# GCC for Xtensa ESP32 +group.cxtensaesp32.compilers=cesp32g2019r2:cesp32g2020r1:cesp32g2020r2:cesp32g2020r3:cesp32g2021r1:cesp32g2021r2 +group.cxtensaesp32.groupName=Xtensa ESP32 GCC +group.cxtensaesp32.supportsBinary=false + +compiler.cesp32g2019r2.exe=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_2_0-esp-2019r2/bin/xtensa-esp32-elf-gcc +compiler.cesp32g2019r2.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_2_0-esp-2019r2/bin/xtensa-esp32-elf-objdump +compiler.cesp32g2019r2.name=Xtensa ESP32 gcc 8.2.0 (2019r2) +compiler.cesp32g2020r1.exe=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_2_0-esp-2020r1/bin/xtensa-esp32-elf-gcc +compiler.cesp32g2020r1.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_2_0-esp-2020r1/bin/xtensa-esp32-elf-objdump +compiler.cesp32g2020r1.name=Xtensa ESP32 gcc 8.2.0 (2020r1) +compiler.cesp32g2020r2.exe=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_2_0-esp-2020r2/bin/xtensa-esp32-elf-gcc +compiler.cesp32g2020r2.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_2_0-esp-2020r2/bin/xtensa-esp32-elf-objdump +compiler.cesp32g2020r2.name=Xtensa ESP32 gcc 8.2.0 (2020r2) +compiler.cesp32g2020r3.exe=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_4_0-esp-2020r3/bin/xtensa-esp32-elf-gcc +compiler.cesp32g2020r3.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_4_0-esp-2020r3/bin/xtensa-esp32-elf-objdump +compiler.cesp32g2020r3.name=Xtensa ESP32 gcc 8.4.0 (2020r3) +compiler.cesp32g2021r1.exe=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_4_0-esp-2021r1/bin/xtensa-esp32-elf-gcc +compiler.cesp32g2021r1.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_4_0-esp-2021r1/bin/xtensa-esp32-elf-objdump +compiler.cesp32g2021r1.name=Xtensa ESP32 gcc 8.4.0 (2021r1) +compiler.cesp32g2021r2.exe=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_4_0-esp-2021r2/bin/xtensa-esp32-elf-gcc +compiler.cesp32g2021r2.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32-elf-gcc8_4_0-esp-2021r2/bin/xtensa-esp32-elf-objdump +compiler.cesp32g2021r2.name=Xtensa ESP32 gcc 8.4.0 (2021r2) + +################################ +# GCC for Xtensa ESP32-S2 +group.cxtensaesp32s2.compilers=cesp32s2g2019r2:cesp32s2g2020r1:cesp32s2g2020r2:cesp32s2g2020r3:cesp32s2g2021r1:cesp32s2g2021r2 +group.cxtensaesp32s2.groupName=Xtensa ESP32-S2 GCC +group.cxtensaesp32s2.supportsBinary=false + +compiler.cesp32s2g2019r2.exe=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_2_0-esp-2019r2/bin/xtensa-esp32s2-elf-gcc +compiler.cesp32s2g2019r2.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_2_0-esp-2019r2/bin/xtensa-esp32s2-elf-objdump +compiler.cesp32s2g2019r2.name=Xtensa ESP32-S2 gcc 8.2.0 (2019r2) +compiler.cesp32s2g2020r1.exe=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r1/bin/xtensa-esp32s2-elf-gcc +compiler.cesp32s2g2020r1.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r1/bin/xtensa-esp32s2-elf-objdump +compiler.cesp32s2g2020r1.name=Xtensa ESP32-S2 gcc 8.2.0 (2020r1) +compiler.cesp32s2g2020r2.exe=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r2/bin/xtensa-esp32s2-elf-gcc +compiler.cesp32s2g2020r2.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r2/bin/xtensa-esp32s2-elf-objdump +compiler.cesp32s2g2020r2.name=Xtensa ESP32-S2 gcc 8.2.0 (2020r2) +compiler.cesp32s2g2020r3.exe=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_4_0-esp-2020r3/bin/xtensa-esp32s2-elf-gcc +compiler.cesp32s2g2020r3.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_4_0-esp-2020r3/bin/xtensa-esp32s2-elf-objdump +compiler.cesp32s2g2020r3.name=Xtensa ESP32-S2 gcc 8.4.0 (2020r3) +compiler.cesp32s2g2021r1.exe=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1/bin/xtensa-esp32s2-elf-gcc +compiler.cesp32s2g2021r1.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r1/bin/xtensa-esp32s2-elf-objdump +compiler.cesp32s2g2021r1.name=Xtensa ESP32-S2 gcc 8.4.0 (2021r1) +compiler.cesp32s2g2021r2.exe=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2/bin/xtensa-esp32s2-elf-gcc +compiler.cesp32s2g2021r2.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2/bin/xtensa-esp32s2-elf-objdump +compiler.cesp32s2g2021r2.name=Xtensa ESP32-S2 gcc 8.4.0 (2021r2) + +################################ +# GCC for Xtensa ESP32-S3 +group.cxtensaesp32s3.compilers=cesp32s3g2020r3:cesp32s3g2021r1:cesp32s3g2021r2 +group.cxtensaesp32s3.groupName=Xtensa ESP32-S3 GCC +group.cxtensaesp32s3.supportsBinary=false + +compiler.cesp32s3g2020r3.exe=/opt/compiler-explorer/xtensa/xtensa-esp32s3-elf-gcc8_4_0-esp-2020r3/bin/xtensa-esp32s3-elf-gcc +compiler.cesp32s3g2020r3.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32s3-elf-gcc8_4_0-esp-2020r3/bin/xtensa-esp32s3-elf-objdump +compiler.cesp32s3g2020r3.name=Xtensa ESP32-S3 gcc 8.4.0 (2020r3) +compiler.cesp32s3g2021r1.exe=/opt/compiler-explorer/xtensa/xtensa-esp32s3-elf-gcc8_4_0-esp-2021r1/bin/xtensa-esp32s3-elf-gcc +compiler.cesp32s3g2021r1.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32s3-elf-gcc8_4_0-esp-2021r1/bin/xtensa-esp32s3-elf-objdump +compiler.cesp32s3g2021r1.name=Xtensa ESP32-S3 gcc 8.4.0 (2021r1) +compiler.cesp32s3g2021r2.exe=/opt/compiler-explorer/xtensa/xtensa-esp32s3-elf-gcc8_4_0-esp-2021r2/bin/xtensa-esp32s3-elf-gcc +compiler.cesp32s3g2021r2.objdumper=/opt/compiler-explorer/xtensa/xtensa-esp32s3-elf-gcc8_4_0-esp-2021r2/bin/xtensa-esp32s3-elf-objdump +compiler.cesp32s3g2021r2.name=Xtensa ESP32-S3 gcc 8.4.0 (2021r2) ############################### # ARM HPC (disabled) From f04db1f59d68b6c6a9b7a30450d678030e99b24e Mon Sep 17 00:00:00 2001 From: Mats Larsen Date: Wed, 15 Dec 2021 18:19:04 +0000 Subject: [PATCH 03/14] Add compilers for Kotlin 1.6.10 (#3178) * Add compilers for Kotlin 1.6.10 * Change default compiler --- etc/config/kotlin.amazon.properties | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/etc/config/kotlin.amazon.properties b/etc/config/kotlin.amazon.properties index 07728cfec..d3d6a2873 100644 --- a/etc/config/kotlin.amazon.properties +++ b/etc/config/kotlin.amazon.properties @@ -3,7 +3,7 @@ compilerType=kotlin versionFlag=-version objdumper=/opt/compiler-explorer/jdk-17.0.0/bin/javap instructionSet=java -defaultCompiler=kotlinc1600 +defaultCompiler=kotlinc1610 demangler= postProcess= options= @@ -12,7 +12,7 @@ needsMulti=false supportsExecute=true interpreted=true -group.kotlin.compilers=kotlinc1400:kotlinc1410:kotlinc1420:kotlinc1421:kotlinc1430:kotlinc1431:kotlinc1432:kotlinc1500:kotlinc1510:kotlinc1520:kotlinc1521:kotlinc1530:kotlinc1531:kotlinc1600 +group.kotlin.compilers=kotlinc1400:kotlinc1410:kotlinc1420:kotlinc1421:kotlinc1430:kotlinc1431:kotlinc1432:kotlinc1500:kotlinc1510:kotlinc1520:kotlinc1521:kotlinc1530:kotlinc1531:kotlinc1600:kotlinc1610 group.kotlin.groupName=Kotlin group.kotlin.baseName=kotlinc group.kotlin.isSemVer=true @@ -72,3 +72,7 @@ compiler.kotlinc1600.exe=/opt/compiler-explorer/kotlin-jvm-1.6.0/bin/kotlinc-jvm compiler.kotlinc1600.semver=1.6.0 compiler.kotlinc1600.java_home=/opt/compiler-explorer/jdk-16.0.1 compiler.kotlinc1600.runtime=/opt/compiler-explorer/jdk-16.0.1/bin/java +compiler.kotlinc1610.exe=/opt/compiler-explorer/kotlin-jvm-1.6.10/bin/kotlinc-jvm +compiler.kotlinc1610.semver=1.6.10 +compiler.kotlinc1610.java_home=/opt/compiler-explorer/jdk-16.0.1 +compiler.kotlinc1610.runtime=/opt/compiler-explorer/jdk-16.0.1/bin/java From 04787cef0515102cd7e4a07fc116ba67f1753b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Wed, 15 Dec 2021 19:19:35 +0100 Subject: [PATCH 04/14] Fix source/assembly mapping when GNAT expanded code pane opened (#3177) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix source/assembly mapping when GNAT expanded code pane opened Using -gnatDGL to get the expanded code also asks GNAT to emit debug informations pointing to the .dg file containing the expanded code, breaking CE that is using these info to map assembly and source lines. Using -gnatGL instead avoids the breaking of asm/source mapping but emits the expanded code in stdout instead of a plain file. This change replaces -gnatDGL by -gnatGL and extracts the expanded code from stdout. fixes #3171 Signed-off-by: Marc Poulhiès * fixup! Fix source/assembly mapping when GNAT expanded code pane opened --- lib/base-compiler.js | 43 +++++++++++++++++++++++++++---------------- lib/compilers/ada.js | 3 ++- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/lib/base-compiler.js b/lib/base-compiler.js index cdf3dab87..f66a51937 100644 --- a/lib/base-compiler.js +++ b/lib/base-compiler.js @@ -789,10 +789,6 @@ export class BaseCompiler { return inputFilename.replace(path.extname(inputFilename), '.ll'); } - getGnatDebugOutputFilename(inputFilename) { - return inputFilename + '.dg'; - } - getOutputFilename(dirPath, outputFilebase, key) { let filename; if (key && key.backendOptions && key.backendOptions.customOutputFilename) { @@ -812,25 +808,40 @@ export class BaseCompiler { return this.getOutputFilename(dirPath, outputFilebase, key); } - async processGnatDebugOutput(inputFilename, output) { - const gnatDebugPath = this.getGnatDebugOutputFilename(inputFilename); + async processGnatDebugOutput(inputFilename, result) { + const content = []; + const keep_stdout = []; + + // Everything before this stays in stdout. + // Everything after is considered expanded code and is moved to the + // corresponding pane. + const startOfExpandedCode = /^Source recreated/; + let isInExpandedCode = false; + + for (const obj of Object.values(result.stdout)) { + if (!isInExpandedCode && startOfExpandedCode.test(obj.text)) { + isInExpandedCode = true; + } + + if (isInExpandedCode) + content.push(obj); + else + keep_stdout.push(obj); + } // Do not check compiler result before looking for expanded code. The - // compiler may exit with an error after the emission. This file is also + // compiler may exit with an error after the emission. This dump is also // very usefull to debug error message. - if (await fs.exists(gnatDebugPath)) { - const content = await fs.readFile(gnatDebugPath, 'utf-8'); - return content.split('\n').map((line) => ({ - text: line, - })); - } else { - // check for possible cause for missing file - if (output.code !== 0) { + + if (content.length === 0) + if (result.code !== 0) { return [{text: 'GNAT exited with an error and did not create the expanded code'}]; } else { return [{text: 'GNAT exited successfully but the expanded code is missing, something is wrong'}]; } - } + + result.stdout = keep_stdout; + return content; } /** diff --git a/lib/compilers/ada.js b/lib/compilers/ada.js index 6a93249de..47b2f27b0 100644 --- a/lib/compilers/ada.js +++ b/lib/compilers/ada.js @@ -51,7 +51,8 @@ export class AdaCompiler extends BaseCompiler { const opts = super.optionsForBackend (backendOptions, outputFilename); if (backendOptions.produceGnatDebug && this.compiler.supportsGnatDebugView) - opts.push('-gnatDGL'); + // This is using stdout + opts.push('-gnatGL'); return opts; } From c8b25ee53b69944114c2087bd945f8603d00da08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Wed, 15 Dec 2021 19:25:16 +0100 Subject: [PATCH 05/14] Fix missing gimple and original tree dump in GCC dump (#3183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both gimple and original dumps are missing because CE currently only checks for dumps coming from a pass advertised in -fdump-passes. Fix this by faking 2 lines as coming from -fdump-passes. fixes #3180 Signed-off-by: Marc Poulhiès --- lib/base-compiler.js | 47 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/lib/base-compiler.js b/lib/base-compiler.js index f66a51937..3b4946a3b 100644 --- a/lib/base-compiler.js +++ b/lib/base-compiler.js @@ -846,7 +846,7 @@ export class BaseCompiler { /** * @returns {{filename_suffix: string, name: string, command_prefix: string}} - * `filename_suffix`: dump file name suffix if GCC default dump names is used + * `filename_suffix`: dump file name suffix if GCC default dump name is used * * `name`: the name to be displayed in the UI * @@ -1746,24 +1746,55 @@ export class BaseCompiler { currentPassOutput: '', syntaxHighlight: false, }; + const treeDumpsNotInPasses = []; + const selectedPasses = []; - if (opts.treeDump) selectedPasses.push('tree'); + if (opts.treeDump) { + selectedPasses.push('tree'); + + // Fake 2 lines as coming from -fdump-passes + // This allows the insertion of 'gimple' and 'original' + // tree dumps that are not really part of a tree pass. + treeDumpsNotInPasses.push ( + [ { text: 'tree-original: ON'}, + { + filename_suffix: 't.original', + name: 'original (tree)', + command_prefix: '-fdump-tree-original', + }, + ], + [ { text: 'tree-gimple: ON'}, + { + filename_suffix: 't.gimple', + name: 'gimple (tree)', + command_prefix: '-fdump-tree-gimple', + }, + ]); + } + if (opts.ipaDump) selectedPasses.push('ipa'); if (opts.rtlDump) selectedPasses.push('rtl'); + // Defaults to a custom file derived from output file name. Works when + // using the -fdump-tree-foo=FILE variant (!removeEmptyPasses). + // Will be overriden later if not. let dumpFileName = this.getGccDumpFileName(outputFilename); let passFound = false; const filtered_stderr = []; const toRemoveFromStderr = /^\s*((ipa|tree|rtl)-)|(\*)([\w-]+).*(ON|OFF)$/; - for (const obj of Object.values(result.stderr)) { - const selectizeObject = this.fromInternalGccDumpName(obj.text, selectedPasses); - if (selectizeObject){ + + const dumpPassesLines = treeDumpsNotInPasses.concat( + Object.values(result.stderr).map( + x => [x, this.fromInternalGccDumpName(x.text, selectedPasses)])); + + for (const [obj, selectizeObject] of dumpPassesLines) { + if (selectizeObject) { if (opts.pass && opts.pass.name === selectizeObject.name) passFound = true; - if (removeEmptyPasses){ + if (removeEmptyPasses) { const f = fs.readdirSync(rootDir).filter(fn => fn.endsWith(selectizeObject.filename_suffix)); // pass is enabled, but the dump hasn't produced anything: @@ -1771,14 +1802,14 @@ export class BaseCompiler { if (f.length === 0) continue; - if (opts.pass && opts.pass.name === selectizeObject.name) + if (passFound) dumpFileName = path.join(rootDir, f[0]); } output.all.push(selectizeObject); } - if (!toRemoveFromStderr.test(obj.text)){ + if (!toRemoveFromStderr.test(obj.text)) { filtered_stderr.push(obj); } } From 112df3211679a67a27ad45f0aefd99db5c690000 Mon Sep 17 00:00:00 2001 From: Mats Larsen Date: Wed, 15 Dec 2021 18:30:03 +0000 Subject: [PATCH 06/14] Use api.ts file for formatter api requests (#3160) --- static/api/api.ts | 34 ++++++++++++++----- .../formatting.interfaces.ts} | 8 ++--- static/formatter-registry.ts | 19 ++++------- 3 files changed, 35 insertions(+), 26 deletions(-) rename static/{formatter-registry.interfaces.ts => api/formatting.interfaces.ts} (93%) diff --git a/static/api/api.ts b/static/api/api.ts index f73ceee23..03a39b59d 100644 --- a/static/api/api.ts +++ b/static/api/api.ts @@ -22,25 +22,41 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. +import _ from 'underscore'; + import { AssemblyDocumentationResponse, AssemblyDocumentationRequest } from './assemblydocumentation.interfaces'; +import { FormattingRequest, FormattingResponse } from './formatting.interfaces'; /** Type wrapper allowing .json() to resolve to a concrete type */ -type TypedResponse = Response & { - json(): Promise +interface TypedResponse extends Response { + json(): Promise; } /** Lightweight fetch() wrapper for CE API urls */ const request = async (uri: string, options?: RequestInit): Promise> => fetch( `${window.location.origin}${window.httpRoot}api${uri}`, { - ...options, - headers: { - ...options?.headers, - 'Accept': 'application/json', - } + ...options, + credentials: 'include', + headers: { + ...options?.headers, + 'Accept': 'application/json', + }, }, ); +/** GET /api/asm/:arch/:instruction */ export const getAssemblyDocumentation = async ( - options: AssemblyDocumentationRequest -) => request(`/asm/${options.instructionSet}/${options.opcode}`); + options: AssemblyDocumentationRequest, +) => await request(`/asm/${options.instructionSet}/${options.opcode}`); + +/** POST /api/format/:formatter */ +export const getFormattedCode = async ( + options: FormattingRequest, +) => await request(`/format/${options.formatterId}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(_.pick(options, 'source', 'base', 'tabWidth', 'useSpaces')), +}); diff --git a/static/formatter-registry.interfaces.ts b/static/api/formatting.interfaces.ts similarity index 93% rename from static/formatter-registry.interfaces.ts rename to static/api/formatting.interfaces.ts index c60aaa188..b2849d211 100644 --- a/static/formatter-registry.interfaces.ts +++ b/static/api/formatting.interfaces.ts @@ -22,9 +22,9 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import { FormatBase } from './settings.interfaces'; +import { FormatBase } from '../settings.interfaces'; -export interface FormatRequestOptions { +export interface FormattingRequest { source: string; formatterId: string; /** @@ -37,8 +37,8 @@ export interface FormatRequestOptions { useSpaces: boolean; } -export interface FormatResponse { +export interface FormattingResponse { answer: string; exit: number; throw?: true; -} +} \ No newline at end of file diff --git a/static/formatter-registry.ts b/static/formatter-registry.ts index d7224002c..818152f97 100644 --- a/static/formatter-registry.ts +++ b/static/formatter-registry.ts @@ -26,8 +26,9 @@ import * as monaco from 'monaco-editor'; import { Alert } from './alert'; import { getStoredSettings } from './settings'; -import { FormatRequestOptions, FormatResponse } from './formatter-registry.interfaces'; import { SiteSettings } from './settings.interfaces'; +import { FormattingRequest } from './api/formatting.interfaces'; +import { getFormattedCode } from './api/api'; // Proxy function to emit the error to the alert system const onFormatError = (cause: string, source: string) => { @@ -39,17 +40,9 @@ const onFormatError = (cause: string, source: string) => { return source; }; -const getFormattedCode = async ({ source, formatterId, base, tabWidth, useSpaces }: FormatRequestOptions) => { - const res = await fetch(`${window.location.origin}${window.httpRoot}api/format/${formatterId}`, { - method: 'POST', - credentials: 'include', - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - }, - body: JSON.stringify({ source, base, tabWidth, useSpaces }), - }); - const body = await res.json() as FormatResponse; +const doFormatRequest = async (options: FormattingRequest) => { + const res = await getFormattedCode(options); + const body = await res.json(); if (res.status === 200 && body.exit === 0) { // API sent 200 and we have a valid response return body.answer; @@ -84,7 +77,7 @@ const getDocumentFormatter = ( const source = model.getValue(); // Request the formatted code. If that API call fails, we just back off // and return the user's old code. - const formattedSource = await getFormattedCode({ + const formattedSource = await doFormatRequest({ formatterId: formatter, tabWidth: settings.tabWidth, useSpaces: settings.useSpaces, From 819e18a045de54278b2a5f2f0f40b4607fba9760 Mon Sep 17 00:00:00 2001 From: timmy-ms <78125318+timmy-ms@users.noreply.github.com> Date: Wed, 15 Dec 2021 10:34:02 -0800 Subject: [PATCH 07/14] Create microsoft-analysis-tool.js (#3172) --- lib/tooling/_all.js | 3 +- lib/tooling/microsoft-analysis-tool.js | 59 ++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 lib/tooling/microsoft-analysis-tool.js diff --git a/lib/tooling/_all.js b/lib/tooling/_all.js index 621b65546..c09ab033c 100644 --- a/lib/tooling/_all.js +++ b/lib/tooling/_all.js @@ -1,4 +1,4 @@ -// Copyright (c) 2020, Compiler Explorer Authors +// Copyright (c) 2021, Compiler Explorer Authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -27,6 +27,7 @@ export { ClangQueryTool } from './clang-query-tool'; export { ClangTidyTool } from './clang-tidy-tool'; export { CompilerDropinTool } from './compiler-dropin-tool'; export { LLVMMcaTool } from './llvm-mca-tool'; +export { MicrosoftAnalysisTool } from './microsoft-analysis-tool'; export { OSACATool } from './osaca-tool'; export { PaholeTool } from './pahole-tool'; export { PvsStudioTool } from './pvs-studio-tool'; diff --git a/lib/tooling/microsoft-analysis-tool.js b/lib/tooling/microsoft-analysis-tool.js new file mode 100644 index 000000000..19f2676f7 --- /dev/null +++ b/lib/tooling/microsoft-analysis-tool.js @@ -0,0 +1,59 @@ +// Copyright (c) 2021, Compiler Explorer Authors +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +import path from 'path'; + +import fs from 'fs-extra'; + +import * as utils from '../utils'; + +import { BaseTool } from './base-tool'; + +export class MicrosoftAnalysisTool extends BaseTool { + static get key() { return 'microsoft-analysis-tool'; } + + constructor(toolInfo, env) { + super(toolInfo, env); + + this.addOptionsToToolArgs = false; + } + + async runTool(compilationInfo, inputFilepath, args, stdin, supportedLibraries) { + const sourcefile = inputFilepath; + const options = compilationInfo.options; + const libOptions = super.getLibraryOptions(compilationInfo.libraries, supportedLibraries); + const includeflags = super.getIncludeArguments(compilationInfo.libraries, supportedLibraries); + + let compileFlags = utils.splitArguments(compilationInfo.compiler.options); + compileFlags = compileFlags.concat(includeflags); + compileFlags = compileFlags.concat(libOptions); + + const manualCompileFlags = options.filter(option => (option !== sourcefile)); + compileFlags = compileFlags.concat(manualCompileFlags); + compileFlags = compileFlags.concat("/analyze:plugin EspXEngine.dll"); + compileFlags = compileFlags.concat(this.tool.options); + + return await super.runTool(compilationInfo, sourcefile, args); + } +} From 86d9ca5de22903726715fa4e11fe342584b9ed9a Mon Sep 17 00:00:00 2001 From: Patrick Quist Date: Wed, 15 Dec 2021 20:20:11 +0100 Subject: [PATCH 08/14] mpcoro api too unstable for examples --- etc/config/c++.amazon.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/config/c++.amazon.properties b/etc/config/c++.amazon.properties index cde8dbf7e..27f063944 100644 --- a/etc/config/c++.amazon.properties +++ b/etc/config/c++.amazon.properties @@ -1867,7 +1867,6 @@ libs.mp-coro.name=mp-coro libs.mp-coro.versions=trunk libs.mp-coro.url=https://github.com/mpusz/mp-coro libs.mp-coro.description=A C++20 coroutine support library -libs.mp-coro.examples=rYqW65rxr libs.mp-coro.versions.trunk.version=trunk libs.mp-coro.versions.trunk.path=/opt/compiler-explorer/libs/mp-coro/trunk/src/include From 0de5dd994382319804d472f1338182b008932de9 Mon Sep 17 00:00:00 2001 From: partouf Date: Wed, 15 Dec 2021 19:35:31 +0000 Subject: [PATCH 09/14] Revert "Fix missing gimple and original tree dump in GCC dump (#3183)" This reverts commit c8b25ee53b69944114c2087bd945f8603d00da08. --- lib/base-compiler.js | 47 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/lib/base-compiler.js b/lib/base-compiler.js index 3b4946a3b..f66a51937 100644 --- a/lib/base-compiler.js +++ b/lib/base-compiler.js @@ -846,7 +846,7 @@ export class BaseCompiler { /** * @returns {{filename_suffix: string, name: string, command_prefix: string}} - * `filename_suffix`: dump file name suffix if GCC default dump name is used + * `filename_suffix`: dump file name suffix if GCC default dump names is used * * `name`: the name to be displayed in the UI * @@ -1746,55 +1746,24 @@ export class BaseCompiler { currentPassOutput: '', syntaxHighlight: false, }; - const treeDumpsNotInPasses = []; - const selectedPasses = []; - if (opts.treeDump) { - selectedPasses.push('tree'); - - // Fake 2 lines as coming from -fdump-passes - // This allows the insertion of 'gimple' and 'original' - // tree dumps that are not really part of a tree pass. - treeDumpsNotInPasses.push ( - [ { text: 'tree-original: ON'}, - { - filename_suffix: 't.original', - name: 'original (tree)', - command_prefix: '-fdump-tree-original', - }, - ], - [ { text: 'tree-gimple: ON'}, - { - filename_suffix: 't.gimple', - name: 'gimple (tree)', - command_prefix: '-fdump-tree-gimple', - }, - ]); - } - + if (opts.treeDump) selectedPasses.push('tree'); if (opts.ipaDump) selectedPasses.push('ipa'); if (opts.rtlDump) selectedPasses.push('rtl'); - // Defaults to a custom file derived from output file name. Works when - // using the -fdump-tree-foo=FILE variant (!removeEmptyPasses). - // Will be overriden later if not. let dumpFileName = this.getGccDumpFileName(outputFilename); let passFound = false; const filtered_stderr = []; const toRemoveFromStderr = /^\s*((ipa|tree|rtl)-)|(\*)([\w-]+).*(ON|OFF)$/; - - const dumpPassesLines = treeDumpsNotInPasses.concat( - Object.values(result.stderr).map( - x => [x, this.fromInternalGccDumpName(x.text, selectedPasses)])); - - for (const [obj, selectizeObject] of dumpPassesLines) { - if (selectizeObject) { + for (const obj of Object.values(result.stderr)) { + const selectizeObject = this.fromInternalGccDumpName(obj.text, selectedPasses); + if (selectizeObject){ if (opts.pass && opts.pass.name === selectizeObject.name) passFound = true; - if (removeEmptyPasses) { + if (removeEmptyPasses){ const f = fs.readdirSync(rootDir).filter(fn => fn.endsWith(selectizeObject.filename_suffix)); // pass is enabled, but the dump hasn't produced anything: @@ -1802,14 +1771,14 @@ export class BaseCompiler { if (f.length === 0) continue; - if (passFound) + if (opts.pass && opts.pass.name === selectizeObject.name) dumpFileName = path.join(rootDir, f[0]); } output.all.push(selectizeObject); } - if (!toRemoveFromStderr.test(obj.text)) { + if (!toRemoveFromStderr.test(obj.text)){ filtered_stderr.push(obj); } } From e003f1112245f35cfc9eac4f2ebf05d19b1f05f0 Mon Sep 17 00:00:00 2001 From: partouf Date: Wed, 15 Dec 2021 21:01:54 +0000 Subject: [PATCH 10/14] Revert "Create microsoft-analysis-tool.js (#3172)" This reverts commit 819e18a045de54278b2a5f2f0f40b4607fba9760. --- lib/tooling/_all.js | 3 +- lib/tooling/microsoft-analysis-tool.js | 59 -------------------------- 2 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 lib/tooling/microsoft-analysis-tool.js diff --git a/lib/tooling/_all.js b/lib/tooling/_all.js index c09ab033c..621b65546 100644 --- a/lib/tooling/_all.js +++ b/lib/tooling/_all.js @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Compiler Explorer Authors +// Copyright (c) 2020, Compiler Explorer Authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -27,7 +27,6 @@ export { ClangQueryTool } from './clang-query-tool'; export { ClangTidyTool } from './clang-tidy-tool'; export { CompilerDropinTool } from './compiler-dropin-tool'; export { LLVMMcaTool } from './llvm-mca-tool'; -export { MicrosoftAnalysisTool } from './microsoft-analysis-tool'; export { OSACATool } from './osaca-tool'; export { PaholeTool } from './pahole-tool'; export { PvsStudioTool } from './pvs-studio-tool'; diff --git a/lib/tooling/microsoft-analysis-tool.js b/lib/tooling/microsoft-analysis-tool.js deleted file mode 100644 index 19f2676f7..000000000 --- a/lib/tooling/microsoft-analysis-tool.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2021, Compiler Explorer Authors -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -import path from 'path'; - -import fs from 'fs-extra'; - -import * as utils from '../utils'; - -import { BaseTool } from './base-tool'; - -export class MicrosoftAnalysisTool extends BaseTool { - static get key() { return 'microsoft-analysis-tool'; } - - constructor(toolInfo, env) { - super(toolInfo, env); - - this.addOptionsToToolArgs = false; - } - - async runTool(compilationInfo, inputFilepath, args, stdin, supportedLibraries) { - const sourcefile = inputFilepath; - const options = compilationInfo.options; - const libOptions = super.getLibraryOptions(compilationInfo.libraries, supportedLibraries); - const includeflags = super.getIncludeArguments(compilationInfo.libraries, supportedLibraries); - - let compileFlags = utils.splitArguments(compilationInfo.compiler.options); - compileFlags = compileFlags.concat(includeflags); - compileFlags = compileFlags.concat(libOptions); - - const manualCompileFlags = options.filter(option => (option !== sourcefile)); - compileFlags = compileFlags.concat(manualCompileFlags); - compileFlags = compileFlags.concat("/analyze:plugin EspXEngine.dll"); - compileFlags = compileFlags.concat(this.tool.options); - - return await super.runTool(compilationInfo, sourcefile, args); - } -} From d00878f2b8e53a3755776724269eaaa9c3e1167b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Wed, 15 Dec 2021 19:25:16 +0100 Subject: [PATCH 11/14] Fix missing gimple and original tree dump in GCC dump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both gimple and original dumps are missing because CE currently only checks for dumps coming from a pass advertised in -fdump-passes. Fix this by faking 2 lines as coming from -fdump-passes. fixes #3180 This is a fixed version of c8b25ee53b69944114c2087bd945f8603d00da08 (#3183) Signed-off-by: Marc Poulhiès --- lib/base-compiler.js | 45 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/lib/base-compiler.js b/lib/base-compiler.js index f66a51937..9730bc1a7 100644 --- a/lib/base-compiler.js +++ b/lib/base-compiler.js @@ -846,7 +846,7 @@ export class BaseCompiler { /** * @returns {{filename_suffix: string, name: string, command_prefix: string}} - * `filename_suffix`: dump file name suffix if GCC default dump names is used + * `filename_suffix`: dump file name suffix if GCC default dump name is used * * `name`: the name to be displayed in the UI * @@ -1746,24 +1746,55 @@ export class BaseCompiler { currentPassOutput: '', syntaxHighlight: false, }; + const treeDumpsNotInPasses = []; + const selectedPasses = []; - if (opts.treeDump) selectedPasses.push('tree'); + if (opts.treeDump) { + selectedPasses.push('tree'); + + // Fake 2 lines as coming from -fdump-passes + // This allows the insertion of 'gimple' and 'original' + // tree dumps that are not really part of a tree pass. + treeDumpsNotInPasses.push ( + [ { text: 'tree-original: ON'}, + { + filename_suffix: 't.original', + name: 'original (tree)', + command_prefix: '-fdump-tree-original', + }, + ], + [ { text: 'tree-gimple: ON'}, + { + filename_suffix: 't.gimple', + name: 'gimple (tree)', + command_prefix: '-fdump-tree-gimple', + }, + ]); + } + if (opts.ipaDump) selectedPasses.push('ipa'); if (opts.rtlDump) selectedPasses.push('rtl'); + // Defaults to a custom file derived from output file name. Works when + // using the -fdump-tree-foo=FILE variant (!removeEmptyPasses). + // Will be overriden later if not. let dumpFileName = this.getGccDumpFileName(outputFilename); let passFound = false; const filtered_stderr = []; const toRemoveFromStderr = /^\s*((ipa|tree|rtl)-)|(\*)([\w-]+).*(ON|OFF)$/; - for (const obj of Object.values(result.stderr)) { - const selectizeObject = this.fromInternalGccDumpName(obj.text, selectedPasses); - if (selectizeObject){ + + const dumpPassesLines = treeDumpsNotInPasses.concat( + Object.values(result.stderr).map( + x => [x, this.fromInternalGccDumpName(x.text, selectedPasses)])); + + for (const [obj, selectizeObject] of dumpPassesLines) { + if (selectizeObject) { if (opts.pass && opts.pass.name === selectizeObject.name) passFound = true; - if (removeEmptyPasses){ + if (removeEmptyPasses) { const f = fs.readdirSync(rootDir).filter(fn => fn.endsWith(selectizeObject.filename_suffix)); // pass is enabled, but the dump hasn't produced anything: @@ -1778,7 +1809,7 @@ export class BaseCompiler { output.all.push(selectizeObject); } - if (!toRemoveFromStderr.test(obj.text)){ + if (!toRemoveFromStderr.test(obj.text)) { filtered_stderr.push(obj); } } From b74a8dfcfea9749312856007198f619ccdd6babb Mon Sep 17 00:00:00 2001 From: partouf Date: Wed, 15 Dec 2021 22:02:16 +0000 Subject: [PATCH 12/14] Revert "Update vis" This reverts commit 2b2d324d3a1336e521b399102996f5d531158c7b. --- package-lock.json | 20 ++++++++++---------- package.json | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index e51c17a24..a75b1ca5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10310,9 +10310,9 @@ "dev": true }, "moment": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", - "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" }, "monaco-editor": { "version": "0.27.0", @@ -12478,11 +12478,11 @@ "dev": true }, "propagating-hammerjs": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/propagating-hammerjs/-/propagating-hammerjs-1.5.0.tgz", - "integrity": "sha512-3PUXWmomwutoZfydC+lJwK1bKCh6sK6jZGB31RUX6+4EXzsbkDZrK4/sVR7gBrvJaEIwpTVyxQUAd29FKkmVdw==", + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/propagating-hammerjs/-/propagating-hammerjs-1.4.6.tgz", + "integrity": "sha1-/tAOmwB2f/1C0U9bUxvEk+tnLjc=", "requires": { - "hammerjs": "^2.0.8" + "hammerjs": "^2.0.6" } }, "protobufjs": { @@ -15774,9 +15774,9 @@ } }, "vis": { - "version": "4.21.0-EOL", - "resolved": "https://registry.npmjs.org/vis/-/vis-4.21.0-EOL.tgz", - "integrity": "sha512-JVS1mywKg5S88XbkDJPfCb3n+vlg5fMA8Ae2hzs3KHAwD4ryM5qwlbFZ6ReDfY8te7I4NLCpuCoywJQEehvJlQ==", + "version": "4.20.1", + "resolved": "https://registry.npmjs.org/vis/-/vis-4.20.1.tgz", + "integrity": "sha1-Z+ku2v5y2mOxXJMCmRr57fL4Zhk=", "requires": { "emitter-component": "^1.1.1", "hammerjs": "^2.0.8", diff --git a/package.json b/package.json index ee663537d..3e2beb26b 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "tslib": "^2.3.1", "underscore": "^1.13.1", "url-join": "^4.0.1", - "vis": "^4.21.0-EOL", + "vis": "4.20.1", "whatwg-fetch": "^3.6.2", "which": "^2.0.2", "winston": "^3.3.3", From 0e34de6d9b898d9ac1330c653668d0e1832f054e Mon Sep 17 00:00:00 2001 From: Patrick Quist Date: Thu, 16 Dec 2021 02:26:16 +0100 Subject: [PATCH 13/14] Update test-and-deploy.yml --- .github/workflows/test-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index e5c5f8194..a94273506 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -1,6 +1,6 @@ name: Compiler Explorer -on: [ push ] +on: [push, pull_request] jobs: build-and-test: From 0330722e3856015151e3998768badf96faf1aa78 Mon Sep 17 00:00:00 2001 From: Anders Schau Knatten Date: Mon, 20 Dec 2021 20:26:23 +0100 Subject: [PATCH 14/14] Add link to Assembly talk (#3195) This adds a link in the Videos section of the README to the talk "Just Enough Assembly for Compiler Explorer" which I gave at CppCon 2021. (As mentioned on Twitter https://twitter.com/knatten/status/1472937932814172160) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4da68ec44..81ba764a3 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ There are a number of videos that showcase some features of Compiler Explorer: * [Presentation for CppCon 2019 about the project](https://www.youtube.com/watch?v=kIoZDUd5DKw) * [Older 2 part series of videos](https://www.youtube.com/watch?v=4_HL3PH4wDg) which go into a bit more detail into the more obscure features. +* [Just Enough Assembly for Compiler Explorer](https://youtu.be/QLolzolunJ4): Practical introduction to Assembly with a focus on usage on Compiler Explorer, from CppCon 2021. * [Playlist: Compiler Explorer](https://www.youtube.com/playlist?list=PL2HVqYf7If8dNYVN6ayjB06FPyhHCcnhG): A collection of videos discussing Compiler Explorer; using it, installing it, what it's for, etc. A [Road map](docs/Roadmap.md) is available which gives a little insight into