Skip to content

Commit 3466319

Browse files
jdKyle-Verhoog
authored andcommitted
fix(profiling): allow to build on Alpine Linux (#1391)
This hides the pthread_t type usage and force the cast to unsigned long thread no matter what. This is fine with glibc and musl libc at least. Fixes #1388
1 parent 3b9a242 commit 3466319

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

.circleci/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ s3_bucket: &s3_bucket pypi.datadoghq.com
77
resource_class: &resource_class medium
88
busybox_image: &busybox_image busybox:latest
99
cimg_base_image: &cimg_base_image cimg/base:2020.01
10+
python38-alpine_image: &python38-alpine_image python:3.8-alpine
1011
python38_image: &python38_image circleci/python:3.8
1112
python37_image: &python37_image circleci/python:3.7
1213
python36_image: &python36_image circleci/python:3.6
@@ -165,6 +166,10 @@ executors:
165166
docker:
166167
- image: *cimg_base_image
167168
resource_class: *resource_class
169+
python38-alpine:
170+
docker:
171+
- image: *python38-alpine_image
172+
resource_class: *resource_class
168173
python38:
169174
docker:
170175
- image: *python38_image
@@ -251,6 +256,11 @@ jobs:
251256
- run: |
252257
docker build .
253258
259+
test_build_alpine:
260+
executor: python38-alpine
261+
steps:
262+
- run: apk add git gcc musl-dev libffi-dev openssl-dev
263+
- test_build
254264
test_build_py38:
255265
executor: python38
256266
steps:
@@ -809,6 +819,7 @@ workflows:
809819
- flake8
810820

811821
# Test building the package
822+
- test_build_alpine: *requires_pre_test
812823
- test_build_py38: *requires_pre_test
813824
- test_build_py37: *requires_pre_test
814825
- test_build_py36: *requires_pre_test
@@ -927,6 +938,7 @@ workflows:
927938
- requestsgevent
928939
- sqlalchemy
929940
- sqlite3
941+
- test_build_alpine
930942
- test_build_py38
931943
- test_build_py37
932944
- test_build_py36

ddtrace/profiling/collector/stack.pyx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ IF UNAME_SYSNAME == "Linux":
3232

3333
cdef extern from "<pthread.h>":
3434
# POSIX says this might be a struct, but CPython relies on it being an unsigned long.
35-
ctypedef unsigned long pthread_t
36-
int pthread_getcpuclockid(pthread_t thread, clockid_t *clock_id)
35+
# We should be defining pthread_t here like this:
36+
# ctypedef unsigned long pthread_t
37+
# but e.g. musl libc defines pthread_t as a struct __pthread * which breaks the arithmetic Cython
38+
# wants to do.
39+
# We pay this with a warning at compilation time, but it works anyhow.
40+
int pthread_getcpuclockid(unsigned long thread, clockid_t *clock_id)
3741

3842
cdef p_pthread_getcpuclockid(tid):
3943
cdef clockid_t clock_id

docs/installation_quickstart.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ If you want to use the profiler, you'll need to specify the ``profiling`` flavor
2323

2424
$ pip install ddtrace[profiling]
2525

26-
27-
.. note::
28-
29-
The profiler does not work on Alpine Linux.
30-
3126
Quickstart
3227
----------
3328

0 commit comments

Comments
 (0)