Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions cmake/MujocoLinkOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ function(get_mujoco_extra_link_options OUTPUT_VAR)
set(EXTRA_LINK_OPTIONS)

if(WIN32)
set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -Wl,/STACK:16777216)
set(CMAKE_REQUIRED_FLAGS "-fuse-ld=lld-link")
check_c_source_compiles("int main() {}" SUPPORTS_LLD)
if(SUPPORTS_LLD)
set(EXTRA_LINK_OPTIONS
${EXTRA_LINK_OPTIONS}
-fuse-ld=lld-link
-Wl,/OPT:REF
-Wl,/OPT:ICF
)
check_c_source_compiles("int main() {}" SUPPORTS_LLD_LINK)
if(SUPPORTS_LLD_LINK)
set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -fuse-ld=lld-link -Wl,/STACK:16777216 -Wl,/OPT:REF -Wl,/OPT:ICF)
else()
set(EXTRA_LINK_OPTIONS ${EXTRA_LINK_OPTIONS} -Wl,--stack,16777216)
endif()
else()
set(CMAKE_REQUIRED_FLAGS "-fuse-ld=lld")
Expand Down
2 changes: 2 additions & 0 deletions python/mujoco/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ endif()

include(MujocoLinkOptions)
get_mujoco_extra_link_options(EXTRA_LINK_OPTIONS)
list(FILTER EXTRA_LINK_OPTIONS EXCLUDE REGEX "STACK")
list(FILTER EXTRA_LINK_OPTIONS EXCLUDE REGEX "stack")
add_link_options(${EXTRA_LINK_OPTIONS})

include(MujocoMacOS)
Expand Down
10 changes: 6 additions & 4 deletions src/engine/engine_util_errmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void mju_writeLog(const char* type, const char* msg) {

#if defined(_POSIX_C_SOURCE) || defined(__APPLE__) || defined(__STDC_VERSION_TIME_H__) || defined(__EMSCRIPTEN__)
localtime_r(&rawtime, &timeinfo);
#elif _MSC_VER
#elif defined(_WIN32)
localtime_s(&timeinfo, &rawtime);
#elif __STDC_LIB_EXT1__
localtime_s(&rawtime, &timeinfo);
Expand Down Expand Up @@ -207,8 +207,10 @@ void* mju_malloc(size_t size) {
// default allocator
else {
// pad size to multiple of 64
if ((size%64)) {
size += 64 - (size%64);
if (size == 0) {
size = 64;
} else if ((size % 64)) {
size += 64 - (size % 64);
}

// allocate
Expand All @@ -217,7 +219,7 @@ void* mju_malloc(size_t size) {

// error if null pointer
if (!ptr) {
mju_error("Could not allocate memory");
mju_error("Could not allocate memory: size = %zu", size);
}

return ptr;
Expand Down
6 changes: 5 additions & 1 deletion src/experimental/usd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ function(configure_and_install_usd_plugin_info plugin_name source_subpath instal
set(LIB_PREFIX "")
endif()

set(PLUG_INFO_LIBRARY_PATH "../../${LIB_PREFIX}${plugin_name}${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(WIN32)
set(PLUG_INFO_LIBRARY_PATH "../../../bin/${LIB_PREFIX}${plugin_name}${CMAKE_SHARED_LIBRARY_SUFFIX}")
else()
set(PLUG_INFO_LIBRARY_PATH "../../${LIB_PREFIX}${plugin_name}${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
set(OUTPUT_DIR "${CMAKE_BINARY_DIR}/${install_base_dir}/${plugin_name}")
set(OUTPUT_FILE "${OUTPUT_DIR}/plugInfo.json")

Expand Down
14 changes: 9 additions & 5 deletions src/experimental/usd/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <cstddef>
#include <string>
#include <vector>

#if defined(_WIN32) || defined(__CYGWIN__)
#include <windows.h>
Expand Down Expand Up @@ -88,14 +89,17 @@ bool RegisterMujocoUsdPlugins() {
#endif

if (!plugin_path.empty()) {
std::vector<std::string> search_paths;
#if defined(_WIN32) || defined(__CYGWIN__)
std::string full_path =
plugin_path + "\\" + "mujoco-usd-resources" + "\\**\\plugInfo.json";
search_paths.push_back(plugin_path + "\\" + "mujoco-usd-resources" + "\\**\\plugInfo.json");
search_paths.push_back(plugin_path + "\\..\\lib\\" + "mujoco-usd-resources" + "\\**\\plugInfo.json");
#else
std::string full_path =
plugin_path + "/" + "mujoco-usd-resources" + "/**/plugInfo.json";
search_paths.push_back(plugin_path + "/" + "mujoco-usd-resources" + "/**/plugInfo.json");
search_paths.push_back(plugin_path + "/../lib/" + "mujoco-usd-resources" + "/**/plugInfo.json");
#endif
pxr::PlugRegistry::GetInstance().RegisterPlugins(full_path);
for (const auto& path : search_paths) {
pxr::PlugRegistry::GetInstance().RegisterPlugins(path);
}
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/user/user_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <unistd.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#define stat _stat
#endif

Expand Down