|
From: GitLab M. <git...@ke...> - 2025-12-11 14:43:56
|
README.rst | 3 +++
amdgpu/amdgpu_asic_id.c | 10 ++++++++--
meson.build | 2 ++
3 files changed, 13 insertions(+), 2 deletions(-)
New commits:
commit 64ef303d70f971c65c3bf0890ad6c629af2c6c3a
Author: Sergio Costas Rodriguez <ser...@ca...>
Date: Tue Dec 9 10:36:14 2025 +0100
amdgpu: NetBSD lacks secure_getenv
When adding support for defining extra paths for the `amdgpu.ids`
file using an environment variable, the patch used a call to
secure_getenv(), which is only available in GNU. This breaks the
build in NetBSD systems.
This patch adds conditional compilation to use secure_getenv()
only when compiling against the GNU libraries.
Fix https://gitlab.freedesktop.org/mesa/libdrm/-/commit/c3c7fb21aa21ee6694754b746bedd11dbf5b3d28#note_3229411
Signed-off-by: Sergio Costas Rodriguez <ser...@ca...>
diff --git a/README.rst b/README.rst
index c47ee7ef..7d80181f 100644
--- a/README.rst
+++ b/README.rst
@@ -58,3 +58,6 @@ The AMDGPU driver requires the `amdgpu.ids` file. It is usually located at
paths at runtime by setting the `AMDGPU_ASIC_ID_TABLE_PATHS` environment
variable with one or more colon-separated paths where to search for the
`amdgpu.ids` file.
+
+For this option to be available, the C library must support secure_getenv()
+function. In systems without it (like NetBSD), this option won't be available.
\ No newline at end of file
diff --git a/amdgpu/amdgpu_asic_id.c b/amdgpu/amdgpu_asic_id.c
index 6ca37cd1..cd8ee596 100644
--- a/amdgpu/amdgpu_asic_id.c
+++ b/amdgpu/amdgpu_asic_id.c
@@ -165,6 +165,7 @@ static void amdgpu_parse_proc_cpuinfo(struct amdgpu_device *dev)
fclose(fp);
}
+#if HAVE_SECURE_GETENV
static char *join_path(const char *dir, const char *file) {
size_t dir_len = strlen(dir);
size_t file_len = strlen(file);
@@ -268,6 +269,7 @@ static char *find_asic_id_table(void)
split_env_var_free(paths);
return found_path;
}
+#endif
void amdgpu_parse_asic_ids(struct amdgpu_device *dev)
{
@@ -278,8 +280,12 @@ void amdgpu_parse_asic_ids(struct amdgpu_device *dev)
int line_num = 1;
int r = 0;
- char *amdgpu_asic_id_table_path = find_asic_id_table();
-
+ char *amdgpu_asic_id_table_path = NULL;
+#if HAVE_SECURE_GETENV
+ // if this system lacks secure_getenv(), don't allow extra paths
+ // for security reasons.
+ amdgpu_asic_id_table_path = find_asic_id_table();
+#endif
// if not found, use the default AMDGPU_ASIC_ID_TABLE path
if (!amdgpu_asic_id_table_path)
amdgpu_asic_id_table_path = strdup(AMDGPU_ASIC_ID_TABLE);
diff --git a/meson.build b/meson.build
index 0ea09e15..e567a0ac 100644
--- a/meson.build
+++ b/meson.build
@@ -51,6 +51,8 @@ dep_threads = dependency('threads')
cc = meson.get_compiler('c')
+config.set10('HAVE_SECURE_GETENV', cc.has_function('secure_getenv'))
+
android = cc.compiles('''int func() { return __ANDROID__; }''')
# Solaris / Illumos
|