Skip to content

Commit

Permalink
sol2: Fix a bug building with clang-19 (#26383)
Browse files Browse the repository at this point in the history
* sol2: Fix a bug with clang-19

ThePhD/sol2@d805d02
ThePhD/sol2#1617

* apply_conandata_patches on source method

---------

Co-authored-by: Ernesto de Gracia Herranz <ernestodgh@jfrog.com>
  • Loading branch information
miklelappo and ErniGH authored Jan 15, 2025
1 parent 628fdb7 commit 127b2d0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions recipes/sol2/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ sources:
"2.20.6":
url: "https://github.com/ThePhD/sol2/archive/v2.20.6.tar.gz"
sha256: "90c72e120cdd67d516434b51fdcff2d63cc25afe06fb7866fcf7f5bc85366808"

patches:
"3.3.1":
- patch_file: patches/0001-Fix-emplace.patch
9 changes: 5 additions & 4 deletions recipes/sol2/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conan.tools.files import apply_conandata_patches, copy, get, export_conandata_patches
from conan.tools.layout import basic_layout
from conan.tools.scm import Version

Expand Down Expand Up @@ -58,6 +58,9 @@ def _compilers_minimum_version(self):
},
}.get(self._min_cppstd, {})

def export_sources(self):
export_conandata_patches(self)

def layout(self):
basic_layout(self, src_folder="src")

Expand Down Expand Up @@ -92,9 +95,7 @@ def loose_lt_semver(v1, v2):

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def build(self):
pass
apply_conandata_patches(self)

def package(self):
copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
Expand Down
14 changes: 14 additions & 0 deletions recipes/sol2/all/patches/0001-Fix-emplace.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/include/sol/optional_implementation.hpp b/include/sol/optional_implementation.hpp
index 26f41d0c..e22226d6 100644
--- a/include/sol/optional_implementation.hpp
+++ b/include/sol/optional_implementation.hpp
@@ -2191,7 +2191,8 @@ namespace sol {
static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args");

*this = nullopt;
- this->construct(std::forward<Args>(args)...);
+ new (static_cast<void*>(this)) optional(std::in_place, std::forward<Args>(args)...);
+ return **this;
}

/// Swaps this optional with the other.

0 comments on commit 127b2d0

Please sign in to comment.