[Piglit] [PATCH] Fix MacOS build for OpenCL tests

Aaron Watry awatry at gmail.com
Wed Nov 14 18:09:52 PST 2012


1) Fix creation of libpiglitutil_cl.dylib
2) Fix includes of OpenCL.h to finish fixing MacOS build

Previous error message when linking dylib was:

Linking C shared library ../../../../lib/libpiglitutil_cl.dylib
Undefined symbols for architecture x86_64:
  "_piglit_cl_get_test_config", referenced from:
      _piglit_cl_framework_run in piglit-framework-cl.c.o
ld: symbol(s) not found for architecture x86_64
---
 tests/util/CMakeLists.cl.txt     |    6 ++++++
 tests/util/piglit-util-cl-enum.h |    5 ++++-
 tests/util/piglit-util-cl.h      |    2 --
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tests/util/CMakeLists.cl.txt b/tests/util/CMakeLists.cl.txt
index fac7695..aa50636 100644
--- a/tests/util/CMakeLists.cl.txt
+++ b/tests/util/CMakeLists.cl.txt
@@ -3,9 +3,15 @@ include_directories(
 	${OPENCL_INCLUDE_PATH}
 	)
 
+#MacOS has issues with linking a dylib with missing symbols without these flags
+if (APPLE)
+	set(link_opts -Wl,-undefined,dynamic_lookup)
+endif(APPLE)
+
 link_libraries(
 	piglitutil
 	${OPENCL_opencl_LIBRARY}
+	${link_opts}
 	)
 
 piglit_add_library (piglitutil_${piglit_target_api}
diff --git a/tests/util/piglit-util-cl-enum.h b/tests/util/piglit-util-cl-enum.h
index cb4d818..16c8d3e 100644
--- a/tests/util/piglit-util-cl-enum.h
+++ b/tests/util/piglit-util-cl-enum.h
@@ -25,8 +25,11 @@
 #ifndef PIGLIT_UTIL_CL_ENUM_H
 #define PIGLIT_UTIL_CL_ENUM_H
 
+#ifdef __APPLE__
+#include <OpenCL/opencl.h>
+#else
 #include <CL/opencl.h>
-
+#endif
 /**
  * \brief Convert a CL enum to a string.
  *
diff --git a/tests/util/piglit-util-cl.h b/tests/util/piglit-util-cl.h
index a19f812..4420e32 100644
--- a/tests/util/piglit-util-cl.h
+++ b/tests/util/piglit-util-cl.h
@@ -25,8 +25,6 @@
 #ifndef PIGLIT_UTIL_CL_H
 #define PIGLIT_UTIL_CL_H
 
-#include <CL/opencl.h>
-
 #include "piglit-util.h"
 #include "piglit-util-cl-enum.h"
 
-- 
1.7.4.4



More information about the Piglit mailing list