Skip to content

Commit

Permalink
Add Flang frontend driver to Fortran Compilers (compiler-explorer#6419)
Browse files Browse the repository at this point in the history
  • Loading branch information
harishch4 authored May 10, 2024
1 parent a71168c commit 15bcb0a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 9 additions & 1 deletion etc/config/fortran.amazon.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/compilers/_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
72 changes: 72 additions & 0 deletions lib/compilers/flang-fc1.ts
Original file line number Diff line number Diff line change
@@ -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<string, any>,
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;
}
}

0 comments on commit 15bcb0a

Please sign in to comment.