OpenCV: libgomp.so.1: 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:
cmake -D CMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_opencv_apps=OFF -DBUILD_DOCS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_LIBV4L=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DWITH_OPENMP=ON -DWITH_GSTREAMER=ON -DWITH_OPENCL=ON -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ../

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/__init__.py", line 89, in <module>
    bootstrap()
  File "/usr/local/lib/python3.7/dist-packages/cv2/__init__.py", line 79, in bootstrap
    import cv2
ImportError: /usr/lib/aarch64-linux-gnu/libgomp.so.1: cannot allocate memory in static TLS block

@ljking were you ever hit by this issue?

EDIT:
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.