Skip to content

Commit

Permalink
[workspace] Cherry-pick various patches from upstreams (#22363)
Browse files Browse the repository at this point in the history
The new patches all relate to removing global variables.

For packages we're already touching here to add new upstream patches,
we also take a moment to refresh the older upstream patches with more
up-to-date commentary and/or content.
  • Loading branch information
jwnimmer-tri authored Jan 7, 2025
1 parent f6bd995 commit f8c7471
Show file tree
Hide file tree
Showing 20 changed files with 1,354 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
Add a missing linkopts setting to a library, so the subsequent patch
command to set all libraries to static linking will indeed find all
libraries.
[abseil-cpp] Add missing linkopts setting to a cctz library

This patch is sufficient for Drake's purposes. A patch suitable for
upstreaming would likely import default link flags and use them.
This ensures that Drake's subsequent patch_cmds script to set all
libraries to static linking will indeed find all libraries.

Submitted upstream as https://github.com/google/cctz/pull/305 but
Google requested to implement this themselves a different way (with
Copybara magic).

If we don't see them fix it the next few months, maybe we can try re-
pinging them.

--- absl/time/internal/cctz/BUILD.bazel
+++ absl/time/internal/cctz/BUILD.bazel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[abseil-cpp] Remove unncessary <iostream> includes

Submitted upstream as https://github.com/abseil/abseil-cpp/pull/1801
but Google requested to implement this remaining part of the patch in
a different way ("change that code to output to a std::string and let
the user dump it").

If we don't see them fix it the next few months, maybe we can try re-
submitting a new patch using that other approach, ourselves.

--- absl/strings/cord.cc
+++ absl/strings/cord.cc
@@ -23,7 +23,6 @@
#include <cstring>
#include <iomanip>
#include <ios>
-#include <iostream>
#include <limits>
#include <memory>
#include <ostream>

--- absl/strings/internal/cord_rep_btree.cc
+++ absl/strings/internal/cord_rep_btree.cc
@@ -17,10 +17,13 @@
#include <atomic>
#include <cassert>
#include <cstdint>
-#include <iostream>
#include <ostream>
#include <string>

+#ifndef NDEBUG
+#include <iostream>
+#endif
+
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/raw_logging.h"

--- absl/strings/internal/cord_rep_btree_navigator.h
+++ absl/strings/internal/cord_rep_btree_navigator.h
@@ -16,7 +16,6 @@
#define ABSL_STRINGS_INTERNAL_CORD_REP_BTREE_NAVIGATOR_H_

#include <cassert>
-#include <iostream>

#include "absl/strings/internal/cord_internal.h"
#include "absl/strings/internal/cord_rep_btree.h"
1 change: 1 addition & 0 deletions tools/workspace/abseil_cpp_internal/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def abseil_cpp_internal_repository(
sha256 = "01474554fc2981e92fcda71c7ce29d3ed4ee8dd0707b346da3f8978cd349fa33", # noqa
patches = [
":patches/upstream/civil_time_linkopts.patch",
":patches/upstream/specific_iostream_includes.patch",
":patches/disable_int128_on_clang.patch",
":patches/hidden_visibility.patch",
":patches/inline_namespace.patch",
Expand Down
23 changes: 23 additions & 0 deletions tools/workspace/clarabel_cpp_internal/patches/upstream/pr52.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Clarabel.cpp] Cherry-pick of https://github.com/oxfordcontrol/Clarabel.cpp/pull/52

We can drop this patch once we upgrade to a release that contains it.

From: Jeremy Nimmer <[email protected]>
Date: Mon, 30 Dec 2024 17:48:20 -0800
Subject: [PATCH] Remove unncessary <iostream> include

Including iostream means introducing the static (global) constructors
and destructors for std::cin, std::cerr, and std::cout. That extra
init and fini code is undesirable when those streams are not actually
used.

--- include/cpp/CscMatrix.h
+++ include/cpp/CscMatrix.h
@@ -1,7 +1,6 @@
#pragma once

#include <cstdint>
-#include <iostream>
#include <type_traits>

namespace clarabel
3 changes: 2 additions & 1 deletion tools/workspace/clarabel_cpp_internal/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ def clarabel_cpp_internal_repository(
sha256 = "4dfff59667623bf4264ba27f25eef08bda64899a4e443f8d1993d5d5a9a36ab0", # noqa
build_file = ":package.BUILD.bazel",
patches = [
":patches/upstream/allow_unused_must_use.patch",
":patches/upstream/pr52.patch",
":patches/extern_c.patch",
":patches/git_submodule.patch",
":patches/sdp.patch",
":patches/upstream/allow_unused_must_use.patch",
],
mirrors = mirrors,
)
2 changes: 2 additions & 0 deletions tools/workspace/gz_math_internal/package.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ _MOST_HDRS = [
"include/gz/math/detail/Cone.hh",
"include/gz/math/detail/Cylinder.hh",
"include/gz/math/detail/Ellipsoid.hh",
"include/gz/math/detail/Error.hh",
"include/gz/math/detail/InterpolationPoint.hh",
"include/gz/math/detail/Sphere.hh",
"include/gz/math/detail/WellOrderedVector.hh",
Expand Down Expand Up @@ -218,6 +219,7 @@ _SRCS = [
"src/Color.cc",
"src/CoordinateVector3.cc",
"src/DiffDriveOdometry.cc",
"src/Error.cc",
"src/Frustum.cc",
"src/GaussMarkovProcess.cc",
"src/Helpers.cc",
Expand Down
Loading

0 comments on commit f8c7471

Please sign in to comment.