Generating shared/dynamic libs from Crashpad instead of static

181 views
Skip to first unread message

Matthew Spelman

unread,
Jul 15, 2022, 10:07:31 AM7/15/22
to Crashpad-dev
Is there a way to have Crashpad generate .so/.dylib/.dll versions of its library files instead of the static .a/.lib? I looked at https://stackoverflow.com/questions/55302553/how-to-build-dynamic-shared-libraries-of-crashpad and https://stackoverflow.com/questions/57486462/how-do-i-build-google-crashpad-into-shared-dynamic-libraries but those only seem to talk about Windows with the /MD flag, and I need to do this on Linux and Mac, as well. Ideally, there would be a way to pass this to GN via the --args flag, since I am calling both GN and Ninja programmatically when I build Crashpad. I tried --args="extra_cflags=\"-shared\"" and --args="extra_cflags=\"-dynamiclib\"" but that didn't seem to work.

Joshua Peraza

unread,
Jul 15, 2022, 2:11:39 PM7/15/22
to Matthew Spelman, Crashpad-dev
This line of the BUILD file makes it a static library. Change to `crashpad_loadable_module` to make a shared library. https://source.chromium.org/chromium/chromium/src/+/main:third_party/crashpad/crashpad/client/BUILD.gn;drc=761ff9773d30f6f82382516b47e9f3af2a5e216c;l=17

On Fri, Jul 15, 2022 at 7:07 AM Matthew Spelman <mjs...@gmail.com> wrote:
Is there a way to have Crashpad generate .so/.dylib/.dll versions of its library files instead of the static .a/.lib? I looked at https://stackoverflow.com/questions/55302553/how-to-build-dynamic-shared-libraries-of-crashpad and https://stackoverflow.com/questions/57486462/how-do-i-build-google-crashpad-into-shared-dynamic-libraries but those only seem to talk about Windows with the /MD flag, and I need to do this on Linux and Mac, as well. Ideally, there would be a way to pass this to GN via the --args flag, since I am calling both GN and Ninja programmatically when I build Crashpad. I tried --args="extra_cflags=\"-shared\"" and --args="extra_cflags=\"-dynamiclib\"" but that didn't seem to work.

--
You received this message because you are subscribed to the Google Groups "Crashpad-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to crashpad-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/crashpad-dev/f229d6f8-9235-40f2-954d-368b29c14c75n%40chromium.org.

Matthew Spelman

unread,
Jul 15, 2022, 3:09:35 PM7/15/22
to Crashpad-dev, Joshua Peraza, Crashpad-dev, Matthew Spelman
This fails to link, unfortunately:

[414/488] LINK ./crashpad_database_util
FAILED: crashpad_database_util
g++ -Wl,--as-needed -Wl,-z,noexecstack -pthread -m64 -Wl,-O1 -Wl,--gc-sections -pie -o "./crashpad_database_util" -Wl,--start-group obj/tools/crashpad_database_util.crashpad_database_util.o obj/tools/tool_support.tool_support.o obj/compat/libcompat.a obj/util/libutil.a obj/third_party/mini_chromium/mini_chromium/base/libbase.a   -Wl,--end-group -ldl -lz
/gcc-10.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: obj/tools/crashpad_database_util.crashpad_database_util.o: in function `std::unique_ptr<crashpad::CrashReportDatabase::NewReport, std::default_delete<crashpad::CrashReportDatabase::NewReport> >::~unique_ptr()':
crashpad_database_util.cc:(.text._ZNSt10unique_ptrIN8crashpad19CrashReportDatabase9NewReportESt14default_deleteIS2_EED2Ev[_ZNSt10unique_ptrIN8crashpad19CrashReportDatabase9NewReportESt14default_deleteIS2_EED5Ev]+0x21): undefined reference to `crashpad::CrashReportDatabase::NewReport::~NewReport()'
/gcc-10.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: obj/tools/crashpad_database_util.crashpad_database_util.o: in function `crashpad::(anonymous namespace)::DatabaseUtilMain(int, char**)':
crashpad_database_util.cc:(.text._ZN8crashpad12_GLOBAL__N_116DatabaseUtilMainEiPPc+0x765): undefined reference to `crashpad::CrashReportDatabase::Initialize(base::FilePath const&)'
/gcc-10.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: crashpad_database_util.cc:(.text._ZN8crashpad12_GLOBAL__N_116DatabaseUtilMainEiPPc+0x8e4): undefined reference to `crashpad::CrashReportDatabase::Report::Report()'
/gcc-10.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: crashpad_database_util.cc:(.text._ZN8crashpad12_GLOBAL__N_116DatabaseUtilMainEiPPc+0xa06): undefined reference to `crashpad::CrashReportDatabase::InitializeWithoutCreating(base::FilePath const&)'
/gcc-10.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: crashpad_database_util.cc:(.text._ZN8crashpad12_GLOBAL__N_116DatabaseUtilMainEiPPc+0xa52): undefined reference to `crashpad::Settings::GetClientID(crashpad::UUID*)'
/gcc-10.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: crashpad_database_util.cc:(.text._ZN8crashpad12_GLOBAL__N_116DatabaseUtilMainEiPPc+0xb66): undefined reference to `crashpad::Settings::SetLastUploadAttemptTime(long)'
/gcc-10.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: crashpad_database_util.cc:(.text._ZN8crashpad12_GLOBAL__N_116DatabaseUtilMainEiPPc+0xd3d): undefined reference to `crashpad::Settings::GetUploadsEnabled(bool*)'
/gcc-10.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: crashpad_database_util.cc:(.text._ZN8crashpad12_GLOBAL__N_116DatabaseUtilMainEiPPc+0xdd2): undefined reference to `crashpad::Settings::GetLastUploadAttemptTime(long*)'
/gcc-10.3.0/bin/../lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: crashpad_database_util.cc:(.text._ZN8crashpad12_GLOBAL__N_116DatabaseUtilMainEiPPc+0xfd5): undefined reference to `crashpad::Settings::SetUploadsEnabled(bool)'
collect2: error: ld returned 1 exit status


Do I need to convert any other Crashpad modules besides client to a loadable_module? Or are there any other compiler flags I need to specify?

Mark Mentovai

unread,
Jul 15, 2022, 3:20:54 PM7/15/22
to Matthew Spelman, Crashpad-dev, Joshua Peraza
Nobody’s ever gone to the trouble of uglifying Crashpad’s source code with all of the visibility macros that would be needed to make this work. You could hack it up with -fvisibility=default (or remove our default -fvisibility=hidden) if you were determined to do something quick and dirty.

Matthew Spelman

unread,
Jul 25, 2022, 3:11:28 PM7/25/22
to Crashpad-dev, Mark Mentovai, Crashpad-dev, Joshua Peraza, Matthew Spelman
Thanks, I messed around with it but I think I'll stick with static linking for now.
Reply all
Reply to author
Forward
0 new messages