cilkplus / clang

Other
27 stars 6 forks source link

Builds ok, but then fails to link sample program #17

Open seth4618 opened 8 years ago

seth4618 commented 8 years ago

We followed the direction at https://cilkplus.github.io/ and everything appeared to work ok. However, when we try and compile and link the example program, fib.c, we get the following:

Clang Front-End version 3.4.1 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
 "/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/clang-3.4" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -resource-dir /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/../lib/clang/3.4.1 -c-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include -c-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include -c-isystem . -cxx-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include -cxx-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include -cxx-isystem . -internal-isystem /usr/local/include -internal-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/../lib/clang/3.4.1/include -internal-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/../lib/clang/3.4.1/include/clang -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /afs/cs.cmu.edu/academic/class/15740-f15/scratch -ferror-limit 19 -fmessage-length 0 -fcilkplus -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-slp -o /tmp/test-adc0b6.o -x c test.c
clang -cc1 version 3.4.1 based upon LLVM 3.4.1 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/../lib/clang/3.4.1/include/clang"
ignoring nonexistent directory "/include"
ignoring duplicate directory "/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include"
#include "..." search starts here:
#include <...> search starts here:
 /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include
 .
 /usr/local/include
 /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/../lib/clang/3.4.1/include
 /usr/include
End of search list.
 "/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../.. -L/lib -L/usr/lib /tmp/test-adc0b6.o -L/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib -L/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib -L. -lcilkrts -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o
/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib/libcilkrts.so: undefined reference to `__cilkrts_xchg'
/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib/libcilkrts.so: undefined reference to `sysdep_save_fp_ctrl_state'
/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib/libcilkrts.so: undefined reference to `__cilkrts_short_pause'
/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib/libcilkrts.so: undefined reference to `restore_x86_fp_state'
clang-3.4: error: linker command failed with exit code 1 (use -v to see invocation)

Any help would be appreciated. (Oh, and the src for test.c is:

#include <cilk/cilk.h>
#include <assert.h>

int fib(int n) {
  if (n < 2)
    return n;
  int a = cilk_spawn fib(n-1);
  int b = fib(n-2);
  cilk_sync;
  return a + b;
}

int main() {
  int result = fib(30);
  assert(result == 832040);
  return 0;
}

Thanks!

avt77 commented 8 years ago

Sorry for delay with answer. Is it still important for you or the issue was resolved already? At the first glance you don't have "cilkrts" library. Did you build the one?

Andrew

2015-12-09 23:20 GMT+03:00 Seth notifications@github.com:

We followed the direction at https://cilkplus.github.io/ and everything appeared to work ok. However, when we try and compile and link the example program, fib.c, we get the following:

Clang Front-End version 3.4.1 (tags/RELEASE_34/final) Target: x86_64-unknown-linux-gnu Thread model: posix Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2 Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5 Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5 "/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/clang-3.4" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -resource-dir /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/../lib/clang/3.4.1 -c-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include -c-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include -c-isystem . -cxx-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include -cxx-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include -cxx-isystem . -internal-isystem /usr/local/include -internal-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/../lib/clang/3.4.1/include -internal-isystem /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/ bin/../lib/clang/3.4.1/include/clang -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /afs/cs.cmu.edu/academic/class/15740-f15/scratch -ferror-limit 19 -fmessage-length 0 -fcilkplus -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-slp -o /tmp/test-adc0b6.o -x c test.c clang -cc1 version 3.4.1 based upon LLVM 3.4.1 default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/../lib/clang/3.4.1/include/clang" ignoring nonexistent directory "/include" ignoring duplicate directory "/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include"

include "..." search starts here:

include <...> search starts here:

/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/include . /usr/local/include /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/bin/../lib/clang/3.4.1/include /usr/include End of search list. "/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../.. -L/lib -L/usr/lib /tmp/test-adc0b6.o -L/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib -L/afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib -L. -lcilkrts -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib/libcilkrts.so: undefined reference to __cilkrts_xchg' /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib/libcilkrts.so: undefined reference tosysdep_save_fp_ctrl_state' /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib/libcilkrts.so: undefined reference to __cilkrts_short_pause' /afs/cs.cmu.edu/academic/class/15740-f15/scratch/compiler/lib/libcilkrts.so: undefined reference torestore_x86_fp_state' clang-3.4: error: linker command failed with exit code 1 (use -v to see invocation)

Any help would be appreciated. (Oh, and the src for test.c is:

include <cilk/cilk.h>

include

int fib(int n) { if (n < 2) return n; int a = cilk_spawn fib(n-1); int b = fib(n-2); cilk_sync; return a + b; }

int main() { int result = fib(30); assert(result == 832040); return 0; }

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/cilkplus/clang/issues/17.