Skip to content

Commit

Permalink
Allow mixing debug and release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
msimberg committed Feb 10, 2021
1 parent 4906627 commit 5f3ef5f
Show file tree
Hide file tree
Showing 20 changed files with 159 additions and 200 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/windows_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,33 @@ jobs:
run: |
cmake --build build --config Debug \
--target ALL_BUILD \
cmake_build_dir_targets_test.make_compile \
cmake_build_dir_macros_test.make_compile \
cmake_debug_build_dir_targets_test \
cmake_minsizerel_build_dir_targets_test \
cmake_release_build_dir_targets_test \
cmake_relwithdebinfo_build_dir_targets_test \
cmake_debug_build_dir_macros_test \
cmake_minsizerel_build_dir_macros_test \
cmake_release_build_dir_macros_test \
cmake_relwithdebinfo_build_dir_macros_test \
-- -maxcpucount -verbosity:minimal -nologo
- name: Install
shell: bash
run: |
cmake --install build
- name: Build External
shell: bash
run: |
cmake --build build --config Release \
--target \
cmake_debug_install_dir_targets_test \
cmake_minsizerel_install_dir_targets_test \
cmake_release_install_dir_targets_test \
cmake_relwithdebinfo_install_dir_targets_test \
cmake_debug_install_dir_macros_test \
cmake_minsizerel_install_dir_macros_test \
cmake_release_install_dir_macros_test \
cmake_relwithdebinfo_install_dir_macros_test \
-- -maxcpucount -verbosity:minimal -nologo
- name: Test
shell: bash
run: |
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/windows_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ jobs:
run: |
cmake --build build --config Release \
--target ALL_BUILD \
cmake_build_dir_targets_test.make_compile \
cmake_build_dir_macros_test.make_compile \
cmake_debug_build_dir_targets_test \
cmake_minsizerel_build_dir_targets_test \
cmake_release_build_dir_targets_test \
cmake_relwithdebinfo_build_dir_targets_test \
cmake_debug_build_dir_macros_test \
cmake_minsizerel_build_dir_macros_test \
cmake_release_build_dir_macros_test \
cmake_relwithdebinfo_build_dir_macros_test \
-- -maxcpucount -verbosity:minimal -nologo
- name: Install
shell: bash
Expand All @@ -40,8 +46,15 @@ jobs:
shell: bash
run: |
cmake --build build --config Release \
--target cmake_install_dir_targets_test.make_compile \
cmake_install_dir_macros_test.make_compile \
--target \
cmake_debug_install_dir_targets_test \
cmake_minsizerel_install_dir_targets_test \
cmake_release_install_dir_targets_test \
cmake_relwithdebinfo_install_dir_targets_test \
cmake_debug_install_dir_macros_test \
cmake_minsizerel_install_dir_macros_test \
cmake_release_install_dir_macros_test \
cmake_relwithdebinfo_install_dir_macros_test \
-- -maxcpucount -verbosity:minimal -nologo
- name: Test
shell: bash
Expand Down
19 changes: 1 addition & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1720,23 +1720,6 @@ hpx_option(
ADVANCED
)

# ##############################################################################
# Add necessary compiler flags. Flags added here include flags to disable/enable
# certain warnings, enabling C++11 mode and disabling asserts. Setting of
# optimization flags is not handled here and is left to the responsibility of
# the user to avoid conflicts in the resulting binaries

hpx_add_target_compile_definition(_DEBUG PUBLIC CONFIGURATIONS Debug)
hpx_add_target_compile_definition(DEBUG PUBLIC CONFIGURATIONS Debug)
hpx_add_target_compile_definition(
HPX_DISABLE_ASSERTS PUBLIC CONFIGURATIONS Release RelWithDebInfo
MinSizeRelease
)
hpx_add_target_compile_definition(
BOOST_DISABLE_ASSERTS PUBLIC CONFIGURATIONS Release RelWithDebInfo
MinSizeRelease
)

# ##############################################################################
# C++ feature tests
# ##############################################################################
Expand Down Expand Up @@ -1843,7 +1826,7 @@ if(WIN32)
# non-referenced functions and data (-Zc:inline)
hpx_add_target_compile_option(-Zc:inline PUBLIC)
hpx_add_target_compile_option(
-Gw PUBLIC CONFIGURATIONS Release RelWithDebInfo MinSizeRelease
-Gw PUBLIC CONFIGURATIONS Release RelWithDebInfo MinSizeRel
)
hpx_add_target_compile_option(-Zo PUBLIC CONFIGURATIONS RelWithDebInfo)
if(HPX_WITH_DATAPAR_VC)
Expand Down
4 changes: 1 addition & 3 deletions cmake/HPX_AddModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ function(add_hpx_module libname modulename)
endif()

target_compile_definitions(
hpx_${modulename}
PRIVATE $<$<CONFIG:Debug>:DEBUG> $<$<CONFIG:Debug>:_DEBUG>
HPX_${libname_upper}_EXPORTS
hpx_${modulename} PRIVATE HPX_${libname_upper}_EXPORTS
)

# This is a temporary solution until all of HPX has been modularized as it
Expand Down
7 changes: 7 additions & 0 deletions cmake/HPX_CompilerFlagsTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ target_compile_definitions(
hpx_public_flags INTERFACE $<$<CONFIG:Debug>:HPX_DEBUG>
)

target_compile_definitions(
hpx_private_flags
INTERFACE $<$<CONFIG:MinSizeRel>:NDEBUG>
INTERFACE $<$<CONFIG:Release>:NDEBUG>
INTERFACE $<$<CONFIG:RelWithDebInfo>:NDEBUG>
)

# Remaining flags are set through the macros in cmake/HPX_AddCompileFlag.cmake

include(HPX_ExportTargets)
Expand Down
1 change: 0 additions & 1 deletion cmake/templates/HPXConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ if(NOT HPX_CMAKE_LOGLEVEL)
set(HPX_CMAKE_LOGLEVEL "WARN")
endif()

hpx_check_cmake_build_type()
hpx_check_compiler_compatibility()
hpx_check_boost_compatibility()
hpx_check_allocator_compatibility()
Expand Down
22 changes: 0 additions & 22 deletions cmake/templates/HPXMacros.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,3 @@ function(hpx_check_allocator_compatibility)
"informational purposes to dependent projects and should not be changed.")
endif()
endfunction()

