[tint] Link libraries for dlopen
The code added for loading DXC from a library uses `dlopen()` and
`dlsym()`, and some platforms complain that these symbols cannot be
found unless libdl is linked in.
Change-Id: Ie86461553e5f263a61d5f0f73dc9d4a2923bcd8b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/187201
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn
index b1e1a64..30d21d4 100644
--- a/src/tint/BUILD.gn
+++ b/src/tint/BUILD.gn
@@ -139,6 +139,10 @@
}
}
+source_set("dl") {
+ # GN doesn't appear to need to depend on any dl libraries.
+}
+
source_set("thread") {
# GN doesn't appear to need to depend on any thread libraries.
}
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 79eb76b..43538e6 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -505,6 +505,8 @@
target_link_libraries(${TARGET} PRIVATE
absl_strings
)
+ elseif(${DEPENDENCY} STREQUAL "dl")
+ target_link_libraries(${TARGET} PRIVATE ${CMAKE_DL_LIBS})
elseif(${DEPENDENCY} STREQUAL "dxc-include")
target_include_directories(${TARGET} PRIVATE "${DAWN_THIRD_PARTY_DIR}/dxc/include")
elseif(${DEPENDENCY} STREQUAL "jsoncpp")
diff --git a/src/tint/externals.json b/src/tint/externals.json
index 03048a5..8b8bd96 100644
--- a/src/tint/externals.json
+++ b/src/tint/externals.json
@@ -8,6 +8,12 @@
"absl/**"
]
},
+ "dl": {
+ "IncludePatterns": [
+ "dlfcn.h"
+ ],
+ "Condition": "tint_build_hlsl_writer"
+ },
"dxc-include": {
"IncludePatterns": [
"dxc/**"
diff --git a/src/tint/lang/hlsl/validate/BUILD.bazel b/src/tint/lang/hlsl/validate/BUILD.bazel
index e045855..41ec67c 100644
--- a/src/tint/lang/hlsl/validate/BUILD.bazel
+++ b/src/tint/lang/hlsl/validate/BUILD.bazel
@@ -59,6 +59,7 @@
] + select({
":tint_build_hlsl_writer": [
+
],
"//conditions:default": [],
}),
diff --git a/src/tint/lang/hlsl/validate/BUILD.cmake b/src/tint/lang/hlsl/validate/BUILD.cmake
index 5aded7f..272eae6 100644
--- a/src/tint/lang/hlsl/validate/BUILD.cmake
+++ b/src/tint/lang/hlsl/validate/BUILD.cmake
@@ -61,6 +61,7 @@
if(TINT_BUILD_HLSL_WRITER)
tint_target_add_external_dependencies(tint_lang_hlsl_validate lib
+ "dl"
"dxc-include"
)
endif(TINT_BUILD_HLSL_WRITER)
diff --git a/src/tint/lang/hlsl/validate/BUILD.gn b/src/tint/lang/hlsl/validate/BUILD.gn
index 3143d42..b22d7b8 100644
--- a/src/tint/lang/hlsl/validate/BUILD.gn
+++ b/src/tint/lang/hlsl/validate/BUILD.gn
@@ -58,7 +58,10 @@
]
if (tint_build_hlsl_writer) {
- deps += [ "${tint_src_dir}:dxc-include" ]
+ deps += [
+ "${tint_src_dir}:dl",
+ "${tint_src_dir}:dxc-include",
+ ]
}
}
}
diff --git a/tools/src/cmd/gen/build/BUILD.bazel.tmpl b/tools/src/cmd/gen/build/BUILD.bazel.tmpl
index 46eafcb..8432d76 100644
--- a/tools/src/cmd/gen/build/BUILD.bazel.tmpl
+++ b/tools/src/cmd/gen/build/BUILD.bazel.tmpl
@@ -141,6 +141,7 @@
*/ -}}
{{- define "ExternalDependencyTarget"}}
{{- if eq $.Name "abseil" -}}"@abseil_cpp//absl/strings",
+{{- else if eq $.Name "dl" -}}{{/* unsupported */}}
{{- else if eq $.Name "dxc-include" -}}{{/* unsupported */}}
{{- else if eq $.Name "glslang-res-limits" -}}{{/* unsupported */}}
{{- else if eq $.Name "glslang" -}}{{/* unsupported */}}
diff --git a/tools/src/cmd/gen/build/BUILD.gn.tmpl b/tools/src/cmd/gen/build/BUILD.gn.tmpl
index fee28b7..8e24e99 100644
--- a/tools/src/cmd/gen/build/BUILD.gn.tmpl
+++ b/tools/src/cmd/gen/build/BUILD.gn.tmpl
@@ -165,6 +165,7 @@
*/ -}}
{{- define "ExternalDependencyTargets"}}
{{- if eq $.Name "abseil" -}}"${tint_src_dir}:abseil",
+{{- else if eq $.Name "dl" -}}"${tint_src_dir}:dl",
{{- else if eq $.Name "dxc-include" -}}"${tint_src_dir}:dxc-include",
{{- else if eq $.Name "glslang-res-limits" -}}"${tint_glslang_dir}:glslang_default_resource_limits_sources",
{{- else if eq $.Name "glslang" -}}"${tint_glslang_dir}:glslang_lib_sources",