Skip to content

Commit

Permalink
[mdl-sdk] Workaround broken gcc-11 <bit> (#32008)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal committed Jun 15, 2023
1 parent dc6188d commit 1f47615
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
13 changes: 13 additions & 0 deletions ports/mdl-sdk/010-workaround-gcc-bit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/include/mi/base/types.h b/include/mi/base/types.h
index a6faabe..47f836b 100644
--- a/include/mi/base/types.h
+++ b/include/mi/base/types.h
@@ -349,7 +349,7 @@ namespace {
/// float fval( 0.0f );
/// Uint32 uval( binary_cast<Uint32>(fval) );
/// \endcode
-#if (defined(_WIN32) && defined(_HAS_CXX20) && _HAS_CXX20) || (defined(__GNUC__) && (__GNUC__ >= 11 ))
+#if (defined(_WIN32) && defined(_HAS_CXX20) && _HAS_CXX20) || (defined(__GNUC__) && (__GNUC__ >= 12 ))
#include <bit>
template<class T, class S> constexpr T binary_cast(const S& src) noexcept { return std::bit_cast<T,S>(src); }
#else
20 changes: 20 additions & 0 deletions ports/mdl-sdk/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ endif()

# MDL-SDK

# The patch "workaround gcc bit" works around <bit> included with gcc included with Ubuntu 22.04
# failing to compile as used here, with errors originating *inside* <bit> like:
# [156/1742] /usr/bin/c++ -DBIT64=1 -DDEBUG -DHAS_SSE -DMDL_SOURCE_RELEASE -DMI_PLATFORM=\"linux-x86-64-gcc\" -DMI_PLATFORM_UNIX -DX86=1 -D_DEBUG -I/home/bion/vcpkg/buildtrees/mdl-sdk/x64-linux-dbg/src/base/system/main -I/home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/src/base/system/main -I/home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/include -I/home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/src -fPIC -g -fPIC -fno-strict-aliasing -march=nocona -gdwarf-3 -gstrict-dwarf -Wall -Wvla -Wno-init-list-lifetime -Wno-placement-new -Wno-parentheses -Wno-sign-compare -Wno-narrowing -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Wno-deprecated-declarations -Wno-unknown-pragmas -std=gnu++17 -MD -MT src/base/system/main/CMakeFiles/base-system-main.dir/module_registration_entry.cpp.o -MF src/base/system/main/CMakeFiles/base-system-main.dir/module_registration_entry.cpp.o.d -o src/base/system/main/CMakeFiles/base-system-main.dir/module_registration_entry.cpp.o -c /home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/src/base/system/main/module_registration_entry.cpp
# FAILED: src/base/system/main/CMakeFiles/base-system-main.dir/module_registration_entry.cpp.o
# /usr/bin/c++ -DBIT64=1 -DDEBUG -DHAS_SSE -DMDL_SOURCE_RELEASE -DMI_PLATFORM=\"linux-x86-64-gcc\" -DMI_PLATFORM_UNIX -DX86=1 -D_DEBUG -I/home/bion/vcpkg/buildtrees/mdl-sdk/x64-linux-dbg/src/base/system/main -I/home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/src/base/system/main -I/home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/include -I/home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/src -fPIC -g -fPIC -fno-strict-aliasing -march=nocona -gdwarf-3 -gstrict-dwarf -Wall -Wvla -Wno-init-list-lifetime -Wno-placement-new -Wno-parentheses -Wno-sign-compare -Wno-narrowing -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Wno-deprecated-declarations -Wno-unknown-pragmas -std=gnu++17 -MD -MT src/base/system/main/CMakeFiles/base-system-main.dir/module_registration_entry.cpp.o -MF src/base/system/main/CMakeFiles/base-system-main.dir/module_registration_entry.cpp.o.d -o src/base/system/main/CMakeFiles/base-system-main.dir/module_registration_entry.cpp.o -c /home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/src/base/system/main/module_registration_entry.cpp
# In file included from /home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/src/base/system/main/types.h:37,
# from /home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/src/base/system/main/module_registration_entry.h:39,
# from /home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/src/base/system/main/module_registration_entry.cpp:34:
# /home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/include/mi/base/types.h: In function ‘constexpr T mi::base::binary_cast(const S&)’:
# /home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/include/mi/base/types.h:356:89: error: ‘bit_cast’ is not a member of ‘mi::base::std’
# 356 | template<class T, class S> constexpr T binary_cast(const S& src) noexcept { return std::bit_cast<T,S>(src); }
# | ^~~~~~~~
# /home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/include/mi/base/types.h:356:99: error: expected primary-expression before ‘,’ token
# 356 | template<class T, class S> constexpr T binary_cast(const S& src) noexcept { return std::bit_cast<T,S>(src); }
# | ^
# /home/bion/vcpkg/buildtrees/mdl-sdk/src/830ab63109-115b19fca8/include/mi/base/types.h:356:101: error: expected primary-expression before ‘>’ token
# 356 | template<class T, class S> constexpr T binary_cast(const S& src) noexcept { return std::bit_cast<T,S>(src); }
# | ^

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO NVIDIA/MDL-SDK
Expand All @@ -81,6 +100,7 @@ vcpkg_from_github(
007-plugin-options.patch
008-build-static-llvm.patch
009-include-priority-vendored-llvm.patch
010-workaround-gcc-bit.patch
)

string(COMPARE NOTEQUAL "${VCPKG_CRT_LINKAGE}" "static" _MVSC_CRT_LINKAGE_OPTION)
Expand Down
1 change: 1 addition & 0 deletions ports/mdl-sdk/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "mdl-sdk",
"version": "2021.1.2",
"port-version": 1,
"description": "NVIDIA Material Definition Language SDK",
"homepage": "https://github.com/NVIDIA/MDL-SDK",
"license": "BSD-3-Clause",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5202,7 +5202,7 @@
},
"mdl-sdk": {
"baseline": "2021.1.2",
"port-version": 0
"port-version": 1
},
"mdns": {
"baseline": "1.4.2",
Expand Down
5 changes: 5 additions & 0 deletions versions/m-/mdl-sdk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "7b540090b50df32e1bdcab5953994590e0fb37bd",
"version": "2021.1.2",
"port-version": 1
},
{
"git-tree": "1ea6f971b1824f51c7beed4983f54733b24f1bed",
"version": "2021.1.2",
Expand Down

0 comments on commit 1f47615

Please sign in to comment.