Skip to content

Commit 8882738

Browse files
authored
gmp: windows arm64 fixes (#28810)
* gmp: windows arm64 fixes * gmp: fix crossbuilding on macos
1 parent 5d3d03d commit 8882738

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

recipes/gmp/all/conanfile.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from conan import ConanFile
22
from conan.errors import ConanInvalidConfiguration
33
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os
4-
from conan.tools.files import copy, export_conandata_patches, get, patch, rm, rmdir
4+
from conan.tools.build import cross_building
5+
from conan.tools.files import copy, export_conandata_patches, get, patch, replace_in_file, rm, rmdir
56
from conan.tools.gnu import Autotools, AutotoolsToolchain
67
from conan.tools.layout import basic_layout
78
from conan.tools.microsoft import check_min_vs, is_msvc, unix_path
@@ -78,8 +79,9 @@ def build_requirements(self):
7879
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
7980
self.tool_requires("msys2/cci.latest")
8081
if is_msvc(self):
81-
self.tool_requires("yasm/1.3.0") # Needed for determining 32-bit word size
8282
self.tool_requires("automake/1.16.5") # Needed for lib-wrapper
83+
if self.settings.arch in ["x86", "x86_64"]:
84+
self.tool_requires("yasm/1.3.0") # Needed for determining 32-bit word size
8385

8486
def source(self):
8587
get(self, **self.conan_data["sources"][self.version], strip_root=True)
@@ -110,11 +112,12 @@ def generate(self):
110112
yasm_machine = {
111113
"x86": "x86",
112114
"x86_64": "amd64",
113-
}[str(self.settings.arch)]
115+
}.get(str(self.settings.arch), None)
114116
ar_wrapper = unix_path(self, self.conf.get("user.automake:lib-wrapper"))
115117
dumpbin_nm = unix_path(self, os.path.join(self.source_folder, "dumpbin_nm.py"))
116118
env.define("CC", "cl -nologo")
117-
env.define("CCAS", f"{yasm_wrapper} -a x86 -m {yasm_machine} -p gas -r raw -f win32 -g null -X gnu")
119+
if yasm_machine:
120+
env.define("CCAS", f"{yasm_wrapper} -a x86 -m {yasm_machine} -p gas -r raw -f win32 -g null -X gnu")
118121
env.define("CXX", "cl -nologo")
119122
env.define("LD", "link -nologo")
120123
env.define("AR", f'{ar_wrapper} "lib -nologo"')
@@ -142,6 +145,11 @@ def build(self):
142145
self._patch_sources()
143146
autotools = Autotools(self)
144147
autotools.configure()
148+
if self.settings.os == "Macos" and cross_building(self):
149+
# LD flags are not passed properly by the scripts - in particular '-arch x86_64' when crossbuilding
150+
# and invoking libtool to generate one of the libraries. Being conservative here, but there's a chance
151+
# this may need to be generalised
152+
replace_in_file(self, os.path.join(self.build_folder, "libtool"), 'archive_cmds="\$CC ', 'archive_cmds="\$CC $LDFLAGS ')
145153
autotools.make()
146154
# INFO: According to the gmp readme file, make check should not be omitted, but it causes timeouts on the CI server.
147155
if self.options.run_checks:

0 commit comments

Comments
 (0)