Go to file
Arthur Cohen 7e42c1ee80 const-block: Add testcase
gcc/testsuite/ChangeLog:

	* rust/execute/torture/const_block1.rs: New test.
2025-05-27 11:18:07 +00:00
.github ci: Update warnings for new location in install.texi 2025-04-14 09:30:17 +00:00
INSTALL README: Do not mention CVS. 2014-10-12 15:05:28 +00:00
c++tools Update copyright years. 2024-01-03 12:19:35 +01:00
config Daily bump. 2024-01-12 00:17:54 +00:00
contrib Rust: Move 'libformat_parser' build into libgrust 2024-04-16 07:46:13 +00:00
fixincludes Daily bump. 2023-11-23 00:18:14 +00:00
gcc const-block: Add testcase 2025-05-27 11:18:07 +00:00
gnattools Update Copyright year in ChangeLog files 2024-01-03 11:35:18 +01:00
gotools Daily bump. 2023-11-04 00:16:45 +00:00
include Daily bump. 2024-03-01 00:16:41 +00:00
libada Update copyright years. 2024-01-03 12:19:35 +01:00
libatomic Daily bump. 2024-02-15 00:17:50 +00:00
libbacktrace Daily bump. 2024-03-09 00:17:14 +00:00
libcc1 Daily bump. 2024-03-01 00:16:41 +00:00
libcody Update Copyright year in ChangeLog files 2024-01-03 11:35:18 +01:00
libcpp Daily bump. 2024-02-23 00:16:46 +00:00
libdecnumber Update copyright years. 2024-01-03 12:19:35 +01:00
libffi Daily bump. 2023-10-27 00:17:12 +00:00
libgcc Daily bump. 2024-02-23 00:16:46 +00:00
libgfortran Daily bump. 2024-03-08 00:17:33 +00:00
libgm2 Daily bump. 2024-02-26 00:16:54 +00:00
libgo libgo: bump libgo version for GCC 14 release 2024-02-05 11:28:30 -08:00
libgomp Daily bump. 2024-03-09 00:17:14 +00:00
libgrust rust: Lower minimum supported Rust version to 1.49 2025-03-26 11:33:01 +00:00
libiberty Daily bump. 2024-02-20 00:17:58 +00:00
libitm Daily bump. 2024-02-06 00:18:46 +00:00
libobjc Update copyright years. 2024-01-03 12:19:35 +01:00
libphobos Daily bump. 2024-03-04 00:16:47 +00:00
libquadmath Daily bump. 2024-01-04 00:18:45 +00:00
libsanitizer Daily bump. 2024-02-17 00:17:08 +00:00
libssp Daily bump. 2024-02-07 00:18:31 +00:00
libstdc++-v3 libstdc++: Do not require a time-of-day when parsing sys_days [PR114240] 2024-03-09 00:21:42 +00:00
libvtv Update copyright years. 2024-01-03 12:19:35 +01:00
lto-plugin Update copyright years. 2024-01-03 12:19:35 +01:00
maintainer-scripts Daily bump. 2023-11-14 12:23:39 +00:00
zlib Daily bump. 2023-10-23 00:16:43 +00:00
.dir-locals.el dir-locals: Use https for bug references 2021-07-20 11:40:34 +01:00
.gitattributes Add *.md diff=md. 2020-01-15 14:29:53 +01:00
.gitignore Rust: Move 'libformat_parser' build into the GCC build directory 2024-04-16 07:46:13 +00:00
.remarkrc Added Remark.yml and .remarkrc 2021-11-06 20:15:06 +05:30
ABOUT-NLS intl: New directory; see intl/ChangeLog for details. 2003-07-04 18:18:54 +00:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2021-05-20 12:03:38 +01:00
CONTRIBUTING.md ci: remove bors mention 2024-11-23 17:08:04 +00:00
COPYING COPYING, [...]: Sync from upstream sources. 2005-07-14 01:08:13 +00:00
COPYING.LIB Update COPYING.LIB from upstream. Correct last Changelog. 2005-07-14 01:41:54 +00:00
COPYING.RUNTIME Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception. 2009-04-09 17:00:19 +02:00
COPYING3 COPYING_v3: New file. 2007-07-17 08:37:53 +00:00
COPYING3.LIB COPYING_v3: New file. 2007-07-17 08:37:53 +00:00
ChangeLog Daily bump. 2024-03-09 00:17:14 +00:00
ChangeLog.jit Merger of dmalcolm/jit branch from git 2014-11-11 21:55:52 +00:00
ChangeLog.tree-ssa Merge tree-ssa-20020619-branch into mainline. 2004-05-13 02:41:07 -04:00
Dockerfile Bump our docker build's debian base image version to match rust:latest's 2023-09-02 22:31:36 +00:00
MAINTAINERS Merge commit 'a857ec6aada08d8c334c389c7b682198d749b6c9^' into HEAD 2024-03-19 16:47:48 +01:00
Makefile.def Merge commit '9f7afa99c67f039e43019ebd08d14a7f01e2d89c' into HEAD 2024-03-22 10:07:29 +01:00
Makefile.in rust: Do not link with libdl and libpthread unconditionally 2024-06-12 08:29:11 +00:00
Makefile.tpl rust: Do not link with libdl and libpthread unconditionally 2024-06-12 08:29:11 +00:00
README * README: Document use of ranges of years in copyright notices. 2012-07-16 15:01:34 +01:00
README.md Add build dependencies for Fedora 2024-11-27 18:33:42 +00:00
SECURITY.txt SECURITY.txt: Drop "exploitable" in reference to hardening issues 2024-01-09 10:49:01 -05:00
ar-lib Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
compile Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
config-ml.in LoongArch: Reimplement multilib build option handling. 2023-09-15 10:42:12 +08:00
config.guess config.sub, config.guess : Import upstream 2021-01-25. 2021-02-23 17:21:10 +08:00
config.rpath Remove freebsd1 from libtool.m4 macros and config.rpath. 2011-02-13 11:45:53 +00:00
config.sub config.sub: change mode to 755. 2021-12-21 09:10:57 +01:00
configure build: update bootstrap req to C++14 2024-12-10 08:14:09 +00:00
configure.ac build: update bootstrap req to C++14 2024-12-10 08:14:09 +00:00
depcomp Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
install-sh Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
libtool-ldflags re PR sanitizer/56781 (boostrap-asan failure: fixincl fails to link (missing -lasan)) 2014-04-17 14:23:28 +02:00
libtool.m4 Build: fix error in fixinclude configure 2023-11-22 11:54:33 +01:00
logo.png Add logo to README 2020-12-23 15:02:02 +00:00
ltgcc.m4 libtool.m4: Update to libtool 2.2.6. 2008-09-26 16:21:02 +00:00
ltmain.sh Do not use HAVE_DOS_BASED_FILE_SYSTEM for Cygwin. 2020-04-17 09:22:51 +02:00
ltoptions.m4 Sync from git Libtool and regenerate. 2009-12-05 17:18:53 +00:00
ltsugar.m4 libtool.m4: Update to libtool 2.2.6. 2008-09-26 16:21:02 +00:00
ltversion.m4 Sync from git Libtool and regenerate. 2009-12-05 17:18:53 +00:00
lt~obsolete.m4 Sync from git Libtool and regenerate. 2009-12-05 17:18:53 +00:00
missing Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
mkdep merge with /cvs/src 2000-07-22 04:08:22 -04:00
mkinstalldirs Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
move-if-change Update move-if-change from gnulib 2014-11-16 16:12:44 +00:00
multilib.am Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
symlink-tree COPYING, [...]: Sync from upstream sources. 2005-07-14 01:08:13 +00:00
test-driver Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
ylwrap Update from upstream Automake files. 2014-11-16 14:07:13 +00:00

