Skip to content

Commit

Permalink
Merge pull request #653 from pyrtsa/osx-clang
Browse files Browse the repository at this point in the history
Make HPX build on OS X + Clang + libc++
  • Loading branch information
hkaiser committed Jan 4, 2013
2 parents c94fd33 + 70ba913 commit 7544eac
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 52 deletions.
23 changes: 20 additions & 3 deletions CMakeLists.txt
Expand Up @@ -129,7 +129,11 @@ endif()

# Decide whether to use Boost.Context for coroutine implementation
if(${BOOST_MINOR_VERSION} GREATER 50)
hpx_option(HPX_USE_GENERIC_COROUTINE_CONTEXT BOOL "Use Boost.Context as the underlying coroutines context switch implementation (default: OFF)." OFF ADVANCED)
if (APPLE)
hpx_option(HPX_USE_GENERIC_COROUTINE_CONTEXT BOOL "Use Boost.Context as the underlying coroutines context switch implementation (default: ON)." ON ADVANCED)
else()
hpx_option(HPX_USE_GENERIC_COROUTINE_CONTEXT BOOL "Use Boost.Context as the underlying coroutines context switch implementation (default: OFF)." OFF ADVANCED)
endif()
endif()

################################################################################
Expand Down Expand Up @@ -458,7 +462,11 @@ endif()
################################################################################
# Native TLS configuration
################################################################################
hpx_option(HPX_HAVE_NATIVE_TLS BOOL "Use native TLS support if available (default: ON)" ON ADVANCED)
if(APPLE)
hpx_option(HPX_HAVE_NATIVE_TLS BOOL "Use native TLS support if available (default: OFF)" OFF ADVANCED)
else()
hpx_option(HPX_HAVE_NATIVE_TLS BOOL "Use native TLS support if available (default: ON)" ON ADVANCED)
endif()

if(HPX_HAVE_NATIVE_TLS)
hpx_info("tls" "Native TLS is enabled.")
Expand Down Expand Up @@ -774,6 +782,11 @@ else()
hpx_use_flag_if_available(-fPIC LANGUAGES CXX C Fortran)
endif()

if(APPLE)
hpx_use_flag_if_available(-stdlib=libc++ LANGUAGES CXX)
hpx_use_flag_if_available(-ftemplate-depth=256 LANGUAGES CXX)
endif()

##############################################################################
# C++11
##############################################################################
Expand Down Expand Up @@ -971,7 +984,11 @@ else()
##############################################################################
# System libraries
##############################################################################
set(hpx_RUNTIME_LIBRARIES ${hpx_RUNTIME_LIBRARIES} dl rt)
set(hpx_RUNTIME_LIBRARIES ${hpx_RUNTIME_LIBRARIES} dl)

if(NOT APPLE)
set(hpx_RUNTIME_LIBRARIES ${hpx_RUNTIME_LIBRARIES} rt)
endif()

hpx_check_for_pthread_affinity_np(HPX_PTHREAD_AFFINITY_NP
DEFINITIONS HPX_HAVE_PTHREAD_AFFINITY_NP)
Expand Down
5 changes: 4 additions & 1 deletion cmake/HPX_AddConfigTest.cmake
Expand Up @@ -50,7 +50,10 @@ macro(add_hpx_config_test name variable)
OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/config_tests/${name}
FLAGS ${${name}_FLAGS})

if("${${name}_RESULT}" STREQUAL "0")
if(NOT "${${name}_HAS_UNUSED_ARGUMENT_WARNING}" STREQUAL "")
set(${variable} OFF CACHE STRING "${name} state.")
hpx_warn("config_test.${name}" "Test failed to compile without unused argument warnings with the ${${name}_LANGUAGE} compiler.")
elseif("${${name}_RESULT}" STREQUAL "0")
set(test_result 0)

