On 2020/12/26 13:21, Dimitri Karamazov wrote: > On Sat, Dec 26, 2020 at 11:41:13AM +0100, Sebastien Marie wrote: > > > > > > > > does usd has already been ported to OpenBSD ? it seems that this build > > > > assumes a Darwin option to be present (which is not and so fail). > > > > > > > > you might want to found from where the option "-Wl,-force_load" comes > > > > from. > > > > > > > I'm porting it. The build goes fine when I allow for separate shared libs > > > but that is not in accordance with how blender wants it. It expects a > > > single monolith library which is enabled with PXR_BUILD_MONOLITH. > > > > > > If required can this option be enabled in the ports llvm? I'll see if I > > > can > > > do without it. > > > > no. the option exists only on Darwin (MacOS). > > > > > I'm attaching the port below, if any one wants to take a look. The part > > > which contains that option is: > > > > thanks. I took a look at it. > > > > for others, we are speaking of > > https://github.com/PixarAnimationStudios/USD/ (v20.11, the latest). > > > > I looked at the commit which introduced "-force_load". it is commit > > 3598908bcd > > (https://github.com/PixarAnimationStudios/USD/commit/3598908bcd6307cb0a6ca0f78657bf4563152b33): > > > > For citing a part of the commit message: > > > > Each platform has a different way to link the entire contents of > > an archive library. On Linux it's "--whole-archive <lib> > > --no-whole-archive"; on Darwin it's "-force_load <lib>"; and on > > Windows it's "/WHOLEARCHIVE:<lib>". > > > > From the CMake snippet you included, it seems that USD assumes that if > > the software is build with clang, it means it is Darwin, which is > > slightly inexact :) > > > > You should patch the CMake file to use '--whole-archive' stuff on > > OpenBSD (even if built with clang). > > > Worked quiet fine for me, blender picks the static lib. I'm currently > building blender lets see how it goes, this foreboding is because a > part of the code expected to get a file Name from a file Pointer > through ArchGetFileName defined in pxr/base/arch/fileSystem.cpp which > is referenced only once in pxr/usd/usd/crateFile.cpp, turns out not > possible in OpenBSD so I've patched it with little understanding. > > Anyway thanks for all the help! > > --- cmake/macros/Public.cmake.orig > --- cmake/macros/Public.cmake > @@ -970,10 +970,10 @@ function(pxr_toplevel_epilogue) > PRIVATE > -Wl,--whole-archive $<TARGET_FILE:usd_m> > -Wl,--no-whole-archive > ) > - elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") > + elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") > target_link_libraries(usd_ms > PRIVATE > - -Wl,-force_load $<TARGET_FILE:usd_m> > + -Wl,--whole-archive $<TARGET_FILE:usd_m> > -Wl,--no-whole-archive > ) > endif()
(original is at https://github.com/PixarAnimationStudios/USD/blob/release/cmake/macros/Public.cmake#L955) neither their original code nor this diff really feel the natural way to handle this - why check the type of _compiler_ to decide on a linker option? how about this instead (which should be closer to being acceptable upstream too..)? if(MSVC) target_link_libraries(usd_ms PRIVATE -WHOLEARCHIVE:$<TARGET_FILE:usd_m> ) elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") target_link_libraries(usd_ms PRIVATE -Wl,-force_load $<TARGET_FILE:usd_m> ) else target_link_libraries(usd_ms PRIVATE -Wl,--whole-archive $<TARGET_FILE:usd_m> -Wl,--no-whole-archive ) endif()