Skip to content

Commit c96615c

Browse files
committed
Adding rustc-cg-gcc
GCC backend for rustc is still in a very early state. It is in the process of being merged in main rustc source: rust-lang/compiler-team#442 Currently reusing main rust compiler class and simply remove -Cllvm= argument if any (only for intel asm syntax). refs compiler-explorer#2683
1 parent 7074739 commit c96615c

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

etc/config/rust.amazon.properties

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
compilers=&rust:&rustgcc:&mrustc
1+
compilers=&rust:&rustgcc:&mrustc:&rustccggcc
22
objdumper=/opt/compiler-explorer/gcc-11.1.0/bin/objdump
33
linker=/opt/compiler-explorer/gcc-11.1.0/bin/gcc
44
defaultCompiler=r1530
@@ -131,6 +131,11 @@ group.rustgcc.compilerType=gccrs
131131
group.rustgcc.compilers=gccrs-snapshot
132132
group.rustgcc.groupName=Rust-GCC
133133

134+
group.rustccggcc.compilers=rustccggcc-master
135+
compiler.rustccggcc-master.exe=/opt/compiler-explorer/rustc-cg-gcc-master/bin/rustc
136+
compiler.rustccggcc-master.semver=(rustc - GCC)
137+
group.rustccggcc.compilerType=rustc-cg-gcc
138+
134139
compiler.mrustc-master.exe=/opt/compiler-explorer/mrustc-master/bin/mrustc
135140
compiler.mrustc-master.semver=(mrustc)
136141
group.mrustc.compilerType=mrustc

lib/compilers/_all.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export { PPCICompiler } from './ppci';
5858
export { PtxAssembler } from './ptxas';
5959
export { PythonCompiler } from './python';
6060
export { RustCompiler } from './rust';
61+
export { RustcCgGCCCompiler } from './rustc-cg-gcc';
6162
export { MrustcCompiler } from './mrustc';
6263
export { SdccCompiler } from './sdcc';
6364
export { SwiftCompiler } from './swift';

lib/compilers/rustc-cg-gcc.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2021, Compiler Explorer Authors
2+
// All rights reserved.
3+
//
4+
// Redistribution and use in source and binary forms, with or without
5+
// modification, are permitted provided that the following conditions are met:
6+
//
7+
// * Redistributions of source code must retain the above copyright notice,
8+
// this list of conditions and the following disclaimer.
9+
// * Redistributions in binary form must reproduce the above copyright
10+
// notice, this list of conditions and the following disclaimer in the
11+
// documentation and/or other materials provided with the distribution.
12+
//
13+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16+
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17+
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23+
// POSSIBILITY OF SUCH DAMAGE.
24+
25+
import { RustCompiler } from './rust';
26+
27+
export class RustcCgGCCCompiler extends RustCompiler {
28+
static get key() { return 'rustc-cg-gcc'; }
29+
30+
constructor(info, env) {
31+
super(info, env);
32+
this.compiler.supportsIrView = false;
33+
}
34+
35+
optionsForFilter(filters, outputFilename, userOptions) {
36+
let options = ['-C', 'panic=abort',
37+
'-Z', 'codegen-backend=librustc_codegen_gcc.so',
38+
'--sysroot', this.toolchainPath + '/sysroot' ];
39+
40+
// rust.js makes the asumption that LLVM is used. This may go away when cranelift is available.
41+
// Until this is the case and the super() class is refactored, simply ditch -Cllvm arg.
42+
let super_options = super.optionsForFilter(filters, outputFilename, userOptions).filter(arg => !/-Cllvm.*/.test(arg));
43+
options = options.concat(super_options);
44+
return options;
45+
}
46+
}

0 commit comments

Comments
 (0)