Commit cba2a079 authored by Dominik Charousset's avatar Dominik Charousset

Reorganized configure options

Due to ongoing problems with Boost on Linux distributions, this patch disables
Boost support by default, i.e., turns context-switching off. Users can enable
it explicitly by using `--enable-context-switching`. The old configure options
to disable this feature explicitly are now deprecated. Furthermore,
`--with-opencl` is replaced by `--enable-opencl` and
`--disable-context-switching` is replaced by `--no-context-switching`. This
change implements a more consistent naming scheme. The old option names are
still valid, but give a deprecated warning to the user and will be removed in
the future.
parent 69e859c5
......@@ -263,38 +263,20 @@ if (DISABLE_MEM_MANAGEMENT)
add_definitions(-DCPPA_DISABLE_MEM_MANAGEMENT)
endif (DISABLE_MEM_MANAGEMENT)
if (STANDALONE_BUILD)
add_definitions(-DCPPA_STANDALONE_BUILD)
endif (STANDALONE_BUILD)
if (STANDALONE_BUILD)
# explicitly disabled, don't include Boost
else (STANDALONE_BUILD)
find_package(Boost 1.54.0 COMPONENTS system context coroutine)
# without REQUIRED, find_package(Boost...) returns with Boost_FOUND=FALSE
if (NOT Boost_FOUND)
# disable implicitly
add_definitions(-DCPPA_STANDALONE_BUILD)
set(DISABLE_CONTEXT_SWITCHING true)
else (NOT Boost_FOUND)
set(LD_FLAGS ${LD_FLAGS} ${Boost_COROUTINE_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY})
# This hack fixes a problem when the linker search path is the same as
# the one provided by the compiler. In this case, CMake replaces the absolute
# path (e.g., /path/to/lib.so) with -l<lib>, which may cause it to pick up the wrong
# library. So when this replacement happens, we ensure that the right
# library gets picked by adding a -L directive for the affected libraries
# (which is just Boost Context here).
set(CMAKE_EXE_LINKER_FLAGS -L${Boost_LIBRARY_DIRS})
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
set(LD_DIRS ${LD_DIRS} ${Boost_LIBRARY_DIRS})
set(DISABLE_CONTEXT_SWITCHING false)
endif (NOT Boost_FOUND)
endif (STANDALONE_BUILD)
# set compiler flag when compiling w/o context-switching actors
if (DISABLE_CONTEXT_SWITCHING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_DISABLE_CONTEXT_SWITCHING")
endif ()
if (ENABLE_CONTEXT_SWITCHING)
find_package(Boost 1.54.0 COMPONENTS system context coroutine REQUIRED)
set(LD_FLAGS ${LD_FLAGS} ${Boost_COROUTINE_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY})
# This hack fixes a problem when the linker search path is the same as
# the one provided by the compiler. In this case, CMake replaces the absolute
# path (e.g., /path/to/lib.so) with -l<lib>, which may cause it to pick up the wrong
# library. So when this replacement happens, we ensure that the right
# library gets picked by adding a -L directive for the affected libraries
# (which is just Boost Context here).
set(CMAKE_EXE_LINKER_FLAGS -L${Boost_LIBRARY_DIRS})
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
set(LD_DIRS ${LD_DIRS} ${Boost_LIBRARY_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_ENABLE_CONTEXT_SWITCHING")
endif (ENABLE_CONTEXT_SWITCHING)
# build shared library if not compiling static only
if (NOT "${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes")
......@@ -379,9 +361,9 @@ endif ()
# set optional flags
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
set(CONTEXT_SWITCHING "yes")
if (DISABLE_CONTEXT_SWITCHING)
set(CONTEXT_SWITCHING "no")
set(CONTEXT_SWITCHING "no")
if (ENABLE_CONTEXT_SWITCHING)
set(CONTEXT_SWITCHING "yes")
endif ()
# check for doxygen and add custom "doc" target to Makefile
......
......@@ -18,8 +18,8 @@ usage="\
Usage: $0 [OPTION]... [VAR=VALUE]...
Build Options:
--generator=GENERATOR CMake generator to use (see cmake --help)
--build-type=DIR CMake build type: [RelWithDebInfo]
--generator=GENERATOR set CMake generator (see cmake --help)
--build-type=TYPE set CMake build type [RelWithDebInfo]:
- Debug: debugging flags enabled
- MinSizeRel: minimal output size
- Release: optimizations on, debugging off
......@@ -29,41 +29,47 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--lib-dir=DIR library directory [build/lib]
--with-clang=FILE path to clang++ executable
--with-gcc=FILE path to g++ executable
--dual-build build both with gcc and clang
--no-examples build libcppa without examples
--no-qt-examples build libcppa without Qt examples
--no-protobuf-examples build libcppa without protobuf examples
--no-unit-tests build libcppa without unit tests
--build-static build libcppa as static and shared library
--build-static-only build libcppa as static library only
--with-opencl build libcppa with OpenCL support
--without-memory-management build libcppa without memory management
--standalone-build build libcppa without Boost or other dependencies
--dual-build build using both gcc and clang
--build-static build as static and shared library
--build-static-only build as static library only
--more-clang-warnings enables most of Clang's warning flags
Installation Directories:
--prefix=PREFIX installation directory [/usr/local]
Optional Features:
--enable-debug compile in debugging mode
(always sets --build-type=Debug)
--enable-perftools use Google perftools
--enable-address-sanitizer use Clang's address sanitizer
--with-cppa-log-level=LVL sets the debugging output, possible values:
Add Optional Features:
--enable-opencl build with OpenCL support
--enable-context-switching build with context-switching (requires Boost)
--enable-perftools build with Google perftools
Remove Standard Features (even if all dependencies are available):
--no-memory-management build without memory management
--no-examples build without examples
--no-qt-examples build without Qt examples
--no-protobuf-examples build without Google Protobuf examples
--no-unit-tests build without unit tests
Debugging:
--enable-debug build with requirement checks at runtime
(always sets --build-type=Debug implicitly)
--with-cppa-log-level=LVL build with debugging output, possible values:
- ERROR
- WARNING
- INFO
- DEBUG
- TRACE
(implicitly sets --enable-debug)
Platform-Dependent Adjustments:
--disable-context-switching compile libcppa without context-switching actors
even if Boost.Context is available
--enable-address-sanitizer build with Clang's address sanitizer
Required Packages in Non-Standard Locations:
--with-boost=PATH path to Boost install root
Deprecated Options:
--without-memory-management replaced by --no-memory-management
--with-opencl replaced by --enable-opencl
--standalone-build build without Boost even if available (default)
--disable-context-switching build without context-switching (default)
Influential Environment Variables (only on first invocation
per build directory):
CXX C++ compiler command
......@@ -161,7 +167,7 @@ builddir="$sourcedir/build"
CMakeCacheEntries=""
append_cache_entry CMAKE_INSTALL_PREFIX PATH /usr/local
append_cache_entry ENABLE_DEBUG BOOL false
append_cache_entry DISABLE_CONTEXT_SWITCHING BOOL false
append_cache_entry ENABLE_CONTEXT_SWITCHING BOOL false
# Parse arguments.
while [ $# -ne 0 ]; do
......@@ -187,14 +193,22 @@ while [ $# -ne 0 ]; do
--enable-address-sanitizer)
append_cache_entry ENABLE_ADDRESS_SANITIZER BOOL true
;;
--enable-opencl)
append_cache_entry ENABLE_OPENCL BOOL true
;;
--with-opencl)
echo "*** WARNING: --with-opencl is deprecated"
append_cache_entry ENABLE_OPENCL BOOL true
;;
--no-memory-management)
append_cache_entry DISABLE_MEM_MANAGEMENT BOOL true
;;
--without-memory-management)
echo "*** WARNING: --without-memory-management is deprecated"
append_cache_entry DISABLE_MEM_MANAGEMENT BOOL true
;;
--standalone-build)
append_cache_entry STANDALONE_BUILD BOOL true
echo "*** WARNING: --standalone-build is deprecated"
;;
--more-clang-warnings)
append_cache_entry MORE_CLANG_WARNINGS BOOL true
......@@ -223,8 +237,11 @@ while [ $# -ne 0 ]; do
;;
esac
;;
--enable-context-switching)
append_cache_entry ENABLE_CONTEXT_SWITCHING BOOL true
;;
--disable-context-switching)
append_cache_entry DISABLE_CONTEXT_SWITCHING BOOL true
echo "*** WARNING: --disable-context-switching is deprecated"
;;
--with-boost=*)
append_cache_entry BOOST_ROOT PATH $optarg
......
......@@ -33,11 +33,8 @@
// Config pararameters defined by the build system (usually CMake):
//
// CPPA_STANDALONE_BUILD:
// - builds libcppa without Boost
//
// CPPA_DISABLE_CONTEXT_SWITCHING:
// - disables context switching even if Boost is available
// CPPA_ENABLE_CONTEXT_SWITCHING:
// - enables context switching (requires Boost)
//
// CPPA_DEBUG_MODE:
// - check requirements at runtime
......
......@@ -78,6 +78,7 @@
#ifdef __clang__
# pragma clang diagnostic ignored "-Wshorten-64-to-32"
# pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
# pragma clang diagnostic ignored "-Wunused-const-variable"
#endif // __clang__
using namespace cppa;
......
......@@ -29,7 +29,7 @@
#include "cppa/policy/context_switching_resume.hpp"
#ifndef CPPA_DISABLE_CONTEXT_SWITCHING
#ifdef CPPA_ENABLE_CONTEXT_SWITCHING
#include <iostream>
......@@ -67,7 +67,7 @@ void context_switching_resume::trampoline(void* this_ptr) {
} // namespace policy
} // namespace cppa
#else // ifdef CPPA_DISABLE_CONTEXT_SWITCHING
#else // ifdef CPPA_ENABLE_CONTEXT_SWITCHING
namespace cppa {
namespace policy {
......@@ -79,4 +79,4 @@ void context_switching_resume::trampoline(void*) {
} // namespace policy
} // namespace cppa
#endif // ifdef CPPA_DISABLE_CONTEXT_SWITCHING
#endif // ifdef CPPA_ENABLE_CONTEXT_SWITCHING
......@@ -40,18 +40,9 @@ namespace {
typedef void* vptr;
typedef void (*cst_fun)(vptr);
// Boost's coroutine minimal stack size is pretty small
// and easily causes stack overflows when using libcppa
// in debug mode or with logging
#if defined(CPPA_DEBUG_MODE) || defined(CPPA_LOG_LEVEL)
constexpr size_t stack_multiplier = 4;
#else
constexpr size_t stack_multiplier = 2;
#endif
} // namespace <anonmyous>
#if defined(CPPA_DISABLE_CONTEXT_SWITCHING) || defined(CPPA_STANDALONE_BUILD)
#ifndef CPPA_ENABLE_CONTEXT_SWITCHING
namespace cppa {
namespace detail {
......@@ -63,8 +54,8 @@ cs_thread::cs_thread(cst_fun, vptr) : m_impl(nullptr) { }
cs_thread::~cs_thread() { }
void cs_thread::swap(cs_thread&, cs_thread&) {
throw std::logic_error("libcppa was compiled using "
"CPPA_DISABLE_CONTEXT_SWITCHING");
throw std::logic_error("to enable context-switching, recompile libcppa "
"using CPPA_ENABLE_CONTEXT_SWITCHING");
}
const bool cs_thread::is_disabled_feature = true;
......@@ -72,8 +63,7 @@ const bool cs_thread::is_disabled_feature = true;
} // namespace util
} // namespace cppa
#else // CPPA_DISABLE_CONTEXT_SWITCHING || CPPA_STANDALONE_BUILD
#else // ifndef CPPA_ENABLE_CONTEXT_SWITCHING
// optional valgrind include
#ifdef CPPA_ANNOTATE_VALGRIND
......@@ -90,6 +80,15 @@ CPPA_POP_WARNINGS
namespace cppa {
namespace detail {
// Boost's coroutine minimal stack size is pretty small
// and easily causes stack overflows, especially when using
// libcppa's debug mode or logging
#if defined(CPPA_DEBUG_MODE) || defined(CPPA_LOG_LEVEL)
constexpr size_t stack_multiplier = 4;
#else
constexpr size_t stack_multiplier = 2;
#endif
void cst_trampoline(intptr_t iptr);
namespace {
......@@ -266,5 +265,4 @@ const bool cs_thread::is_disabled_feature = false;
} // namespace util
} // namespace cppa
#endif // CPPA_DISABLE_CONTEXT_SWITCHING
#endif // ifndef CPPA_ENABLE_CONTEXT_SWITCHING
......@@ -28,6 +28,8 @@
\******************************************************************************/
#include <iostream>
#include "cppa/config.hpp"
#include "cppa/util/get_root_uuid.hpp"
......@@ -39,12 +41,6 @@ constexpr char uuid_format[] = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF";
namespace {
inline void erase_trailing_newline(std::string& str) {
while (!str.empty() && (*str.rbegin()) == '\n') {
str.resize(str.size() - 1);
}
}
constexpr const char* s_get_uuid = "/usr/sbin/diskutil info / | "
"/usr/bin/awk '$0 ~ /UUID/ { print $3 }'";
......@@ -62,7 +58,19 @@ std::string get_root_uuid() {
uuid += cbuf;
}
pclose(get_uuid_cmd);
erase_trailing_newline(uuid);
// erase trailing newlines
while (!uuid.empty() && uuid.back() == '\n') uuid.pop_back();
// check whether uuid is valid
auto valid = uuid.size() == sizeof(uuid_format)
&& std::equal(uuid.begin(), uuid.end(), uuid_format,
[](char lhs, char rhs) {
return (rhs == 'F' && ::isxdigit(lhs))
|| (rhs == '-' && lhs == '-');
});
if (!valid) {
std::cerr << "*** WARNING: found invalid root UUID: "
<< uuid << std::endl;
}
return uuid;
}
......
......@@ -39,9 +39,9 @@ void coroutine [[noreturn]] (void* worker) {
int main() {
CPPA_TEST(test_yield_interface);
# ifdef CPPA_DISABLE_CONTEXT_SWITCHING
CPPA_PRINT("WARNING: context switching was explicitly "
"disabled by defining CPPA_DISABLE_CONTEXT_SWITCHING");
# ifndef CPPA_ENABLE_CONTEXT_SWITCHING
CPPA_PRINT("WARNING: context switching disabled by default, "
"enable by defining CPPA_ENABLE_CONTEXT_SWITCHING");
# else
cs_thread fself;
pseudo_worker worker;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment