wsmoses / Tapir-Meta

24 stars 7 forks source link

Failed to build #7

Open wheatman opened 4 years ago

wheatman commented 4 years ago

When I first try and build using ./build.sh release

I get CMake Error at cmake/modules/CheckCompilerVersion.cmake:12 (message): Host GCC version must be at least 4.8! Call Stack (most recent call first): cmake/config-ix.cmake:14 (include) CMakeLists.txt:594 (include)

This is because on the host machine the default g++ and gcc are 4.4.7

However, I have installed gcc 10.0.0 in my path, but it doesn't seem to find them and I did not find the proper way to specify them.

I tried to specify them by changing the following line in the build.sh script

line 54: cmake $MODE -DLLVM_TARGETS_TO_BUILD=host $LLVM_SRC

to: cmake $MODE -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_C_COMPILER=/home/wheatman/install_dir/gcc/bin/gcc -DCMAKE_CXX_COMPILER=/home/wheatman/install_dir/gcc/bin/g++ $LLVM_SRC

Which I thought would set it up to use the correct compiler and it seems to get through the configuration, then fails when building.

The output is attached.

pane.txt

Let me know what other details you need or how I can fix this problem.

neboat commented 4 years ago

I'm not familiar with GCC 10. From what I can tell, GCC 10 has not been official released; it's still a work-in-progress.

You might try installing the current stable release of GCC. I would also recommend trying to build a newer version of Tapir than what the Tapir-Meta currently points to. Newer versions of the Tapir and LLVM codebases include changes that are necessary to accommodate updates to the C++ standard, various compiler defaults, and standard libraries.

wheatman commented 4 years ago

I tried switching to gcc 9.2, the most recent stable version and am able to get through the configuration to the build step and it fails with a fatal error: cilk/reducer.h: No such file or directory

I am on a machine without cilk, so I wonder if it is a requirement to have cilk on the machine before installing tapir.

neboat commented 4 years ago

You should not need Cilk on the machine to build and install Tapir. Can you provide more context for that error message? (In other words, what were the commands you ran, and what command failed with that error message?)

wheatman commented 4 years ago

I ran

git clone https://github.com/wsmoses/Tapir-LLVM.git src
git clone https://github.com/wsmoses/Tapir-Clang.git src/tools/clang
git clone https://github.com/wsmoses/Tapir-compiler-rt.git src/projects/compiler-rt
git clone https://github.com/wsmoses/Tapir-Polly.git src/tools/polly

mkdir src/build
cd src/build
CC=gcc9.2 CXX=g++9.2 cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host -DLLVM_BINUTILS_INCDIR=/home/wheatman/install_dir/binutils/include/ -DCMAKE_INSTALL_PREFIX=/home/wheatman/install_dir/tapir2/ -DLLVM_TARGETS_TO_BUILD="AArch64;AMDGPU;ARM;BPF;Hexagon;Mips;MSP430;PowerPC;Sparc;SystemZ;X86;XCore;NVPTX"  ..
cmake --build . -- -j8

I failed with

/home/wheatman/install_dir/Tapir2/src/projects/compiler-rt/lib/cilkscale/cilkscale.c:24:10: fatal error: cilk/reducer.h: No such file or directory
   24 | #include <cilk/reducer.h>
      |          ^~~~~~~~~~~~~~~~

I have since managed to get farther into the build process by switching to gcc 4.9, which did include cilk, but I had to make a few changes. I think they were related to the fact that older versions of gcc did not handle static asserts the same. I first tried using CMAKE_C_FLAGS and CMAKE_CXX_FLAGS to enable c11 and c++11 features but ended up having to make the following changes to get it past a few errors compiling.

