Go to file
Philip Herron 4153a8a99b Create CODE_OF_CONDUCT.md
Adding a code of conduct lays out rules that we can all follow in the project.
2021-05-20 12:03:38 +01:00
.github Add issue templates ported from rust-clippy 2021-05-14 15:14:27 +01:00
INSTALL README: Do not mention CVS. 2014-10-12 15:05:28 +00:00
c++tools Daily bump. 2021-02-26 00:16:36 +00:00
config Daily bump. 2021-01-06 00:16:55 +00:00
contrib Daily bump. 2021-03-24 00:16:25 +00:00
fixincludes Daily bump. 2020-12-15 00:16:35 +00:00
gcc Merge #393 #431 2021-05-20 08:56:46 +00:00
gnattools PR81878: fix --disable-bootstrap --enable-languages=ada 2018-11-20 00:07:47 +00:00
gotools Daily bump. 2021-02-03 00:16:23 +00:00
include Daily bump. 2021-01-17 00:16:23 +00:00
intl intl: Unbreak intl build with bison 3 when no regeneration is needed [PR92008] 2020-04-16 11:55:00 +02:00
libada Update copyright years. 2021-01-04 10:26:59 +01:00
libatomic Daily bump. 2021-01-16 00:16:29 +00:00
libbacktrace Daily bump. 2021-03-04 00:16:48 +00:00
libcc1 Daily bump. 2021-01-06 00:16:55 +00:00
libcody Daily bump. 2021-01-13 00:16:36 +00:00
libcpp Daily bump. 2021-03-09 00:16:57 +00:00
libdecnumber Update copyright years. 2021-01-04 10:26:59 +01:00
libffi Daily bump. 2021-01-06 00:16:55 +00:00
libgcc Daily bump. 2021-03-24 00:16:25 +00:00
libgfortran Daily bump. 2021-03-13 00:16:20 +00:00
libgo libgo: update to Go 1.16.2 release 2021-03-15 14:52:55 -07:00
libgomp libgomp HSA/GCN plugins: don't prepend the 'HSA_RUNTIME_LIB' path to 'libhsa-runtime64.so' 2021-03-25 14:11:50 +01:00
libhsail-rt Daily bump. 2021-01-06 00:16:55 +00:00
libiberty Daily bump. 2021-03-17 00:16:25 +00:00
libitm Daily bump. 2021-01-16 00:16:29 +00:00
libobjc Daily bump. 2021-01-06 00:16:55 +00:00
liboffloadmic Daily bump. 2021-01-06 00:16:55 +00:00
libphobos Daily bump. 2021-02-05 00:16:23 +00:00
libquadmath Daily bump. 2021-01-06 00:16:55 +00:00
libsanitizer Daily bump. 2021-03-09 00:16:57 +00:00
libssp Daily bump. 2021-01-06 00:16:55 +00:00
libstdc++-v3 Daily bump. 2021-03-24 00:16:25 +00:00
libvtv Daily bump. 2021-01-06 00:16:55 +00:00
lto-plugin Daily bump. 2021-01-06 00:16:55 +00:00
maintainer-scripts Daily bump. 2020-12-17 00:16:37 +00:00
zlib Daily bump. 2021-01-06 00:16:55 +00:00
.dir-locals.el .dir-locals.el: Set 'fill-column' to 80 for c-mode 2020-12-14 12:19:56 +01:00
.gitattributes Add *.md diff=md. 2020-01-15 14:29:53 +01:00
.gitignore Merge commit '7c1e856bedb4ae190c420ec2d2ca5e08730cf21d' [#247] 2021-04-02 22:56:26 +02:00
ABOUT-NLS
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2021-05-20 12:03:38 +01:00
CONTRIBUTING.md Create CONTRIBUTING.md 2021-05-14 12:48:34 +01:00
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2021-03-24 00:16:25 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
Dockerfile Update Automations to only build rust to improve build times 2020-12-07 10:13:16 +00:00
MAINTAINERS MAINTAINERS: add myself as static analyzer maintainer 2021-03-23 13:09:07 -04:00
Makefile.def Merge commit '7c1e856bedb4ae190c420ec2d2ca5e08730cf21d' [#247] 2021-04-02 22:56:26 +02:00
Makefile.in Merge commit '7c1e856bedb4ae190c420ec2d2ca5e08730cf21d' [#247] 2021-04-02 22:56:26 +02:00
Makefile.tpl Add -fprofile-reproducible=parallel-runs to STAGEfeedback_CFLAGS to Makefile.tpl. 2021-03-11 16:18:56 +01:00
README
README.md Add link to contributing guidlines 2021-05-14 13:40:18 +01:00
ar-lib
compile
config-ml.in config-ml.in: Suppress output from multi-do recipes 2020-11-09 14:28:37 +00:00
config.guess config.sub, config.guess : Import upstream 2021-01-25. 2021-02-23 17:21:10 +08:00
config.rpath
config.sub config.sub, config.guess : Import upstream 2021-01-25. 2021-02-23 17:21:10 +08:00
configure Add C++tools 2020-12-15 07:42:59 -08:00
configure.ac Add C++tools 2020-12-15 07:42:59 -08:00
depcomp
install-sh
libtool-ldflags
libtool.m4 Update GNU/Hurd configure support 2021-01-05 16:04:14 -07:00
logo.png Add logo to README 2020-12-23 15:02:02 +00:00
ltgcc.m4
ltmain.sh Do not use HAVE_DOS_BASED_FILE_SYSTEM for Cygwin. 2020-04-17 09:22:51 +02:00
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree
test-driver
ylwrap

README.md

C/C++ CI GCC Bootstrap Build Docker Build Docker Pulls project chat Bors enabled

GCC Rust

GCC Rust

Please note, the compiler is in a very early stage and not usable yet for compiling real Rust programs.

gccrs is a full alternative implementation of the Rust language ontop of GCC with the goal to become fully upstream with the GNU toolchain.

The origin of this project was a community effort several years ago where Rust was still at version 0.9; the language was subject to so much change that it became difficult for a community effort to play catch up. Now that the language is stable, it is an excellent time to create alternative compilers. The developers of the project are keen “Rustaceans” with a desire to give back to the Rust community and to learn what GCC is capable of when it comes to a modern language.

FAQ

Please find the answers to frequently asked questions over on: https://github.com/Rust-GCC/gccrs/wiki/Frequently-Asked-Questions

Development Environment

Building

Fetch dependencies for Ubuntu:

$ apt install build-essential libgmp3-dev libmpfr-dev libmpc-dev flex bison autogen gcc-multilib dejagnu

Clone the repository

$ git clone git@github.com:Rust-GCC/gccrs.git

It is important to remember that GNU toolchain projects are designed to be built outside of their source directory which is why a build directory is created.

$ mkdir gccrs-build
$ cd gccrs-build
$ ../gccrs/configure --prefix=$HOME/gccrs-install --disable-bootstrap --enable-multilib --enable-languages=rust
$ make

Running the compiler itself without make install we can simply invoke the compiler proper:

$ ./gcc/rust1 test.rs -frust-dump-parse -Warray-bounds -dumpbase test.rs -mtune=generic -march=x86-64 -O0 -version -fdump-tree-gimple -o test.s -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64

To invoke the compiler driver (gccrs) we need to:

$ make install

Then invoke the compiler from the installation directory:

$ $HOME/gccrs-install/gccrs -g -O2 -c test.rs -o test.o
$ $HOME/gccrs-install/gccrs -o test test.o

You can also setup your shell to automatically find the installed compiler. For example for bash, add the following in your $HOME/.bashrc:

export PATH=$HOME/gccrs-install/bin:$PATH

Testsuite

Invoke the full testsuite from the build directory (gcc/gccrs-build in the previous commands):

$ make check-rust

Invoke a subset of the testsuite. For example, to only execute the tests that are expected to fail:

$ make check-rust  RUNTESTFLAGS="xfail_compile.exp"

The project currently has 3 sets of tests:

  • execute.exp : execution tests
  • compile.exp : compilation only tests, using combination of options
  • xfail_compile.exp : compilation only tests expected to fail

Invoke only a specific test :

$ make check-rust  RUNTESTFLAGS="xfail_compile.exp=continue1.rs"

Logs (with corresponding commands) can be found in : gccrs-build/gcc/testsuite/rust/rust.log.

See GCC Testing documentation for more details.

Test cases are located within gcc/testsuite/rust.test please feel free to contribute your specific test cases referencing any issues on Github.

Debugging

Enabling internal checks

GCC has several internal checks that can be enabled during configuration. In the case of gccrs, you can enable the following:

$ ../gccrs/configure --prefix=$HOME/gccrs-install --disable-bootstrap --enable-multilib --enable-languages=rust --enable-checking=gimple,tree,types

GDB

You can directly invoke gdb on the rust1 compiler process (you can find the exact command adding --verbose to your gccrs invocation):

$ gccrs test.rs -O0 -S -o arithmetic_expressions1.s --verbose
...
 /some/path/../../rust1 test.rs -quiet -dumpbase arithmetic_expressions1.rs -dumpbase-ext .rs
 -mtune=generic -march=x86-64 -O0 -w -version -fdiagnostics-color=never -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers -fdiagnostics-urls=never -fdiagnostics-path-format=separate-events -o test.s -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
...
$ gdb --args  /some/path/../../rust1 test.rs -quiet -dumpbase arithmetic_expressions1.rs -dumpbase-ext .rs
 -mtune=generic -march=x86-64 -O0 -w -version -fdiagnostics-color=never -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers -fdiagnostics-urls=never -fdiagnostics-path-format=separate-events -o test.s -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu

Or simply add the -wrapper gdb,--args option. This will call each subcommand in gdb and you simply have to break/debug in rust1:

$ gccrs test.rs -O0 -S -o arithmetic_expressions1.s -wrapper gdb,--args

Docker image

There is a docker image hosted over on:

https://hub.docker.com/repository/docker/philberty/gccrs

$ docker pull philberty/gccrs

Or you can build your own image:

$ docker build . -t gccrs-dev

If you want to build an object file:

$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp \
    gccrs-dev:latest gccrs -g -O2 -c \
    gcc/testsuite/rust.test/compilable/type_infer1.rs -o type_infer1.o

If you want to build an executable file:

$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp \
    gccrs-dev:latest gccrs -g -O2 \
    gcc/testsuite/rust.test/compilable/type_infer1.rs -o type_infer1

To emit assembly :

$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp \
    gccrs-dev:latest gccrs -g -O2 \
    gcc/testsuite/rust.test/compilable/type_infer1.rs -S -o type_infer1.s 

To emit the debug outputs you can add the option -frust-dump-all :

$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp \
    gccrs-dev:latest gccrs -g -O2 \
    gcc/testsuite/rust.test/compilable/type_infer1.rs -o type_infer1 -frust-dump-all

Contributing

If you want to contribute to GCC Rust, you can find more information in CONTRIBUTING.md.

Please be aware this project is designed to be pushed upstream to GCC when we reach some milestones, and this means we require contributions to have copyright assignment in place. Please see https://gcc.gnu.org/contribute.html.

Not all contributions must be code; we would love to see new test cases or bugs and issues to be reported. Feel free to add any comments on open PRs

Community

We can be found on all usual Rust channels such as Zulip, but we also have our own channels: