[SYCL] Enhance device libraries filename check when constructing llvm-link commands (#2944)
We check input files' name when constructing "llvm-link -only-needed" for linking
SYCL device libraries. Currently, the criteria is:
1. has the prefix 'libsycl-'
2. has the postfix '.o'
Such check is too fragile, this PR aims to enhance the check, input SYCL device
libraries' filename pattern is "libsycl-${pure-name}-$random.o" where
${pure-name} is in list {'crt', 'cmath', 'cmath-fp64', 'complex', 'complex-fp64',
'fallback-cassert', 'fallback-cmath', 'fallback-cmath-fp64', 'fallback-complex',
'fallback-complex-fp64'} and ${random} is a random string,
so the updated criteria is:
1. has the prefix 'libsycl-'
2. has the postfix '.o'
3. includes at least 2 '-' character in the filename
4. the 'pure name' extracted from the input filename should be in sycl device
library 'pure name' list.
5. Input file list includes 2 files at least(when using llvm-link -only-needed, we
will put user's device code and several sycl device libraries into input list
which means there are 2 input files at least)
This enhancement can only mitigate the fragility since the check is still based
on filename. If we switch to approach of "-mlink-builtin-bitcode" for SYCL
device library link in the future, this problem will be gone automatically.
Signed-off-by: gejin <ge.jin@intel.com>