mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

Remove uselsess TINYOBJLOADER_IMPLEMENTATION definition

Open traversaro opened this issue 3 years ago • 2 comments

As far as I understand, TINYOBJLOADER_IMPLEMENTATION macro is used to be defined in libraries or executables that consume tinyobjloader only including its header, without linking the corresponding library. However mujoco (at least with the CMake build system provided in this repo) is already linking the tinyobjloader library in which all the symbols are defined, so there is no need to re-defined them.

traversaro avatar May 27 '22 17:05 traversaro

I am not fully 100% sure about the reasoning behind the PR, so one of the reasons for opening the PR is indeed to check if the CI works correctly even by removing the TINYOBJLOADER_IMPLEMENTATION definition.

traversaro avatar May 27 '22 17:05 traversaro

OK so I've now run this on our internal CI, and this is in fact required for our internal build process that we use to generate our official binaries.

The prebuilt library that we ship contains all of MuJoCo's dependencies statically linked in, but with symbols hidden. We still believe that this is the cleanest and safest way for us to ship prebuilt libraries (we also target GLIBC_2.17 aka manylinux2014 aka CentOS 7, and our libmujoco.so doesn't have any exposed C++ ABI surface -- it has its own copy of libc++ baked in, and also hidden). This means that in our build we want that file to provide tinyobjloader symbols.

The correct "fix" for this would be to define a CMake variable (MUJOCO_STATIC_TINYOBJLOADER or something like that) that translates to a macro that controls whether TINYOBJLOADER_IMPLEMENTATION is defined.

saran-t avatar May 27 '22 18:05 saran-t

The correct "fix" for this would be to define a CMake variable (MUJOCO_STATIC_TINYOBJLOADER or something like that) that translates to a macro that controls whether TINYOBJLOADER_IMPLEMENTATION is defined.

Sorry, I had missed that. I will look into this, thanks!

traversaro avatar Oct 27 '22 16:10 traversaro

@saran-t I tried to implement in the simplest way possible your suggestions.

What happens with this PR is the following:

  • If MuJoCo is built with CMake, TINYOBJLOADER_IMPLEMENTATION is not defined
  • When MuJoCo is built with some other build system not mantained in this repo such as your internal build process, TINYOBJLOADER_IMPLEMENTATION

Is this ok for you? I kind of made the assumption that your internal build process is not based at all on CMake (I guess is blaze/bazel-based), but please tell me if this assumption is wrong.

traversaro avatar Oct 28 '22 22:10 traversaro

@saran-t I tried to implement in the simplest way possible your suggestions.

What happens with this PR is the following:

* If MuJoCo is built with CMake, `TINYOBJLOADER_IMPLEMENTATION` is not defined

* When MuJoCo is built with some other build system not mantained in this repo such as your internal build process, `TINYOBJLOADER_IMPLEMENTATION`

Is this ok for you? I kind of made the assumption that your internal build process is not based at all on CMake (I guess is blaze/bazel-based), but please tell me if this assumption is wrong.

Hello @saran-t, I was doing a cleanup of PRs that I had open, are you still interested in this change? If yes I can keep the PR open, otherwise perhaps I would close it to cleanup my PRs list. Thanks a lot in advance!

traversaro avatar May 02 '23 21:05 traversaro

Thanks @saran-t !

traversaro avatar May 06 '23 00:05 traversaro