(cherry picked from commit b673b8987872adfd97fdb8821198450ff229118d)
mostly from void-linux (thanks!)