Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ginkgo: disable autodiscovery of ccache + fix build of 1.7.0 with msvc & C++20 #21626

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
12 changes: 8 additions & 4 deletions recipes/ginkgo/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@ sources:
sha256: "1b0e907b4046cdf7cef16d1730c12ba812b38f2764f49f74f454239a27f63596"
patches:
"1.7.0":
- patch_file: "patches/libc++-chrono.patch"
- patch_file: "patches/1.7.0-0001-libc++-chrono.patch"
patch_type: "official"
patch_description: "Fix for std::chrono incompatibility with libc++"
patch_source: "https://github.com/ginkgo-project/ginkgo/pull/1463"
- patch_file: "patches/1.7.0-0002-msvc-c++20.patch"
patch_type: "portability"
patch_description: "Fix compilation with Visual Studio and C++20"
patch_source: "https://github.com/ginkgo-project/ginkgo/pull/1496"
"1.4.0":
- patch_file: "patches/windows-symbols.patch"
- patch_file: "patches/1.4.0-0001-windows-symbols.patch"
patch_type: "official"
patch_description: "Fix for excessive link symbol count with MSVC"
patch_source: "https://github.com/ginkgo-project/ginkgo/pull/868"
"1.3.0":
- patch_file: "patches/cmake-fixes.patch"
- patch_file: "patches/1.3.0-0001-cmake-fixes.patch"
patch_type: "official"
patch_description: "Fixes for CMake issues"
patch_source: "https://github.com/ginkgo-project/ginkgo/pull/713, https://github.com/ginkgo-project/ginkgo/pull/720"
- patch_file: "patches/windows-iterator.patch"
- patch_file: "patches/1.3.0-0002-windows-iterator.patch"
patch_type: "official"
patch_description: "Fixes for MSVC compatibility"
patch_source: "https://github.com/ginkgo-project/ginkgo/pull/665"
63 changes: 63 additions & 0 deletions recipes/ginkgo/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,58 @@ def build_requirements(self):
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def _get_visual_generator(self):
compiler_version = str(self.settings.compiler.version)

if self.settings.compiler == "msvc":
toolset_override = self.conf.get("tools.microsoft.msbuild:vs_version", check_type=str)
if toolset_override:
visual_version = toolset_override
else:
visual_version = {
"170": "11",
"180": "12",
"190": "14",
"191": "15",
"192": "16",
"193": "17",
}[compiler_version]
else:
visual_version = compiler_version

visual_gen_suffix = {
"8": "8 2005",
"9": "9 2008",
"10": "10 2010",
"11": "11 2012",
"12": "12 2013",
"14": "14 2015",
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
"15": "15 2017",
"16": "16 2019",
"17": "17 2022",
}[visual_version]

return f"Visual Studio {visual_gen_suffix}"

def generate(self):
tc = CMakeToolchain(self)

# Since 1.5.0, force MSBuild generator if:
# - msvc & shared
# - user has set tools.cmake.cmaketoolchain:generator to Ninja
# It's a workaround for LINK : fatal error LNK1189: library limit of 65535 objects exceeded
# See https://github.com/ginkgo-project/ginkgo/issues/1495#issuecomment-1841983036
# and https://github.com/microsoft/vcpkg/pull/34280#discussion_r1351515284
if Version(self.version) >= "1.5.0" and is_msvc(self) and self.options.shared:
if self.conf.get("tools.cmake.cmaketoolchain:generator") == "Ninja":
visual_generator = self._get_visual_generator()
self.output.warning(
f"You asked for Ninja generator, but fallback to {visual_generator}, "
"otherwise it will fail during creation of DLL with "
"LINK : fatal error LNK1189: library limit of 65535 objects exceeded"
)
Comment on lines +156 to +160
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it now, this might be confussing behaviour - were there any objetctions to raising in validate() for this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a consumer I consider that CMake generator is a wish for an internal detail and has no impact on produced binaries, so I don't care if it's not honored. I prefer a simple conan install command so that it can work out of the box, instead of "die and retry" iterations in order to find correct conan command to install my dependencies.

So sure we could raise, but I believe it would be a bad user experience.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tc.generator = visual_generator

tc.variables["GINKGO_BUILD_TESTS"] = False
tc.variables["GINKGO_BUILD_EXAMPLES"] = False
tc.variables["GINKGO_BUILD_BENCHMARKS"] = False
Expand All @@ -117,6 +167,8 @@ def generate(self):
tc.variables["GINKGO_BUILD_DPCPP"] = False
tc.variables["GINKGO_BUILD_HWLOC"] = False
tc.variables["GINKGO_BUILD_MPI"] = False
if Version(self.version) >= "1.4.0":
tc.variables["GINKGO_WITH_CCACHE"] = False
tc.generate()

def build(self):
Expand Down Expand Up @@ -167,6 +219,13 @@ def package_info(self):
self.cpp_info.components["ginkgo_reference"].libs = [
"ginkgo_reference" + debug_suffix]

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["ginkgo_core"].system_libs.append("m")
self.cpp_info.components["ginkgo_cuda"].system_libs.append("m")
self.cpp_info.components["ginkgo_omp"].system_libs.append("m")
self.cpp_info.components["ginkgo_hip"].system_libs.append("m")
self.cpp_info.components["ginkgo_reference"].system_libs.append("m")

if has_dpcpp_device: # Always add these components
# See https://github.com/conan-io/conan-center-index/pull/7044#discussion_r698181588
self.cpp_info.components["ginkgo_core"].requires += ["ginkgo_dpcpp"]
Expand All @@ -180,6 +239,10 @@ def package_info(self):
self.cpp_info.components["ginkgo_device"].libs = [
"ginkgo_device" + debug_suffix]

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["ginkgo_dpcpp"].system_libs.append("m")
self.cpp_info.components["ginkgo_device"].system_libs.append("m")

self.cpp_info.components["ginkgo_omp"].requires += [
"ginkgo_dpcpp", "ginkgo_device"]
self.cpp_info.components["ginkgo_reference"].requires += ["ginkgo_device"]
Expand Down
12 changes: 12 additions & 0 deletions recipes/ginkgo/all/patches/1.7.0-0002-msvc-c++20.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- a/include/ginkgo/core/base/std_extensions.hpp
+++ b/include/ginkgo/core/base/std_extensions.hpp
@@ -73,7 +73,8 @@ using void_t = typename detail::make_void<Ts...>::type;
// Disable deprecation warnings when using standard > C++14
inline bool uncaught_exception() noexcept
{
-#if __cplusplus > 201402L
+// MSVC uses _MSVC_LANG as __cplusplus
+#if (defined(_MSVC_LANG) && _MSVC_LANG > 201402L) || __cplusplus > 201402L
return std::uncaught_exceptions() > 0;
#else
return std::uncaught_exception();