execute_process(
Expand Down
24 changes: 13 additions & 11 deletions cmake/HPX_Compile.cmake
Expand Up @@ -59,8 +59,8 @@ macro(hpx_compile name)

if(${name}_QUIET)
hpx_debug("compile" "${CMAKE_${${name}_LANGUAGE}_COMPILER}"
"${${name}_FLAGS} ${${name}_SOURCE}"
${outflag} "${${name}_${${name}_LANGUAGE}_COMPILEROUTNAME}")
" ${${name}_FLAGS} ${${name}_SOURCE} "
" ${outflag} ${${name}_${${name}_LANGUAGE}_COMPILEROUTNAME}")
execute_process(
COMMAND "${CMAKE_${${name}_LANGUAGE}_COMPILER}" ${${name}_FLAGS}
"${${name}_SOURCE}"
Expand All @@ -69,8 +69,8 @@ macro(hpx_compile name)
message(${${name}_ERROR_OUTPUT})
else()
hpx_debug("compile" "${CMAKE_${${name}_LANGUAGE}_COMPILER}"
"${${name}_FLAGS} ${${name}_SOURCE}"
${outflag} "${${name}_${${name}_LANGUAGE}_COMPILEROUTNAME}")
" ${${name}_FLAGS} ${${name}_SOURCE}"
" ${outflag} ${${name}_${${name}_LANGUAGE}_COMPILEROUTNAME}")
execute_process(
COMMAND "${CMAKE_${${name}_LANGUAGE}_COMPILER}" ${${name}_FLAGS}
"${${name}_SOURCE}"
Expand All @@ -82,16 +82,18 @@ macro(hpx_compile name)
ERROR_STRIP_TRAILING_WHITESPACE
)
if(${name}_STDERR)
if("${CMAKE_${${name}_LANGUAGE}_COMPILER_ID}" STREQUAL "Intel")
string(REGEX MATCH ".*command line warning #.*" ${name}_HAS_COMMAND_LINE_WARNING ${${name}_STDERR})
if(${name}_HAS_COMMAND_LINE_WARNING)
set(${name}_RESULT "1")
endif()
if("${CMAKE_${${name}_LANGUAGE}_COMPILER_ID}" STREQUAL "Intel")
string(REGEX MATCH ".*command line warning #.*" ${name}_HAS_COMMAND_LINE_WARNING ${${name}_STDERR})
if(${name}_HAS_COMMAND_LINE_WARNING)
set(${name}_RESULT "1")
endif()
file(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.${${name}_LANGUAGE}.stderr ${${name}_STDERR})
elseif("${CMAKE_${${name}_LANGUAGE}_COMPILER_ID}" STREQUAL "Clang")
string(REGEX MATCH ".*(argument unused during compilation|unknown warning option).*" ${name}_HAS_UNUSED_ARGUMENT_WARNING ${${name}_STDERR})
endif()
file(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.${${name}_LANGUAGE}.stderr ${${name}_STDERR})
endif()
if(${name}_STDOUT)
file(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.${${name}_LANGUAGE}.stdout ${${name}_STDOUT})
file(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.${${name}_LANGUAGE}.stdout ${${name}_STDOUT})
endif()
endif()
endmacro()
Expand Down
1 change: 1 addition & 0 deletions external/logging/boost/logging/detail/ts/ts_none.hpp
Expand Up @@ -31,6 +31,7 @@ namespace threading {

struct no_lock {
no_lock(no_mutex &) {}
~no_lock() {}
};

struct no_mutex {
Expand Down
4 changes: 2 additions & 2 deletions external/plugin/boost/plugin/detail/dll_dlopen.hpp
Expand Up @@ -24,7 +24,7 @@

#include <boost/plugin/config.hpp>

#if !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
#include <link.h>
#endif
#include <dlfcn.h>
Expand Down Expand Up @@ -257,7 +257,7 @@ namespace boost { namespace plugin {
}

public:
#if !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
std::string get_directory() const
{
// now find the full path of the loaded library
Expand Down
3 changes: 3 additions & 0 deletions hpx/hpx_fwd.hpp
Expand Up @@ -9,6 +9,9 @@
#if !defined(HPX_HPX_FWD_MAR_24_2008_1119AM)
#define HPX_HPX_FWD_MAR_24_2008_1119AM

// FIXME: Make HPX work with the "decltype" result_of, and remove this #define!
#define BOOST_RESULT_OF_USE_TR1

#include <cstdlib>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion hpx/lcos/local/shared_mutex.hpp
Expand Up @@ -207,7 +207,7 @@ namespace hpx { namespace lcos { namespace local
release_waiters();
}

void try_unlock_shared_and_lock()
bool try_unlock_shared_and_lock()
{
typename mutex_type::scoped_lock lk(state_change);
if( !state.exclusive
Expand Down
4 changes: 2 additions & 2 deletions hpx/lcos/preprocessed/wait_any_5.hpp
Expand Up @@ -19,9 +19,9 @@ namespace hpx
typedef boost::fusion::tuple<
lcos::future<T>
> argument_type;
lcos::local::futures_factory<return_type()> p(
lcos::local::futures_factory<return_type()> p((
detail::when_any_tuple<argument_type, T>(
argument_type(f0)));
argument_type(f0))));
p.apply();
return p.get_future();
}
Expand Down
4 changes: 2 additions & 2 deletions hpx/lcos/wait_any.hpp
Expand Up @@ -468,9 +468,9 @@ namespace hpx
BOOST_PP_ENUM(N, HPX_WHEN_ANY_FUTURE_TYPE, _)
> argument_type;

lcos::local::futures_factory<return_type()> p(
lcos::local::futures_factory<return_type()> p((
detail::when_any_tuple<argument_type, T>(
argument_type(BOOST_PP_ENUM(N, HPX_WHEN_ANY_FUTURE_VAR, _))));
argument_type(BOOST_PP_ENUM(N, HPX_WHEN_ANY_FUTURE_VAR, _)))));

p.apply();
return p.get_future();
Expand Down
2 changes: 1 addition & 1 deletion hpx/runtime/actions/action_support.hpp
Expand Up @@ -575,7 +575,7 @@ namespace hpx { namespace actions
>::type
get(transfer_action<Action> & args)
{
return args.get<N>();
return args.template get<N>();
}

#include <hpx/runtime/actions/construct_continuation_function_objects.hpp>
Expand Down
16 changes: 8 additions & 8 deletions hpx/util/thread_specific_ptr.hpp
Expand Up @@ -10,6 +10,14 @@

#include <boost/config.hpp>

#include <hpx/config/export_definitions.hpp>

#if !defined(BOOST_WINDOWS)
# define HPX_EXPORT_THREAD_SPECIFIC_PTR HPX_EXPORT
#else
# define HPX_EXPORT_THREAD_SPECIFIC_PTR
#endif

// native implementation
#if defined(HPX_HAVE_NATIVE_TLS)

Expand All @@ -25,14 +33,6 @@

#include <boost/assert.hpp>

#include <hpx/config/export_definitions.hpp>

#if !defined(BOOST_WINDOWS)
# define HPX_EXPORT_THREAD_SPECIFIC_PTR HPX_EXPORT
#else
# define HPX_EXPORT_THREAD_SPECIFIC_PTR
#endif

namespace hpx { namespace util
{

Expand Down
3 changes: 3 additions & 0 deletions hpx/version.hpp
Expand Up @@ -120,6 +120,8 @@ namespace hpx
// library, forcing to resolve the variable HPX_CHECK_VERSION.
namespace
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
// Note: this function is never executed.
char const* check_hpx_version()
{
Expand All @@ -128,6 +130,7 @@ namespace hpx
};
return versions[0];
}
#pragma clang diagnostic pop
}
#endif

Expand Down
59 changes: 43 additions & 16 deletions src/exception.cpp
Expand Up @@ -29,6 +29,13 @@
#include <stdexcept>
#include <algorithm>

#ifdef __APPLE__
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
#elif !defined(BOOST_WINDOWS)
extern char **environ;
#endif

namespace hpx { namespace detail
{
///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -171,41 +178,61 @@ namespace hpx { namespace detail
}

///////////////////////////////////////////////////////////////////////////
template HPX_EXPORT void throw_exception(hpx::exception const&,
template HPX_EXPORT boost::exception_ptr
get_exception(hpx::exception const&, std::string const&,
std::string const&, long);

template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(hpx::exception const&,
std::string const&, std::string const&, long);

template HPX_EXPORT void throw_exception(boost::system::system_error const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(boost::system::system_error const&,
std::string const&, std::string const&, long);

template HPX_EXPORT void throw_exception(std::exception const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(std::exception const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(hpx::detail::std_exception const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(hpx::detail::std_exception const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(std::bad_exception const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(std::bad_exception const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(hpx::detail::bad_exception const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(hpx::detail::bad_exception const&,
std::string const&, std::string const&, long);
#ifndef BOOST_NO_TYPEID
template HPX_EXPORT void throw_exception(std::bad_typeid const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(std::bad_typeid const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(hpx::detail::bad_typeid const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(hpx::detail::bad_typeid const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(std::bad_cast const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(std::bad_cast const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(hpx::detail::bad_cast const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(hpx::detail::bad_cast const&,
std::string const&, std::string const&, long);
#endif
template HPX_EXPORT void throw_exception(std::bad_alloc const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(std::bad_alloc const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(hpx::detail::bad_alloc const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(hpx::detail::bad_alloc const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(std::logic_error const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(std::logic_error const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(std::runtime_error const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(std::runtime_error const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(std::out_of_range const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(std::out_of_range const&,
std::string const&, std::string const&, long);
template HPX_EXPORT void throw_exception(std::invalid_argument const&,
template BOOST_ATTRIBUTE_NORETURN HPX_EXPORT void
throw_exception(std::invalid_argument const&,
std::string const&, std::string const&, long);

///////////////////////////////////////////////////////////////////////////
Expand Down
9 changes: 4 additions & 5 deletions src/util/find_prefix.cpp
Expand Up @@ -28,7 +28,7 @@ namespace hpx { namespace util
std::string library
)
{
#if !defined(__ANDROID__) && !defined(ANDROID)
#if !defined(__ANDROID__) && !defined(ANDROID) && !defined(__APPLE__)
try {
boost::plugin::dll dll(HPX_MAKE_DLL_STRING(library));

Expand Down Expand Up @@ -87,18 +87,17 @@ namespace hpx { namespace util
r = exe_path;

#elif defined(__APPLE__)
char exe_path[MAXPATHLEN + 1];
boost::uint32_t buf_length
char exe_path[PATH_MAX + 1];
boost::uint32_t len = sizeof(exe_path) / sizeof(exe_path[0]);

int length = _NSGetExecutablePath(exe_path, &len);
if (0 != _NSGetExecutablePath(exe_path, &len))
{
HPX_THROW_EXCEPTION(hpx::dynamic_link_failure,
"get_executable_filename",
"unable to find executable filename");
}

exe_path[length] = '\0';
exe_path[len] = '\0';
r = exe_path;

#else
Expand Down

0 comments on commit 7544eac

Please sign in to comment.