Older system might not have support for memfd_create at the kernel level. There we won't be able to use aubinator.
We also initially tried to workaround some libc having the memfd_create syscall number defined, but not the memfd_create() function. This change fixes the broken build on the travis CI by only compiling aubinator if memfd_create() is available as part of the libc. Annoyingly the man page says which should include <sys/memfd.h> but that header doesn't exist on my system and memfd_create() is instead defined in bits/mman-shared.h. Hence the new checks... Signed-off-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> --- configure.ac | 8 +++++++- meson.build | 2 +- src/intel/Makefile.tools.am | 6 +++++- src/intel/tools/aubinator.c | 13 +++---------- src/intel/tools/meson.build | 33 +++++++++++++++++++++++---------- 5 files changed, 39 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index f135d057365..939585411f9 100644 --- a/configure.ac +++ b/configure.ac @@ -872,10 +872,16 @@ AC_HEADER_MAJOR AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"]) AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"]) AC_CHECK_HEADERS([endian.h]) +AC_CHECK_HEADERS([sys/memfd.h], [DEFINES="$DEFINES -DHAVE_SYS_MEMFD_H") AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"]) AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"]) AC_CHECK_FUNC([timespec_get], [DEFINES="$DEFINES -DHAVE_TIMESPEC_GET"]) -AC_CHECK_FUNC([memfd_create], [DEFINES="$DEFINES -DHAVE_MEMFD_CREATE"]) +AC_CHECK_FUNC([memfd_create], [MEMFD_CREATE=yes], [MEMFD_CREATE=no]) + +AM_CONDITIONAL(HAVE_MEMFD_CREATE, test "x$MEMFD_CREATE" = xyes) +if test "x$MEMFD_CREATE" = xyes; then + DEFINES="$DEFINES -DHAVE_MEMFD_CREATE" +fi AC_MSG_CHECKING([whether strtod has locale support]) AC_LINK_IFELSE([AC_LANG_SOURCE([[ diff --git a/meson.build b/meson.build index b2722c71e5b..89f17128c03 100644 --- a/meson.build +++ b/meson.build @@ -956,7 +956,7 @@ elif cc.has_header_symbol('sys/mkdev.h', 'major') pre_args += '-DMAJOR_IN_MKDEV' endif -foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h'] +foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'sys/memfd.h'] if cc.compiles('#include <@0@>'.format(h), name : '@0@'.format(h)) pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify()) endif diff --git a/src/intel/Makefile.tools.am b/src/intel/Makefile.tools.am index b00cc8cc2cb..16cc1095f62 100644 --- a/src/intel/Makefile.tools.am +++ b/src/intel/Makefile.tools.am @@ -19,8 +19,12 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +if HAVE_MEMFD_CREATE +noinst_PROGRAMS += \ + tools/aubinator +endif + noinst_PROGRAMS += \ - tools/aubinator \ tools/aubinator_error_decode tools_aubinator_SOURCES = \ diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c index 8989d558b66..24ec1a276d9 100644 --- a/src/intel/tools/aubinator.c +++ b/src/intel/tools/aubinator.c @@ -36,6 +36,9 @@ #include <sys/stat.h> #include <sys/wait.h> #include <sys/mman.h> +#ifdef HAVE_SYS_MEMFD_H +#include <sys/memfd.h> +#endif #include "util/list.h" #include "util/macros.h" @@ -46,16 +49,6 @@ #include "common/gen_gem.h" #include "intel_aub.h" -#ifndef HAVE_MEMFD_CREATE -#include <sys/syscall.h> - -static inline int -memfd_create(const char *name, unsigned int flags) -{ - return syscall(SYS_memfd_create, name, flags); -} -#endif - /* Below is the only command missing from intel_aub.h in libdrm * So, reuse intel_aub.h from libdrm and #define the * AUB_MI_BATCH_BUFFER_END as below diff --git a/src/intel/tools/meson.build b/src/intel/tools/meson.build index 705a353f26a..717f03c9002 100644 --- a/src/intel/tools/meson.build +++ b/src/intel/tools/meson.build @@ -18,16 +18,29 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -aubinator = executable( - 'aubinator', - files('aubinator.c', 'intel_aub.h'), - dependencies : [dep_expat, dep_zlib, dep_dl, dep_thread, dep_m], - include_directories : [inc_common, inc_intel], - link_with : [libintel_common, libintel_compiler, libintel_dev, libmesa_util], - c_args : [c_vis_args, no_override_init_args], - build_by_default : with_tools.contains('intel'), - install : with_tools.contains('intel'), -) +has_memfd_create = cc.compiles('''#include <sys/mman.h> + int main() { + return memfd_create("", 0); + }''', + name : 'memfd create') or + cc.compiles('''#include <sys/memfd.h> + int main() { + return memfd_create("", 0); + }''', + name : 'memfd create') + +if has_memfd_create + aubinator = executable( + 'aubinator', + files('aubinator.c', 'intel_aub.h'), + dependencies : [dep_expat, dep_zlib, dep_dl, dep_thread, dep_m], + include_directories : [inc_common, inc_intel], + link_with : [libintel_common, libintel_compiler, libintel_dev, libmesa_util], + c_args : [c_vis_args, no_override_init_args], + build_by_default : with_tools.contains('intel'), + install : with_tools.contains('intel'), + ) +endif aubinator_error_decode = executable( 'aubinator_error_decode', -- 2.18.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev