From 5a9ceba8fd21973118f1866686aca5622cc60ba2 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Sun, 10 Jan 2021 16:14:26 +0000 Subject: Mark DECL_PUBLIC for main fn or functions with visibility. This change will need more thought later when it comes to traits and generics etc. Fixes #136 --- gcc/rust/backend/rust-compile-item.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index e042ccb..c5fe9a2 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -138,10 +138,24 @@ public: // convert to the actual function type auto compiled_fn_type = TyTyCompile::compile (ctx->get_backend (), fnType); + unsigned int flags = 0; + bool is_main_fn = function.function_name.compare ("main") == 0; + + // if its the main fn or pub visibility mark its as DECL_PUBLIC + // please see https://github.com/Rust-GCC/gccrs/pull/137 + if (is_main_fn || function.has_visibility ()) + flags |= Backend::function_is_visible; + + std::string asm_name = function.function_name; + if (!is_main_fn) + { + // FIXME need name mangling + asm_name = "__" + function.function_name; + } + Bfunction *fndecl = ctx->get_backend ()->function (compiled_fn_type, function.function_name, - "" /* asm_name */, 0 /* flags */, - function.get_locus ()); + asm_name, flags, function.get_locus ()); ctx->insert_function_decl (function.get_mappings ().get_hirid (), fndecl); // setup the params -- cgit v1.1 From da3e15f13f8e3f00f1826efec8a74ebb67637b4c Mon Sep 17 00:00:00 2001 From: Vlad Doster Date: Sun, 10 Jan 2021 22:34:23 -0600 Subject: (docs) update README.md - Correct grammar/spelling - Add language syntax for code fences - Link to test-suite file --- README.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 1e1ec49..4129370 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,18 @@ # GCC Rust ![GCC Rust](logo.png?raw=true "GCC rust Logo") -This is a full alternative implementaion of the Rust language ontop of GCC which the goal +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 in a stable state, it is a good time to create alternative compilers. The developers of +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. -## Development Enviroment +## Development Environment -Fetch dependancies for ubuntu: +Fetch dependencies for Ubuntu: ```bash $ apt install build-essential libgmp3-dev libmpfr-dev libmpc-dev flex bison autogen gcc-multilib dejagnu @@ -28,8 +28,8 @@ Clone the repository $ git clone git@github.com:Rust-GCC/gccrs.git ``` -Compilation script. It is important to remember that GNU toolchain projects are designed to be built outside of its source directory -this is why a build directory is created. +Compilation script. 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. ```bash $ mkdir gccrs-build @@ -40,33 +40,33 @@ $ make Running the compiler itself without make install we can simply invoke the compiler proper: -``` +```bash $ gdb --args ./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 invoking the compiler driver (gccrs) we need to: -``` +```bash $ make install ``` Then invoke the compiler as expected: -``` +```bash $ gccrs -g -O2 -c test.rs -o test.o $ gccrs -o test test.o ``` ## Testsuite -The test suite can be invoked via: +Invoke the test suite via: -``` +```bash $ make check-rust ``` -Test cases can be found within gcc/testsuite/rust.test please feel free to contribute your specific -test cases referencing any issues on github. +Test cases are located within [gcc/testsuite/rust.test](gcc/testsuite/rust.test) please feel free to contribute your specific +test cases referencing any issues on Github. ## Docker image @@ -74,13 +74,13 @@ There is a docker image hosted over on: https://hub.docker.com/repository/docker/philberty/gccrs -``` +```bash $ docker pull philberty/gccrs ``` Or you can build your own image: -``` +```bash $ docker build . -t gccrs-dev $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp \ gccrs-dev:latest gccrs -g -O2 -c \ @@ -89,14 +89,14 @@ $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp \ ## Contributing -Please be aware this project is designed to be pushed upstream to GCC when we reach some milestones and this means we require -contribtions to have copyright assignment in place. Please see: https://gcc.gnu.org/contribute.html +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 +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: +We can be found on all usual Rust channels such as Zulip, but we also have our own channels: * GCC Rust Zulip: https://gcc-rust.zulipchat.com/ * Twitter: https://twitter.com/gcc_rust -- cgit v1.1 From 05b9f235566d7d361709c5bc44e7c36598515946 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Tue, 12 Jan 2021 13:48:32 +0000 Subject: Fix link to build status shield The repository was moved into the Rust-GCC organization from philberty --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4129370..0c7670d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![C/C++ CI](https://github.com/philberty/gccrs/workflows/C/C++%20CI/badge.svg) +![C/C++ CI](https://github.com/Rust-GCC/gccrs/workflows/C/C++%20CI/badge.svg) ![Docker Build](https://img.shields.io/docker/cloud/build/philberty/gccrs) ![Docker Pulls](https://img.shields.io/docker/pulls/philberty/gccrs) [![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://gcc-rust.zulipchat.com/) -- cgit v1.1