diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c
index 7e86473e..3156dfc2 100644
--- a/benchmarks/gem_exec_tracer.c
+++ b/benchmarks/gem_exec_tracer.c
@@ -271,7 +271,11 @@ static int is_i915(int fd)
 }
 
 int
+#ifdef __GLIBC__
 ioctl(int fd, unsigned long request, ...)
+#else
+ioctl(int fd, int request, ...)
+#endif
 {
 	struct trace *t, **p;
 	va_list args;
diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index 312c428b..e0740fc1 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -46,6 +46,8 @@
 #include <linux/unistd.h>
 #endif
 
+#define sigev_notify_thread_id sigev_notify_function
+
 #include "i915/gem_create.h"
 #include "i915/gem_ring.h"
 #include "igt_aux.h"
diff --git a/lib/amdgpu/amd_pci_unplug.c b/lib/amdgpu/amd_pci_unplug.c
index 078398b5..554f489c 100644
--- a/lib/amdgpu/amd_pci_unplug.c
+++ b/lib/amdgpu/amd_pci_unplug.c
@@ -21,6 +21,7 @@
  *
 */
 #include <linux/limits.h>
+#include <limits.h> // PATH_MAX
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <pthread.h>
diff --git a/lib/igt_audio.c b/lib/igt_audio.c
index e0b1bafe..dd5e0d2c 100644
--- a/lib/igt_audio.c
+++ b/lib/igt_audio.c
@@ -26,6 +26,7 @@
 
 #include "config.h"
 
+#include <limits.h> // PATH_MAX
 #include <errno.h>
 #include <fcntl.h>
 #include <gsl/gsl_fft_real.h>
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 15e30440..9792899d 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -31,6 +31,7 @@
 #endif
 #include <stdio.h>
 #include <fcntl.h>
+#include <limits.h> // PATH_MAX
 #include <pwd.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index e734c87b..b626d28c 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -48,7 +48,7 @@
 # ifndef HAVE_GETTID
 #  define gettid() (pid_t)(syscall(__NR_gettid))
 # endif
-# define sigev_notify_thread_id _sigev_un._tid
+# define sigev_notify_thread_id sigev_notify_function
 #endif
 
 /* auxialiary igt helpers from igt_aux.c */
diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index ed128d24..ebff1ad3 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -27,6 +27,7 @@
 #include "igt_list.h"
 #include "intel_chipset.h"
 
+#include <limits.h> // PATH_MAX
 #include <ctype.h>
 #include <dirent.h>
 #include <fcntl.h>
diff --git a/lib/igt_eld.c b/lib/igt_eld.c
index ef6625df..3e9b8a40 100644
--- a/lib/igt_eld.c
+++ b/lib/igt_eld.c
@@ -26,6 +26,7 @@
 #include "config.h"
 
 #include <dirent.h>
+#include <limits.h> // PATH_MAX
 #include <errno.h>
 #include <glob.h>
 #include <stdint.h>
diff --git a/lib/igt_frame.c b/lib/igt_frame.c
index 45523a79..86b8aad4 100644
--- a/lib/igt_frame.c
+++ b/lib/igt_frame.c
@@ -26,6 +26,7 @@
 
 #include "config.h"
 
+#include <limits.h> // PATH_MAX
 #include <fcntl.h>
 #include <pixman.h>
 #include <cairo.h>
diff --git a/lib/igt_halffloat.c b/lib/igt_halffloat.c
index 08ab05fc..7d6a6e6a 100644
--- a/lib/igt_halffloat.c
+++ b/lib/igt_halffloat.c
@@ -162,7 +162,7 @@ static inline float _half_to_float(uint16_t val)
 	return fi.f;
 }
 
-#if defined(__x86_64__) && !defined(__clang__)
+#if defined(__x86_64__) && !defined(__clang__) && defined(__GLIBC__)
 #pragma GCC push_options
 #pragma GCC target("f16c")
 
diff --git a/lib/igt_hwmon.c b/lib/igt_hwmon.c
index 309019d6..6216a160 100644
--- a/lib/igt_hwmon.c
+++ b/lib/igt_hwmon.c
@@ -2,6 +2,7 @@
 /*
  * Copyright © 2022 Intel Corporation
  */
+#include <limits.h> // PATH_MAX
 #include <sys/stat.h>
 #include <sys/sysmacros.h>
 #include <dirent.h>
diff --git a/lib/igt_x86.c b/lib/igt_x86.c
index 6ac700df..ddf5edda 100644
--- a/lib/igt_x86.c
+++ b/lib/igt_x86.c
@@ -190,7 +190,7 @@ char *igt_x86_features_to_string(unsigned features, char *line)
 }
 #endif
 
-#if defined(__x86_64__) && !defined(__clang__)
+#if defined(__x86_64__) && !defined(__clang__) && defined(__GLIBC__)
 #pragma GCC push_options
 #pragma GCC target("sse4.1")
 #pragma GCC diagnostic ignored "-Wpointer-arith"
