2323
2424const DEVICE_LIBS:: Dict{String, DevLib} = Dict {String, DevLib} ()
2525
26- function link_device_libs! (
27- target:: GCNCompilerTarget , mod :: LLVM.Module ;
26+ function get_device_libs_paths (
27+ target:: GCNCompilerTarget ;
2828 wavefrontsize64:: Bool ,
2929)
30- isnothing (libdevice_libs) && return
31- if ! isempty (AMDGPU. ROCmDiscovery. clang_path)
32- return
33- end
30+ paths = String[]
31+ isnothing (libdevice_libs) && return paths
3432
3533 # 1. Load other libraries.
3634 lib_names = (" hc" , " hip" , " irif" , " ockl" , " opencl" , " ocml" )
3735 for lib_name in lib_names
38- devlib = get! (DEVICE_LIBS, lib_name) do
39- DevLib (lib_name, locate_lib (lib_name))
40- end
41- load_and_link! (devlib, mod)
36+ path = locate_lib (lib_name)
37+ ! isnothing (path) && push! (paths, path)
4238 end
4339
4440 # 2. Load OCLC library.
45- devlib = get! (DEVICE_LIBS, " oclc" ) do
46- isa_short = replace (target. dev_isa, " gfx" => " " )
47- DevLib (" oclc" , locate_lib (" oclc_isa_version_$isa_short " ))
48- end
49- load_and_link! (devlib, mod)
41+ isa_short = replace (target. dev_isa, " gfx" => " " )
42+ path = locate_lib (" oclc_isa_version_$isa_short " )
43+ ! isnothing (path) && push! (paths, path)
5044
5145 # 3. Load OCLC ABI library.
52- devlib = get! (DEVICE_LIBS, " oclc_abi" ) do
53- DevLib (" oclc_abi" , locate_lib (" oclc_abi_version_500" ))
54- end
55- load_and_link! (devlib, mod)
46+ path = locate_lib (" oclc_abi_version_500" )
47+ ! isnothing (path) && push! (paths, path)
5648
5749 # 4. Load options libraries.
5850 options = (
@@ -65,8 +57,25 @@ function link_device_libs!(
6557 for (option, value) in options
6658 toggle = value ? " on" : " off"
6759 name = " oclc_$(option) _$(toggle) "
60+ path = locate_lib (name)
61+ ! isnothing (path) && push! (paths, path)
62+ end
63+ return paths
64+ end
65+
66+ function link_device_libs! (
67+ target:: GCNCompilerTarget , mod:: LLVM.Module ;
68+ wavefrontsize64:: Bool ,
69+ )
70+ isnothing (libdevice_libs) && return
71+ if ! isempty (AMDGPU. ROCmDiscovery. clang_path)
72+ return
73+ end
74+
75+ for path in get_device_libs_paths (target; wavefrontsize64)
76+ name = basename (path)
6877 devlib = get! (DEVICE_LIBS, name) do
69- DevLib (name, locate_lib (name) )
78+ DevLib (name, path )
7079 end
7180 load_and_link! (devlib, mod)
7281 end
0 commit comments