Skip to content

Difficult to cross-compile (e.g. Yocto) #104

Closed
@cmcqueen

Description

@cmcqueen
  • uvloop version: 0.8.0
  • Python version: 3.5.2
  • Platform: Cross-compile build using Yocto for BeagleBone Black (ARM)
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: N/A

I am trying to make a Yocto bitbake recipe to build uvloop. At the build_ext step it gives an error for the libuv ./configure call, saying for cross-compilation it needs the --host parameter specified.

It might be possible to use the --use-system-libuv option, but at the moment Yocto doesn't support custom options for the build_ext step.

I applied the following patch to work around this:

From 56604f7720089da7d9afd43825fc29f006a0e4bf Mon Sep 17 00:00:00 2001
From: Craig McQueen <craig.mcqueen@innerrange.com>
Date: Thu, 31 Aug 2017 16:31:17 +1000
Subject: [PATCH] Allow for cross-compile of libuv

If HOST_SYS environment variable is defined, then call ./configure with
--host parameter set to HOST_SYS value.
---
 setup.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index ae9a65a..ad474e8 100644
--- a/setup.py
+++ b/setup.py
@@ -226,8 +226,12 @@ class uvloop_build_ext(build_ext):
              'Makefile.am', 'Makefile.in'],
             cwd=LIBUV_BUILD_DIR, env=env, check=True)
 
+        if 'HOST_SYS' in env:
+            cmd = ['./configure', '--host=' + env['HOST_SYS']]
+        else:
+            cmd = ['./configure']
         subprocess.run(
-            ['./configure'],
+            cmd,
             cwd=LIBUV_BUILD_DIR, env=env, check=True)
 
         j_flag = '-j{}'.format(os.cpu_count() or 1)
-- 
2.14.1

But then I had another problem, which is when I tried to import uvloop, I got an error regarding an unresolved symbol pthread_atfork. I used the following patch to resolve this:

From abb18a622d5c3c341fd64da46b243d2734cbe2c8 Mon Sep 17 00:00:00 2001
From: Craig McQueen <craig.mcqueen@innerrange.com>
Date: Thu, 31 Aug 2017 17:25:13 +1000
Subject: [PATCH] Specify pthread library dependency for uvloop.loop extension

---
 setup.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/setup.py b/setup.py
index ad474e8..3eed39e 100644
--- a/setup.py
+++ b/setup.py
@@ -293,6 +293,9 @@ setup(
             sources=[
                 "uvloop/loop.pyx",
             ],
+            libraries=[
+                "pthread",
+            ],
             extra_compile_args=CFLAGS
         ),
     ],
-- 
2.14.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions