clangupc / clang-upc

Clang UPC Front-End
https://clangupc.github.io/
Other
16 stars 5 forks source link

UPC timer (upc_tick.h) calls require -lrt when linking on some systems #10

Closed gary-funck closed 11 years ago

gary-funck commented 11 years ago

The intrepid test, test31 fails to link.

/usr/local/clang-upc/bin/clangupc  -O0 -fupc-pts=packed -fupc-pts-vaddr-order=f
irst  -Wall -Wextra -Wwrite-strings -Werror  -g test31.upc -o test31
/usr/local/clang-upc/bin/../lib/libupc.a(upc_tick.c.o): In function `upc_ticks_
now':
/eng/upc/dev/gary/clang/src/llvm/tools/clang/runtime/libupc/smp/upc_tick.c:31:
undefined reference to `clock_gettime'
clang-3: error: linker command failed with exit code 1 (use -v to see invocatio
n)

Per "man clock_gettime":

NAME
       clock_getres, clock_gettime, clock_settime - clock and time functions

SYNOPSIS
       #include 

       int clock_getres(clockid_t clk_id, struct timespec *res);

       int clock_gettime(clockid_t clk_id, struct timespec *tp);

       int clock_settime(clockid_t clk_id, const struct timespec *tp);

       Link with -lrt.

When GUPC is configured, it will add -lrt to the linker line on systems linking with librt is required (most modern Linux systems).

The addition of -lrt is handled by this logic in configure.ac in GUPC's libgupc configure logic.

# At least for glibc, clock_gettime is in librt.  But don't pull that
# in if it still doesn't give us the function we want.
if test $ac_cv_func_clock_gettime = no; then
  AC_CHECK_LIB(rt, clock_gettime,[ac_cv_func_clock_gettime="yes"])
  if test $ac_cv_func_clock_gettime = yes; then
    LIBS="-lrt $LIBS"
    AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
              [Define to 1 if you have the `clock_gettime' function.])
  fi
fi
swatanabe commented 11 years ago

I don't know how to do this with CMake. target_link_libraries seems to be ignored for static libs.

swatanabe commented 11 years ago

Okay. It looks like clang's handling of this is a lot more primitive than gcc's. I'm just going to have to hard-code -lrt in Driver/Tools.cpp.

gary-funck commented 11 years ago

Confirmed closed: passes the internal test suite and the separate clang upc test suite.

Side note: we removed the non-integer (float) arg. to the upc_barrier compilation test, because this is now allowed by the 1.3 spec.