Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ visibility support (take II) #233

Merged
merged 21 commits into from
Nov 17, 2017
Merged

C++ visibility support (take II) #233

merged 21 commits into from
Nov 17, 2017

Conversation

j-rivero
Copy link
Contributor

Continues discussion and work done in #231. Reproducing the summary:

This PR implements the control of binary symbols visibility in FCL.

It adds a new FCL_VISIBLE preprocessor define to any class, struct or function that needs to be exposed publicly to third party software. Since the number of files in this library is not small, I've patched all what I found needed to compile the whole test suite. It would be good to use another third party software using FCL extensively to test that I did not forget about any of them.

The PR also adds the FCL_HIDE_ALL_SYMBOLS option (OFF by the default). This option covers a use case we found in Drake where a software uses FCL (linked statically) but does not expose it in the public API (headers). In this scenario the best option to avoid any possible conflict with other versions of fcl is to hide all the symbols from the public ABI.

Numbers before and after:

Version Number of symbols libfcl size
current 18942 11922 Kb
with visibility from this PR 16530 11257Kb
no symbols 157 9012Kb

Summary: 13% symbols less and 6% size less .

The PR will alter the ABI so a new bump in the FCL version prior to release it would be ideal.

@j-rivero j-rivero mentioned this pull request Oct 11, 2017
@j-rivero
Copy link
Contributor Author

I think that all the compilers/options on Linux and Windows are now happy. Mac is failing due to a problem finding ccd (I think it is unrelated to this PR).

@j-rivero
Copy link
Contributor Author

j-rivero commented Nov 9, 2017

@jslee02 I've been trying to compile this branch with Dart (master and tag 6.3.1) but there are compilation failures due to a change in headers location. Do you know if there is any branch ready in Dart ready to work with fcl current master?

@jslee02
Copy link
Member

jslee02 commented Nov 9, 2017

@j-rivero dartsim/dart#873 should work with this PR. I tested it against FCL 0.5 as well.

Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on exporting symbols, but this looks a great change according to the description!

I've made some comments:

  • I guess you replaced "class " with "class FCL_EXPOSE ". It seems this made unintended changes in descriptions of some classes.
  • About the name and installation location of fcl_expose.h.

Besides on that, it looks good to me.

@@ -47,9 +47,9 @@
namespace fcl
{

/// @brief A class describing a bounding volume node. It includes the tree structure providing in BVNodeBase and also the geometry data provided in BV template parameter.
/// @brief A class FCL_EXPORT describing a bounding volume node. It includes the tree structure providing in BVNodeBase and also the geometry data provided in BV template parameter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an oversight?

@@ -60,9 +60,9 @@ enum SplitMethodType
SPLIT_METHOD_BV_CENTER
};

/// @brief A class describing the split rule that splits each BV node
/// @brief A class FCL_EXPORT describing the split rule that splits each BV node
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an oversight?

@@ -38,7 +38,7 @@
#ifndef FCL_GEOMETRY_SHAPE_UTILITY_H
#define FCL_GEOMETRY_SHAPE_UTILITY_H

// This header shouldn't be included by any bounding volumen classes (e.g.,
// This header shouldn't be included by any bounding volumen class FCL_EXPORTes (e.g.,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an oversight?

@@ -43,10 +43,10 @@
namespace fcl
{

/// @brief A class describing the AABB collision structure, which is a box in 3D
/// @brief A class FCL_EXPORT describing the AABB collision structure, which is a box in 3D
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an oversight?

@@ -46,9 +46,9 @@
namespace fcl
{

/// @brief Oriented bounding box class
/// @brief Oriented bounding box class FCL_EXPORT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an oversight?

CMakeLists.txt Outdated
# Need to include directory to find export file
include_directories(${PROJECT_BINARY_DIR})

install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}_export.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we change the export header to simply export.h? I don't see any ambiguity or confliction in including this file if we install this file under ${CMAKE_INSTALL_INCLUDEDIR}/fcl. In this way, we could include this file as:

#include "fcl/export.h" // in FCL code base

#include <fcl/export.h> // in FCL dependent projects.

@@ -42,6 +45,7 @@ include(FCLMacros)
include(CompilerSettings)
include(FCLVersion)
include(GNUInstallDirs)
include(GenerateExportHeader)
Copy link
Member

@jslee02 jslee02 Nov 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just learned this very useful CMake utility! 😮

{
using S = S_;

/// @brief intersection checking between two shapes
/// @deprecated use shapeIntersect(const Shape1&, const Transform3<S>&, const Shape2&, const Transform3<S>&, std::vector<ContactPoint<S>>*) const
template<typename Shape1, typename Shape2>
FCL_DEPRECATED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an oversight or removed intentionally? fcl_export.h still has the definition of FCL_DEPRECATED. This deprecation was introduced in #52 for backward compatibility. If we want to remove this deprecation, I would like to remove this function entirely not to cause confusion of which shapeIntersect should be used.

{
using S = S_;

/// @brief intersection checking between two shapes
/// @deprecated use shapeIntersect(const Shape1&, const Transform3<S>&, const Shape2&, const Transform3<S>&, std::vector<ContactPoint<S>>*) const
template<typename Shape1, typename Shape2>
FCL_DEPRECATED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto:

Is this an oversight or removed intentionally? fcl_export.h still has the definition of FCL_DEPRECATED. This deprecation was introduced in #52 for backward compatibility. If we want to remove this deprecation, I would like to remove this function entirely not to cause confusion of which shapeIntersect should be used.

@@ -212,7 +216,7 @@ bool initialize(
DistanceResult<S>& result);

template <typename BV>
FCL_DEPRECATED
FCL_EXPORT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be FCL_DEPRECATED_EXPORT.

@jslee02 jslee02 added this to the FCL 0.6.0 milestone Nov 10, 2017
@j-rivero
Copy link
Contributor Author

Thanks JS for the review.

I guess you replaced "class " with "class FCL_EXPOSE ". It seems this made unintended changes in descriptions of some classes.

You were right. I think I've reverted all the changes you detected. Thanks for carefully looking into them.

About the name and installation location of fcl_expose.h.

I agree, we can use fcl/export.h. I've modified the code in f98dd43 to do it.

Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@j-rivero
Copy link
Contributor Author

While testing DART compilation against this branch I found a little problem with export.h location and fixed it in 831a13e. In my opinion, we are ready to merge.

@jslee02
Copy link
Member

jslee02 commented Nov 16, 2017

While testing DART compilation against this branch I found a little problem with export.h location and fixed it in 831a13e.

Good catch! Let's merge this unless we have more feedback by tomorrow.

@jslee02 jslee02 merged commit 4304833 into flexible-collision-library:master Nov 17, 2017
@jslee02 jslee02 mentioned this pull request Mar 22, 2018
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants