OpenCV: cannot allocate memory in static TLS block

I am compiling opencv from source in order to enable multi-core support.

I am building open cv with the following config:

but every time I import it using python, I get the following error. A lot of the results on-line seems to be very vague and/or point towards a bug in gcc 4.2 fixed in 4.3 and I am currently on 8.x :

root@linaro-developer:~# python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/cv2/", line 89, in <module>
  File "/usr/local/lib/python3.7/dist-packages/cv2/", line 79, in bootstrap
    import cv2
ImportError: /usr/lib/aarch64-linux-gnu/ cannot allocate memory in static TLS block

@ljking were you ever hit by this issue?

This is on opencv master branch as well as 4.0.1

Yes, I was hit by exactly that error, but I don’t remember what I updated/backdated to get around it.