diff --git a/cypress/e2e/remote-id.cy.ts b/cypress/e2e/remote-id.cy.ts new file mode 100644 index 000000000..c043eca90 --- /dev/null +++ b/cypress/e2e/remote-id.cy.ts @@ -0,0 +1,9 @@ +import {runFrontendTest} from '../support/utils'; + +describe('RemoteId testing', () => { + before(() => { + cy.visit('/'); + }); + + runFrontendTest('remoteId'); +}); diff --git a/etc/config/kotlin.amazon.properties b/etc/config/kotlin.amazon.properties index 838c36f64..d4d8ddef2 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-23.0.1/bin/javap instructionSet=java -defaultCompiler=kotlinc2100 +defaultCompiler=kotlinc2121 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:kotlinc1610:kotlinc1620:kotlinc1700:kotlinc1800:kotlinc1810:kotlinc1820:kotlinc1900:kotlinc1910:kotlinc1920:kotlinc2000:kotlinc2010:kotlinc2020:kotlinc2021:kotlinc2100 +group.kotlin.compilers=kotlinc1400:kotlinc1410:kotlinc1420:kotlinc1421:kotlinc1430:kotlinc1431:kotlinc1432:kotlinc1500:kotlinc1510:kotlinc1520:kotlinc1521:kotlinc1530:kotlinc1531:kotlinc1600:kotlinc1610:kotlinc1620:kotlinc1700:kotlinc1800:kotlinc1810:kotlinc1820:kotlinc1900:kotlinc1910:kotlinc1920:kotlinc2000:kotlinc2010:kotlinc2020:kotlinc2021:kotlinc2100:kotlinc2110:kotlinc2120:kotlinc2121 group.kotlin.groupName=Kotlin group.kotlin.baseName=kotlinc group.kotlin.isSemVer=true @@ -131,6 +131,18 @@ compiler.kotlinc2100.exe=/opt/compiler-explorer/kotlin-jvm-2.1.0/bin/kotlinc-jvm compiler.kotlinc2100.semver=2.1.0 compiler.kotlinc2100.java_home=/opt/compiler-explorer/jdk-23.0.1 compiler.kotlinc2100.runtime=/opt/compiler-explorer/jdk-23.0.1/bin/java +compiler.kotlinc2110.exe=/opt/compiler-explorer/kotlin-jvm-2.1.10/bin/kotlinc-jvm +compiler.kotlinc2110.semver=2.1.10 +compiler.kotlinc2110.java_home=/opt/compiler-explorer/jdk-23.0.1 +compiler.kotlinc2110.runtime=/opt/compiler-explorer/jdk-23.0.1/bin/java +compiler.kotlinc2120.exe=/opt/compiler-explorer/kotlin-jvm-2.1.20/bin/kotlinc-jvm +compiler.kotlinc2120.semver=2.1.20 +compiler.kotlinc2120.java_home=/opt/compiler-explorer/jdk-23.0.1 +compiler.kotlinc2120.runtime=/opt/compiler-explorer/jdk-23.0.1/bin/java +compiler.kotlinc2121.exe=/opt/compiler-explorer/kotlin-jvm-2.1.21/bin/kotlinc-jvm +compiler.kotlinc2121.semver=2.1.21 +compiler.kotlinc2121.java_home=/opt/compiler-explorer/jdk-23.0.1 +compiler.kotlinc2121.runtime=/opt/compiler-explorer/jdk-23.0.1/bin/java libs=kotlinx-coroutines-core-jvm diff --git a/etc/config/rust.amazon.properties b/etc/config/rust.amazon.properties index df07619a9..37e4c8f2c 100644 --- a/etc/config/rust.amazon.properties +++ b/etc/config/rust.amazon.properties @@ -2,14 +2,14 @@ compilers=&rust:&rustgcc:&mrustc:&rustccggcc objdumper=/opt/compiler-explorer/gcc-14.1.0/bin/objdump linker=/opt/compiler-explorer/gcc-14.1.0/bin/gcc aarch64linker=/opt/compiler-explorer/arm64/gcc-14.1.0/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc -defaultCompiler=r1860 +defaultCompiler=r1870 demangler=/opt/compiler-explorer/gcc-14.1.0/bin/c++filt demanglerArgs=--format=rust buildenvsetup=ceconan-rust buildenvsetup.host=https://conan.compiler-explorer.com -group.rust.compilers=r1860:r1850:r1840:r1830:r1820:r1810:r1800:r1790:r1780:r1770:r1760:r1750:r1740:r1730:r1720:r1710:r1700:r1690:r1680:r1670:r1660:r1650:r1640:r1630:r1620:r1610:r1600:r1590:r1580:r1570:r1560:r1550:r1540:r1530:r1520:r1510:r1500:r1490:r1480:r1470:r1460:r1452:r1450:r1440:r1430:r1420:r1410:r1400:r1390:r1380:r1370:r1360:r1350:r1340:r1330:r1320:r1310:r1300:r1290:r1280:r1271:r1270:r1260:r1250:r1240:r1230:r1220:r1210:r1200:r1190:r1180:r1170:r1160:r1151:r1140:r1130:r1120:r1110:r1100:r190:r180:r170:r160:r150:r140:r130:r120:r110:r100:nightly:beta +group.rust.compilers=r1870:r1860:r1850:r1840:r1830:r1820:r1810:r1800:r1790:r1780:r1770:r1760:r1750:r1740:r1730:r1720:r1710:r1700:r1690:r1680:r1670:r1660:r1650:r1640:r1630:r1620:r1610:r1600:r1590:r1580:r1570:r1560:r1550:r1540:r1530:r1520:r1510:r1500:r1490:r1480:r1470:r1460:r1452:r1450:r1440:r1430:r1420:r1410:r1400:r1390:r1380:r1370:r1360:r1350:r1340:r1330:r1320:r1310:r1300:r1290:r1280:r1271:r1270:r1260:r1250:r1240:r1230:r1220:r1210:r1200:r1190:r1180:r1170:r1160:r1151:r1140:r1130:r1120:r1110:r1100:r190:r180:r170:r160:r150:r140:r130:r120:r110:r100:nightly:beta group.rust.compilerType=rust group.rust.isSemVer=true group.rust.unwiseOptions=-Ctarget-cpu=native|target-cpu=native @@ -22,6 +22,9 @@ group.rust.supportsBinaryObject=true group.rust.supportsClippy=true # Rust 1.83+ needs `libPath` for execution with dynamically linked standard library # see https://github.com/compiler-explorer/compiler-explorer/pull/7367 +compiler.r1870.exe=/opt/compiler-explorer/rust-1.87.0/bin/rustc +compiler.r1870.semver=1.87.0 +compiler.r1870.libPath=${exePath}/../lib/rustlib/x86_64-unknown-linux-gnu/lib compiler.r1860.exe=/opt/compiler-explorer/rust-1.86.0/bin/rustc compiler.r1860.semver=1.86.0 compiler.r1860.libPath=${exePath}/../lib/rustlib/x86_64-unknown-linux-gnu/lib diff --git a/lib/options-handler.ts b/lib/options-handler.ts index 6b477d350..fb8bf15fe 100755 --- a/lib/options-handler.ts +++ b/lib/options-handler.ts @@ -37,6 +37,7 @@ import type {Source} from '../types/source.interfaces.js'; import type {ToolTypeKey} from '../types/tool.interfaces.js'; import {AppArguments} from './app.interfaces.js'; +import {getRemoteId} from '../shared/remote-utils.js'; import {logger} from './logger.js'; import type {PropertyGetter, PropertyValue} from './properties.interfaces.js'; import {CompilerProps} from './properties.js'; @@ -376,11 +377,6 @@ export class ClientOptionsHandler { return libraries; } - getRemoteId(remoteUrl: string, language: LanguageKey) { - const url = new URL(remoteUrl); - return url.host.replaceAll('.', '_') + '_' + language; - } - libArrayToObject(libsArr: any[]) { const libs: Record = {}; for (const lib of libsArr) { @@ -397,9 +393,9 @@ export class ClientOptionsHandler { } async getRemoteLibraries(language: LanguageKey, remoteUrl: string) { - const remoteId = this.getRemoteId(remoteUrl, language); + const remoteId = getRemoteId(remoteUrl, language); if (!this.remoteLibs[remoteId]) { - return new Promise(resolve => { + return await new Promise(resolve => { const url = ClientOptionsHandler.getRemoteUrlForLibraries(remoteUrl, language); logger.info(`Fetching remote libraries from ${url}`); let fullData = ''; diff --git a/shared/remote-utils.ts b/shared/remote-utils.ts new file mode 100644 index 000000000..23b5c083b --- /dev/null +++ b/shared/remote-utils.ts @@ -0,0 +1,28 @@ +// Copyright (c) 2025, 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. + +export function getRemoteId(remoteUrl: string, language: string): string { + const url: URL = new URL(remoteUrl); + return url.host.replace(/\./g, '_') + url.pathname.replace(/\//g, '_') + '_' + language; +} diff --git a/shared/url-testcases.ts b/shared/url-testcases.ts new file mode 100644 index 000000000..dc3616891 --- /dev/null +++ b/shared/url-testcases.ts @@ -0,0 +1,32 @@ +export const UrlTestCases = [ + { + remoteUrl: 'https://example.com/path/to/resource', + language: 'cpp', + expectedId: 'example_com_path_to_resource_cpp', + }, + { + remoteUrl: 'https://example.com', + language: 'java', + expectedId: 'example_com__java', + }, + { + remoteUrl: 'https://sub.domain.com/a/b/c/', + language: 'rust', + expectedId: 'sub_domain_com_a_b_c__rust', + }, + { + remoteUrl: 'https://godbolt.org:443/gpu', + language: 'c++', + expectedId: 'godbolt_org_gpu_c++', + }, + { + remoteUrl: 'https://godbolt.org:443/winprod', + language: 'c++', + expectedId: 'godbolt_org_winprod_c++', + }, + { + remoteUrl: 'https://godbolt.org:443', + language: 'c++', + expectedId: 'godbolt_org__c++', + }, +]; diff --git a/static/lib-utils.ts b/static/lib-utils.ts index 88f111c35..f1a5b2b68 100644 --- a/static/lib-utils.ts +++ b/static/lib-utils.ts @@ -22,19 +22,15 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. +import {getRemoteId} from '../shared/remote-utils.js'; import {Remote} from './compiler.interfaces.js'; import {LanguageLibs, Library} from './options.interfaces.js'; import {options} from './options.js'; const LIB_MATCH_RE = /([\w-]*)\.([\w-]*)/i; -function getRemoteId(language: string, remoteUrl: string): string { - const url: URL = new URL(remoteUrl); - return url.host.replace(/\./g, '_') + '_' + language; -} - function getRemoteLibraries(language: string, remoteUrl: string): LanguageLibs { - const remoteId = getRemoteId(language, remoteUrl); + const remoteId = getRemoteId(remoteUrl, language); return options.remoteLibs[remoteId]; } @@ -78,7 +74,7 @@ export function getSupportedLibraries( } return allLibs; } - const allLibs = getRemoteLibraries(langId, remote.target); + const allLibs = getRemoteLibraries(langId, remote.target + remote.basePath); if (supportedLibrariesArr && supportedLibrariesArr.length > 0) { return copyAndFilterLibraries(allLibs, supportedLibrariesArr); } diff --git a/static/panes/opt-view.ts b/static/panes/opt-view.ts index a4d228e96..99454566d 100644 --- a/static/panes/opt-view.ts +++ b/static/panes/opt-view.ts @@ -38,14 +38,6 @@ import {Hub} from '../hub.js'; import {extendConfig} from '../monaco-config.js'; import {Toggles} from '../widgets/toggles.js'; -type OptClass = 'None' | 'Missed' | 'Passed' | 'Analysis'; - -type OptviewLine = { - text: string; - srcLine: number; - optClass: OptClass; -}; - export class Opt extends MonacoPane { // Note: bool | undef here instead of just bool because of an issue with field initialization order private isCompilerSupported?: boolean; @@ -54,13 +46,14 @@ export class Opt extends MonacoPane; private wrapTitle: JQuery; - // Keep optRemarks as state, to avoid triggerring a recompile when options change + // Keep optRemarks as state, to avoid triggering a recompile when options change private optRemarks: OptRemark[]; - private srcAsOptview: OptviewLine[]; + private optRemarkViewZoneIds: string[]; constructor(hub: Hub, container: Container, state: OptState & MonacoPaneState) { super(hub, container, state); this.optRemarks = state.optOutput ?? []; + this.optRemarkViewZoneIds = []; this.eventHub.emit('optViewOpened', this.compilerInfo.compilerId); } @@ -124,29 +117,19 @@ export class Opt extends MonacoPane { cursorSelectionThrottledFunction(e); }); + + this.editor.onDidLayoutChange(({contentWidth}) => { + this.showOptRemarks(contentWidth); + }); } override onCompileResult(id: number, compiler: CompilerInfo, result: CompilationResult) { if (this.compilerInfo.compilerId !== id || !this.isCompilerSupported) return; - const splitLines = (text: string): string[] => { - if (!text) return []; - const result = text.split(/\r?\n/); - if (result.length > 0 && result[result.length - 1] === '') return result.slice(0, -1); - return result; - }; - const srcLines: string[] = result.source ? splitLines(result.source) : []; - this.srcAsOptview = []; - - for (const i in srcLines) { - this.srcAsOptview.push({text: srcLines[i], srcLine: Number(i), optClass: 'None'}); - } - this.editor.setValue(unwrap(result.source)); - if (result.optOutput) { - this.optRemarks = result.optOutput; - this.showOptRemarks(); - } + this.optRemarks = result.optOutput ?? []; + this.showOptRemarks(); + // TODO: This is inelegant again. Previously took advantage of fourth argument for the compileResult event. const lang = compiler.lang === 'c++' ? 'cpp' : compiler.lang; const model = this.editor.getModel(); @@ -172,7 +155,7 @@ export class Opt extends MonacoPane x.DebugLoc.Line); - const resLines = [...this.srcAsOptview]; - for (const [key, value] of Object.entries(groupedRemarks)) { - const origLineNum = Number(key); - const curLineNum = resLines.findIndex(line => line.srcLine === origLineNum); - const contents = value.map(rem => ({ - text: rem.displayString, - srcLine: -1, - optClass: rem.optType, - })); - resLines.splice(curLineNum, 0, ...contents); - } + this.editor?.changeViewZones(accessor => { + const maxWidth = width ?? this.editor.getLayoutInfo().contentWidth; + this.optRemarkViewZoneIds.forEach(id => accessor.removeZone(id)); + this.optRemarkViewZoneIds = remarksToDisplay.map(({displayString, optType, DebugLoc}) => { + const domNode = document.createElement('div'); + domNode.classList.add('view-line', 'opt-line', optType.toLowerCase()); + this.editor.applyFontInfo(domNode); + domNode.innerText = displayString; - const newText: string = resLines.reduce((accText, curSrcLine) => { - return accText + (curSrcLine.optClass === 'None' ? curSrcLine.text : ' ') + '\n'; - }, ''); - this.editor.setValue(newText); + // let the browser calculate the height that the text needs + domNode.style.visibility = 'hidden'; + domNode.style.maxWidth = `${maxWidth}px`; + document.body.appendChild(domNode); + const heightInPx = domNode.clientHeight; + document.body.removeChild(domNode); + domNode.style.removeProperty('visibility'); + domNode.style.removeProperty('max-width'); - const optDecorations: monaco.editor.IModelDeltaDecoration[] = []; - resLines.forEach((line, lineNum) => { - if (line.optClass !== 'None') { - optDecorations.push({ - range: new monaco.Range(lineNum + 1, 1, lineNum + 1, Number.POSITIVE_INFINITY), - options: { - isWholeLine: true, - after: { - content: line.text, - }, - inlineClassName: 'opt-line.' + line.optClass.toLowerCase(), - }, + return accessor.addZone({ + domNode, + heightInPx, + afterLineNumber: DebugLoc.Line === 0 ? 0 : DebugLoc.Line - 1, }); - } + }); }); - this.editorDecorations.set(optDecorations); } override onCompiler(id: number, compiler: CompilerInfo | null, options: string, editorId: number, treeId: number) { @@ -230,6 +204,8 @@ export class Opt extends MonacoPane'); + this.optRemarks = []; + this.showOptRemarks(); } } } diff --git a/static/panes/stack-usage-view.ts b/static/panes/stack-usage-view.ts index 55a76b3fe..47060cc80 100644 --- a/static/panes/stack-usage-view.ts +++ b/static/panes/stack-usage-view.ts @@ -87,9 +87,10 @@ export class StackUsage extends MonacoPane'; } - showStackUsageResults(suEntries: suCodeEntry[], source?: string) { + showStackUsageResults(suEntries: suCodeEntry[], source: string) { const splitLines = (text: string): string[] => { if (!text) return []; const result = text.split(/\r?\n/); diff --git a/static/tests/_all.ts b/static/tests/_all.ts index 0f2f1ec18..6c9b96803 100644 --- a/static/tests/_all.ts +++ b/static/tests/_all.ts @@ -25,3 +25,4 @@ import './frontend-testing'; import './hello-world'; import './motd'; +import './remote-id'; diff --git a/static/tests/remote-id.ts b/static/tests/remote-id.ts new file mode 100644 index 000000000..3d86d6b78 --- /dev/null +++ b/static/tests/remote-id.ts @@ -0,0 +1,47 @@ +// Copyright (c) 2025, 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 {getRemoteId} from '../../shared/remote-utils.js'; + +import {UrlTestCases} from '../../shared/url-testcases.js'; + +import {ITestable} from './frontend-testing.interfaces.js'; + +class RemoteIdTests implements ITestable { + public readonly description: string = 'remoteId'; + + public async run() { + UrlTestCases.forEach(testCase => { + if (getRemoteId(testCase.remoteUrl, testCase.language) !== testCase.expectedId) { + throw new Error( + `Test case failed for language: ${testCase.language}, remoteUrl: ${testCase.remoteUrl}, expectedId: ${testCase.expectedId}`, + ); + } + }); + } +} + +window.compilerExplorerFrontendTesting.add(new RemoteIdTests()); diff --git a/test/options-handler.ts b/test/options-handler.ts index a8d4653dc..8e36e18b7 100644 --- a/test/options-handler.ts +++ b/test/options-handler.ts @@ -37,6 +37,9 @@ import {BaseTool} from '../lib/tooling/base-tool.js'; import {CompilerInfo} from '../types/compiler.interfaces.js'; import {LanguageKey} from '../types/languages.interfaces.js'; +import {getRemoteId} from '../shared/remote-utils.js'; +import {UrlTestCases} from '../shared/url-testcases.js'; + import {makeFakeCompilerInfo} from './utils.js'; const languages = { @@ -593,4 +596,13 @@ describe('Options handler', () => { expect(librariesUrl).toEqual('https://godbolt.org:443/gpu/api/libraries/c++'); }); + + describe('getRemoteId', () => { + UrlTestCases.forEach(testCase => { + it(`should generate remote ID for URL "${testCase.remoteUrl}" with language "${testCase.language}"`, () => { + const result = getRemoteId(testCase.remoteUrl, testCase.language); + expect(result).toBe(testCase.expectedId); + }); + }); + }); });