diff --git a/runner/executor.c b/runner/executor.c
index 9d3623b4..aac3ac56 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -1,6 +1,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <limits.h> // PATH_MAX
 #include <glib.h>
 #ifdef __linux__
 #include <linux/watchdog.h>
diff --git a/runner/runner_tests.c b/runner/runner_tests.c
index a7e968f8..6d605251 100644
--- a/runner/runner_tests.c
+++ b/runner/runner_tests.c
@@ -1,5 +1,6 @@
 #include <dirent.h>
 #include <fcntl.h>
+#include <limits.h> // PATH_MAX
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
diff --git a/tests/device_reset.c b/tests/device_reset.c
index 39ee8dca..fa8e3b9f 100644
--- a/tests/device_reset.c
+++ b/tests/device_reset.c
@@ -3,6 +3,7 @@
  * Copyright(c) 2020 Intel Corporation. All rights reserved.
  */
 #include <fcntl.h>
+#include <limits.h> // PATH_MAX
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <signal.h>
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index 74935430..0dc87d8c 100644
--- a/tests/intel/i915_pm_rpm.c
+++ b/tests/intel/i915_pm_rpm.c
@@ -27,6 +27,10 @@
 
 #include "config.h"
 
+#ifdef HAVE_LIBGEN_H
+#include <libgen.h>  // basename()
+#endif
+#include <limits.h> // PATH_MAX
 #include <stdio.h>
 #include <stdint.h>
 #include <stdbool.h>
diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 2a3fb74b..781af5e8 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -830,7 +830,7 @@ static void crtc_invalid_params_fence(igt_pipe_t *pipe,
 {
 	int timeline, fence_fd;
 	void *map;
-	const ptrdiff_t PAGE_SIZE = sysconf(_SC_PAGE_SIZE);
+	const ptrdiff_t intelsize = sysconf(_SC_PAGE_SIZE);
 	uint64_t old_mode_id = pipe->values[IGT_CRTC_MODE_ID];
 
 	igt_require_sw_sync();
@@ -838,28 +838,28 @@ static void crtc_invalid_params_fence(igt_pipe_t *pipe,
 	timeline = sw_sync_timeline_create();
 
 	/* invalid out_fence_ptr */
-	map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+	map = mmap(NULL, intelsize, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 	igt_assert(map != MAP_FAILED);
 
 	igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)map);
 	crtc_commit_atomic_err(pipe, plane, ATOMIC_RELAX_NONE, EFAULT);
-	munmap(map, PAGE_SIZE);
+	munmap(map, intelsize);
 
 	/* invalid out_fence_ptr */
-	map = mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+	map = mmap(NULL, intelsize, PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 	igt_assert(map != MAP_FAILED);
 
 	igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)map);
 	crtc_commit_atomic_err(pipe, plane, ATOMIC_RELAX_NONE, EFAULT);
-	munmap(map, PAGE_SIZE);
+	munmap(map, intelsize);
 
 	/* invalid out_fence_ptr */
-	map = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+	map = mmap(NULL, intelsize, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 	igt_assert(map != MAP_FAILED);
 
 	igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)map);
 	crtc_commit_atomic_err(pipe, plane, ATOMIC_RELAX_NONE, EFAULT);
-	munmap(map, PAGE_SIZE);
+	munmap(map, intelsize);
 
 	/* valid in fence but not allowed prop on crtc */
 	fence_fd = sw_sync_timeline_create_fence(timeline, 1);
diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c
index 77521108..3b16cba8 100644
--- a/tests/kms_sysfs_edid_timing.c
+++ b/tests/kms_sysfs_edid_timing.c
@@ -22,6 +22,7 @@
  */
 #include "igt.h"
 
+#include <limits.h> // PATH_MAX
 #include <dirent.h>
 #include <fcntl.h>
 #include <sys/stat.h>
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index ee272dfb..b8146b41 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -58,6 +58,7 @@
 #include <strings.h>
 #include <unistd.h>
 #include <termios.h>
+#include <limits.h> // PATH_MAX
 #include <sys/poll.h>
 #include <sys/time.h>
 #include <sys/ioctl.h>
diff --git a/tests/tools_test.c b/tests/tools_test.c
index 8412ba52..f36a6192 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -26,6 +26,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <limits.h> // PATH_MAX
 #include <libgen.h>
 #include <unistd.h>
 #ifdef __linux__
diff --git a/tools/igt_compliance_utils.c b/tools/igt_compliance_utils.c
index 0faf3fc8..f6bd970e 100644
--- a/tools/igt_compliance_utils.c
+++ b/tools/igt_compliance_utils.c
@@ -24,6 +24,7 @@
  */
 
 #include "igt.h"
+#include <limits.h> // PATH_MAX
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
--- a/tests/intel/kms_pm_backlight.c
+++ b/tests/intel/kms_pm_backlight.c
@@ -36,6 +36,9 @@
  */
 
 #include "igt.h"
+#ifdef HAVE_LIBGEN_H
+#include <libgen.h>    /* basename() */
+#endif
 #include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
