Skip to content

mpdecimal: Enable build on Apple Silicon (M1) #8603

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

Merged
merged 5 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion recipes/mpdecimal/2.4.2/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def _source_subfolder(self):
_autotools = None

def configure(self):
if self.settings.arch not in ("x86", "x86_64"):
if self.settings.os != "Macos" and self.settings.arch not in ("x86", "x86_64"):
raise ConanInvalidConfiguration("Arch is unsupported")
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.options.shared:
del self.options.fPIC

def config_options(self):
if self.settings.os == "Windows":
Expand Down Expand Up @@ -161,6 +163,8 @@ def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
if self.settings.os == "Macos" and self.settings.arch == "armv8":
self._autotools.link_flags.append("-arch arm64")
self._autotools .configure()
return self._autotools

Expand Down
8 changes: 6 additions & 2 deletions recipes/mpdecimal/2.5.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def build_requirements(self):
self.build_requires("msys2/cci.latest")

def validate(self):
if self.settings.arch not in ("x86", "x86_64"):
if self.settings.os != "Macos" and self.settings.arch not in ("x86", "x86_64"):
raise ConanInvalidConfiguration("Arch is unsupported")
if self.options.cxx:
if self.options.shared and self.settings.os == "Windows":
Expand Down Expand Up @@ -123,10 +123,14 @@ def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
conf_vars = self._autotools.vars
if self.settings.os == "Macos" and self.settings.arch == "armv8":
conf_vars["LDFLAGS"] += " -arch arm64"
conf_vars["LDXXFLAGS"] = "-arch arm64"
conf_args = [
"--enable-cxx" if self.options.cxx else "--disable-cxx"
]
self._autotools.configure(args=conf_args)
self._autotools.configure(args=conf_args, vars=conf_vars)
return self._autotools

@property
Expand Down
5 changes: 5 additions & 0 deletions recipes/mpdecimal/2.5.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ project(test_package)
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup(TARGETS)

# Workaround for -rpath on arm64: https://cmake.org/cmake/help/latest/release/3.20.html#id2
if(CMAKE_VERSION VERSION_LESS "3.20.1" AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
Copy link
Contributor

Choose a reason for hiding this comment

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

usually we just require a hire CMake version but this is good to know

set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
endif()

# This is a non-official mpdecimal module!
find_package(mpdecimal REQUIRED)

Expand Down