Skip to content

Commit

Permalink
CMakeLists.txt
Browse files Browse the repository at this point in the history
runtime/libupc/CMakeLists.txt
include/clang/Config/config.h.cmake
include/clang/Config/config.h.in
	Add configure for UPC backtracing.  On some systems (e.g. freebsd)
	and extra library (execinfo) must be placed on the UPC link line
	for backtrace and backtrace_symbl functions.
lib/Driver/Tools.cpp
	Add exexinfo library on FreeBSD/OpenBSD/NetBSD systems if UPC
	backtracing is enabled.
  • Loading branch information
Nenad Vukicevic committed Jun 25, 2014
1 parent ef69081 commit d4601ba
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ endif()
set(LIBUPC_ENABLE_LINK_SCRIPT TRUE CACHE STRING "enable UPC's use of a custom linker script; this will define the UPC shared section as a no load section on targets where this feature is supported (requires GNU LD)")
set(LIBUPC_LINK_SCRIPT ${LIBUPC_ENABLE_LINK_SCRIPT})

# Check for backtrace on systems (freebsd,..) that need an extra library
set(LIBUPC_ENABLE_BACKTRACE TRUE CACHE STRING "enable UPC backtrace; enable stack frame backtrace report when UPC run-time fatal errors occur or by user request (via signal)")
if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" OR
${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
# Check if libexecinfo with backtrace exists
CHECK_LIBRARY_EXISTS(execinfo backtrace "" HAVE_EXECINFO_LIB)
if (NOT ${HAVE_EXECINFO_LIB})
set(LIBUPC_ENABLE_BACKTRACE FALSE)
endif()
endif()

configure_file(
${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
${CLANG_BINARY_DIR}/include/clang/Config/config.h)
Expand Down
3 changes: 3 additions & 0 deletions include/clang/Config/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
/* UPC link script enabled. */
#cmakedefine LIBUPC_LINK_SCRIPT 1

/* Enable UPC backtrace */
#cmakedefine LIBUPC_ENABLE_BACKTRACE 1

/* Portals4 support */
#cmakedefine LIBUPC_PORTALS4 "${LIBUPC_PORTALS4}"

Expand Down
3 changes: 3 additions & 0 deletions include/clang/Config/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
/* Define to 1 if UPC link script is supported. */
#undef LIBUPC_LINK_SCRIPT

/* Define to 1 if UPC backtrace is enabled. */
#undef LIBUPC_ENABLE_BACKTRACE

/* Portals4 support */
#undef LIBUPC_PORTALS4

Expand Down
9 changes: 9 additions & 0 deletions lib/Driver/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5674,6 +5674,9 @@ void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString("-T" + getToolChain().GetFilePath("upc.ld")));
#endif
CmdArgs.push_back(GetUPCLibOption(Args));
#ifdef LIBUPC_ENABLE_BACKTRACE
CmdArgs.push_back("-lexecinfo");
#endif
}

if (!Args.hasArg(options::OPT_nostdlib) &&
Expand Down Expand Up @@ -6079,6 +6082,9 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString("-T" + getToolChain().GetFilePath("upc.ld")));
#endif
CmdArgs.push_back(GetUPCLibOption(Args));
#ifdef LIBUPC_ENABLE_BACKTRACE
CmdArgs.push_back("-lexecinfo");
#endif
}

if (!Args.hasArg(options::OPT_nostdlib) &&
Expand Down Expand Up @@ -6304,6 +6310,9 @@ void netbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString("-T" + getToolChain().GetFilePath("upc.ld")));
#endif
CmdArgs.push_back(GetUPCLibOption(Args));
#ifdef LIBUPC_ENABLE_BACKTRACE
CmdArgs.push_back("-lexecinfo");
#endif
}

unsigned Major, Minor, Micro;
Expand Down
11 changes: 11 additions & 0 deletions runtime/libupc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,18 @@ string(REGEX REPLACE [A-Za-z]] "\\1" LIBUPC_RUNTIME_MODEL ${LIBUPC_RUNTIME_MODEL

set(LIBUPC_ENABLE_LINK_SCRIPT TRUE CACHE STRING "enable UPC's use of a custom linker script; this will define the UPC shared section as a no load section on targets where this feature is supported (requires GNU LD)")

# Check for backtrace on systems (freebsd,..) that need an extra library
set(LIBUPC_ENABLE_BACKTRACE TRUE CACHE STRING "enable UPC backtrace; enable stack frame backtrace report when UPC run-time fatal errors occur or by user request (via signal)")
if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" OR
${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
# Check if libexecinfo with backtrace exists
CHECK_LIBRARY_EXISTS(execinfo backtrace "" HAVE_EXECINFO_LIB)
if (NOT ${HAVE_EXECINFO_LIB})
set(LIBUPC_ENABLE_BACKTRACE FALSE)
endif()
else()
endif()
set(HAVE_UPC_BACKTRACE ${LIBUPC_ENABLE_BACKTRACE})

set(LIBUPC_ENABLE_BACKTRACE_ADDR2LINE TRUE CACHE STRING "enable the use of addr2line for UPC stack backtrace")
Expand Down

0 comments on commit d4601ba

Please sign in to comment.