From 15bcb0ab3d0455f19d3b3975b048835ae2679d35 Mon Sep 17 00:00:00 2001 From: harishch4 Date: Sat, 11 May 2024 00:17:29 +0530 Subject: [PATCH] Add Flang frontend driver to Fortran Compilers (#6419) --- .github/labeler.yml | 1 + etc/config/fortran.amazon.properties | 10 +++- lib/compilers/_all.ts | 1 + lib/compilers/flang-fc1.ts | 72 ++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 lib/compilers/flang-fc1.ts diff --git a/.github/labeler.yml b/.github/labeler.yml index 289076495e3..e23ac4c63a4 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -148,6 +148,7 @@ - changed-files: - any-glob-to-any-file: - 'lib/compilers/flang.ts' + - 'lib/compilers/flang-fc1.ts' - 'lib/compilers/fortran.ts' - 'etc/config/fortran.*.properties' - 'static/modes/fortran-mode.ts' diff --git a/etc/config/fortran.amazon.properties b/etc/config/fortran.amazon.properties index 045428f8041..212eb03fcd5 100644 --- a/etc/config/fortran.amazon.properties +++ b/etc/config/fortran.amazon.properties @@ -547,7 +547,7 @@ compiler.fs390xg1410.demangler=/opt/compiler-explorer/s390x/gcc-14.1.0/s390x-ibm ############################### # LLVM Flang for X86 -group.clang_llvmflang.compilers=flangtrunk:flangtrunknew +group.clang_llvmflang.compilers=flangtrunk:flangtrunknew:flangtrunknew-fc group.clang_llvmflang.groupName=LLVM-FLANG x86-64 group.clang_llvmflang.compilerType=flang @@ -563,6 +563,14 @@ compiler.flangtrunknew.gfortranPath=/opt/compiler-explorer/gcc-snapshot/bin compiler.flangtrunknew.ldPath=${exePath}/../lib|${exePath}/../lib32|${exePath}/../lib64|/opt/compiler-explorer/gcc-snapshot/lib|/opt/compiler-explorer/gcc-snapshot/lib32|/opt/compiler-explorer/gcc-snapshot/lib64 compiler.flangtrunknew.isNightly=true +compiler.flangtrunknew-fc.exe=/opt/compiler-explorer/clang-llvmflang-trunk/bin/flang-new +compiler.flangtrunknew-fc.name=flang-trunk-fc1 (flang-new) +compiler.flangtrunknew-fc.compilerType=flang-fc1 +compiler.flangtrunknew-fc.isNightly=true +compiler.flangtrunknew-fc.supportsBinary=false +compiler.flangtrunknew-fc.supportsBinaryObject=false +compiler.flangtrunknew-fc.supportsBinaryExecute=false + ############################### # GCC for ARM 64bit group.gccaarch64.compilers=farm64g640:farm64g730:farm64g820:farm64g1050:farm64g1210:farm64g1220:farm64g1230:farm64g1310:farm64g1140:farm64g1320:farm64g1410 diff --git a/lib/compilers/_all.ts b/lib/compilers/_all.ts index 3efb9e01be4..d27227392d8 100644 --- a/lib/compilers/_all.ts +++ b/lib/compilers/_all.ts @@ -63,6 +63,7 @@ export {EWARMCompiler} from './ewarm.js'; export {EWAVRCompiler} from './ewavr.js'; export {FakeCompiler} from './fake-for-test.js'; export {FlangCompiler} from './flang.js'; +export {FlangFC1Compiler} from './flang-fc1.js'; export {FortranCompiler} from './fortran.js'; export {FPCCompiler} from './pascal.js'; export {FSharpCompiler} from './dotnet.js'; diff --git a/lib/compilers/flang-fc1.ts b/lib/compilers/flang-fc1.ts new file mode 100644 index 00000000000..cd340cf2156 --- /dev/null +++ b/lib/compilers/flang-fc1.ts @@ -0,0 +1,72 @@ +// Copyright (c) 2024, 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 {ConfiguredOverrides} from '../../types/compilation/compiler-overrides.interfaces.js'; +import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; +import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; +import {BaseCompiler} from '../base-compiler.js'; + +export class FlangFC1Compiler extends BaseCompiler { + static get key() { + return 'flang-fc1'; + } + + constructor(compilerInfo: PreliminaryCompilerInfo, env) { + super( + { + disabledFilters: [ + 'binary', + 'execute', + 'demangle', + 'intel', + 'labels', + 'libraryCode', + 'directives', + 'commentOnly', + 'trim', + 'debugCalls', + ], + ...compilerInfo, + }, + env, + ); + } + + override prepareArguments( + userOptions: string[], + filters: ParseFiltersAndOutputOptions, + backendOptions: Record, + inputFilename: string, + outputFilename: string, + libraries, + overrides: ConfiguredOverrides, + ) { + let options = ['-fc1']; + userOptions = this.filterUserOptions(userOptions) || []; + options = options.concat(userOptions); + options = options.concat(['-o', this.filename(outputFilename)]); + options = options.concat(inputFilename); + return options; + } +}