Skip to content

Commit 0ed462e

Browse files
committed
Add config for gcc build directory
1 parent 17b73a8 commit 0ed462e

File tree

8 files changed

+16
-7
lines changed

8 files changed

+16
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
gcc_path
12
target
23
**/*.rs.bk
34
*.rlib

Readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The following two patches need to be applied:**
1010
* https://gcc.gnu.org/pipermail/jit/2020q3/001228.html
1111
* https://gcc.gnu.org/pipermail/jit/2020q3/001247.html
1212

13+
**Put the path to your custom build of libgccjit in the file `gcc_path`.**
14+
1315
```bash
1416
$ git clone https://github.com/antoyo/rustc_codegen_gcc.git
1517
$ cd rustc_codegen_gcc

config.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ set -e
22

33
export CARGO_INCREMENTAL=0
44

5+
export GCC_PATH=$(cat gcc_path)
6+
57
unamestr=`uname`
68
if [[ "$unamestr" == 'Linux' ]]; then
79
dylib_ext='so'
@@ -39,7 +41,7 @@ fi
3941
RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out"
4042
export RUSTC_LOG=warn # display metadata load errors
4143

42-
export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib:$(pwd)/../../../Projets/gcc-build/build/gcc/"
44+
export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib:$GCC_PATH"
4345
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
4446

4547
export CG_CLIF_DISPLAY_CG_TIME=1

gcc-test-backend/Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gcc_path

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/tmp/gcc-build/build/gcc

src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_hand
182182
}
183183

184184
EmitObj::Bitcode => {
185-
unimplemented!();
185+
//unimplemented!();
186186
/*debug!("copying bitcode {:?} to obj {:?}", bc_out, obj_out);
187187
if let Err(e) = link_or_copy(&bc_out, &obj_out) {
188188
diag_handler.err(&format!("failed to copy bitcode to object file: {}", e));

test.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#set -x
44
set -e
55

6-
export LD_LIBRARY_PATH="$(pwd)/../../../Projets/gcc-build/build/gcc/"
6+
export GCC_PATH=$(cat gcc_path)
7+
8+
export LD_LIBRARY_PATH="$GCC_PATH"
79
if [[ "$1" == "--release" ]]; then
810
export CHANNEL='release'
911
CARGO_INCREMENTAL=1 cargo rustc --release -- -Zrun_dsymutil=no

tests/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ use lang_tester::LangTester;
88
use tempfile::TempDir;
99

1010
fn main() {
11-
// TODO: load correct libgccjit.so file.
1211
let tempdir = TempDir::new().expect("temp dir");
1312
let current_dir = current_dir().expect("current dir");
1413
let current_dir = current_dir.to_str().expect("current dir").to_string();
15-
env::set_var("LD_LIBRARY_PATH", format!("{}/../../../Projets/gcc-build/build/gcc/", current_dir));
14+
let gcc_path = include_str!("../gcc_path");
15+
let gcc_path = gcc_path.trim();
16+
env::set_var("LD_LIBRARY_PATH", gcc_path);
1617
LangTester::new()
1718
.test_dir("tests/run")
1819
.test_file_filter(|path| path.extension().expect("extension").to_str().expect("to_str") == "rs")

0 commit comments

Comments
 (0)