aguinet / dragonffi

C Foreign Function Interface and JIT using Clang/LLVM
Apache License 2.0
548 stars 23 forks source link

Towards rv64gc port (Qemu)/tests are failing, on OpenSUSE #59

Closed advancedwebdeveloper closed 3 years ago

advancedwebdeveloper commented 3 years ago

Here is what I have under Qemu/on OpenSUSE:

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./anon_members WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch.

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./anon_struct WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./anon_union WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./array WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch.

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./asm_redirect WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./attrs WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch.

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./bool WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch.

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./cconv WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./compile WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch.

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./compile_error WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. /__dffi_private/anon_cu_0.c:1:1: error: unknown type name 'this' this is not valid C code ^ /__dffi_private/anon_cu_0.c:1:8: error: expected ';' after top level declarator this is not valid C code ^ ;

/__dffi_private/anon_cu_1.c:1:1: error: unknown type name 'still' still invalide code ^ /__dffi_private/anon_cu_1.c:1:15: error: expected ';' after top level declarator still invalide code ^ ;

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./decl WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. coucou coucou LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./dlopen Unable to open (null)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./enum WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. V10 = 10 V4 = 4 V1 = 1 V0 = 0

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./func_ptr WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./includes terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./inline WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch.

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./multiple_defs WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch.

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./stdint WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch.

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./struct WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./system_headers WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./typedef WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./union WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

oceanfish81@riscv:/home/oceanfish81/dragonffi/build/tests> ./varargs WARNING: This target JIT is not designed for the host you are running. If bad things happen, please choose a different -march switch. LLVM ERROR: Relocation type not implemented yet! Aborted (core dumped)

Surely there is no actual port - and not all tests failed. I might check more tests, if they are available.

advancedwebdeveloper commented 3 years ago

I was able to build using Clang 11:

$cmake -DBUILD_TESTS=ON -DCMAKE_MODULE_PATH=/usr/lib64/cmake/clang -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G Ninja .. && ninja -j4 and GCC 10.2.1 $cmake -DBUILD_TESTS=ON -DCMAKE_MODULE_PATH=/usr/lib64/cmake/clang -G Ninja .. && ninja -j4

. Due to the current bug https://bugzilla.opensuse.org/show_bug.cgi?id=1180748#c8 - I had to apply a patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt index 393a533..67b02d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,15 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third-party)

set(LLVM_LINK_COMPONENTS

  • ${LLVM_NATIVE_ARCH}
  • ${LLVM_NATIVE_ARCH} - commenting out, as proposed in issue #1180748

  • Adding the following, on behave of resolving the above issue:

  • RISCVCodeGen
  • RISCVAsmParser
  • RISCVDisassembler
  • RISCVDesc
  • RISCVInfo
  • RISCVUtils
  • # AggressiveInstCombine Analysis AsmParser
aguinet commented 3 years ago

Please reformat your patch,it can't be read properly.

From what I understand, this is the patch proposed in the OpenSUSE ticket. I will try it as soon as I have time. Closing this issue and reopening a cleaner one to track this patch: https://github.com/aguinet/dragonffi/issues/60 .

About RiscV support, it's not something I have time to invest into right now. Feel free to submit PRs that could fix the issue you face!