Go to file
Philip Herron 6496291f34 Enforce win64 abi test to always run on -m64 mode
Fixes #1439
2022-08-09 16:35:37 +01:00
.github Add in -m32,-m64 configuration to make check-rust 2022-08-09 15:33:31 +01:00
INSTALL
c++tools Update copyright years. 2022-01-03 10:42:10 +01:00
config Daily bump. 2021-12-22 00:16:30 +00:00
contrib Daily bump. 2022-01-18 00:16:54 +00:00
fixincludes Fix glitch in entry for vxworks_posix_open 2022-01-17 13:23:40 +00:00
gcc Enforce win64 abi test to always run on -m64 mode 2022-08-09 16:35:37 +01:00
gnattools Daily bump. 2021-10-23 00:16:26 +00:00
gotools Daily bump. 2021-09-22 00:16:28 +00:00
include Update copyright years. 2022-01-03 10:42:10 +01:00
intl Daily bump. 2021-11-30 00:16:44 +00:00
libada Update copyright years. 2022-01-03 10:42:10 +01:00
libatomic Update copyright years. 2022-01-03 10:42:10 +01:00
libbacktrace Update copyright years. 2022-01-03 10:42:10 +01:00
libcc1 Update copyright years. 2022-01-03 10:42:10 +01:00
libcody Update Copyright in ChangeLog files 2022-01-03 10:31:39 +01:00
libcpp Daily bump. 2022-01-18 00:16:54 +00:00
libdecnumber Update copyright years. 2022-01-03 10:42:10 +01:00
libffi Daily bump. 2021-11-16 00:16:31 +00:00
libgcc Daily bump. 2022-01-18 00:16:54 +00:00
libgfortran Daily bump. 2022-01-18 00:16:54 +00:00
libgo compiler, libgo: don't pad sparc64-linux epollevent 2021-12-29 15:52:23 -08:00
libgomp Daily bump. 2022-01-18 00:16:54 +00:00
libiberty Daily bump. 2022-01-16 00:16:26 +00:00
libitm Daily bump. 2022-01-04 00:16:40 +00:00
libobjc Update copyright years. 2022-01-03 10:42:10 +01:00
liboffloadmic Daily bump. 2021-10-20 00:16:43 +00:00
libphobos Daily bump. 2022-01-04 00:16:40 +00:00
libquadmath Daily bump. 2022-01-12 00:16:39 +00:00
libsanitizer Daily bump. 2021-12-07 00:16:23 +00:00
libssp Update copyright years. 2022-01-03 10:42:10 +01:00
libstdc++-v3 Daily bump. 2022-01-18 00:16:54 +00:00
libvtv Update copyright years. 2022-01-03 10:42:10 +01:00
lto-plugin Update copyright years. 2022-01-03 10:42:10 +01:00
maintainer-scripts
zlib Daily bump. 2021-12-17 00:16:20 +00:00
.dir-locals.el dir-locals: Use https for bug references 2021-07-20 11:40:34 +01:00
.gitattributes
.gitignore Merge commit '2961ac45b9e19523958757e607d11c5893d6368b' [#247] 2021-09-24 18:20:21 +02:00
.remarkrc Added Remark.yml and .remarkrc 2021-11-06 20:15:06 +05:30
ABOUT-NLS
CODE_OF_CONDUCT.md
CONTRIBUTING.md Removed markdown linting errors from README.md and CONTRIBUTING.md 2021-11-20 16:55:45 +05:30
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2022-01-18 00:16:54 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
Dockerfile docker: Fix GCCRS_BUILD info 2022-06-08 10:57:16 +02:00
MAINTAINERS Change references of .c files to .cc files 2022-01-17 22:12:07 +01:00
Makefile.def Merge commit '490e23032baaece71f2ec09fa1805064b150fbc2' [#247] 2022-01-24 10:06:43 +01:00
Makefile.in Merge commit '490e23032baaece71f2ec09fa1805064b150fbc2' [#247] 2022-01-24 10:06:43 +01:00
Makefile.tpl Revert "Sync with binutils: GCC: Pass --plugin to AR and RANLIB" 2021-12-15 20:45:58 -08:00
README
README.md Update build farm status 2022-07-15 14:01:23 +01:00
ar-lib
build.log Allow propagations from inner loop to outer loop. 2022-01-07 23:09:05 +08:00
compile
config-ml.in
config.guess
config.rpath
config.sub config.sub: change mode to 755. 2021-12-21 09:10:57 +01:00
configure config: Add check whether D compiler works (PR103528) 2021-12-21 21:29:35 +01:00
configure.ac Revert "Sync with binutils: GCC: Pass --plugin to AR and RANLIB" 2021-12-15 20:45:58 -08:00
depcomp
install-sh
libtool-ldflags
libtool.m4 Revert "Sync with binutils: GCC: Pass --plugin to AR and RANLIB" 2021-12-15 20:45:58 -08:00
logo.png
ltgcc.m4
ltmain.sh
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 Build Docker image 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.

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

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

Running GCC Rust

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

$ ./gcc/rust1 test.rs -frust-debug -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 (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 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/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/bors_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: