Skip to content

Default compile takes 62 minutes, no knobs to exclude protobof-lite or support for unneeded languages from protoc? #20539

@hartwork

Description

@hartwork

Hi!

It has come to my attention that a default compile (meaning plain cmake -S . -B build) of Protobuf (commit 24830cf of 2025-02-28 and GCC 13) takes 62 minutes on a Lenovo ThinkPad X220, and that much of that time could be saved if only the build system would allow to (1) compile protobuf compiler "protoc" with fewer languages included (e.g. when all I need is C++ and none of C#/Java/JKotlin/ObjectiveC/PHP/Python/Ruby/Rust) and (2) exclude protobuf-lite. 62 minutes!

This was in context of libprotobuf-mutator where switch -DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON would download and compile an almost complete Protobuf originally e.g. because Protobuf in many mainline distros is so far behind Protobuf upstream, including Ubuntu (20.04/22.04/)24.04. I should note that currently 14 projects in OSS-Fuzz are doing that because they had no choice: compile almost all of Protobuf without genuine need to.

For a case where (nothing but) libprotobuf and a protoc compiler with C++ support are needed (as with libprotobuf-mutator), the only two build switches reducing compile time I found were -Dprotobuf_BUILD_TESTS:BOOL=OFF -Dprotobuf_BUILD_LIBUPB:BOOL=OFF but they break the build (see #20538) and are not cutting of much. I was demoing a quick-hack to reduce compile time in https://github.com/google/libprotobuf-mutator/pull/267/files earlier but it was not the right place, not in upstreamable form, not a true fix.

Is reducing the build to fewer unneeded parts at the source something that your are considering?

Best, Sebastian

CC @vitalybuka

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedauto added to all issues by default when created.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions