Skip to content

Commit 03ad856

Browse files
messensedavidhewitt
authored andcommitted
Always try to detect cross compiling on *NIX systems
1 parent 84592ef commit 03ad856

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ jobs:
193193
cross-expose cffi
194194
pip install wheel
195195
pip install -e ../../
196-
unset CARGO_BUILD_TARGET
197196
python setup.py bdist_wheel --py-limited-api=cp36
198197
ls -la dist/
199198
' > build-wheels.sh

setuptools_rust/build.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
)
2828

2929

30+
3031
class _TargetInfo:
3132
def __init__(self, triple=None, cross_lib=None, linker=None, link_args=None):
3233
self.triple = triple
@@ -88,9 +89,7 @@ def get_target_info(self):
8889
# we'll target a 32-bit Rust build.
8990
# Automatic target detection can be overridden via the CARGO_BUILD_TARGET
9091
# environment variable or --target command line option
91-
if self.target:
92-
return _TargetInfo(self.target)
93-
elif self.plat_name == "win32":
92+
if self.plat_name == "win32":
9493
return _TargetInfo("i686-pc-windows-msvc")
9594
elif self.plat_name == "win-amd64":
9695
return _TargetInfo("x86_64-pc-windows-msvc")
@@ -111,7 +110,7 @@ def get_nix_target_info(self):
111110

112111
if not host_type or host_type == build_type:
113112
# not *NIX, or not cross compiling
114-
return _TargetInfo()
113+
return _TargetInfo(self.target)
115114

116115
stdlib = sysconfig.get_path("stdlib")
117116
cross_lib = os.path.dirname(stdlib)
@@ -128,6 +127,7 @@ def get_nix_target_info(self):
128127
# hopefully an exact match
129128
targets = get_rust_target_list()
130129
if host_type in targets:
130+
# FIXME: what if self.target != host_type
131131
return _TargetInfo(host_type, cross_lib, linker, linker_args)
132132

133133
# the vendor field can be ignored, so x86_64-pc-linux-gnu is compatible
@@ -137,8 +137,12 @@ def get_nix_target_info(self):
137137
components[1] = "unknown"
138138
host_type2 = "-".join(components)
139139
if host_type2 in targets:
140+
# FIXME: what if self.target != host_type2
140141
return _TargetInfo(host_type2, cross_lib, linker, linker_args)
141142

143+
if self.target:
144+
return _TargetInfo(self.target, cross_lib)
145+
142146
raise DistutilsPlatformError(
143147
"Don't know the correct rust target for system type %s. Please "
144148
"set the CARGO_BUILD_TARGET environment variable." % host_type

0 commit comments

Comments
 (0)