Enable Unity(Jumbo) builds

Signed-off-by: Jean-Simon Lapointe <jean-simon.lapointe@ubisoft.com>
pull/16454/head
Jean-Simon Lapointe 7 months ago
parent 0e3650c29c
commit a387ffd862
No known key found for this signature in database
  1. 1
      CMakeLists.txt
  2. 1
      cmake/libprotobuf-lite.cmake
  3. 17
      cmake/protobuf-configure-target.cmake
  4. 1
      cmake/tests.cmake
  5. 1
      src/google/protobuf/arenaz_sampler.cc
  6. 1
      src/google/protobuf/generated_enum_util.cc
  7. 2
      src/google/protobuf/generated_message_tctable_lite.cc
  8. 3
      src/google/protobuf/generated_message_util.cc
  9. 5
      src/google/protobuf/implicit_weak_message.cc
  10. 1
      src/google/protobuf/inlined_string_field.cc
  11. 1
      src/google/protobuf/io/zero_copy_stream.cc
  12. 1
      src/google/protobuf/io/zero_copy_stream_impl_lite.cc
  13. 1
      src/google/protobuf/port.cc
  14. 1
      src/google/protobuf/raw_ptr.cc

@ -35,6 +35,7 @@ option(protobuf_BUILD_LIBUPB "Build libupb" ON)
option(protobuf_DISABLE_RTTI "Remove runtime type information in the binaries" OFF)
option(protobuf_TEST_XML_OUTDIR "Output directory for XML logs from tests." "")
option(protobuf_ALLOW_CCACHE "Adjust build flags to allow for ccache support." OFF)
option(protobuf_USE_UNITY_BUILD "Enable Unity (Jumbo) build for" OFF)
if (BUILD_SHARED_LIBS)
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
else (BUILD_SHARED_LIBS)

@ -29,6 +29,7 @@ target_include_directories(libprotobuf-lite PUBLIC
)
target_link_libraries(libprotobuf-lite PUBLIC ${protobuf_ABSL_USED_TARGETS})
protobuf_configure_target(libprotobuf-lite)
protobuf_configure_unity_target(libprotobuf-lite)
if(protobuf_BUILD_SHARED_LIBS)
target_compile_definitions(libprotobuf-lite
PUBLIC PROTOBUF_USE_DLLS

@ -52,4 +52,21 @@ function(protobuf_configure_target target)
if (HAVE_ZLIB)
target_compile_definitions("${target}" PRIVATE -DHAVE_ZLIB)
endif ()
endfunction ()
function(protobuf_configure_unity_target target)
if(protobuf_USE_UNITY_BUILD)
# UNITY_BUILD available in CMake >=3.18.
if(${CMAKE_VERSION} VERSION_GREATER 3.18 OR ${CMAKE_VERSION} VERSION_EQUAL 3.18)
# If protobuf_USE_UNITY_BUILD is set to ON, set target to use Unity builds.
set_target_properties("${target}"
PROPERTIES
UNITY_BUILD ON
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 50
)
endif()
endif()
endfunction ()

@ -103,6 +103,7 @@ add_executable(tests ${tests_files} ${common_test_files})
if (MSVC)
target_compile_options(tests PRIVATE
/wd4146 # unary minus operator applied to unsigned type, result still unsigned
/bigobj
)
endif()
target_link_libraries(tests

@ -221,3 +221,4 @@ void SetThreadSafeArenazGlobalNextSample(int64_t next_sample) {}
} // namespace internal
} // namespace protobuf
} // namespace google
#include "google/protobuf/port_undef.inc"

@ -219,3 +219,4 @@ std::vector<uint32_t> GenerateEnumData(absl::Span<const int32_t> values) {
} // namespace internal
} // namespace protobuf
} // namespace google
#include "google/protobuf/port_undef.inc"

@ -2932,3 +2932,5 @@ const char* TcParser::DiscardEverythingFallback(PROTOBUF_TC_PARAM_DECL) {
} // namespace internal
} // namespace protobuf
} // namespace google
#include <google/protobuf/port_undef.inc>

@ -28,7 +28,10 @@
// Must be included last
#include "google/protobuf/port_def.inc"
#ifndef PROTOBUF_PRAGMA_INIT_SEG_DONE
PROTOBUF_PRAGMA_INIT_SEG
#define PROTOBUF_PRAGMA_INIT_SEG_DONE
#endif
namespace google {

@ -14,7 +14,12 @@
// Must be included last.
#include "google/protobuf/port_def.inc"
// Since we could be merging Translation units, we must check if this was done
// before.
#ifndef PROTOBUF_PRAGMA_INIT_SEG_DONE
PROTOBUF_PRAGMA_INIT_SEG
#define PROTOBUF_PRAGMA_INIT_SEG_DONE
#endif
namespace google {
namespace protobuf {

@ -116,3 +116,4 @@ void InlinedStringField::ClearToDefault(const LazyString& default_value,
} // namespace internal
} // namespace protobuf
} // namespace google
#include "google/protobuf/port_undef.inc"

@ -119,3 +119,4 @@ bool ZeroCopyOutputStream::WriteAliasedRaw(const void* /* data */,
} // namespace io
} // namespace protobuf
} // namespace google
#include "google/protobuf/port_undef.inc"

@ -683,3 +683,4 @@ absl::Cord CordOutputStream::Consume() {
} // namespace io
} // namespace protobuf
} // namespace google
#include "google/protobuf/port_undef.inc"

@ -27,3 +27,4 @@ void protobuf_assumption_failed(const char* pred, const char* file, int line) {
} // namespace internal
} // namespace protobuf
} // namespace google
#include "google/protobuf/port_undef.inc"

@ -23,3 +23,4 @@ ABSL_CONST_INIT PROTOBUF_EXPORT
} // namespace internal
} // namespace protobuf
} // namespace google
#include "google/protobuf/port_undef.inc"

Loading…
Cancel
Save