Skip to content

Commit fc3dd98

Browse files
authored
Merge pull request ceph#63655 from tchaikov/wip-cmake-breakpad
cmake: enable out-of-source build of breakpad Reviewed-by: Marcel Lauhoff <[email protected]> Reviewed-by: Jesse F. Williamson <[email protected]>
2 parents b734edd + 0d89cd8 commit fc3dd98

File tree

10 files changed

+82
-60
lines changed

10 files changed

+82
-60
lines changed

src/CMakeLists.txt

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -327,46 +327,62 @@ endif(WITH_BLKIN)
327327

328328
## breakpad
329329
if(WITH_BREAKPAD)
330+
include(FindMake)
331+
find_make("MAKE_EXECUTABLE" "make_cmd")
332+
330333
set(breakpad_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/breakpad)
331334
set(lss_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/lss)
332335

333-
add_custom_target(breakpad_lss_symlink)
334-
add_custom_command(
335-
TARGET breakpad_lss_symlink
336-
PRE_BUILD
337-
COMMAND ${CMAKE_COMMAND} -E create_symlink ${lss_SOURCE_DIR} ${breakpad_SOURCE_DIR}/src/third_party/lss
338-
COMMENT "Creating symbolic link lss -> breakpad third party"
339-
)
340336
ExternalProject_Add(
341337
breakpad_project
342338
SOURCE_DIR "${breakpad_SOURCE_DIR}"
343-
CONFIGURE_COMMAND cd "${breakpad_SOURCE_DIR}"
344-
COMMAND "${breakpad_SOURCE_DIR}/configure"
345-
"CC=${CMAKE_C_COMPILER}"
346-
"CXX=${CMAKE_CXX_COMPILER}"
347-
"CFLAGS=${CMAKE_C_FLAGS} -fPIC -Wno-unknown-warning-option -Wno-array-bounds -Wno-maybe-uninitialized"
348-
"CXXFLAGS=${CMAKE_CXX_FLAGS} -fPIC -Wno-unknown-warning-option -Wno-ignored-qualifiers -Wno-array-bounds -Wno-maybe-uninitialized"
349-
"LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wno-unknown-warning-option -Wno-array-bounds -Wno-maybe-uninitialized"
350-
BUILD_COMMAND
351-
/bin/sh -cx "cd ${breakpad_SOURCE_DIR} && make"
352-
INSTALL_COMMAND ""
339+
PATCH_COMMAND ${CMAKE_COMMAND} -E create_symlink ${lss_SOURCE_DIR} ${breakpad_SOURCE_DIR}/src/third_party/lss
340+
# the minidump processor is used when processing the minidump, we only
341+
# use the breakpad's client for generating the minidump at this moment.
342+
#
343+
# also cancel the -Werror used by breakpad, as new compilers are more
344+
# picky, and might fail the build because of warnings.
345+
CONFIGURE_COMMAND ${breakpad_SOURCE_DIR}/configure --disable-processor --disable-tools --prefix=<INSTALL_DIR>
346+
"CC=${CMAKE_C_COMPILER}"
347+
"CFLAGS=${CMAKE_C_FLAGS} -fPIC"
348+
"CXX=${CMAKE_CXX_COMPILER}"
349+
"CXXFLAGS=${CMAKE_CXX_FLAGS} -fPIC -Wno-error"
350+
BUILD_COMMAND ${make_cmd}
351+
# Install this library to ensure headers are included with proper prefixed paths
352+
# (e.g., "breakpad/client/linux/handler/minidump_descriptor.h") rather than
353+
# unprefixed paths (e.g., "client/linux/handler/minidump_descriptor.h").
354+
# Prefixed paths make the library dependency explicit and avoid ambiguity.
355+
#
356+
# Note: DESTDIR is unset to prevent Debian packaging from overriding install
357+
# paths, which would break header/library discovery during build. This is safe
358+
# since breakpad artifacts are not redistributed in the final package.
359+
INSTALL_COMMAND ${CMAKE_COMMAND} -E env --unset=DESTDIR ${make_cmd} install
353360
UPDATE_DISCONNECTED ON
354-
BUILD_IN_SOURCE ON
355-
DEPENDS breakpad_lss_symlink
356-
BUILD_BYPRODUCTS "${breakpad_SOURCE_DIR}/src/libbreakpad.a;${breakpad_SOURCE_DIR}/src/client/linux/libbreakpad_client.a"
357-
)
358-
359-
add_library(libbreakpad STATIC IMPORTED GLOBAL)
360-
set_property(TARGET libbreakpad PROPERTY IMPORTED_LOCATION ${breakpad_SOURCE_DIR}/src/libbreakpad.a)
361-
add_library(libbreakpad_client STATIC IMPORTED GLOBAL)
362-
set_property(TARGET libbreakpad_client PROPERTY IMPORTED_LOCATION ${breakpad_SOURCE_DIR}/src/client/linux/libbreakpad_client.a)
361+
BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libbreakpad_client.a")
363362

364-
include_directories(SYSTEM "${breakpad_SOURCE_DIR}/src")
365-
add_dependencies(libbreakpad breakpad_project)
366-
add_dependencies(libbreakpad_client breakpad_project)
367-
368-
add_library(breakpad INTERFACE)
369-
target_link_libraries(breakpad INTERFACE libbreakpad libbreakpad_client)
363+
ExternalProject_Get_Property(breakpad_project INSTALL_DIR)
364+
# create the directory so cmake won't complain when looking at the imported
365+
# target
366+
file(MAKE_DIRECTORY ${INSTALL_DIR}/include/breakpad)
367+
368+
add_library(Breakpad::client STATIC IMPORTED GLOBAL)
369+
add_dependencies(Breakpad::client breakpad_project)
370+
set_target_properties(Breakpad::client PROPERTIES
371+
# unfortunately, breakpad's public headers use internal include paths
372+
# (e.g., "client/linux/..." rather than the installed include path
373+
# (e.g., "breakpad/client/linux/..."), because the library's source
374+
# structure differs between build time and install time. so we have to
375+
# add ${INSTALL_DIR}/include/breakpad as well.
376+
INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include;${INSTALL_DIR}/include/breakpad"
377+
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
378+
IMPORTED_LOCATION "${INSTALL_DIR}/lib/libbreakpad_client.a")
379+
380+
# for header-only library
381+
add_library(Breakpad::breakpad INTERFACE IMPORTED GLOBAL)
382+
add_dependencies(Breakpad::breakpad breakpad_project)
383+
set_target_properties(Breakpad::breakpad PROPERTIES
384+
INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include"
385+
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
370386
endif(WITH_BREAKPAD)
371387

372388
if(WITH_JAEGER)
@@ -525,11 +541,6 @@ if(WITH_JAEGER)
525541
target_link_libraries(common-objs jaeger_base)
526542
endif()
527543

528-
if(WITH_BREAKPAD)
529-
add_dependencies(common-objs breakpad_project)
530-
target_link_libraries(common-objs breakpad)
531-
endif()
532-
533544
CHECK_C_COMPILER_FLAG("-fvar-tracking-assignments" HAS_VTA)
534545
add_subdirectory(auth)
535546
add_subdirectory(common)
@@ -591,10 +602,6 @@ if(WITH_JAEGER)
591602
list(APPEND ceph_common_deps jaeger_base)
592603
endif()
593604

594-
if(WITH_BREAKPAD)
595-
list(APPEND ceph_common_deps breakpad)
596-
endif()
597-
598605
if(WIN32)
599606
list(APPEND ceph_common_deps ws2_32 mswsock iphlpapi bcrypt)
600607
list(APPEND ceph_common_deps dlfcn_win32)
@@ -623,6 +630,10 @@ if(WITH_BLUESTORE_PMEM OR WITH_RBD_RWL)
623630
endif()
624631
endif()
625632

633+
if(WITH_BREAKPAD)
634+
list(APPEND ceph_common_deps Breakpad::client)
635+
endif()
636+
626637
add_library(common STATIC ${ceph_common_objs})
627638
target_link_libraries(common
628639
${ceph_common_deps}
@@ -631,10 +642,6 @@ if(WITH_JAEGER)
631642
add_dependencies(common jaeger_base)
632643
endif()
633644

634-
if(WITH_BREAKPAD)
635-
add_dependencies(common breakpad_project)
636-
endif()
637-
638645
if (WIN32)
639646
# Statically building ceph-common on Windows fails. We're temporarily
640647
# reverting this: 22fefb2338cfc4fcb03ece3cbf77aa964a7f17f2

src/common/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ target_compile_definitions(common-common-objs PRIVATE
196196
"CEPH_INSTALL_FULL_PKGLIBDIR=\"${CEPH_INSTALL_FULL_PKGLIBDIR}\""
197197
"CEPH_INSTALL_DATADIR=\"${CEPH_INSTALL_DATADIR}\""
198198
$<TARGET_PROPERTY:${FMT_LIB},INTERFACE_COMPILE_DEFINITIONS>)
199-
target_link_libraries(common-common-objs legacy-option-headers)
199+
target_link_libraries(common-common-objs PUBLIC legacy-option-headers)
200+
if(WITH_BREAKPAD)
201+
target_link_libraries(common-common-objs PUBLIC
202+
Breakpad::client)
203+
endif()
200204

201205
set(common_mountcephfs_srcs
202206
armor.c

src/common/ceph_context.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222

2323
#include <boost/algorithm/string.hpp>
2424

25+
#ifdef HAVE_BREAKPAD
26+
#include <breakpad/client/linux/handler/exception_handler.h>
27+
#endif
28+
2529
#include "include/common_fwd.h"
2630
#include "include/mempool.h"
2731
#include "include/stringify.h"

src/common/ceph_context.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
#include "common/cmdparse.h"
3535
#include "common/code_environment.h"
3636
#include "msg/msg_types.h"
37-
#ifdef HAVE_BREAKPAD
38-
#include "breakpad/src/client/linux/handler/exception_handler.h"
39-
#endif
4037
#ifdef WITH_CRIMSON
4138
#include "crimson/common/config_proxy.h"
4239
#include "crimson/common/perf_counters_collection.h"
@@ -49,6 +46,12 @@
4946

5047
#include "crush/CrushLocation.h"
5148

49+
#ifdef HAVE_BREAKPAD
50+
namespace google_breakpad {
51+
class ExceptionHandler;
52+
}
53+
#endif
54+
5255
class AdminSocket;
5356
class AdminSocketHook;
5457
class CryptoHandler;

src/crimson/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ if(WITH_JAEGER)
138138
endif()
139139

140140
if(WITH_BREAKPAD)
141-
list(APPEND crimson_common_public_deps breakpad)
141+
list(APPEND crimson_common_deps Breakpad::client)
142142
endif()
143143

144144
if(NOT WITH_SYSTEM_BOOST)

src/crimson/os/alienstore/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ if(WITH_CEPH_DEBUG_MUTEX)
3232
endif()
3333
add_library(crimson-alien-common STATIC
3434
${crimson_alien_common_srcs})
35+
if(WITH_BREAKPAD)
36+
target_link_libraries(crimson-alien-common Breakpad::client)
37+
endif()
3538

3639
add_library(alien::cflags INTERFACE IMPORTED)
3740
set_target_properties(alien::cflags PROPERTIES

src/global/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ endif()
99

1010
add_library(libglobal_objs OBJECT ${libglobal_srcs})
1111
target_link_libraries(libglobal_objs legacy-option-headers)
12+
if(WITH_BREAKPAD)
13+
target_link_libraries(libglobal_objs
14+
Breakpad::client)
15+
endif()
1216

1317
add_library(global-static STATIC
1418
$<TARGET_OBJECTS:libglobal_objs>)

src/global/global_init.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
#include <filesystem>
1616
#include <memory>
17+
#include "acconfig.h"
18+
#ifdef HAVE_BREAKPAD
19+
#include <breakpad/client/linux/handler/exception_handler.h>
20+
#include <breakpad/client/linux/handler/minidump_descriptor.h>
21+
#include <breakpad/google_breakpad/common/minidump_format.h>
22+
#endif
1723
#include "common/async/context_pool.h"
1824
#include "common/ceph_argparse.h"
1925
#include "common/code_environment.h"
@@ -26,10 +32,6 @@
2632
#include "extblkdev/ExtBlkDevPlugin.h"
2733
#include "global/global_context.h"
2834
#include "global/global_init.h"
29-
#ifdef HAVE_BREAKPAD
30-
#include <client/linux/handler/minidump_descriptor.h>
31-
#include <google_breakpad/common/minidump_format.h>
32-
#endif
3335
#include "global/pidfile.h"
3436
#include "global/signal_handler.h"
3537
#include "include/compat.h"

src/rgw/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,6 @@ if(WITH_JAEGER)
365365
target_link_libraries(rgw_common PUBLIC jaeger_base)
366366
endif()
367367

368-
if(WITH_BREAKPAD)
369-
add_dependencies(rgw_common breakpad_project)
370-
target_link_libraries(rgw_common PUBLIC breakpad)
371-
endif()
372-
373368
if(WITH_RADOSGW_DBSTORE)
374369
target_link_libraries(rgw_common PRIVATE global dbstore)
375370
endif()

src/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ if(WITH_BREAKPAD)
10321032
add_executable(unittest_ceph_breakpad
10331033
ceph_breakpad.cc)
10341034
add_ceph_unittest(unittest_ceph_breakpad)
1035-
target_link_libraries(unittest_ceph_breakpad ceph-common global)
1035+
target_link_libraries(unittest_ceph_breakpad ceph-common global Breakpad::breakpad)
10361036
endif()
10371037

10381038
if(NOT WIN32)

0 commit comments

Comments
 (0)