Patchwork [2,of,3] rust-cpython: fix build for MacOSX

login
register
mail settings
Submitter Georges Racinet
Date June 14, 2019, 10:42 a.m.
Message ID <2cbfd089a1ce0ec46f9e.1560508940@ishtar>
Download mbox | patch
Permalink /patch/40506/
State Accepted
Headers show

Comments

Georges Racinet - June 14, 2019, 10:42 a.m.
# HG changeset patch
# User Georges Racinet <georges.racinet@octobus.net>
# Date 1560507486 -3600
#      Fri Jun 14 11:18:06 2019 +0100
# Node ID 2cbfd089a1ce0ec46f9e124e0574e74491fa4788
# Parent  559b63fe9ffeabb43c7d5322a53ad6defa718fb1
# EXP-Topic rust-build-platforms
rust-cpython: fix build for MacOSX

MacOSX needs special link flags. Quoting the README of rust-cpython:

  create a `.cargo/config` with the following content:

  ```
  [target.x86_64-apple-darwin]
  rustflags = [
    "-C", "link-arg=-undefined",
    "-C", "link-arg=dynamic_lookup",
  ]
  ```

This is tested with Python 2.7 (Anaconda install) and Python 3
(Homebrew install)

Patch

diff -r 559b63fe9ffe -r 2cbfd089a1ce setup.py
--- a/setup.py	Fri Jun 14 10:57:07 2019 +0100
+++ b/setup.py	Fri Jun 14 11:18:06 2019 +0100
@@ -1199,6 +1199,9 @@ 
         if sys.version_info[0] == 3 and self.py3_features is not None:
             cargocmd.extend(('--features', self.py3_features,
                              '--no-default-features'))
+        if sys.platform == 'darwin':
+            env['RUSTFLAGS'] = ("-C link-arg=-undefined "
+                                "-C link-arg=dynamic_lookup")
         try:
             subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir)
         except OSError as exc: