-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[workspace] Improve qhull hidden visibility (#17229)
When building C++ code, we should not use -fvisibility=hidden because it infects all #included code, even the standard library. This causes a lot of console spam during macOS builds, and is a typeinfo (vtable) problem even on Ubuntu, potentially leading to ODR violation. Instead, we should wrap the third-party C++ code in a inline hidden namespace. That way, only the third-party code itself is hidden, not anything that it #includes. We are substantially patching and subsetting this library to weave it into Drake. We shouldn't give the illusion to users that it's available for reuse downstream; therefore, we'll add an "_internal" suffix and deprecate the original repository name.
- Loading branch information
1 parent
9c9e575
commit b7c0b58
Showing
10 changed files
with
119 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- python -*- | ||
|
||
def _impl(repo_ctx): | ||
name = repo_ctx.attr.name | ||
date = repo_ctx.attr.date | ||
cc_aliases = repo_ctx.attr.cc_aliases | ||
|
||
build = "package(default_visibility = [\"//visibility:public\"])\n" | ||
deprecation = "".join([ | ||
"DRAKE DEPRECATED: The @{} external is deprecated".format(name), | ||
" and will be removed from Drake on or after {}.".format(date), | ||
]) | ||
for label, actual in cc_aliases.items(): | ||
build += "cc_library({})\n".format(", ".join([ | ||
"name = " + repr(label), | ||
"deps = [" + repr(actual) + "]", | ||
"deprecation = " + repr(deprecation), | ||
])) | ||
|
||
repo_ctx.file("BUILD.bazel", build) | ||
|
||
add_deprecation = repository_rule( | ||
doc = """Adds a repository rule with deprecated aliases to other targets. | ||
This is particularly useful when renaming an external repository. | ||
Example: | ||
add_deprecation( | ||
name = "qhull", | ||
date = "2038-01-19", | ||
cc_aliases = {"qhull": "@qhull_internal//:qhull"}, | ||
) | ||
""", | ||
attrs = { | ||
"date": attr.string( | ||
doc = "Scheduled removal date of the deprecated target(s).", | ||
mandatory = True, | ||
), | ||
"cc_aliases": attr.string_dict( | ||
doc = """ | ||
Optional mapping for cc_library deprecations. The keys are | ||
deprecated target names, the values are the non-deprecated labels. | ||
""", | ||
), | ||
}, | ||
implementation = _impl, | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
For private access within the module, don't use out-of-namespace friendship with | ||
an `extern "C"` function. This doesn't work with drake's namespace vendoring. | ||
|
||
Instead, just make the fields public. | ||
|
||
--- src/libqhullcpp/QhullQh.h.orig | ||
+++ src/libqhullcpp/QhullQh.h | ||
@@ -58,7 +58,7 @@ | ||
#//!\name Constants | ||
|
||
#//!\name Fields | ||
-private: | ||
+public: | ||
int qhull_status; //!< qh_ERRnone if valid | ||
std::string qhull_message; //!< Returned messages from libqhull_r | ||
std::ostream * error_stream; //!< overrides errorMessage, use appendQhullMessage() | ||
@@ -66,8 +66,9 @@ | ||
double factor_epsilon; //!< Factor to increase ANGLEround and DISTround for hyperplane equality | ||
bool use_output_stream; //!< True if using output_stream | ||
|
||
+private: | ||
//! modified by qh_fprintf in QhullUser.cpp | ||
- friend void ::qh_fprintf(qhT *qh, FILE *fp, int msgcode, const char *fmt, ... ); | ||
+ //friend void ::qh_fprintf(qhT *qh, FILE *fp, int msgcode, const char *fmt, ... ); | ||
|
||
static const double default_factor_epsilon; //!< Default factor_epsilon is 1.0, never updated | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters