forked from ofiwg/libfabric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1070 lines (928 loc) · 33.4 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
dnl
dnl Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2019-2021 Intel, Inc. All rights reserved.
dnl Copyright (c) 2019-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
dnl (C) Copyright 2020 Hewlett Packard Enterprise Development LP
dnl Copyright (c) 2022 DataDirect Networks, Inc. All rights reserved.
dnl Copyright (c) 2023 Tactical Computing Labs, LLC. All rights reserved.
dnl
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.60])
AC_INIT([libfabric], [1.21.0a1], [[email protected]])
AC_CONFIG_SRCDIR([src/fabric.c])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([1.11 dist-bzip2 foreign -Wall -Werror subdir-objects parallel-tests tar-pax])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
m4_include(config/fi_check_package.m4)
m4_include(config/fi_strip_optflags.m4)
AC_CANONICAL_HOST
macos=0
linux=0
freebsd=0
case $host_os in
*darwin*)
macos=1
;;
*linux*)
linux=1
;;
*freebsd*)
freebsd=1
;;
*)
AC_MSG_ERROR([libfabric only builds on Linux, OS X, and FreeBSD])
;;
esac
AM_CONDITIONAL([MACOS], [test "x$macos" = "x1"])
AM_CONDITIONAL([LINUX], [test "x$linux" = "x1"])
AM_CONDITIONAL([FREEBSD], [test "x$freebsd" = "x1"])
base_c_warn_flags="-Wall -Wundef -Wpointer-arith"
debug_c_warn_flags="-Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers"
debug_c_other_flags="-fstack-protector-strong"
picky_c_warn_flags="-Wno-long-long -Wmissing-prototypes -Wstrict-prototypes -Wcomment -pedantic"
AC_ARG_WITH([build_id],
[AS_HELP_STRING([--with-build_id],
[Enable build_id annotation @<:@default=no@:>@])],
[], [with_build_id=no])
AS_IF([test x"$with_build_id" = x"no"], [with_build_id=""])
AC_DEFINE_UNQUOTED([BUILD_ID],["$with_build_id"],
[adds build_id to version if it was defined])
# Override autoconf default CFLAG settings (e.g. "-g -O2") while still
# allowing the user to explicitly set CFLAGS=""
: ${CFLAGS="-fvisibility=hidden ${base_c_warn_flags}"}
# AM_PROG_AS would set CFLAGS="-g -O2" by default if not set already so it
# should not be called earlier
AM_PROG_AS()
# AM PROG_AR did not exist pre AM 1.11.x (where x is somewhere >0 and
# <3), but it is necessary in AM 1.12.x.
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_ARG_WITH([valgrind],
AS_HELP_STRING([--with-valgrind],
[Enable valgrind annotations @<:@default=no@:>@]))
if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
AC_DEFINE([INCLUDE_VALGRIND], 1,
[Define to 1 to enable valgrind annotations])
if test -d $with_valgrind; then
CPPFLAGS="$CPPFLAGS -I$with_valgrind/include"
fi
fi
AC_ARG_ENABLE([direct],
[AS_HELP_STRING([--enable-direct=@<:@provider@:>@],
[Enable direct calls to a fabric provider @<:@default=no@:>@])
],
[],
[enable_direct=no])
AC_ARG_ENABLE([only],
[AS_HELP_STRING([--enable-only],
[Only build explicitly specified fabric providers])
],
[],
[enable_only=no])
AC_ARG_ENABLE([atomics],
[AS_HELP_STRING([--enable-atomics],
[Enable atomics support @<:@default=yes@:>@])
],
[],
[enable_atomics=yes])
dnl Checks for programs
AC_PROG_CC
dnl Autoconf 2.70 changed behavior of how it searches for C / C99
dnl compilers. Since the world hasn't uniformly updated to Autoconf
dnl >=v2.70, support both <v2.70 and >=v2.70.
m4_version_prereq([2.70],
[ dnl If Autoconf is >= v2.70
AC_MSG_CHECKING([for C compiler conformance level])
AC_MSG_RESULT([$ac_prog_cc_stdc])
AS_IF([test "$ac_prog_cc_stdc" = "c89"],
[AC_MSG_WARN([Libfabric requires a C99-compliant compiler])
AC_MSG_ERROR([Cannot continue])])
],
[ dnl If Autoconf is < v2.70
AC_PROG_CC_C99
AS_IF([test "$ac_cv_prog_cc_c99" = "no"],
[AC_MSG_WARN([Libfabric requires a C99-compliant compiler])
AC_MSG_ERROR([Cannot continue])])
])
AM_PROG_CC_C_O
AC_PROG_CPP
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Enable debugging @<:@default=no@:>@])
],
[],
[enable_debug=no])
AS_IF([test x"$enable_debug" != x"no"],
[dbg=1
# See if the flags in $debug_c_warn_flags and $debug_c_other_flags work
good_flags=
CFLAGS_save="$CFLAGS"
for flag in $debug_c_warn_flags $debug_c_other_flags; do
AC_MSG_CHECKING([to see if compiler supports $flag])
CFLAGS="$flag $CFLAGS_save"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int i = 3;]])],
[AC_MSG_RESULT([yes])
good_flags="$flag $good_flags"],
[AC_MSG_RESULT([no])])
done
debug_c_flags=$good_flags
unset good_flags
CFLAGS="-g -O0 ${base_c_warn_flags} ${debug_c_flags} ${CFLAGS_save}"
unset CFLAGS_save],
[dbg=0
CFLAGS="-O2 -DNDEBUG $CFLAGS"])
AC_DEFINE_UNQUOTED([ENABLE_DEBUG],[$dbg],
[defined to 1 if libfabric was configured with --enable-debug, 0 otherwise])
AC_ARG_ENABLE([profile],
[AS_HELP_STRING([--enable-profile],
[Enable profiling @<:@default=no@:>@])],
[],
[enable_profile=no])
AS_IF([test x"$enable_profile" != x"no"],
[AC_DEFINE([HAVE_FABRIC_PROFILE], [1],
[defined to 1 if libfabric was configured with --enable-profile, 0 otherwise])
])
AC_DEFUN([FI_ARG_ENABLE_SANITIZER],[
AC_ARG_ENABLE([$1],
[AS_HELP_STRING([--enable-$1],
[Enable $3Sanitizer @<:@default=no@:>@])
],
[],
[enable_$1=no])
AS_IF([test x"$enable_$1" != x"no"],
[CFLAGS="-fsanitize=$2 $CFLAGS"])
])
m4_map([FI_ARG_ENABLE_SANITIZER],[
[asan, address, Address],
[lsan, leak, Leak],
[tsan, thread, Thread],
[ubsan, undefined, UndefinedBehavior]
])
dnl Checks for header files.
dnl This is only necessary for Autoconf <v2.70.
m4_version_prereq([2.70],
[],
[AC_HEADER_STDC])
dnl Check for compiler features
AC_C_TYPEOF
LT_INIT
LT_OUTPUT
dnl dlopen support is optional
AC_ARG_WITH([dlopen],
AS_HELP_STRING([--with-dlopen],
[dl-loadable provider support @<:@default=yes@:>@]),
)
if test "$freebsd" = "0"; then
AS_IF([test x"$with_dlopen" != x"no"], [
AC_CHECK_LIB(dl, dlopen, [],
AC_MSG_ERROR([dlopen not found. libfabric requires libdl.]))
])
fi
dnl handle picky option
AC_ARG_ENABLE([picky],
[AS_HELP_STRING([--enable-picky],
[Enable developer-level compiler pickyness when building @<:@default=no@:>@])])
AS_IF([test x"$enable_picky" = x"yes" && test x"$GCC" = x"yes"],
[AS_IF([test x"$enable_debug" = x"no"],
[CFLAGS="${base_c_warn_flags} ${debug_c_flags} ${picky_c_warn_flags} $CFLAGS"],
[CFLAGS="${picky_c_warn_flags} $CFLAGS"])
])
dnl Checks for libraries
AC_CHECK_LIB(pthread, pthread_mutex_init, [],
AC_MSG_ERROR([pthread_mutex_init() not found. libfabric requires libpthread.]))
AC_CHECK_FUNC([pthread_spin_init],
[have_spinlock=1],
[have_spinlock=0])
dnl shm_open not used in the common code on os-x
if test "$macos" -eq 0; then
AC_CHECK_FUNC([shm_open],
[],
[AC_SEARCH_LIBS([shm_open],[rt],[],
[AC_MSG_ERROR([shm_open() not found. libfabric requires shm_open.])])])
fi
AC_DEFINE_UNQUOTED([PT_LOCK_SPIN], [$have_spinlock],
[Define to 1 if pthread_spin_init is available.])
AC_ARG_ENABLE([epoll],
[AS_HELP_STRING([--disable-epoll],
[Disable epoll if available@<:@default=no@:>@])],
[],
[enable_epoll=auto]
)
AS_IF([test x"$enable_epoll" != x"no"],
[AC_CHECK_FUNCS([epoll_create])
if test "$ac_cv_func_epoll_create" = yes; then
AC_DEFINE([HAVE_EPOLL], [1], [Define if you have epoll support.])
fi]
)
AC_CHECK_HEADER([linux/perf_event.h],
[AC_CHECK_DECL([__builtin_ia32_rdpmc],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <linux/perf_event.h>]],
[[__builtin_ia32_rdpmc(0);]])],
[linux_perf_rdpmc=1],
[linux_perf_rdpmc=0])
],
[linux_perf_rdpmc=0],
[#include <linux/perf_event.h>])],
[linux_perf_rdpmc=0])
AC_DEFINE_UNQUOTED(HAVE_LINUX_PERF_RDPMC, [$linux_perf_rdpmc],
[Whether we have __builtin_ia32_rdpmc() and linux/perf_event.h file or not])
AM_CONDITIONAL([HAVE_LINUX_PERF_RDPMC], [test "x$linux_perf_rdpmc" = "x1"])
dnl Check for gcc atomic intrinsics
AS_IF([test x"$enable_atomics" != x"no"],
AC_MSG_CHECKING(compiler support for c11 atomics)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdatomic.h>]], [[atomic_int a;
atomic_init(&a, 0);
#ifdef __STDC_NO_ATOMICS__
#error c11 atomics are not supported
#else
return 0;
#endif
]])],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ATOMICS, 1, [Set to 1 to use c11 atomic functions])
],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(compiler support for c11 atomic `least` types)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdatomic.h>]], [[atomic_int_least32_t a;
atomic_int_least64_t b;
]])],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ATOMICS_LEAST_TYPES, 1,
[Set to 1 to use c11 atomic `least` types])
],[
AC_MSG_RESULT(no)
]),
[
AC_MSG_RESULT(configure: atomics support for c11 is disabled)
])
dnl Check for gcc built-in atomics
AS_IF([test x"$enable_atomics" != x"no"],
AC_MSG_CHECKING(compiler support for built-in atomics)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>]], [[int32_t a;
__sync_add_and_fetch(&a, 0);
__sync_sub_and_fetch(&a, 0);
#if defined(__PPC__) && !defined(__PPC64__)
#error compiler built-in atomics are not supported on PowerPC 32-bit
#else
return 0;
#endif
]])],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BUILTIN_ATOMICS, 1, [Set to 1 to use built-in intrincics atomics])
],[AC_MSG_RESULT(no)]),
[
AC_MSG_RESULT(configure: atomics support built-in is disabled)
])
dnl Check for gcc memory model aware built-in atomics
dnl If supported check to see if not internal to compiler
dnl If built-in atomics present, check for 128-bit atomic support
have_mm_atomics=0
LIBS_save=$LIBS
AC_SEARCH_LIBS([__atomic_load_8], [atomic])
AS_IF([test x"$enable_atomics" != x"no"],
AC_MSG_CHECKING(compiler support for built-in memory model aware atomics)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>]],
[[uint64_t d;
uint64_t s;
uint64_t c;
uint64_t r;
r = __atomic_fetch_add(&d, s, __ATOMIC_SEQ_CST);
r = __atomic_load_8(&d, __ATOMIC_SEQ_CST);
__atomic_exchange(&d, &s, &r, __ATOMIC_SEQ_CST);
__atomic_compare_exchange(&d,&c,&s,0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
#if defined(__PPC__) && !defined(__PPC64__)
#error compiler built-in memory model aware atomics are not supported on PowerPC 32-bit
#else
return 0;
#endif
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BUILTIN_MM_ATOMICS, 1, [Set to 1 to use built-in intrinsics memory model aware atomics])
have_mm_atomics=1
],
[
AC_MSG_RESULT(no)
LIBS=$LIBS_save
]),
[
AC_MSG_RESULT(configure: -latomic key is disabled)
LIBS=$LIBS_save
])
unset LIBS_save
dnl Check for 128-bit integer support
AC_CHECK_TYPE([__int128],
[AC_DEFINE(HAVE___INT128, 1, [Set to 1 to use 128-bit ints])])
dnl Check for 128-bit integer built-in atomic support
AS_IF([test "$have_mm_atomics" -eq 1 -a "$ac_cv_type___int128" = "yes"],
AC_MSG_CHECKING(compiler support for built-in memory model aware 128-bit atomics)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>]],
[[__int128 d;
__int128 s;
__int128 c;
__int128 r;
r = __atomic_fetch_add(&d, s, __ATOMIC_SEQ_CST);
__atomic_load(&d, &r, __ATOMIC_SEQ_CST);
__atomic_exchange(&d, &s, &r, __ATOMIC_SEQ_CST);
__atomic_compare_exchange(&d, &c, &s, 0, __ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST);
return !__atomic_is_lock_free(sizeof(d), NULL);
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BUILTIN_MM_INT128_ATOMICS, 1, [Set to 1 to use built-in intrinsics memory model aware 128-bit integer atomics])
],
[
AC_MSG_RESULT(no)
]),
)
dnl Check for gcc cpuid intrinsics
AC_MSG_CHECKING(compiler support for cpuid)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stddef.h>
#include <cpuid.h>]], [[
int a, b, c, d;
__cpuid_count(0, 0, a, b, c, d);
]])],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_CPUID, 1, [Set to 1 to use cpuid])
],[AC_MSG_RESULT(no)])
if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
AC_CHECK_HEADER(valgrind/memcheck.h, [],
AC_MSG_ERROR([valgrind requested but <valgrind/memcheck.h> not found.]))
fi
AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
[if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
ac_cv_version_script=yes
else
ac_cv_version_script=no
fi])
AC_ARG_ENABLE([embedded],
[AS_HELP_STRING([--enable-embedded],
[Enable embedded support (turns off symbol versioning) @<:@default=no@:>@])
],
[ac_asm_symver_support=0
icc_symver_hack=1],
[enable_embedded=no])
AM_CONDITIONAL([EMBEDDED], [test x"$enable_embedded" = x"yes"])
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$ac_cv_version_script" = "yes")
xpmem_happy=0
AC_ARG_ENABLE([xpmem],
[AS_HELP_STRING([--enable-xpmem@<:@=yes|no|PATH@:>@],
[Enable xpmem (providers) @<:@default=yes@:>@
(yes: enable xpmem; no: disable xpmem;
PATH: enable xpmem and use xpmem installed under PATH)])],
)
FI_CHECK_PACKAGE([xpmem],
[xpmem.h],
[xpmem],
[xpmem_make],
[],
[$enable_xpmem],
[$enable_xpmem/lib64],
[xpmem_happy=1])
AS_IF([test x"$enable_xpmem" != x"no" && test -n "$enable_xpmem" && test "$xpmem_happy" = "0" ],
[AC_MSG_ERROR([XPMEM support requested but XPMEM runtime not available.])])
AC_DEFINE_UNQUOTED([HAVE_XPMEM], [$xpmem_happy],
[XPMEM support availability])
LIBS="$LIBS $xpmem_LIBS"
CPPFLAGS="$CPPFLAGS $xpmem_CPPFLAGS"
LDFLAGS="$LDFLAGS $xpmem_LDFLAGS"
dnl Disable symbol versioning when -ipo is in CFLAGS or ipo is disabled by icc.
dnl The gcc equivalent ipo (-fwhole-program) seems to work fine.
AS_CASE([$CFLAGS],
[*-ipo*],[
AC_MSG_NOTICE([disabling symbol versioning support with -ipo CFLAG])
icc_symver_hack=1
ac_asm_symver_support=0
],
[]
)
dnl Check for symbol versioning compiler + linker support.
dnl If icc + ipo, then print disabled and skip check
AC_MSG_CHECKING(for .symver assembler support)
AS_IF([test "$icc_symver_hack"],
[AC_MSG_RESULT(disabled)],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[__asm__(".symver main_, main@ABIVER_1.0");]], [[]])],[
AC_MSG_RESULT(yes)
ac_asm_symver_support=1
],[
AC_MSG_RESULT(no)
ac_asm_symver_support=0
])
]) dnl AS_IF icc_symver_hack
AC_DEFINE_UNQUOTED([HAVE_SYMVER_SUPPORT], [$ac_asm_symver_support],
[Define to 1 if compiler/linker support symbol versioning.])
AC_MSG_CHECKING(for __alias__ attribute support)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
int foo(int arg);
int foo(int arg) { return arg + 3; };
int foo2(int arg) __attribute__ (( __alias__("foo")));
]], [[ foo2(1); ]])],[
AC_MSG_RESULT(yes)
ac_prog_cc_alias_symbols=1
],[
AC_MSG_RESULT(no)
ac_prog_cc_alias_symbols=0
])
AC_DEFINE_UNQUOTED([HAVE_ALIAS_ATTRIBUTE], [$ac_prog_cc_alias_symbols],
[Define to 1 if the linker supports alias attribute.])
AC_CHECK_FUNCS([getifaddrs])
dnl Check for ethtool support
AC_MSG_CHECKING(ethtool support)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <net/if.h>
#include <sys/types.h>
#include <linux/ethtool.h>
#include <linux/sockios.h>
#include <sys/ioctl.h>]], [[
unsigned long ioctl_req = SIOCETHTOOL;
struct ethtool_cmd cmd = {
.cmd = ETHTOOL_GSET,
};
long speed = cmd.speed;
]])],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ETHTOOL, 1, [Set to 1 to use ethtool])
],[AC_MSG_RESULT(no)])
dnl Check for ethtool SPEED_UNKNOWN macro (suppoirted in the linux
dnl kernel >= 3.2) and ethtool_cmd_speed function declarations
dnl supported in the linux kernel >= 2.6.26
AC_CHECK_DECLS([ethtool_cmd_speed, SPEED_UNKNOWN], [], [],
[#include <linux/ethtool.h>])
dnl Check for userfault fd support
have_uffd=0
AC_CHECK_HEADERS([linux/userfaultfd.h],
[AC_CHECK_DECL([__NR_userfaultfd],
[have_uffd=1],
[],
[[#include <sys/syscall.h>]])],
[], [])
AS_IF([test $have_uffd -eq 1],
[AC_MSG_CHECKING([for userfaultfd unmap support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <linux/userfaultfd.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <fcntl.h>
#include <sys/ioctl.h>
]],
[[
int fd;
struct uffdio_api api_obj;
api_obj.api = UFFD_API;
api_obj.features = UFFD_FEATURE_EVENT_UNMAP |
UFFD_FEATURE_EVENT_REMOVE |
UFFD_FEATURE_EVENT_REMAP;
fd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
return ioctl(fd, UFFDIO_API, &api_obj);
]])
],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
have_uffd=0])])
AC_DEFINE_UNQUOTED([HAVE_UFFD_UNMAP], [$have_uffd],
[Define to 1 if platform supports userfault fd unmap])
dnl restricted DL open
restricted_dl=0
AC_ARG_ENABLE([restricted_dl],
[AC_HELP_STRING([--enable-restricted-dl],
[only look for dl providers under default location if FI_PROVIDER_PATH is not set])],
[restricted_dl=1],
[])
AC_DEFINE_UNQUOTED([HAVE_RESTRICTED_DL], [$restricted_dl],
[Define to 1 to only look for dl providers under default location if FI_PROVIDER_PATH is not set])
dnl Check support to intercept syscalls
AC_CHECK_HEADERS_ONCE(elf.h sys/auxv.h)
dnl Check support to clock_gettime
have_clock_gettime=0
AC_SEARCH_LIBS([clock_gettime],[rt],
[have_clock_gettime=1],
[])
AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME, [$have_clock_gettime],
[Define to 1 if clock_gettime is available.])
AM_CONDITIONAL(HAVE_CLOCK_GETTIME, [test $have_clock_gettime -eq 1])
dnl Check for io_uring runtime libraries
AC_ARG_WITH([uring],
[AS_HELP_STRING([--with-uring@<:@=DIR@:>@],
[Enable uring support @<:@default=yes@:>@.
Optional=<Path to where liburing is installed.>])])
have_liburing=0
AS_IF([test x"$with_uring" != x"no"],
[FI_CHECK_PACKAGE([uring],
[liburing.h],
[uring],
[io_uring_queue_init],
[-luring],
[$with_uring],
[],
[have_liburing=1])
])
AS_IF([test "$have_liburing" = "1"], [
# Requires liburing >= 2.1 for multishot support
save_CPPFLAGS="$CPPFLAGS"
AS_IF([test $with_uring != ""]
[CPPFLAGS="$CPPFLAGS -I$with_uring/include/"])
AC_CHECK_DECLS([io_uring_prep_poll_multishot, IORING_CQE_F_MORE],
[AC_DEFINE_UNQUOTED([HAVE_LIBURING], [1], [io_uring support])],
[have_liburing=0], [[#include <liburing.h>]])
CPPFLAGS="$save_CPPFLAGS"
])
AS_IF([test x"$with_uring" != x"no" && test -n "$with_uring" && test $have_liburing -eq 0],
[AC_MSG_ERROR([io_uring support requested but liburing not available.])],
[])
AM_CONDITIONAL([HAVE_LIBURING], test "$have_liburing" -eq 1)
AS_IF([test x"$with_uring" != x"yes" && test x"$with_uring" != x"no"],
[CPPFLAGS="$CPPFLAGS $uring_CPPFLAGS"
LDFLAGS="$LDFLAGS $uring_LDFLAGS"])
LIBS="$LIBS $uring_LIBS"
dnl Check for CUDA runtime libraries
AC_ARG_WITH([cuda],
[AS_HELP_STRING([--with-cuda=DIR],
[Enable CUDA build and fail if not found.
Optional=<Path to where the CUDA libraries
and headers are installed.>])])
have_cuda=0
cuda_dlopen=0
have_cuda_dmabuf=0
AC_ARG_ENABLE([cuda-dlopen],
[AS_HELP_STRING([--enable-cuda-dlopen],
[Enable dlopen of CUDA libraries @<:@default=no@:>@])
],
[
AS_IF([test "$with_dlopen" = "no"],
[AC_MSG_ERROR([dlopen not found. libfabric requires libdl.])])
AS_IF([test "$enable_cuda_dlopen" != "no"], [cuda_dlopen=1])
])
AS_IF([test x"$with_cuda" != x"no"],
[
AS_IF([test "$cuda_dlopen" != "0"],
[
_FI_CHECK_PACKAGE_HEADER([cuda],
[cuda_runtime.h],
[$with_cuda],
[have_cuda=1],
[AC_MSG_ERROR([CUDA headers not found. Cannot enable CUDA DL])])
],
[
FI_CHECK_PACKAGE([cuda],
[cuda_runtime.h],
[cudart],
[cudaMemcpy],
[-lcuda -lnvidia-ml],
[$with_cuda],
[],
[have_cuda=1])
])
have_cuda_dmabuf=1
AC_CHECK_DECL([cuMemGetHandleForAddressRange],
[],
[have_cuda_dmabuf=0],
[[#include <cuda.h>]])
AC_CHECK_DECL([CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED],
[],
[have_cuda_dmabuf=0],
[[#include <cuda.h>]])
AC_CHECK_DECL([CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD],
[],
[have_cuda_dmabuf=0],
[[#include <cuda.h>]])
])
AC_DEFINE_UNQUOTED([ENABLE_CUDA_DLOPEN], [$cuda_dlopen], [dlopen CUDA libraries])
AS_IF([test x"$with_cuda" != x"no" && test -n "$with_cuda" && test "$have_cuda" = "0" ],
[AC_MSG_ERROR([CUDA support requested but CUDA runtime not available.])])
AC_DEFINE_UNQUOTED([HAVE_CUDA], [$have_cuda], [CUDA support])
AC_DEFINE_UNQUOTED([HAVE_CUDA_DMABUF], [$have_cuda_dmabuf], [CUDA dmabuf support])
AS_IF([test "$cuda_dlopen" != "1"], [LIBS="$LIBS $cuda_LIBS"])
AS_IF([test "$have_cuda" = "1" && test x"$with_cuda" != x"yes"],
[CPPFLAGS="$CPPFLAGS $cuda_CPPFLAGS"
LDFLAGS="$LDFLAGS $cuda_LDFLAGS"])
AC_ARG_WITH([ze],
[AS_HELP_STRING([--with-ze=DIR], [Enable ZE build and fail if not found.
Optional=<Path to where the ZE libraries
and headers are installed.>])])
have_ze=0
ze_dlopen=0
AC_ARG_ENABLE([ze-dlopen],
[AS_HELP_STRING([--enable-ze-dlopen],
[Enable dlopen of ZE libraries @<:@default=no@:>@])
],
[
AS_IF([test "$with_dlopen" = "no"],
[AC_MSG_ERROR([dlopen not found. libfabric requires libdl.])])
AS_IF([test "$enable_ze_dlopen" != "no"], [ze_dlopen=1])
])
AS_IF([test x"$with_ze" != x"no"],
[
AS_IF([test "$ze_dlopen" != "0"],
[
_FI_CHECK_PACKAGE_HEADER([ze],
[level_zero/ze_api.h],
[$with_ze],
[have_ze=1],
[AC_MSG_ERROR([ZE headers not found. Cannot enable ZE DL])])
],
[
FI_CHECK_PACKAGE([ze],
[level_zero/ze_api.h],
[ze_loader],
[zeInit],
[],
[$with_ze],
[],
[have_ze=1])
])
])
AC_DEFINE_UNQUOTED([ENABLE_ZE_DLOPEN], [$ze_dlopen], [dlopen ZE libraries])
have_drm=0
have_libdrm=0
AS_IF([test "$have_ze" = "1"],
[AC_CHECK_HEADER(drm/i915_drm.h,
[have_drm=1],
[AC_CHECK_HEADER(libdrm/i915_drm.h,
[have_libdrm=1])])])
AS_IF([test x"$with_ze" != x"no" && test -n "$with_ze" && test "$have_ze" = "0" ],
[AC_MSG_ERROR([ZE support requested but ZE runtime not available.])])
AC_DEFINE_UNQUOTED([HAVE_ZE], [$have_ze], [ZE support])
AC_DEFINE_UNQUOTED([HAVE_DRM], [$have_drm], [i915 DRM header])
AC_DEFINE_UNQUOTED([HAVE_LIBDRM], [$have_libdrm], [i915 DRM header])
AS_IF([test "$ze_dlopen" != "1"], [LIBS="$LIBS $ze_LIBS"])
AS_IF([test "$have_ze" = "1" && test x"$with_ze" != x"yes"],
[CPPFLAGS="$CPPFLAGS $ze_CPPFLAGS"
LDFLAGS="$LDFLAGS $ze_LDFLAGS"])
dnl Check for AWS Neuron runtime library for Neuron device support
have_neuron=0
AC_ARG_WITH([neuron],
AS_HELP_STRING([--with-neuron=DIR],
[Enable Neuron build and fail if not found.
Optional=<Path to where the Neuron libraries
and headers are installed.>]))
_FI_CHECK_PACKAGE_HEADER([neuron], [nrt/nrt.h], [$with_neuron],
[
AS_IF([test "$with_dlopen" = "no"],
[AC_MSG_ERROR([dlopen not found. libfabric requires libdl.])])
have_neuron=1
],
)
AS_IF([test x"$with_neuron" != x"no" && test -n "$with_neuron" && test "$have_neuron" = "0" ],
[AC_MSG_ERROR([Neuron support requested but headers are not available.])])
AC_DEFINE_UNQUOTED([HAVE_NEURON], [$have_neuron], [Build with Neuron support])
dnl Check for SynapseAI runtime libraries
AC_ARG_WITH([synapseai],
[AS_HELP_STRING([--with-synapseai=DIR],
[Enable SynapseAI build and fail if not found.
Optional=<Path to where the SynapseAI libraries
and headers are installed.>])])
have_synapseai=0
AS_IF([test x"$with_synapseai" != x"no"],
[
_FI_CHECK_PACKAGE_HEADER([synapseai], [habanalabs/synapse_api.h], [$with_synapseai],
[
AS_IF([test "$with_dlopen" = "no"],
[AC_MSG_ERROR([dlopen not found. libfabric requires libdl.])])
have_synapseai=1
],)
]
)
AS_IF([test x"$with_synapseai" != x"no" && test -n "$with_synapseai" && test "$have_synapseai" = "0" ],
[AC_MSG_ERROR([SynapseAI support requested but SynapseAI runtime not available.])])
AC_DEFINE_UNQUOTED([HAVE_SYNAPSEAI], [$have_synapseai], [SynapseAI support])
AS_IF([test "$have_synapseai" = "1" && test x"$with_synapseai" != x"yes"],
[CPPFLAGS="$CPPFLAGS $synapseai_CPPFLAGS"
LDFLAGS="$LDFLAGS $synapseai_LDFLAGS"])
enable_memhooks=1
AC_ARG_ENABLE([memhooks-monitor],
[AS_HELP_STRING([--disable-memhooks-monitor],
[Determine whether memhooks memory monitor is disabled.])],
[AS_IF([test "$enable_memhooks_monitor" = "no"],[enable_memhooks=0])],
[])
AC_DEFINE_UNQUOTED(ENABLE_MEMHOOKS_MONITOR, [$enable_memhooks],
[Define to 1 to enable memhooks memory monitor])
dnl Check for LTTNG tracing capability
have_lttng=0
AC_ARG_WITH([lttng],
AS_HELP_STRING([--with-lttng=DIR],
[Enable LTTng userspace tracepoints @<:@default=no@:>@]))
AS_IF([test -n "$with_lttng" && test x"$with_lttng" != x"no"],
[FI_CHECK_PACKAGE([lttng],
[lttng/tracepoint.h],
[lttng-ust],
[lttng_ust_init_thread],
[],
[$with_lttng],
[],
[have_lttng=1],
[AC_MSG_ERROR([LTTng-UST support requested but liblttng-ust is not available.])])
])
AS_IF([test "$have_lttng" = "1" && test x"$with_lttng" != x"yes"],
[CPPFLAGS="$CPPFLAGS $lttng_CPPFLAGS"
LDFLAGS="$LDFLAGS $lttng_LDFLAGS"])
AM_CONDITIONAL([HAVE_LTTNG], test "$have_lttng" -eq 1)
AC_DEFINE_UNQUOTED([HAVE_LTTNG], [$have_lttng], [Build with LTTng userspace tracepoints])
AS_IF([test "$enable_memhooks" = "1"], [
AC_CHECK_FUNCS([__curbrk __clear_cache])
AC_CHECK_HEADERS([linux/mman.h sys/syscall.h])
AC_CHECK_DECLS([__syscall], [], [], [#include <sys/syscall.h>])
AC_CHECK_FUNCS([__syscall])
], [])
enable_uffd=1
AC_ARG_ENABLE([uffd-monitor],
[AS_HELP_STRING([--disable-uffd-monitor],
[Determine whether uffd memory monitor is disabled.])],
[AS_IF([test "$enable_uffd_monitor" = "no"], [enable_uffd=0])],
[])
AC_DEFINE_UNQUOTED(ENABLE_UFFD_MONITOR, [$enable_uffd],
[Define to 1 to enable uffd memory monitor])
AH_BOTTOM([
#if defined(__linux__) && (defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || (defined(__riscv) && __riscv_xlen == 64)) && ENABLE_MEMHOOKS_MONITOR
#define HAVE_MEMHOOKS_MONITOR 1
#else
#define HAVE_MEMHOOKS_MONITOR 0
#endif
#if HAVE_UFFD_UNMAP && ENABLE_UFFD_MONITOR
#define HAVE_UFFD_MONITOR 1
#else
#define HAVE_UFFD_MONITOR 0
#endif
])
#gdrcopy related configs
AC_ARG_WITH([gdrcopy],
[AS_HELP_STRING([--with-gdrcopy=DIR], [Enable gdrcopy build and fail if not found.
Optional=<Path to where the gdrcopy development
and runtime libraries are installed.>])])
have_gdrcopy=0
gdrcopy_dlopen=0
AC_ARG_ENABLE([gdrcopy-dlopen],
[AS_HELP_STRING([--enable-gdrcopy-dlopen],
[Enable dlopen of gdrcopy libraries @<:@default=no@:>@])
],
[
AS_IF([test "$with_dlopen" = "no"],
[AC_MSG_ERROR([dlopen not found. libfabric requires libdl.])])
AS_IF([test "$enable_gdrcopy_dlopen" != "no"], [gdrcopy_dlopen=1])
])
AS_IF([test "$have_cuda" = 1 && test x"$with_gdrcopy" != x"no"],
[
AS_IF([test "$gdrcopy_dlopen" != "0"],
[
_FI_CHECK_PACKAGE_HEADER([gdrcopy],
[gdrapi.h],
[$with_gdrcopy],
[have_gdrcopy=1],
[AC_MSG_ERROR([gdrcopy headers not found. Cannot enable gdrcopy DL])])
],
[
FI_CHECK_PACKAGE([gdrcopy],
[gdrapi.h],
[gdrapi],
[gdr_open],
[],
[$with_gdrcopy],
[],
[have_gdrcopy=1])
])
])
AC_DEFINE_UNQUOTED([ENABLE_GDRCOPY_DLOPEN], [$gdrcopy_dlopen], [dlopen gdrcopy libraries])
AS_IF([test x"$with_gdrcopy" != x"no" && test -n "$with_gdrcopy" && test "$have_gdrcopy" = "0" ],
[AC_MSG_ERROR([gdrcopy support requested but gdrcopy runtime not available.])])
AC_DEFINE_UNQUOTED([HAVE_GDRCOPY], [$have_gdrcopy], [gdrcopy support])
AS_IF([test "$gdrcopy_dlopen" != "1"], [LIBS="$LIBS $gdrcopy_LIBS"])
AS_IF([test "$have_gdrcopy" = "1" && test x"$with_gdrcopy" != x"yes"],
[CPPFLAGS="$CPPFLAGS $gdrcopy_CPPFLAGS"
LDFLAGS="$LDFLAGS $gdrcopy_LDFLAGS"])
#end gdrcopy configures
dnl Check for ROCR runtime libraries.
AC_ARG_WITH([rocr],
[AS_HELP_STRING([--with-rocr=DIR], [Enable ROCR/HSA build and fail if not found.
Optional=<Path to where the ROCR/HSA libraries
and headers are installed.>])])
have_rocr=0
rocr_dlopen=0
have_hsa_amd_portable_export_dmabuf=0
AC_ARG_ENABLE([rocr-dlopen],
[AS_HELP_STRING([--enable-rocr-dlopen],
[Enable dlopen of ROCR libraries @<:@default=no@:>@])
],
[
AS_IF([test "$with_dlopen" = "no"],
[AC_MSG_ERROR([dlopen not found. libfabric requires libdl.])])
AS_IF([test "$enable_rocr_dlopen" != "no"], [rocr_dlopen=1])
])
AS_IF([test x"$with_rocr" != x"no"],
[
AS_IF([test "$rocr_dlopen" != "0"],
[
_FI_CHECK_PACKAGE_HEADER([rocr],
[hsa/hsa_ext_amd.h],
[$with_rocr],
[have_rocr=1],
[AC_MSG_ERROR([ROCR headers not found. Cannot enable ROCR DL])])
],
[
FI_CHECK_PACKAGE([rocr],
[hsa/hsa_ext_amd.h],
[hsa-runtime64],
[hsa_amd_pointer_info],
[],
[$with_rocr],
[$with_rocr/lib],
[have_rocr=1])
])
])
AC_DEFINE_UNQUOTED([ENABLE_ROCR_DLOPEN], [$rocr_dlopen], [dlopen ROCR libraries])
AS_IF([test x"$with_rocr" != x"no" && test -n "$with_rocr" && test "$have_rocr" = "0" ],
[AC_MSG_ERROR([ROCR support requested but ROCR runtime not available.])])
AC_DEFINE_UNQUOTED([HAVE_ROCR], [$have_rocr], [ROCR support])
AS_IF([test "$rocr_dlopen" != "1"], [LIBS="$LIBS $rocr_LIBS"])
AS_IF([test "$have_rocr" = "1" && test x"$with_rocr" != x"yes"],
[CPPFLAGS="$CPPFLAGS $rocr_CPPFLAGS"
LDFLAGS="$LDFLAGS $rocr_LDFLAGS"
have_hsa_amd_portable_export_dmabuf=1
AC_CHECK_DECL([hsa_amd_portable_export_dmabuf],
[],
[have_hsa_amd_portable_export_dmabuf=0],
[[#include <hsa/hsa_ext_amd.h>]])
AC_CHECK_DECL([HSA_AMD_SYSTEM_INFO_DMABUF_SUPPORTED],
[],
[have_hsa_amd_portable_export_dmabuf=0],
[[#include <hsa/hsa.h>]])
],
[])
AC_DEFINE_UNQUOTED([HAVE_HSA_AMD_PORTABLE_EXPORT_DMABUF],[$have_hsa_amd_portable_export_dmabuf],[dmabuf handle support])
AC_CHECK_SIZEOF([void *])
dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
dnl allows for building with clang lto and fast linking with non gnu ld
dnl --> checking if the linker (clang) is GNU ld... no
AS_CASE(["$LD"],
[*clang*],
[AS_CASE(["${host_os}"],
[*linux*],
[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$libname.map -o $lib'])])
dnl Provider-specific checks