README.md

C/C++ CI GCC Bootstrap Build Build Docker image Docker Pulls project chat justforfunnoreally.dev badge

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.

Build Farm Status

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

Fetch dependencies for Fedora:

$ dnf install autoconf automake dejagnu flex bison glibc-devel.{x86_64,i686} gmp-devel libmpc-devel mpfr-devel

Clone the repository

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

Linux

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

MacOS

The path of header dir and sysroot should be specified when you configure the project.

$ mkdir mac-build
$ cd mac-build
$ ../gccrs/configure --prefix=$HOME/gccrs-install --disable-bootstrap --enable-multilib --enable-languages=rust --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
$ make

Alternatively, a docker environment is available for ARM-based Mac contributors.

Please visit gccrs-workspace.

The image is based on Ubuntu ARM and comes with dependencies all fetched.

Running GCC Rust

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

$ ./gcc/crab1 test.rs -frust-debug -frust-dump-ast-pretty -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 -frust-incomplete-and-experimental-compiler-do-not-use

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

$ make install

Then invoke the compiler from the installation directory:

$ $HOME/gccrs-install/bin/gccrs -g -O2 -c test.rs -o test.o -frust-incomplete-and-experimental-compiler-do-not-use
$ $HOME/gccrs-install/bin/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 (gccrs-build in the previous commands):