# Check we are using the same build type as HPX
function(hpx_check_cmake_build_type)
get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (NOT _GENERATOR_IS_MULTI_CONFIG AND
NOT "${HPX_BUILD_TYPE}" STREQUAL "${CMAKE_BUILD_TYPE}" AND
("${HPX_BUILD_TYPE}" STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" STREQUAL "Debug"))
if(HPX_IGNORE_CMAKE_BUILD_TYPE_COMPATIBILITY)
hpx_warn("CMAKE_BUILD_TYPE does not match ${HPX_BUILD_TYPE}: "
"this project uses '${CMAKE_BUILD_TYPE}', HPX uses '${HPX_BUILD_TYPE}'. "
"HPX is not ABI compatible between release and debug modes and it is "
"recommended that you use the same build type for HPX and your project.")
else()
hpx_error("CMAKE_BUILD_TYPE does not match ${HPX_BUILD_TYPE}: "
"this project uses '${CMAKE_BUILD_TYPE}', HPX uses '${HPX_BUILD_TYPE}'. "
"Please add -DCMAKE_BUILD_TYPE=${HPX_BUILD_TYPE} to your cmake command "
"or add -DHPX_IGNORE_CMAKE_BUILD_TYPE_COMPATIBILITY=ON to ignore this "
"check (not recommended; HPX is not ABI compatible between release and "
"debug modes).")
endif()
endif()
endfunction()
4 changes: 0 additions & 4 deletions examples/hello_world_component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ if(EXISTS "${HPX_DIR}")

add_executable(hello_world_client hello_world_client.cpp)
target_include_directories(hello_world_client PRIVATE ${test_SOURCE_DIR})
target_include_directories(hello_world_client PRIVATE HPX_DEBUG)

if("${SETUP_TYPE}" STREQUAL "TARGETS")
target_link_libraries(
Expand All @@ -36,9 +35,6 @@ if(EXISTS "${HPX_DIR}")
target_include_directories(
hello_world_client_only_hpx_init PRIVATE ${test_SOURCE_DIR}
)
target_include_directories(
hello_world_client_only_hpx_init PRIVATE HPX_DEBUG
)

target_link_libraries(
hello_world_client_only_hpx_init PRIVATE hello_world_component
Expand Down
9 changes: 0 additions & 9 deletions hpx/runtime/components/server/component_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ namespace hpx { namespace components
HPX_EXPORT naming::id_type get_unmanaged_id(
naming::gid_type const& gid) const;

#if defined(HPX_DISABLE_ASSERTS) || defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG)
static constexpr void mark_as_migrated()
{
}
static constexpr void on_migrated()
{
}
#else
static void mark_as_migrated()
{
// If this assertion is triggered then this component instance is
Expand All @@ -100,7 +92,6 @@ namespace hpx { namespace components
// migration.
HPX_ASSERT(false);
}
#endif

protected:
// Create a new GID (if called for the first time), assign this
Expand Down
33 changes: 0 additions & 33 deletions hpx/runtime/components/server/fixed_component_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,6 @@ class fixed_component_base : public traits::detail::fixed_component_tag
}
}

#if defined(HPX_DISABLE_ASSERTS) || defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG)
static constexpr void mark_as_migrated()
{
}
static constexpr void on_migrated()
{
}
#else
void mark_as_migrated()
{
// If this assertion is triggered then this component instance is being
Expand All @@ -179,7 +171,6 @@ class fixed_component_base : public traits::detail::fixed_component_tag
// migration.
HPX_ASSERT(false);
}
#endif

private:
mutable naming::gid_type gid_;
Expand All @@ -192,15 +183,6 @@ namespace detail
///////////////////////////////////////////////////////////////////////
struct fixed_heap
{
#if defined(HPX_DISABLE_ASSERTS) || defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG)
static constexpr void* alloc(std::size_t /*count*/)
{
return nullptr;
}
static constexpr void free(void* /*p*/, std::size_t /*count*/)
{
}
#else
static void* alloc(std::size_t /*count*/)
{
HPX_ASSERT(false); // this shouldn't ever be called
Expand All @@ -210,7 +192,6 @@ namespace detail
{
HPX_ASSERT(false); // this shouldn't ever be called
}
#endif
};
}

Expand All @@ -224,17 +205,6 @@ class fixed_component : public Component
typedef component_type derived_type;
typedef detail::fixed_heap heap_type;

#if defined(HPX_DISABLE_ASSERTS) || defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG)
static constexpr Component* create(std::size_t /* count */)
{
return nullptr;
}

static constexpr void destroy(
Component* /* p */, std::size_t /* count */ = 1)
{
}
#else
/// \brief The function \a create is used for allocation and
/// initialization of instances of the derived components.
static Component* create(std::size_t /* count */)
Expand All @@ -249,9 +219,6 @@ class fixed_component : public Component
{
HPX_ASSERT(false); // this shouldn't ever be called
}
#endif
};

}}


9 changes: 0 additions & 9 deletions hpx/runtime/components/server/managed_component_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,6 @@ namespace hpx { namespace components
/// destructed
static constexpr void finalize() {}

#if defined(HPX_DISABLE_ASSERTS) || defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG)
static constexpr void mark_as_migrated()
{
}
static constexpr void on_migrated()
{
}
#else
static void mark_as_migrated()
{
// If this assertion is triggered then this component instance is
Expand All @@ -194,7 +186,6 @@ namespace hpx { namespace components
// migration.
HPX_ASSERT(false);
}
#endif
};
}

Expand Down
15 changes: 2 additions & 13 deletions libs/core/config/include/hpx/config/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,9 @@
#define HPX_BUILD_TYPE
#else

// clang-format off
// Make sure DEBUG macro is defined consistently across platforms
#if defined(_DEBUG) && !defined(DEBUG)
# define DEBUG
#endif

#if defined(DEBUG) && !defined(HPX_DEBUG)
# define HPX_DEBUG
#endif

#if defined(HPX_DEBUG)
# define HPX_BUILD_TYPE debug
#define HPX_BUILD_TYPE debug
#else
# define HPX_BUILD_TYPE release
#define HPX_BUILD_TYPE release
#endif
#endif
// clang-format on
33 changes: 11 additions & 22 deletions libs/core/functional/include/hpx/functional/one_shot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ namespace hpx { namespace util {
class one_shot_wrapper //-V690
{
public:
#if !defined(HPX_DISABLE_ASSERTS)
// default constructor is needed for serialization
constexpr one_shot_wrapper()
#if defined(HPX_DEBUG)
: _called(false)
#endif
{
}

Expand All @@ -37,42 +38,30 @@ namespace hpx { namespace util {
std::is_constructible<F, F_>::value>::type>
constexpr explicit one_shot_wrapper(F_&& f)
: _f(std::forward<F_>(f))
#if defined(HPX_DEBUG)
, _called(false)
#endif
{
}

constexpr one_shot_wrapper(one_shot_wrapper&& other)
: _f(std::move(other._f))
#if defined(HPX_DEBUG)
, _called(other._called)
#endif
{
#if defined(HPX_DEBUG)
other._called = true;
#endif
}

void check_call()
{
#if defined(HPX_DEBUG)
HPX_ASSERT(!_called);

_called = true;
}
#else
// default constructor is needed for serialization
constexpr one_shot_wrapper() {}

template <typename F_,
typename = typename std::enable_if<
std::is_constructible<F, F_>::value>::type>
constexpr explicit one_shot_wrapper(F_&& f)
: _f(std::forward<F_>(f))
{
}

constexpr one_shot_wrapper(one_shot_wrapper&& other)
: _f(std::move(other._f))
{
}

void check_call() {}
#endif
}

template <typename... Ts>
constexpr HPX_HOST_DEVICE
Expand Down Expand Up @@ -118,7 +107,7 @@ namespace hpx { namespace util {

public: // exposition-only
F _f;
#if !defined(HPX_DISABLE_ASSERTS)
#if defined(HPX_DEBUG)
bool _called;
#endif
};
Expand Down
Loading

0 comments on commit 5f3ef5f

Please sign in to comment.