> diff --git a/lib/cilkscale/cilkscale_timer.h b/lib/cilkscale/cilkscale_timer.h
index 9985847..5260064 100644
--- a/lib/cilkscale/cilkscale_timer.h 
+++ b/lib/cilkscale/cilkscale_timer.h
@@ -12,7 +12,7 @@
#ifndef CSCALETIMER
// Valid cilkscale timer values are RDTSC, CLOCK, and INST
-#define CSCALETIMER CLOCK 
+#define CSCALETIMER RDTSC   
#endif 
#if CSCALETIMER == RDTSC
> diff --git a/lib/csi/csirt.c b/lib/csi/csirt.c
> index f460a38..83ce335 100644
> --- a/lib/csi/csirt.c
> +++ b/lib/csi/csirt.c
> @@ -6,6 +6,7 @@
>  #include <csi/csi.h>
> 
>  // Compile-time assert the property structs are 64 bits.
> +/*
>  static_assert(sizeof(func_prop_t) == 8, "Size of func_prop_t is not 64 bits.");
>  static_assert(sizeof(func_exit_prop_t) == 8,
>                "Size of func_exit_prop_t is not 64 bits.");
> @@ -25,7 +26,7 @@ static_assert(sizeof(alloca_prop_t) == 8,
>  static_assert(sizeof(allocfn_prop_t) == 8,
>                "Size of allocfn_prop_t is not 64 bits.");
>  static_assert(sizeof(free_prop_t) == 8, "Size of free_prop_t is not 64 bits.");
> -
> +*/
>  #define CSIRT_API __attribute__((visibility("default")))
> 
> 
>  // ------------------------------------------------------------------------
> @@ -68,12 +69,12 @@ typedef enum {
>      FED_TYPE_FREE,
>      NUM_FED_TYPES // Must be last
>  } fed_type_t;
> -
> +/*
>  static_assert(sizeof(instrumentation_counts_t) ==
>                sizeof(csi_id_t) * NUM_FED_TYPES,
>                "Mismatch between NUM_FED_TYPES and size of "
>                "instrumentation_counts_t");
> -
> +*/
>  // A SizeInfo table is a flat list of SizeInfo entries, indexed by a CSI ID.
>  typedef struct {
>    int64_t num_entries;
> 

The errors I was avoiding were

/home/wheatman/install_dir/binutils/bin/ld: CMakeFiles/clang_rt.cilkscale-dynamic-x86_64.dir/cilkscale.c.o: in function `gettime':
/home/wheatman/install_dir/Tapir/src/projects/compiler-rt/lib/cilkscale/cilkscale_timer.h:57: undefined reference to `clock_gettime'
/home/wheatman/install_dir/binutils/bin/ld: /home/wheatman/install_dir/Tapir/src/projects/compiler-rt/lib/cilkscale/cilkscale_timer.h:57: undefined reference to `clock_/home/wheatman/install_dir/binutils/bin/ld: /home/wheatman/install_dir/Tapir/src/projects/compiler-rt/lib/cilkscale/cilkscale_timer.h:57: undefined reference to `clock_/home/wheatman/install_dir/binutils/bin/ld: /home/wheatman/install_dir/Tapir/src/projects/compiler-rt/lib/cilkscale/cilkscale_timer.h:57: undefined reference to `clock_/home/wheatman/install_dir/binutils/bin/ld: /home/wheatman/install_dir/Tapir/src/projects/compiler-rt/lib/cilkscale/cilkscale_timer.h:57: undefined reference to `clock_/home/wheatman/install_dir/binutils/bin/ld: CMakeFiles/clang_rt.cilkscale-dynamic-x86_64.dir/cilkscale.c.o:/home/wheatman/install_dir/Tapir/src/projects/compiler-rt/libtime' follow
collect2: error: ld returned 1 exit status

and

/home/wheatman/install_dir/Tapir/src/projects/compiler-rt/lib/csi/csirt.c:73:15: error: expected declaration specifiers or ‘...’ before ‘sizeof’
 static_assert(sizeof(instrumentation_counts_t) ==
               ^
/home/wheatman/install_dir/Tapir/src/projects/compiler-rt/lib/csi/csirt.c:75:15: error: expected declaration specifiers or ‘...’ before string constant
               "Mismatch between NUM_FED_TYPES and size of "
               ^
/home/wheatman/install_dir/Tapir/src/projects/compiler-rt/lib/csi/csirt.c:73:15: error: expected declaration specifiers or ‘...’ before ‘sizeof’
 static_assert(sizeof(instrumentation_counts_t) ==
               ^
/home/wheatman/install_dir/Tapir/src/projects/compiler-rt/lib/csi/csirt.c:75:15: error: expected declaration specifiers or ‘...’ before string constant
               "Mismatch between NUM_FED_TYPES and size of "
               ^

The build step with the changes above is still in process and I will update if that fixes things.

I post now since regardless of if it works there still seems to be a bug in compiling on either old systems and systems without cilk.

neboat commented 4 years ago

Regarding the first problem, it appears that GCC is deprecating Cilk in a manner that messes up CMake's ability to tell whether or not the compiler supports Cilk. For now, you can work around this issue by passing the flag -DCOMPILER_RT_HAS_CILK_FLAG=False at the CMake configuration step.