$ make check-rust

Invoke a subset of the testsuite. For example, to only run tests that are currently known/expected to fail:

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

There are the following sets of tests:

  • compile.exp : compilation tests
  • execute.exp : execution tests
  • xfail.exp : tests that are currently known/expected to fail

Invoke only a specific test :

$ make check-rust RUNTESTFLAGS="--all 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/. Please 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 crab1 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/../../crab1 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/../../crab1 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 crab1:

$ 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/compile/torture/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/compile/torture/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/compile/torture/type_infer1.rs -S -o type_infer1.s

To emit Rust front end debug output, you may add options like -frust-debug, -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 copyright assignment or the Developer's Certificate of Origin sign-off. Please see the Contributing to GCC guide or Developer's Certificate of Origin (DCO) Sign-off guide.

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

Continuous Integration

When submitting (or updating) a GitHub Pull Request, several automated checks are run. Generally, a "green status" is necessary before merge.

Compiler Diagnostics

That is, here, diagnostics emitted by the "initial" compiler used to build GCC/Rust.

If building a native toolchain, GCC by default does a 3-stage bootstrap build (https://gcc.gnu.org/install/configure.html). In addition to making sure that GCC is able to reproduce itself bit-by-bit, this also means that stages 2+ are built with -Werror (turning most warning into error diagnostics; see --enable-werror, possibly enabled by default). This helps to catch a good number of bugs, because it enforces that GCC compiles without compiler diagnostics; it's a requirement for upstream patch submission (https://gcc.gnu.org/contribute.html#testing).

GCC generally is only expected to be "warning-clean" without --disable-bootstrap (that is, default --enable-bootstrap for a native build), and not for the initial stage where it's using the "initial" compiler -- otherwise we're at the mercy of whatever "initial" compiler we're using. Doing a --disable-bootstrap build is much faster, of course, so we're often doing that: for example, per the instructions above, or in the standard CI. With that, we're missing out on the aspect that enforces that GCC compiles without compiler diagnostics.

To encounter that, the default CI has a check for new warnings step that verifies in the CI --disable-bootstrap build configuration that no new warnings are introduced. If that step fails, it usually points out a new warning you've introduced erroneously, and should address. Occasionally it means that simply the .github/log_expected_warnings file needs to be updated, for example if due to any kind of "environmental changes" (for example, CI "initial" compiler changes). Unless diligently reproducing the CI configuration (in particular "initial" compiler, GCC version), it's not really feasible to reproduce this check locally. If in doubt, do a local --enable-bootstrap build, or submit your changes, and wait for the CI system's results.

Community

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