rust-lang / rustc_codegen_gcc

libgccjit AOT codegen for rustc
Apache License 2.0
892 stars 60 forks source link

libgccjit testsuite seems to fail due to compile errors in libgccjit++.h #536

Open liamnaddell opened 2 days ago

liamnaddell commented 2 days ago

Sorry if this is not the right place to put this issue, I'm not sure where is the best place to file issues against the custom GCC.

ENV Info:

I downloaded, built, and run gcc as described in the README, with --enable-languages=jit,c++

After building libgccjit, I wanted to run the tests, but observed that all the tests failed:

PASS: ../jit/docs/examples/tut01-hello-world.c (test for excess errors)
Executing on host: /home/liam/rustc_gcc/gcc-build/gcc/testsuite/jit/../../xg++ -B/home/liam/rustc_gcc/gcc-build/gcc/testsuite/jit/../../  /home/liam/rustc_gcc/gcc/gcc/testsuite/../jit/docs/examples/tut01-hello-world.cc    -fdiagnostics-plain-output  -nostdinc++ -I/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/libstdc++-v3/include/aarch64-unknown-linux-gnu -I/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/libstdc++-v3/include -I/home/liam/rustc_gcc/gcc/libstdc++-v3/libsupc++ -I/home/liam/rustc_gcc/gcc/libstdc++-v3/include/backward -I/home/liam/rustc_gcc/gcc/libstdc++-v3/testsuite/util -fmessage-length=0  -I/home/liam/rustc_gcc/gcc/gcc/testsuite/../jit -lgccjit -g -Wall -Werror -rdynamic    -L/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libstdc++-v3/src/.libs  -B/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libstdc++-v3/src/.libs  -L/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libstdc++-v3/src/.libs  -L/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libstdc++-v3/src/experimental/.libs -B/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libitm/ -L/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libitm/.libs -lm  -o tut01-hello-world.cc.exe    (timeout = 300)
spawn -ignore SIGHUP /home/liam/rustc_gcc/gcc-build/gcc/testsuite/jit/../../xg++ -B/home/liam/rustc_gcc/gcc-build/gcc/testsuite/jit/../../ /home/liam/rustc_gcc/gcc/gcc/testsuite/../jit/docs/examples/tut01-hello-world.cc -fdiagnostics-plain-output -nostdinc++ -I/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/libstdc++-v3/include/aarch64-unknown-linux-gnu -I/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/libstdc++-v3/include -I/home/liam/rustc_gcc/gcc/libstdc++-v3/libsupc++ -I/home/liam/rustc_gcc/gcc/libstdc++-v3/include/backward -I/home/liam/rustc_gcc/gcc/libstdc++-v3/testsuite/util -fmessage-length=0 -I/home/liam/rustc_gcc/gcc/gcc/testsuite/../jit -lgccjit -g -Wall -Werror -rdynamic -L/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libstdc++-v3/src/.libs -B/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libstdc++-v3/src/.libs -L/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libstdc++-v3/src/.libs -L/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libstdc++-v3/src/experimental/.libs -B/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libitm/ -L/home/liam/rustc_gcc/gcc-build/aarch64-unknown-linux-gnu/./libitm/.libs -lm -o tut01-hello-world.cc.exe^M
In file included from /home/liam/rustc_gcc/gcc/gcc/testsuite/../jit/docs/examples/tut01-hello-world.cc:20:^M
/home/liam/rustc_gcc/gcc/gcc/testsuite/../jit/libgccjit++.h:1772:1: error: no declaration matches 'void gccjit::rvalue::set_type(gccjit::type*)'^M
/home/liam/rustc_gcc/gcc/gcc/testsuite/../jit/libgccjit++.h:1772:1: note: no functions named 'void gccjit::rvalue::set_type(gccjit::type*)'^M
/home/liam/rustc_gcc/gcc/gcc/testsuite/../jit/libgccjit++.h:480:9: note: 'class gccjit::rvalue' defined here^M
compiler exited with status 1
FAIL: ../jit/docs/examples/tut01-hello-world.cc, initial compilation

I was able to create a patch that gets this test (and all the others failing for the same reason) working:

diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h
index f3ee65cccd7..5fe00e95cb2 100644
--- a/gcc/jit/libgccjit++.h
+++ b/gcc/jit/libgccjit++.h
@@ -485,6 +485,7 @@ namespace gccjit
     gcc_jit_rvalue *get_inner_rvalue () const;

     type get_type ();
+    void set_type (type *new_type);

     rvalue access_field (field field,
                         location loc = location ());
@@ -1771,7 +1772,7 @@ rvalue::get_type ()
 inline void
 rvalue::set_type (type *new_type)
 {
-  gcc_jit_rvalue_set_type (get_inner_rvalue (), new_type);
+  gcc_jit_rvalue_set_type (get_inner_rvalue (), new_type->get_inner_type ());
 }

It seems this error was caused by https://github.com/rust-lang/gcc/commit/341be3b7d7ac6976cfed8ed59da3573c040d0776#diff-70af12ffc4a575792e96588dc518ccf7aacf05f74dfe08d7b931275015c030fe

antoyo commented 2 days ago

Thanks for raising the issue. Indeed, we're having a lot of trouble doing the sync of rustc_codegen_gcc with the Rust repo, and I indeed left the GCC repo in a state where some tests fail: sorry about that. Is this causing any issue for you? If so, I can fix it tomorrow.

liamnaddell commented 2 days ago

I was interested in the testsuite because the README suggested running the check-jit target. I'm guessing that a bad libgccjit++.h won't impact the rust backend, so if it's not worth fixing, it wouldn't impact me at all.

antoyo commented 2 days ago

It won't impact this project indeed, but I will fix these tests in the coming weeks.