Re: graphics/glslang build shared libs
Stuart Henderson writes: > On 2023/04/30 11:41, Thomas Frohwein wrote: >> We have other ports that have shared libraries without version suffix; >> games/lwjgl comes to mind for me. There are probably others, too. > > They aren't usually in /usr/local/lib though. > > If they're linked against by other ports, they should have versions. > > If they're just modules which are dlopen()d by the port then usually no > versions. > >> > +REVISION =1 >> > + >> > +SHARED_LIBS +=glslang 0.0 # 12.0 >> > > > Does it add version numbers if you add the other libs to SHARED_LIBS and > rebuild? Adding to SHARED_LIBS is not sufficient. I also have to substitute LIBSPIRV_VERSION into SOVERSION for plist to pick up the versioning. In cmake, VERSION is the "build version" and SOVERSION is the "API version." see: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html I see the new helpful sections regarding cmake: https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs Since flycast only uses glslang and SPIRV shared objects, would this be OK? Then, the other shared objects can remain unversioned until they are linked against in the future. I tested all consumers. Index: Makefile === RCS file: /cvs/ports/graphics/glslang/Makefile,v retrieving revision 1.17 diff -u -p -u -p -r1.17 Makefile --- Makefile30 Apr 2023 19:11:57 - 1.17 +++ Makefile1 May 2023 21:53:44 - @@ -5,9 +5,10 @@ COMMENT = reference front-end for GLSL a GH_TAGNAME = 12.0.0 GH_ACCOUNT = KhronosGroup GH_PROJECT = glslang -REVISION = 1 +REVISION = 2 SHARED_LIBS += glslang 0.0 # 12.0 +SHARED_LIBS += SPIRV 0.0 # 12.0 CATEGORIES = devel graphics @@ -28,6 +29,9 @@ TEST_DEPENDS =graphics/spirv-tools \ shells/bash CONFIGURE_ARGS += -DBUILD_SHARED_LIBS=ON + +pre-configure: + ${SUBST_CMD} ${WRKSRC}/SPIRV/CMakeLists.txt do-test: cd ${WRKSRC}/Test; exec ./runtests localResults \ Index: patches/patch-SPIRV_CMakeLists_txt === RCS file: patches/patch-SPIRV_CMakeLists_txt diff -N patches/patch-SPIRV_CMakeLists_txt --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-SPIRV_CMakeLists_txt 1 May 2023 21:53:44 - @@ -0,0 +1,21 @@ +define SOVERSION for SPIRV to provide shared library version number + +see: +https://github.com/KhronosGroup/glslang/commit/fbe9a23baf2cb020fe3f80d68d972e2a97d9b954#diff-c275da269cb9eab1ad823f3e969a1070057413af288a2318397b1c9415289fa1 +Index: SPIRV/CMakeLists.txt +--- SPIRV/CMakeLists.txt.orig SPIRV/CMakeLists.txt +@@ -71,8 +71,11 @@ set(SPVREMAP_HEADERS + doc.h) + + add_library(SPIRV ${LIB_TYPE} ${SOURCES} ${HEADERS}) +-set_property(TARGET SPIRV PROPERTY FOLDER glslang) +-set_property(TARGET SPIRV PROPERTY POSITION_INDEPENDENT_CODE ON) ++set_target_properties(SPIRV PROPERTIES ++FOLDER glslang ++POSITION_INDEPENDENT_CODE ON ++VERSION "${GLSLANG_VERSION}" ++SOVERSION "${LIBSPIRV_VERSION}") + target_include_directories(SPIRV PUBLIC + $ + $) Index: pkg/PLIST === RCS file: /cvs/ports/graphics/glslang/pkg/PLIST,v retrieving revision 1.7 diff -u -p -u -p -r1.7 PLIST --- pkg/PLIST 30 Apr 2023 19:11:57 - 1.7 +++ pkg/PLIST 1 May 2023 21:53:44 - @@ -83,7 +83,7 @@ lib/cmake/glslang/glslang-targets.cmake lib/cmake/glslangValidatorTargets.cmake lib/cmake/spirv-remapTargets.cmake @so lib/libHLSL.so -@so lib/libSPIRV.so +@lib lib/libSPIRV.so.${LIBSPIRV_VERSION} @so lib/libSPVRemapper.so @so lib/libglslang-default-resource-limits.so @lib lib/libglslang.so.${LIBglslang_VERSION}
Re: graphics/glslang build shared libs
On 2023/04/30 11:41, Thomas Frohwein wrote: > > > > naddy uncovered a build failure with emulators/flycast. I will have > > details in the flycast email, but the proposed solution is to build > > shared libraries in graphics/glslang so that flycast can use libSPIRV.so > > and libglslang.so.0.0. > > > > >>> +@so lib/libHLSL.so > > >>> +@so lib/libSPIRV.so > > >>> +@so lib/libSPVRemapper.so > > >>> +@so lib/libglslang-default-resource-limits.so > > >>> +@lib lib/libglslang.so.${LIBglslang_VERSION} > > > > Having shared libraries without semantic versioning might be fine? > > Upstream seems to only want to add semantic versioning to the main > > library, libglslang.so.0.0. > > We have other ports that have shared libraries without version suffix; > games/lwjgl comes to mind for me. There are probably others, too. They aren't usually in /usr/local/lib though. If they're linked against by other ports, they should have versions. If they're just modules which are dlopen()d by the port then usually no versions. > > +REVISION = 1 > > + > > +SHARED_LIBS += glslang 0.0 # 12.0 > > Does it add version numbers if you add the other libs to SHARED_LIBS and rebuild?
Re: graphics/glslang build shared libs
On Sat, Apr 29, 2023 at 09:14:18PM -0700, Nam Nguyen wrote: > > Thomas Frohwein writes: > > > >> On Tue, Apr 18, 2023 at 06:41:50PM -0700, Nam Nguyen wrote: > >> Do you have some details on this? Is this an upstream error, that > >> that --no-undefined is wrong when building the shared library? Or is > >> there something that might not be compiling or linking correctly? > > Brad upstreamed a fix recently for removing --no-undefined, included in > this new diff. > > see: > https://github.com/KhronosGroup/glslang/commit/9c7fd1a33e5cecbe465e1cd70170167d5e40d398 > > Here is a new inline diff that: > - backports Brad's fix for removing --no-undefined when building shared > libraries > - builds shared libraries > > naddy uncovered a build failure with emulators/flycast. I will have > details in the flycast email, but the proposed solution is to build > shared libraries in graphics/glslang so that flycast can use libSPIRV.so > and libglslang.so.0.0. > > >>> +@so lib/libHLSL.so > >>> +@so lib/libSPIRV.so > >>> +@so lib/libSPVRemapper.so > >>> +@so lib/libglslang-default-resource-limits.so > >>> +@lib lib/libglslang.so.${LIBglslang_VERSION} > > Having shared libraries without semantic versioning might be fine? > Upstream seems to only want to add semantic versioning to the main > library, libglslang.so.0.0. We have other ports that have shared libraries without version suffix; games/lwjgl comes to mind for me. There are probably others, too. > see: > https://github.com/KhronosGroup/glslang/commit/fbe9a23baf2cb020fe3f80d68d972e2a97d9b954 > > I successfully tested all consumers (vulkan-tools, vkquake and piglit) > again. > > OK? ok thfr@ > Index: Makefile > === > RCS file: /cvs/ports/graphics/glslang/Makefile,v > retrieving revision 1.16 > diff -u -p -u -p -r1.16 Makefile > --- Makefile 10 Mar 2023 22:28:49 - 1.16 > +++ Makefile 30 Apr 2023 03:18:50 - > @@ -5,7 +5,9 @@ COMMENT = reference front-end for GLSL a > GH_TAGNAME = 12.0.0 > GH_ACCOUNT = KhronosGroup > GH_PROJECT = glslang > -REVISION = 0 > +REVISION = 1 > + > +SHARED_LIBS += glslang 0.0 # 12.0 > > CATEGORIES = devel graphics > > @@ -24,6 +26,8 @@ MODULES = devel/cmake \ > lang/python > TEST_DEPENDS = graphics/spirv-tools \ > shells/bash > + > +CONFIGURE_ARGS +=-DBUILD_SHARED_LIBS=ON > > do-test: > cd ${WRKSRC}/Test; exec ./runtests localResults \ > Index: patches/patch-CMakeLists_txt > === > RCS file: patches/patch-CMakeLists_txt > diff -N patches/patch-CMakeLists_txt > --- /dev/null 1 Jan 1970 00:00:00 - > +++ patches/patch-CMakeLists_txt 30 Apr 2023 03:18:50 - > @@ -0,0 +1,38 @@ > +Fix building on OpenBSD when building shared libs > + > +OpenBSD does not link shared libs against libc so it is expected > +that the use of --no-undefined when linking will fail. > + > +Also garbage collect CMAKE_VERSION check while here, as requested, since > +the minimum version is already 3.14. > + > +see: > +https://github.com/KhronosGroup/glslang/commit/9c7fd1a33e5cecbe465e1cd70170167d5e40d398 > + > +Index: CMakeLists.txt > +--- CMakeLists.txt.orig > CMakeLists.txt > +@@ -171,10 +171,8 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") > + add_compile_options(-Werror=deprecated-copy) > + endif() > + > +-if(NOT CMAKE_VERSION VERSION_LESS "3.13" AND NOT CMAKE_SYSTEM_NAME > STREQUAL "Darwin") > ++if(NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" AND NOT CMAKE_SYSTEM_NAME > STREQUAL "Darwin") > + # Error if there's symbols that are not found at link time. > +-# add_link_options() was added in CMake 3.13 - if using an earlier > +-# version don't set this - it should be caught by presubmits anyway. > + add_link_options("-Wl,--no-undefined") > + endif() > + elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC) > +@@ -188,10 +186,8 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NO > + add_compile_options(-fno-exceptions) > + endif() > + > +-if(NOT CMAKE_VERSION VERSION_LESS "3.13") > ++if(NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") > + # Error if there's symbols that are not found at link time. > +-# add_link_options() was added in CMake 3.13 - if using an earlier > +-# version don't set this - it should be caught by presubmits anyway. > + if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") > + add_link_options("-Wl,-undefined,error") > + else() > Index: pkg/PLIST > === > RCS file: /cvs/ports/graphics/glslang/pkg/PLIST,v > retrieving revision 1.6 > diff -u -p -u -p -r1.6 PLIST > --- pkg/PLIST 3 Mar 2023 02:38:37 - 1.6 > +++ pkg/PLIST 30 Apr 2023 03:18:50 - > @@ -72,8 +72,6 @@ include/glslang/SPIRV/spvIR.h >
Re: graphics/glslang build shared libs
> Thomas Frohwein writes: > >> On Tue, Apr 18, 2023 at 06:41:50PM -0700, Nam Nguyen wrote: >> Do you have some details on this? Is this an upstream error, that >> that --no-undefined is wrong when building the shared library? Or is >> there something that might not be compiling or linking correctly? Brad upstreamed a fix recently for removing --no-undefined, included in this new diff. see: https://github.com/KhronosGroup/glslang/commit/9c7fd1a33e5cecbe465e1cd70170167d5e40d398 Here is a new inline diff that: - backports Brad's fix for removing --no-undefined when building shared libraries - builds shared libraries naddy uncovered a build failure with emulators/flycast. I will have details in the flycast email, but the proposed solution is to build shared libraries in graphics/glslang so that flycast can use libSPIRV.so and libglslang.so.0.0. >>> +@so lib/libHLSL.so >>> +@so lib/libSPIRV.so >>> +@so lib/libSPVRemapper.so >>> +@so lib/libglslang-default-resource-limits.so >>> +@lib lib/libglslang.so.${LIBglslang_VERSION} Having shared libraries without semantic versioning might be fine? Upstream seems to only want to add semantic versioning to the main library, libglslang.so.0.0. see: https://github.com/KhronosGroup/glslang/commit/fbe9a23baf2cb020fe3f80d68d972e2a97d9b954 I successfully tested all consumers (vulkan-tools, vkquake and piglit) again. OK? Index: Makefile === RCS file: /cvs/ports/graphics/glslang/Makefile,v retrieving revision 1.16 diff -u -p -u -p -r1.16 Makefile --- Makefile10 Mar 2023 22:28:49 - 1.16 +++ Makefile30 Apr 2023 03:18:50 - @@ -5,7 +5,9 @@ COMMENT = reference front-end for GLSL a GH_TAGNAME = 12.0.0 GH_ACCOUNT = KhronosGroup GH_PROJECT = glslang -REVISION = 0 +REVISION = 1 + +SHARED_LIBS += glslang 0.0 # 12.0 CATEGORIES = devel graphics @@ -24,6 +26,8 @@ MODULES = devel/cmake \ lang/python TEST_DEPENDS = graphics/spirv-tools \ shells/bash + +CONFIGURE_ARGS += -DBUILD_SHARED_LIBS=ON do-test: cd ${WRKSRC}/Test; exec ./runtests localResults \ Index: patches/patch-CMakeLists_txt === RCS file: patches/patch-CMakeLists_txt diff -N patches/patch-CMakeLists_txt --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-CMakeLists_txt30 Apr 2023 03:18:50 - @@ -0,0 +1,38 @@ +Fix building on OpenBSD when building shared libs + +OpenBSD does not link shared libs against libc so it is expected +that the use of --no-undefined when linking will fail. + +Also garbage collect CMAKE_VERSION check while here, as requested, since +the minimum version is already 3.14. + +see: +https://github.com/KhronosGroup/glslang/commit/9c7fd1a33e5cecbe465e1cd70170167d5e40d398 + +Index: CMakeLists.txt +--- CMakeLists.txt.orig CMakeLists.txt +@@ -171,10 +171,8 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") + add_compile_options(-Werror=deprecated-copy) + endif() + +-if(NOT CMAKE_VERSION VERSION_LESS "3.13" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") ++if(NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") + # Error if there's symbols that are not found at link time. +-# add_link_options() was added in CMake 3.13 - if using an earlier +-# version don't set this - it should be caught by presubmits anyway. + add_link_options("-Wl,--no-undefined") + endif() + elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC) +@@ -188,10 +186,8 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NO + add_compile_options(-fno-exceptions) + endif() + +-if(NOT CMAKE_VERSION VERSION_LESS "3.13") ++if(NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") + # Error if there's symbols that are not found at link time. +-# add_link_options() was added in CMake 3.13 - if using an earlier +-# version don't set this - it should be caught by presubmits anyway. + if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + add_link_options("-Wl,-undefined,error") + else() Index: pkg/PLIST === RCS file: /cvs/ports/graphics/glslang/pkg/PLIST,v retrieving revision 1.6 diff -u -p -u -p -r1.6 PLIST --- pkg/PLIST 3 Mar 2023 02:38:37 - 1.6 +++ pkg/PLIST 30 Apr 2023 03:18:50 - @@ -72,8 +72,6 @@ include/glslang/SPIRV/spvIR.h include/glslang/build_info.h lib/cmake/ lib/cmake/HLSLTargets.cmake -lib/cmake/OGLCompilerTargets.cmake -lib/cmake/OSDependentTargets.cmake lib/cmake/SPIRVTargets.cmake lib/cmake/SPVRemapperTargets.cmake lib/cmake/glslang/ @@ -82,15 +80,10 @@ lib/cmake/glslang/glslang-config-version lib/cmake/glslang/glslang-config.cmake lib/cmake/glslang/glslang-targets${MODCMAKE_BUILD_SUFFIX} lib/cmake/glslang/glslang-targets.cmake
Re: graphics/glslang build shared libs
This glslang diff is no longer necessary. I'll build flycast so that it bundles glslang, which it does by default. This will make it easier to review. The rest of the email can be skipped, but I reported some findings inline. Thomas Frohwein writes: > On Tue, Apr 18, 2023 at 06:41:50PM -0700, Nam Nguyen wrote: > Do you have some details on this? Is this an upstream error, that > that --no-undefined is wrong when building the shared library? Or is > there something that might not be compiling or linking correctly? > While trying to compile libglslang-default-resource-limits.so, it complains about functions like strlen, memcpy, atoi, etc. It seems like ld.lld(1) defaults to --allow-shlib-undefined by default, so it's fine to have shared libraries with undefined symbols. Your suggested ifndef BUILD_SHARED_LIBS could be used here. --8<---cut here---start->8--- [28/48] : && /usr/obj/pobj/glslang-12.0.0/bin/c++ -fPIC -O2 -pipe -DNDEBUG -Wl,--no-undefined -shared -Wl,-soname,libglslang-default-resource-limits.so -o StandAlone/libglslang-default-resource-limits.so StandAlone/CMakeFiles/glslang-defa FAILED: StandAlone/libglslang-default-resource-limits.so : && /usr/obj/pobj/glslang-12.0.0/bin/c++ -fPIC -O2 -pipe -DNDEBUG -Wl,--no-undefined -shared -Wl,-soname,libglslang-default-resource-limits.so -o StandAlone/libglslang-default-resource-limits.so StandAlone/CMakeFiles/glslang-default-reso ld: error: undefined symbol: strlen >>> referenced by ResourceLimits.cpp >>> >>> StandAlone/CMakeFiles/glslang-default-resource-limits.dir/ResourceLimits.cpp.o:(DecodeResourceLimits(TBuiltInResource*, >>> char*)) similar for memcpy and atoi --8<---cut here---end--->8--- >> ok? > > Still ok thfr@ as this doesn't break anything existing and apparently > enables flycast, but it would be good to think about the above and if > upstream got this wrong, then let's think about a diff with something > like > > #ifndef BUILD_BUILD_LIBS > ... > #endif >> +@so lib/libHLSL.so >> +@so lib/libSPIRV.so >> +@so lib/libSPVRemapper.so >> +@so lib/libglslang-default-resource-limits.so >> +@lib lib/libglslang.so.${LIBglslang_VERSION} I found another mistake with my diff's shared libs. It would have installed these .so files missing major.minor numbers into /usr/local/lib. I would have had to figure out how to use libHLSL.so as libHLSL.so.0.0. It would cause more maintenance for graphics/glslang. It probably is not worth it, since flycast can use its bundled glslang for now.
Re: graphics/glslang build shared libs
On Tue, Apr 18, 2023 at 06:41:50PM -0700, Nam Nguyen wrote: > > Here is a diff to build shared libraries for glslang. This shared lib > glslang will be used by emulators/flycast. > > I checked consumers graphics/vulkan-tools and graphics/piglit and they > both build and run. I tested building and running vulkan-tools only; can confirm this still builds and runs. > -Wl,--no-undefined is removed to avoid compiler error about missing > functions. Do you have some details on this? Is this an upstream error, that that --no-undefined is wrong when building the shared library? Or is there something that might not be compiling or linking correctly? > ok? Still ok thfr@ as this doesn't break anything existing and apparently enables flycast, but it would be good to think about the above and if upstream got this wrong, then let's think about a diff with something like #ifndef BUILD_BUILD_LIBS ... #endif > > Index: Makefile > === > RCS file: /cvs/ports/graphics/glslang/Makefile,v > retrieving revision 1.16 > diff -u -p -u -p -r1.16 Makefile > --- Makefile 10 Mar 2023 22:28:49 - 1.16 > +++ Makefile 19 Apr 2023 01:34:44 - > @@ -5,7 +5,9 @@ COMMENT = reference front-end for GLSL a > GH_TAGNAME = 12.0.0 > GH_ACCOUNT = KhronosGroup > GH_PROJECT = glslang > -REVISION = 0 > +REVISION = 1 > + > +SHARED_LIBS += glslang 0.0 # 0.0 > > CATEGORIES = devel graphics > > @@ -24,6 +26,8 @@ MODULES = devel/cmake \ > lang/python > TEST_DEPENDS = graphics/spirv-tools \ > shells/bash > + > +CONFIGURE_ARGS +=-DBUILD_SHARED_LIBS=ON > > do-test: > cd ${WRKSRC}/Test; exec ./runtests localResults \ > Index: patches/patch-CMakeLists_txt > === > RCS file: patches/patch-CMakeLists_txt > diff -N patches/patch-CMakeLists_txt > --- /dev/null 1 Jan 1970 00:00:00 - > +++ patches/patch-CMakeLists_txt 19 Apr 2023 01:34:44 - > @@ -0,0 +1,11 @@ > +Index: CMakeLists.txt > +--- CMakeLists.txt.orig > CMakeLists.txt > +@@ -195,7 +195,6 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NO > + if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") > + add_link_options("-Wl,-undefined,error") > + else() > +-add_link_options("-Wl,--no-undefined") > + endif() > + endif() > + elseif(MSVC) > Index: pkg/PLIST > === > RCS file: /cvs/ports/graphics/glslang/pkg/PLIST,v > retrieving revision 1.6 > diff -u -p -u -p -r1.6 PLIST > --- pkg/PLIST 3 Mar 2023 02:38:37 - 1.6 > +++ pkg/PLIST 19 Apr 2023 01:34:44 - > @@ -72,8 +72,6 @@ include/glslang/SPIRV/spvIR.h > include/glslang/build_info.h > lib/cmake/ > lib/cmake/HLSLTargets.cmake > -lib/cmake/OGLCompilerTargets.cmake > -lib/cmake/OSDependentTargets.cmake > lib/cmake/SPIRVTargets.cmake > lib/cmake/SPVRemapperTargets.cmake > lib/cmake/glslang/ > @@ -82,15 +80,10 @@ lib/cmake/glslang/glslang-config-version > lib/cmake/glslang/glslang-config.cmake > lib/cmake/glslang/glslang-targets${MODCMAKE_BUILD_SUFFIX} > lib/cmake/glslang/glslang-targets.cmake > -lib/cmake/glslangTargets.cmake > lib/cmake/glslangValidatorTargets.cmake > lib/cmake/spirv-remapTargets.cmake > -@static-lib lib/libGenericCodeGen.a > -@static-lib lib/libHLSL.a > -@static-lib lib/libMachineIndependent.a > -@static-lib lib/libOGLCompiler.a > -@static-lib lib/libOSDependent.a > -@static-lib lib/libSPIRV.a > -@static-lib lib/libSPVRemapper.a > -@static-lib lib/libglslang-default-resource-limits.a > -@static-lib lib/libglslang.a > +@so lib/libHLSL.so > +@so lib/libSPIRV.so > +@so lib/libSPVRemapper.so > +@so lib/libglslang-default-resource-limits.so > +@lib lib/libglslang.so.${LIBglslang_VERSION}