llvm: fix build flags with older llvm versions
llvm: fix build flags with older llvm versions

Fix fallback code for older (<= 3.8) llvm versions to not be dependent
on readdir() order.

Fixes #4102

mesonbuild/meson,pexip/meson,QuLogic/meson,pexip/meson,becm/meson,pexip/meson,becm/meson,MathieuDuponchelle/meson,MathieuDuponchelle/meson,becm/meson,mesonbuild/meson,mesonbuild/meson,pexip/meson,MathieuDuponchelle/meson,QuLogic/meson,QuLogic/meson,becm/meson,jpakkane/meson,pexip/meson,mesonbuild/meson,MathieuDuponchelle/meson,mesonbuild/meson,jpakkane/meson,mesonbuild/meson,jpakkane/meson,MathieuDuponchelle/meson,mesonbuild/meson,QuLogic/meson,jpakkane/meson,pexip/meson,jpakkane/meson,becm/meson,mesonbuild/meson,pexip/meson,jpakkane/meson,mesonbuild/meson,MathieuDuponchelle/meson,becm/meson,QuLogic/meson,QuLogic/meson,jpakkane/meson,becm/meson,MathieuDuponchelle/meson,mesonbuild/meson,pexip/meson,jpakkane/meson,MathieuDuponchelle/meson,pexip/meson,becm/meson,becm/meson,QuLogic/meson,QuLogic/meson,QuLogic/meson,becm/meson,pexip/meson,MathieuDuponchelle/meson,jpakkane/meson