diff --git a/etc/config/c.amazon.properties b/etc/config/c.amazon.properties index 53786f8cf..a69cd6f25 100644 --- a/etc/config/c.amazon.properties +++ b/etc/config/c.amazon.properties @@ -4505,6 +4505,17 @@ libs.cs50.versions.910.path=/opt/compiler-explorer/libs/cs50/9.1.0/include libs.cs50.versions.910.libpath=/opt/compiler-explorer/libs/cs50/9.1.0/x86_64/lib:/opt/compiler-explorer/libs/cs50/9.1.0/x86/lib libs.cs50.versions.910.liblink=cs50 +libs.glibc.name=glibc +libs.glibc.versions=216:241 +libs.glibc.versions.216.version=2.16 +libs.glibc.versions.216.libpath=/opt/compiler-explorer/libs/glibc/glibc-2.16/usr/lib64:/opt/compiler-explorer/libs/glibc/glibc-2.16/lib64 +libs.glibc.versions.216.sysroot=/opt/compiler-explorer/libs/glibc/glibc-2.16 +libs.glibc.versions.216.dynamicLinker=/opt/compiler-explorer/libs/glibc/glibc-2.16/lib64/ld-linux-x86-64-so.2 +libs.glibc.versions.241.version=2.41 +libs.glibc.versions.241.libpath=/opt/compiler-explorer/libs/glibc/glibc-2.41/usr/lib64:/opt/compiler-explorer/libs/glibc/glibc-2.41/lib64 +libs.glibc.versions.241.sysroot=/opt/compiler-explorer/libs/glibc/glibc-2.41 +libs.glibc.versions.241.dynamicLinker=/opt/compiler-explorer/libs/glibc/glibc-2.41/lib64/ld-linux-x86-64-so.2 + libs.hedley.name=hedley libs.hedley.description=A C/C++ header to help move ifdefs out of your code libs.hedley.versions=v12 diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts index d71954aae..216d15b8e 100644 --- a/lib/base-compiler.ts +++ b/lib/base-compiler.ts @@ -995,6 +995,20 @@ export class BaseCompiler { }); } + getSharedLibraryDynamicLinker(libraries: SelectedLibraryVersion[], dirPath?: string): string[] { + return libraries.flatMap(selectedLib => { + const foundVersion = this.findLibVersion(selectedLib); + if (!foundVersion) return []; + if (foundVersion.dynamicLinker === undefined) return []; + + const paths = [foundVersion.dynamicLinker]; + if (this.buildenvsetup && !this.buildenvsetup.extractAllToRoot && dirPath) { + paths.push(path.join(dirPath, selectedLib.id, 'lib')); + } + return paths; + }); + } + getSharedLibraryBinPaths(libraries: SelectedLibraryVersion[], dirPath?: string): string[] { return libraries.flatMap(selectedLib => { const foundVersion = this.findLibVersion(selectedLib); @@ -1016,6 +1030,8 @@ export class BaseCompiler { ): string[] { const pathFlag = this.compiler.rpathFlag || this.defaultRpathFlag; const libPathFlag = this.compiler.libpathFlag || '-L'; + // TODO: make configurable + const dynamicLinkerFlag = '-Wl,--dynamic-linker='; let toolchainLibraryPaths: string[] = []; if (toolchainPath) { @@ -1033,6 +1049,7 @@ export class BaseCompiler { toolchainLibraryPaths.map(path => pathFlag + path), this.getSharedLibraryPaths(libraries, dirPath).map(path => pathFlag + path), this.getSharedLibraryPaths(libraries, dirPath).map(path => libPathFlag + path), + this.getSharedLibraryDynamicLinker(libraries, dirPath).map(path => dynamicLinkerFlag + path), ); } @@ -1080,6 +1097,9 @@ export class BaseCompiler { getIncludeArguments(libraries: SelectedLibraryVersion[], dirPath: string): string[] { const includeFlag = this.compiler.includeFlag || '-I'; + // TODO: make configurable + const sysrootFlag = '--sysroot='; + return libraries.flatMap(selectedLib => { const foundVersion = this.findLibVersion(selectedLib); if (!foundVersion) return []; @@ -1089,6 +1109,9 @@ export class BaseCompiler { const includePath = path.join(dirPath, selectedLib.id, 'include'); paths.push(includeFlag + includePath); } + if (foundVersion.sysroot) { + paths.push(sysrootFlag + foundVersion.sysroot); + } return paths; }); } diff --git a/lib/options-handler.ts b/lib/options-handler.ts index 708a2d208..f1a3af1bf 100755 --- a/lib/options-handler.ts +++ b/lib/options-handler.ts @@ -59,6 +59,8 @@ export type VersionInfo = { options: string[]; hidden: boolean; packagedheaders?: boolean; + sysroot?: string; + dynamicLinker?: string; $order?: number; }; export type OptionsHandlerLibrary = { @@ -357,10 +359,19 @@ export class ClientOptionsHandler implements ClientOptionsSource { versionObject.lookupname = libraries[lang][lib].lookupname; } + const sysroot = this.compilerProps(lang, libVersionName + '.sysroot'); + if (sysroot !== undefined) { + versionObject.sysroot = sysroot; + } + const includes = this.compilerProps(lang, libVersionName + '.path'); if (includes) { versionObject.path = includes.split(path.delimiter); - } else if (version !== 'autodetect' && !versionObject.packagedheaders) { + } else if ( + version !== 'autodetect' && + !versionObject.packagedheaders && + !versionObject.sysroot + ) { logger.warn(`Library ${lib} ${version} (${lang}) has no include paths`); } @@ -380,6 +391,11 @@ export class ClientOptionsHandler implements ClientOptionsSource { libraries[lang][lib].packagedheaders, ); + const dynamicLinker = this.compilerProps(lang, libVersionName + '.dynamicLinker'); + if (dynamicLinker !== undefined) { + versionObject.dynamicLinker = dynamicLinker; + } + libraries[lang][lib].versions[version] = versionObject; } } else { diff --git a/types/libraries/libraries.interfaces.ts b/types/libraries/libraries.interfaces.ts index baf1b7023..7abebdb7d 100644 --- a/types/libraries/libraries.interfaces.ts +++ b/types/libraries/libraries.interfaces.ts @@ -9,6 +9,8 @@ export type LibraryVersion = { path: string[]; options: string[]; packagedheaders?: boolean; + sysroot?: string; + dynamicLinker?: string; }; export type Library = {