I guess we should consider this as a feature request? Can I ask why your use case is for this function? Does your application have a hard dependency on it?
but it means that the user needs to detect Emscripten platform and have custom code on Emscripten compared to on linux, but with dl_iterate_phdr their linux code would just work for Emscripten.
It's for runtime inspection of the loaded libs. The ones we're interested in particular in threadpoolctl are the libs managing their own threadpool like OpenMP or the different BLAS implementations, but there are other python packages that aim to do a more generic inspection. In fact, threadpoolctl goes beyond just inspection since it provides python bindings to control these threadpools.
Note that this is not only threadpoolctl that cares about this. For example, there is this discussion in the CPython discourse to add a portable way to list the loaded libraries in the stdlib ctypes.util. This discussion mentions that dl_iterate_phdr is used in Python code. see Github search results.
For now there is a package on PyPI dllist, the github repo is https://github.com/WardBrian/dllist. The implementation is very likely similar to what threadpoolctl does.
Activity
sbc100 commented on Feb 15, 2024
Indeed we don't support the dl_iterate_phdr API.
I guess we should consider this as a feature request? Can I ask why your use case is for this function? Does your application have a hard dependency on it?
hoodmane commented on Feb 15, 2024
They just want the names of the loaded libs. We can work around this with:
but it means that the user needs to detect Emscripten platform and have custom code on Emscripten compared to on linux, but with dl_iterate_phdr their linux code would just work for Emscripten.
sbc100 commented on Feb 15, 2024
Who is "they" in this context? I'm curious where the requirement for getting the names of the loaded libs is coming from?
jeremiedbb commented on Feb 15, 2024
It's for runtime inspection of the loaded libs. The ones we're interested in particular in threadpoolctl are the libs managing their own threadpool like OpenMP or the different BLAS implementations, but there are other python packages that aim to do a more generic inspection. In fact, threadpoolctl goes beyond just inspection since it provides python bindings to control these threadpools.
lesteve commented on Feb 16, 2024
Note that this is not only threadpoolctl that cares about this. For example, there is this discussion in the CPython discourse to add a portable way to list the loaded libraries in the stdlib ctypes.util. This discussion mentions that dl_iterate_phdr is used in Python code. see Github search results.
For now there is a package on PyPI dllist, the github repo is https://github.com/WardBrian/dllist. The implementation is very likely similar to what threadpoolctl does.
hoodmane commented on Feb 16, 2024
Perhaps we could start by adding an implementation in Pyodide and seeing if we can get it right and then upstream if it works out.
sbc100 commented on Feb 16, 2024
Sounds like good argument adding this .. I don't think it should be too hard.
hoodmane commented on Feb 16, 2024
Should I look into making a PR to emscripten for this @sbc100?
sbc100 commented on Feb 16, 2024
That would be great thanks!