-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·1422 lines (1301 loc) · 50.8 KB
/
configure
File metadata and controls
executable file
·1422 lines (1301 loc) · 50.8 KB
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
#!/bin/sh
#
# This file is NOT generated (e.g. don't look for configure.ac).
#
# TODO:
# + sanitize/filter GASNET_CONFIGURE_ARGS ??
##
## Begin portable (no bash-isms) logic to check for correct shell.
## We try to reexec with bash if present in $PATH
##
# Note tcsh graciously yields 'BASH_VERSION: Undefined variable' before giving up here.
if test -z "$BASH_VERSION"; then
if test -z "$UPCXX_REEXEC"; then
exec env UPCXX_REEXEC=1 bash "$0" "$@"
fi
fi
# Issue 364: try to avoid /bin/sh that enables bash POSIX mode and is non-standard on Apple
if test x"$BASH" = x"/bin/sh" && test -z "$UPCXX_REEXEC$UPCXX_REEXEC_SILENT" ; then
if test -x /bin/bash ; then
exec env UPCXX_REEXEC_SILENT=1 /bin/bash "$0" "$@"
fi
# on exec failure, try again in PATH
exec env UPCXX_REEXEC=1 bash "$0" "$@"
fi
# Minimum we support is 3.2.57
UPCXX_BASH_MAJ=3
UPCXX_BASH_MIN=2
UPCXX_BASH_PATCH=57
UPCXX_BASH_FLOOR="$UPCXX_BASH_MAJ.$UPCXX_BASH_MIN.$UPCXX_BASH_PATCH"
bad_shell() {
echo "ERROR: UPC++ requires bash version $UPCXX_BASH_FLOOR or newer, please re-run" >&2
echo "ERROR: using '/full/path/to/suitable/bash $0 [args]'" >&2
echo "ERROR: $*" >&2
exit 1
}
# Either could not exec bash in $PATH or we did and it is not bash
if test -z "$BASH_VERSION" || test -z "$BASH"; then
bad_shell 'bash was not found in $PATH, or does not appear to be bash.'
fi
##
## End portable (no bash-isms) logic.
## We may now assume we are running bash
##
## Versioning scheme changed between 2 and 3, but has been stable since
if (( BASH_VERSINFO[0] < 3 )) ||
(( 10000*BASH_VERSINFO[0] + 100*BASH_VERSINFO[1] + BASH_VERSINFO[2] <
10000*UPCXX_BASH_MAJ + 100*UPCXX_BASH_MIN + UPCXX_BASH_PATCH )); then
bad_shell "This bash reports a version of '$BASH_VERSION'."
fi
set +o posix
# Record the full command line (with shell quoting, suitable for reexecution).
# The value has ": " prefixed, but rather than trim that off, we encorporate
# it into the final output.
fullcmd=$(set -- "$0" "$@"; PS4=; exec 2>&1; set -x; : "$@")
# Preserve command and all output for post mortem
if [[ -z "$UPCXX_CONFIGURE_TEED" ]]; then
echo "UPC++ configure$fullcmd" >| config.log
exec &> >(tee -a config.log)
UPCXX_CONFIGURE_TEED=y exec $BASH "$0" "$@"
fi
#
# Usage
#
function usage {
cat <<'EOF'
Usage:
--prefix=...
Specifies the installation directory.
The default is '/usr/local/upcxx'.
--with-cc=...
--with-cxx=...
Specify the C and C++ compilers to use.
Override the values of $CC and $CXX, if any.
The (platform dependent) default is usually appropriate.
--enable-allow-mismatched-compilers
--disable-allow-mismatched-compilers
Controls compiler version sanity checking
By default, this configure script rejects use of CXX and CC which do
not appear to be from the same release. The enable form of this option
converts this behavior to a warning, while the disable form restores
the default (error) behavior.
--with-cross(=...)
--without-cross
Control cross-compilation.
Passing `--with-cross` (without a value) requests the default
auto-detection behavior, while providing a value requests a
specific cross-compilation target.
Passing `--without-cross` disables cross-compilation.
Overrides the value of $UPCXX_CROSS, if any.
The default behavior (auto-detection) is appropriate unless
auto-detection is making the wrong choice.
--enable-cuda
--disable-cuda
Enabled or disable UPC++ Memory Kinds over NVIDIA CUDA.
Overrides the value of $UPCXX_CUDA, if any.
--with-nvcc=...
Overrides the value of $UPCXX_CUDA_NVCC, if any.
The default is to search for 'nvcc' in $PATH.
--with-cuda-cppflags=...
Sets the pre-processor flags needed to find CUDA runtime headers.
Overrides the value of $UPCXX_CUDA_CPPFLAGS, if any.
The default is to probe 'nvcc'.
--with-cuda-libflags=...
Sets the linker flags needed to link CUDA runtime libraries.
Overrides the value of $UPCXX_CUDA_LIBFLAGS, if any.
The default is to probe 'nvcc'.
--enable-hip
--disable-hip
Enable or disable UPC++ Memory Kinds over AMD ROCm/HIP.
--with-hip-home=...
Install prefix of HIP developer tools
The default is determined by searching for 'hipcc' in $PATH.
--with-hip-cppflags=...
Sets the pre-processor flags needed to find HIP runtime headers.
Overrides the value of $UPCXX_HIP_CPPFLAGS, if any.
The default is automatically determined based on the host compiler.
--with-hip-libflags=...
Sets the linker flags needed to link HIP runtime libraries.
Overrides the value of $UPCXX_HIP_LIBFLAGS, if any.
The default is automatically determined.
--with-hip-platform=nvidia
Activates EXPERIMENTAL support for --enable-hip using HIP-over-CUDA on NVIDIA GPUs.
Additionally requires a working CUDA installation (details in INSTALL.md).
The default of --with-hip-platform=amd selects AMD-branded GPU hardware.
--enable-ze
--disable-ze
Enable or disable UPC++ Memory Kinds over Intel Level Zero.
--with-ze-home=...
Install prefix of Level Zero developer tools
The default is determined by searching for 'ocloc' in $PATH.
--with-ze-cppflags=...
Sets the pre-processor flags needed to find Level Zero runtime headers.
Overrides the value of $UPCXX_ZE_CPPFLAGS, if any.
The default is automatically determined.
--with-ze-libflags=...
Sets the linker flags needed to link ze runtime libraries.
Overrides the value of $UPCXX_ZE_LIBFLAGS, if any.
The default is automatically determined.
--enable-ccs-rpc
--disable-ccs-rpc
Enable or disable support for Cross Code Segment (CCS) RPC and
CCS error detection.
--with-default-network=...
Specifies the default network.
The default is system dependent.
--with-gasnet=...
Specifies the URL or path of GASNet sources.
Overrides the value of $GASNET, if any.
The default is normally sufficient.
--with-gmake=...
Specify the location of GNU Make 3.80 or newer.
Overrides the value of $GMAKE, if any.
Default is to search for 'gmake' or 'make' in $PATH.
--with-python=...
Specify the location of Python3 or Python2 version 2.7.5 or newer.
Overrides the value of $UPCXX_PYTHON, if any.
Default is to search for common Python interpreter names in $PATH
at configure time for any meeting the version requirement. The first
one thus identified is then located in $PATH dynamically at runtime.
--enable-valgrind
Enable limited support for the Valgrind dynamic analysis tool,
at some potential cost in performance (off by default).
--enable-discontig-ranks
Enable support for process layouts where the rank numbering assigned
at job spawn is permitted to be discontiguous on any given physical host.
Otherwise, co-located ranks are required to be contiguously numbered.
-h|--help|--usage
Produces this message.
--help=recursive
Produces this message and GASNet's `configure --help` message.
-V|--version
Report version and copyright.
All unrecognized arguments will be passed to GASNet's configure.
Some influential environment variables:
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CXXCPP C++ preprocessor
CC C compiler command
CFLAGS C compiler flags
CPP C preprocessor
CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
headers in a nonstandard directory <include dir>
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to upcxx@googlegroups.com or at https://upcxx-bugs.lbl.gov
UPC++ home page: https://upcxx.lbl.gov
See INSTALL.md for additional information.
EOF
}
function version {
header="$UPCXX_SRC/src/version.hpp"
version=$(grep "# *define *UPCXX_VERSION " ${header} 2>/dev/null| head -1)
if [[ "$version" =~ ([0-9]{4})([0-9]{2})([0-9]{2}) ]]; then
version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]#0}.${BASH_REMATCH[3]#0}"
else
version=${version##*UPCXX_VERSION }
fi
githash=$(git describe --always 2> /dev/null)
echo "UPC++ version $version $githash"
echo "Copyright (c) 2025, The Regents of the University of California,"
echo "through Lawrence Berkeley National Laboratory."
echo "https://upcxx.lbl.gov"
echo ""
}
#
# Global variables
#
# This script's name and location
self=$(basename $0)
UPCXX_SRC=$(cd $(dirname $(type -p $0)) && pwd -P)
# Default installation prefix
PREFIX=/usr/local/upcxx
# Init some options that are undocumented and/or have no documented envvar switch
single=''
hip_platform=''
# Text to emit at end
# Each distinct warning added should start with a newline
warnings=''
# backwards compat: CROSS
# must preserve both unset and set-but-empty, which have significance
if [[ ${UPCXX_CROSS-unset}${CROSS+set} == 'unsetset' ]]; then
export UPCXX_CROSS=${CROSS}
fi
# Preserve env vars which options processing may clobber
UPCXX_CONFIG_ENVVARS=( CC CFLAGS CXX CXXFLAGS CPPFLAGS LDFLAGS LIBS\
GASNET GASNET_CONDUIT GASNET_CONFIGURE_ARGS UPCXX_CROSS \
GMAKE UPCXX_PYTHON \
UPCXX_CUDA{,_NVCC,_CPPFLAGS,_LIBFLAGS} \
HIP_HOME UPCXX_HIP{,_CPPFLAGS,_LIBFLAGS} \
ZE_HOME UPCXX_ZE{,_CPPFLAGS,_LIBFLAGS} )
for var in ${UPCXX_CONFIG_ENVVARS[*]} ; do
eval ORIG_$var=\'${!var}\'
done
# Clear "new" non-legacy configure options
# these are only accepted on the configure line and not via environment
UPCXX_VALGRIND=
UPCXX_DISCONTIG=
UPCXX_FORCE_LEGACY_RELOCATIONS=''
UPCXX_HAVE_OPENMP=
UPCXX_HAVE_CXX17=
unset gasnet_help
#
# Error handling
#
function echo_and_die {
echo $* >&2
exit 1
}
function failure_and_die {
echo "UPC++ configuration failed. Please report the entire log above to: upcxx@googlegroups.com" >&2
exit 1
}
function get_arg_val {
if [[ "$*" =~ (^[^=]*=(.+)) ]]; then
echo "${BASH_REMATCH[2]}"
else
echo "ERROR: option '${1%=}' is missing its required value." >&2
echo "Run '$0 --help' for complete usage information." >&2
exit 1
fi
}
#
# Argument parsing
#
shopt -s extglob
trap exit ERR # so exit in get_arg_val exits from top-level
# DO NOT simplify 'FOO="$(get_arg_val $1)"; export FOO;' to a single command, or get_arg_val can't fatal-exit
while [[ $# -gt 0 ]]; do
arg="$1"
orig_arg="$1"
shift
# uniform preprocessing on args:
if [[ "$arg" =~ (^-+(.+)) ]]; then # normalize to single dash
arg="-${BASH_REMATCH[2]}"
fi
if [[ "$arg" =~ (^-+enable-(.+)) ]]; then # -enable => -with
arg="-with-${BASH_REMATCH[2]}"
fi
if [[ "$arg" =~ (^-+disable-(.+)) ]]; then # -disable => -without
arg="-without-${BASH_REMATCH[2]}"
fi
#echo "configure: arg '$orig_arg' => '$arg'"
case "$arg" in
# Passed explicitly to GASNet's configure:
-prefix?(=*)) PREFIX="$(get_arg_val $arg)";;
# Used to find and run GASNet's configure:
-with-gasnet?(=*)) GASNET="$(get_arg_val $arg)"; export GASNET;;
-with-cross) unset UPCXX_CROSS; export UPCXX_CROSS;;
-with-cross?(=*)) UPCXX_CROSS="$(get_arg_val $arg)"; export UPCXX_CROSS;;
-without-cross) UPCXX_CROSS=''; export UPCXX_CROSS;;
# Not relevant to GASNet's configure:
-with-default-network?(=*)) GASNET_CONDUIT="$(get_arg_val $arg)"; export GASNET_CONDUIT;;
-with-python?(=*)) UPCXX_PYTHON="$(get_arg_val $arg)"; export UPCXX_PYTHON;;
-without-discontig-ranks) UPCXX_DISCONTIG=''; export UPCXX_DISCONTIG;;
-with-discontig-ranks) UPCXX_DISCONTIG=1; export UPCXX_DISCONTIG
warnings+="\nWARNING: --enable-discontig-ranks mode activated.\n"
warnings+='WARNING: This mode has not been carefully tuned and is not recommended for general use.\n'
warnings+='WARNING: If this feature matters to you, please let us know!\n'
;;
-with-allow-compiler-mismatch) UPCXX_ALLOW_COMPILER_MISMATCH=1;;
-without-allow-compiler-mismatch) UPCXX_ALLOW_COMPILER_MISMATCH=0;;
# Passed explicitly to GASNet's configure, potentially after some processing:
-with-cc?(=*)) CC="$(get_arg_val $arg)"; export CC;;
-with-cxx?(=*)) CXX="$(get_arg_val $arg)"; export CXX;;
-with-cflags?(=*)) CFLAGS="$(get_arg_val $arg)"; export CFLAGS;; # NOT documented in usage
-with-cxxflags?(=*)) CXXFLAGS="$(get_arg_val $arg)"; export CXXFLAGS;;# NOT documented in usage
-with-ldflags?(=*)) LDFLAGS="$(get_arg_val $arg)"; export LDFLAGS;; # NOT documented in usage
# Passed to GASNet's configure implicitly via environment:
-with-gmake?(=*)) GMAKE="$(get_arg_val $arg)"; export GMAKE;;
# Note GASNet's related configure option(s) handled later
-with-cuda) UPCXX_CUDA=1; export UPCXX_CUDA;;
-without-cuda) unset UPCXX_CUDA;;
-with-nvcc?(=*)) UPCXX_CUDA_NVCC="$(get_arg_val $arg)"; export UPCXX_CUDA_NVCC;;
-with-cuda-cppflags?(=*)) UPCXX_CUDA_CPPFLAGS="$(get_arg_val $arg)"; export UPCXX_CUDA_CPPFLAGS;;
-with-cuda-libflags?(=*)) UPCXX_CUDA_LIBFLAGS="$(get_arg_val $arg)"; export UPCXX_CUDA_LIBFLAGS;;
-with-hip) UPCXX_HIP=1; export UPCXX_HIP;;
-without-hip) unset UPCXX_HIP;;
-with-hip-home?(=*)) HIP_HOME="$(get_arg_val $arg)"; export HIP_HOME;;
-with-hip-cppflags?(=*)) UPCXX_HIP_CPPFLAGS="$(get_arg_val $arg)"; export UPCXX_HIP_CPPFLAGS;;
-with-hip-libflags?(=*)) UPCXX_HIP_LIBFLAGS="$(get_arg_val $arg)"; export UPCXX_HIP_LIBFLAGS;;
-with-ze) UPCXX_ZE=1; export UPCXX_ZE;;
-without-ze) unset UPCXX_ZE;;
-with-ze-home?(=*)) ZE_HOME="$(get_arg_val $arg)"; export ZE_HOME;;
-with-ze-cppflags?(=*)) UPCXX_ZE_CPPFLAGS="$(get_arg_val $arg)"; export UPCXX_ZE_CPPFLAGS;;
-with-ze-libflags?(=*)) UPCXX_ZE_LIBFLAGS="$(get_arg_val $arg)"; export UPCXX_ZE_LIBFLAGS;;
-with-ccs-rpc) UPCXX_FORCE_LEGACY_RELOCATIONS=''; export UPCXX_FORCE_LEGACY_RELOCATIONS;;
-without-ccs-rpc) UPCXX_FORCE_LEGACY_RELOCATIONS=1; export UPCXX_FORCE_LEGACY_RELOCATIONS;;
-h|-help|-usage)
echo 'UPC++ configure script.'
echo '======================='
usage;
exit 0;
;;
-help=recursive)
echo 'UPC++ configure script.'
echo '======================='
usage;
echo
echo 'GASNet-EX configure script.'
echo '==========================='
gasnet_help=1
;;
-V|-version)
version;
exit 0;
;;
# These are not in the usage message, but autoconf-familiar users may expect these to work:
CC?(=*)) CC="$(get_arg_val $arg)"; export CC;;
CXX?(=*)) CXX="$(get_arg_val $arg)"; export CXX;;
CFLAGS?(=*)) CFLAGS="$(get_arg_val $arg)"; export CFLAGS;;
CXXFLAGS?(=*)) CXXFLAGS="$(get_arg_val $arg)"; export CXXFLAGS;;
LDFLAGS?(=*)) LDFLAGS="$(get_arg_val $arg)"; export LDFLAGS;;
# These are to remain undocumented
-v|-verbose) set -x ;;
-with-single?(=*))
single="$(get_arg_val $arg)"
warnings+="\nWARNING: --enable-single=$single mode enabled.\n"
warnings+='WARNING: This mode is intended for maintainers only.\n'
warnings+='WARNING: Many make targets will fail and components will be missing.\n'
;;
-with-mpsc-queue=*)
UPCXX_MPSC_QUEUE="$(get_arg_val $arg)"; export UPCXX_MPSC_QUEUE
;;
# deliberately undocumented maintainer flags to control default dev-test set
-with-tests-cxx17) UPCXX_HAVE_CXX17=1 ; export UPCXX_HAVE_CXX17 ;;
-without-tests-cxx17) UPCXX_HAVE_CXX17= ; export UPCXX_HAVE_CXX17 ;;
-with-tests-openmp) UPCXX_HAVE_OPENMP=1 ; export UPCXX_HAVE_OPENMP ;;
-without-tests-openmp) UPCXX_HAVE_OPENMP= ; export UPCXX_HAVE_OPENMP ;;
*) # Anything we don't consume above will be passed to GASNet's configure
case "$arg" in
# These options are interpreted here and ALSO passed to GASNet's configure
-with-valgrind) UPCXX_VALGRIND=1 ; export UPCXX_VALGRIND;;
-without-valgrind) UPCXX_VALGRIND= ; export UPCXX_VALGRIND;;
# Deliberately Undocumented
-with-hip-platform?(=*)) hip_platform="$(get_arg_val $arg)";
esac
# Quoting is believed sufficient for space, tab, single-quote and double-quote.
# We pass the unmodified argument to GASNet configure
GASNET_CONFIGURE_ARGS+="${GASNET_CONFIGURE_ARGS+ }\"${orig_arg//\"/\\\"}\""
;;
esac
done
trap failure_and_die ERR # errors after arg parsing are fatal
#
# Helper functions
#
# Warn if a prog was found outside a whitelist of paths
function check_known_path {
local exe="${1%% *}"
case $(dirname "$exe") in
/bin|/usr/bin|/usr/local/bin|/usr/pkg/bin|/opt/csw/bin)
# OK
;;
*)
warnings+="${2+\nWARNING: $2\n}"
warnings+='WARNING: This full path will be encoded in installed scripts.\n'
warnings+='WARNING: Please ensure it is valid for all users and on all nodes.\n'
warnings+="WARNING: Alternatively, configuring with '/usr/bin/env $(basename $exe)'\n"
warnings+='WARNING: can be used to defer the $PATH search until run time.\n'
esac
}
# check_tool_path()
#
# input: the path or filename to check
# accepts full paths
# searches for bare names (no /) in $PATH
# rejects relative paths and bare names not found in $PATH
# also rejects any input which is missing or not executable
# on success returns zero with absolute path on stdout
# returns non-zero on failure with (partial) error message on stdout
check_tool_path() {
local exe="${1%% *}"
local args="${1/$exe}"
if [[ $exe =~ ^/ ]]; then
# full path: check that it exists and is executable
if [[ ! -x $exe ]]; then
echo 'does not exist or is not executable'
return 1
fi
echo "$exe$args"
elif [[ ! $exe =~ / ]]; then
# bare tool name: search in $PATH
local output=$(type -p "$exe" 2>/dev/null || true)
if [[ -z $output || ! -x $output ]]; then
echo 'was not found in $PATH'
return 1
fi
echo "$output$args"
else
# relative path: prohibited
echo 'is a relative path (not permitted)'
return 1
fi
return 0
}
#
# Default GASNet source
# Enable offline installers with an embedded GASNet-EX tarball
#
GASNET_DEFAULT='https://bitbucket.org/berkeleylab/gasnet/downloads/GASNet-stable.tar.gz' # Un-comment for development
#GASNET_DEFAULT='https://gasnet.lbl.gov/EX/GASNet-2025.8.0.tar.gz' # Un-comment for release
#GASNET_DEFAULT='NONE' # Un-comment for snapshots
gex_offline=`/bin/ls "$UPCXX_SRC"/src/GASNet-{stable,2???.*}.tar.gz 2> /dev/null | sort -t. -k1,1 -k2,2n -k3n | tail -1`
if [[ -n "$GASNET" ]]; then
: # keep defn
elif [[ -r "$gex_offline" ]]; then
GASNET="$gex_offline"
elif [[ $GASNET_DEFAULT == 'NONE' ]]; then
echo_and_die 'There is no GASNet tarball available for this UPC++ version. Please obtain a tarball of this UPC++ version containing an embedded GASNet archive.'
else
GASNET=$GASNET_DEFAULT
fi
#
# Fetch and unpack GASNet (as required) and verify
#
function bad_gasnet_fetch {
echo Error: $* >&2
echo_and_die "Please correct the URL or point --with-gasnet=... at a manually downloaded GASNet source .tar.gz file ($GASNET_DEFAULT is the recommended version)"
}
ORIG_GASNET="$GASNET"
GASNET_UNPACKED=""
GASNET_TYPE=source # default
if [[ -n "$single" && -r "$GASNET/gasnet_config.h" ]] ; then
# single + GASNET=builddir (may or may not be a srcdir as well)
GASNET_TYPE=build
# Convert relative path of build directory to absolute if necessary
if ! expr "/$GASNET" : // >/dev/null; then
export GASNET=$(cd "$GASNET" && pwd -P)
fi
elif [ -r "$GASNET/gasnet_config.h.in" ]; then
# Convert relative path of souce directory to absolute if necessary
if ! expr "/$GASNET" : // >/dev/null; then
export GASNET=$(cd "$GASNET" && pwd -P)
fi
elif [ -r "$GASNET/gasnetex.h" ]; then
echo_and_die "GASNET='$GASNET' appears to be an un-bootstraped source tree. Please run '$GASNET/Bootstrap'"
elif expr "$GASNET" : '.*\.tar\.gz' >/dev/null; then
# Unpack tarball into bld/
# Fetch if URL, check access if PATH
unset gex_tmp
if [[ "$GASNET" =~ ^http ]]; then
if [[ -n "$URL_CAT" ]] ; then
: # keep defn
elif [[ -n "$(type -p curl)" ]]; then
URL_CAT='curl --retry 5 -LsSf'
elif [[ -n "$(type -p wget)" ]]; then
URL_CAT='wget --tries=5 -nv -O -'
fi
if [ -z "$URL_CAT" ]; then
bad_gasnet_fetch "Do not know how to fetch a URL (did not find wget or curl in \$PATH)"
fi
gex_tmp="${GASNET##*/}"
echo Fetching $GASNET
eval "$URL_CAT '$GASNET' >'$gex_tmp'"
[[ $? -eq 0 && -r "$gex_tmp" ]] || bad_gasnet_fetch "Failed to fetch '$GASNET'"
else
if [[ ! -r "$GASNET" ]]; then
if [[ ! -e "$GASNET" ]]; then
failure='does not exist'
else
failure='cannot be read'
fi
echo_and_die "GASNET='$GASNET' specifies a file which $failure. Please unset \`GASNET\` in your environment to use the default, or provide a correct value using \`--with-gasnet=...\`"
fi
fi
GASNET="${gex_tmp:-$GASNET}"
unset gex_dir
gex_dir=$(gzip -cd "$GASNET" | tar tf - | head -1 | cut -d/ -f1)
[[ -n $gex_dir ]] || echo_and_die "Could not read TOC from GASNET='$GASNET' (corrupted or truncated?)"
gex_dir="$PWD/bld/$gex_dir"
if [[ -r "$gex_dir" ]]; then
# Sort out what to do about a conflicting destination
if [[ -n "$gasnet_help" ]]; then
: # leave it alone to ensure that --help=recursive is non-destructive
elif [[ ! -r "$gex_dir/gasnet_config.h.in" ]]; then
# Does not appear to be from a GASNet-EX tarball - give up rather than clobber
echo_and_die "Refusing to remove '$gex_dir', which does not appear to be a bootstrapped GASNet-EX source directory. You may need to manually rename or remove it to proceed."
else
rm -Rf "$gex_dir"
fi
fi
if [[ ! -r "$gex_dir" ]]; then
trap - ERR # suspend error handler for detailed diagnostics
mkdir -p bld
echo Unpacking $GASNET
gzip -cd "$GASNET" | ( cd bld && tar xf - )
rc1=${PIPESTATUS[0]} rc2=${PIPESTATUS[1]}
[ $rc1 -eq 0 ] || echo_and_die "Failed to gunzip '$GASNET' (corrupted or truncated?)"
[ $rc2 -eq 0 ] || echo_and_die "Failed to untar '$GASNET' (corrupted or truncated?)"
[ -r "$gex_dir/gasnet.h" ] || echo_and_die "GASNET='$ORIG_GASNET' does not appear to contain GASNet"
if [[ ! -r "$gex_dir/version.git" && -n $(type -p git) ]]; then
# Attempt to fill a missing version.git using commit id, if available
gex_hash=$(gzip -cd "$GASNET" | git get-tar-commit-id 2> /dev/null || echo INVALID)
[[ $gex_hash =~ (^[0-9a-fA-F]{40}$) ]] && echo "gex-archive-g${gex_hash:0:8}" > "$gex_dir/version.git"
fi
trap failure_and_die ERR # restore error handler
[ -n "$gex_tmp" ] && rm -f "$gex_tmp"
GASNET_UNPACKED=$gex_dir
echo
fi
export GASNET="$gex_dir"
else
echo_and_die "GASNET='$GASNET' is not a valid value. GASNET must name local tarball file, tarball url, or gasnet source tree. Please unset \`GASNET\` in your environment to use the default, or provide a correct value using \`--with-gasnet=...\`"
fi
if [[ "$GASNET_TYPE" == 'build' ]]; then
if [ -e "$GASNET/configure" ] ; then
gex_header="$GASNET/gasnetex.h"
else
gex_header='' # TODO: any non G-1 file to check in a VPATH build directory?
fi
gex_spec_file="$GASNET/gasnet_config.h"
else
gex_header="$GASNET/gasnetex.h"
gex_spec_file="$GASNET/docs/GASNet-EX.txt"
fi
# verify distinguishing file (if any)
[[ -z "$gex_header" || -r "$gex_header" ]] || \
echo_and_die "GASNET='$ORIG_GASNET' does not contain GASNet-EX (GASNet-1 or GASNet_Tools?)"
# verify minimum version
[[ $(grep 'EX_SPEC_VERSION_MAJOR' "$gex_spec_file" | head -1 | tr '\t' ' ') =~ ( ([0-9]+)) ]]
HAVE_MAJ=${BASH_REMATCH[2]}
[[ $(grep 'EX_SPEC_VERSION_MINOR' "$gex_spec_file" | head -1 | tr '\t' ' ') =~ ( ([0-9]+)) ]]
HAVE_MIN=${BASH_REMATCH[2]}
upcxx_header="$UPCXX_SRC/src/backend/gasnet/runtime_internal.hpp"
[[ $(grep 'UPCXXI_REQUIRES_GEX_SPEC_VERSION_MAJOR.*' "$upcxx_header" | head -1 | tr '\t' ' ') =~ ( ([0-9]+)) ]]
WANT_MAJ=${BASH_REMATCH[2]}
[[ $(grep 'UPCXXI_REQUIRES_GEX_SPEC_VERSION_MINOR.*' "$upcxx_header" | head -1 | tr '\t' ' ') =~ ( ([0-9]+)) ]]
WANT_MIN=${BASH_REMATCH[2]}
[[ ($HAVE_MAJ -gt $WANT_MAJ) || (($HAVE_MAJ -eq $WANT_MAJ) && ($HAVE_MIN -ge $WANT_MIN)) ]] || \
echo_and_die "GASNET='$ORIG_GASNET' does not contain GASNet-EX implementing specification version $WANT_MAJ.$WANT_MIN or newer"
#
# Bootstrap GASNet-EX sources, if needed
#
if [[ "$GASNET_TYPE" == 'source' && ! -r "$GASNET/gasnet_config.h.in" ]]; then
echo 'Bootstrapping GASNet-EX sources (please be patient)'
rm -f bootstrap.log
$GASNET/Bootstrap &> bootstrap.log || \
echo_and_die "GASNET='$ORIG_GASNET' appears to contain an un-bootstraped source tree and an attempt to bootstrap the sources has failed. This most often occurs when 'autoconf' or 'automake' are not available. Please see 'bootstrap.log' for the output of the failed GASNet-EX bootstrap."
rm -f bootstrap.log
echo
fi
#
# GASNet's help message if requested
#
if [[ -n "$gasnet_help" ]]; then
exec $GASNET/configure --help
echo "Failed to run GASNet's configure --help"
exit 1
fi
#
# Canonicalize $PREFIX
#
# Form a "textually canonical" path.
#
# + Result is a full path without any extraneous / or .
#
# + The input path can be relative or absolute
# + White space in path is safe and is preserved
# + The input path does not need to exist (and is not created)
#
# + Does NOT verify elems are dirs (so /etc/passwd/foo is acceptable)
# + Does NOT resolve symlinks
#
function canon_path() {
local path="$1"
# Make absolute if relative
[[ "$path" =~ (^/) ]] || path="$PWD/$path"
# Ensure trailing '/.' and '/..' are not special cases
path="$path/"
# Convert '//' and '/./' to '/'
while true; do
local tmp=$(sed -e 's|//*|/|g' -e 's|/\./|/|g' <<<"$path")
[[ "$tmp" = "$path" ]] && break
path="$tmp"
done
# Remove all 'dir/../'
while true; do
local tmp=$(sed -e 's|[^/][^/]*/\.\./||g' <<<"$path")
[[ "$tmp" = "$path" ]] && break
path="$tmp"
done
# Convert any leading '/../' to '/'
while true; do
local tmp=$(sed -e 's|^/\.\./|/|g' <<<"$path")
[[ "$tmp" = "$path" ]] && break
path="$tmp"
done
path="${path/%\//}" # removes the trailing /
if [[ -n "$path" ]]; then echo "$path"; else echo '/'; fi
}
PREFIX=$(canon_path "$PREFIX")
#
# --enable-single={opt,debug}
#
case $single in
'')
UPCXX_DBGOPT='debug opt'
;;
opt|debug)
UPCXX_DBGOPT=$single
;;
*)
echo_and_die "ERROR: --enable-single='$single' is not a valid option"
;;
esac
#
# Default UPCXX_MPSC_QUEUE
#
if [[ -z "$UPCXX_MPSC_QUEUE" ]] ; then
UPCXX_MPSC_QUEUE=atomic
else
case "$UPCXX_MPSC_QUEUE" in
atomic|biglock)
;; # OK
*)
echo "ERROR: UPCXX_MPSC_QUEUE='$UPCXX_MPSC_QUEUE' is not a valid value."
echo_and_die 'See docs/maintainer.md for valid values and additional info.'
;;
esac
fi
#
# Cross-compilation
#
if [[ ${UPCXX_CROSS-unset} == 'unset' ]]; then
: # attempt to auto-detect from environment if/when possible
else
case $UPCXX_CROSS in
'')
# disabled: nothing to do
;;
*)
# explicit but unknown
warnings+="\nWARNING: Unrecognized (thus unsupported) cross-compilation target '$UPCXX_CROSS'\n"
;;
esac
fi
export UPCXX_CROSS
#
# system-checks
#
. $UPCXX_SRC/utils/system-checks.sh
sys_info
platform_sanity_checks
platform_settings
#
# Ensure Makefile captures any env vars that platform_sanity_checks may have set/modified
#
export CC
export CXX
# Quoting is believed sufficient for space, tab, single-quote and double-quote.
# Do not make these conditional on non-empty values. We want to preserve empty values too.
GASNET_CONFIGURE_ARGS+=" --with-cc=\"${CC//\"/\\\"}\""
GASNET_CONFIGURE_ARGS+=" --with-cflags=\"${CFLAGS//\"/\\\"}\""
GASNET_CONFIGURE_ARGS+=" --with-cxx=\"${CXX//\"/\\\"}\""
GASNET_CONFIGURE_ARGS+=" --with-cxxflags=\"${CXXFLAGS//\"/\\\"}\""
GASNET_CONFIGURE_ARGS+=" --with-ldflags=\"${LDFLAGS//\"/\\\"}\""
#
# Colorization support
# Use of __INTEL_POST_CFLAGS is an ugly hack to convert a specific warning to an error
# TODO: better soln for Intel?
#
color_opts=( '-fdiagnostics-color=always' )
echo 'int main() { return 0; }' >| conftest.c
UPCXX_COLOR_CFLAGS=''
for opt in "${color_opts[@]}"; do
if __INTEL_POST_CFLAGS+=' -we10148' $CC -c $opt -o conftest.o conftest.c >& /dev/null; then
UPCXX_COLOR_CFLAGS="$opt"
break
fi
done
echo 'int main() { return 0; }' >| conftest.cpp
UPCXX_COLOR_CXXFLAGS=''
for opt in "${color_opts[@]}"; do
if __INTEL_POST_CFLAGS+=' -we10148' $CXX -c $opt -o conftest.o conftest.cpp >& /dev/null; then
UPCXX_COLOR_CXXFLAGS="$opt"
break
fi
done
rm -f conftest.cpp conftest.c conftest.o
#
# UPCXX_PYTHON
# First expand full path or validating existence
# Second check version
#
UPCXX_PYTHON_MIN=2.7.5
function check_py {
"$@" -c "import sys; sys.exit(sys.version_info < (${UPCXX_PYTHON_MIN//./,}));" &> /dev/null;
}
unset py fpy # given/guessed value and its full path
if [[ -n $UPCXX_PYTHON ]]; then
py="$UPCXX_PYTHON"
fpy=$(check_tool_path "$UPCXX_PYTHON") && : # "&& :" prevents ERR trap but preserves $?
if [[ $? -ne 0 ]]; then
echo "ERROR: Python interpreter '$UPCXX_PYTHON' $fpy." >&2
echo_and_die "Use '--with-python=...' to specify a different Python interpreter."
elif [[ $UPCXX_PYTHON =~ ^/ ]]; then
python_whence='specified by full path'
else
python_whence='found in $PATH'
fi
fpy_ver="$($fpy --version 2>&1)" && :
if [[ $? -ne 0 ]]; then
echo_and_die "ERROR: Requested python interpreter failed running '$UPCXX_PYTHON --version'"
fi
if ! check_py $fpy &> /dev/null; then
echo "ERROR: Requested python interpreter '$UPCXX_PYTHON' reports version '$fpy_ver'" >&2
echo_and_die "ERROR: Python interpreter is older than the minimum of $UPCXX_PYTHON_MIN."
fi
else
for py in python python3 python3.{0..20} python2; do
tmp=$(type -p "$py" 2>/dev/null || true)
if [[ -n $tmp && -x $tmp ]] && check_py $tmp; then
fpy="$tmp"
break
fi
done
if [[ -z "$fpy" ]]; then
echo 'ERROR: No suitable Python interpreter was found in $PATH'
echo_and_die "Use '--with-python=...' to specify a Python interpreter ($UPCXX_PYTHON_MIN or newer)."
fi
python_whence='found in $PATH'
fpy_ver="$($fpy --version 2>&1)"
fi
if test -z "$UPCXX_INSTALL_QUIET"; then
echo "$fpy: $fpy_ver"; echo
fi
if [[ -n $UPCXX_PYTHON ]]; then
UPCXX_PYTHON="$fpy"
check_known_path "$fpy" "Python interpreter '$fpy' $python_whence."
else
# If UPCXX_PYTHON unset, then preserve run-time search of $PATH
UPCXX_PYTHON="/usr/bin/env $py"
fi
#
# Find a usable GNU Make
#
# NOTES:
# 1. The current regexp captures the patch level, but it is not yet used.
# 2. The GMAKE_NEED_{MAJ,MIN} values are also used in the generated Makefile
# where the "logic" is more fragile than the shell logic here.
# If the minimum is raised don't forget to update that logic too.
#
GMAKE_NEED_MAJ=3
GMAKE_NEED_MIN=80
function bad_gmake {
echo Error: $* >&2
echo_and_die "Please set GMAKE (or pass --with-gmake=...) to the path to GNU Make $GMAKE_NEED_MAJ.$GMAKE_NEED_MIN or newer."
}
GMAKE_SHORT="$GMAKE"
if [[ -n "$GMAKE" ]]; then
fgm=$(check_tool_path "$GMAKE") && : # "&& :" prevents ERR trap but preserves $?
if [[ $? -ne 0 ]]; then
bad_gmake "--with-gmake='$GMAKE' $fgm"
fi
GMAKE="$fgm"
else
for x in gmake make; do
tmp="$(type -p $x)" || true
if [[ -n "$tmp" ]] ; then
GMAKE_SHORT="$x"
GMAKE="$tmp"
break
fi
done
if [[ -z "$GMAKE" ]] ; then
bad_gmake "no 'gmake' or 'make' found in \$PATH."
fi
fi
if [[ $($GMAKE --version | grep ^GNU) =~ ([0-9]+).([0-9]+)(.[0-9]+)? ]]; then
maj=${BASH_REMATCH[1]}
min=${BASH_REMATCH[2]}
if [[ $maj -lt $GMAKE_NEED_MAJ ||
( $maj -eq $GMAKE_NEED_MAJ && $min -lt $GMAKE_NEED_MIN ) ]] ; then
bad_gmake "'$GMAKE' is older than $GMAKE_NEED_MAJ.$GMAKE_NEED_MIN"
fi
else
bad_gmake "'$GMAKE' does not appear to be GNU Make"
fi
echo -e "$GMAKE\nGNU Make version ${BASH_REMATCH[0]}\n"
#
# Find a usable checksum command
# "Usable" is defined here as 32 or more alphanumerics characters
# followed by optional space
#
UPCXX_CSUMCMD=''
for cmd in shasum sha1sum md5sum md5; do
if [[ -n $(type -p $cmd) &&
$($cmd <<< '') =~ ^[a-zA-Z0-9]{32,}\ ? ]]; then
UPCXX_CSUMCMD=$cmd
break
fi
done
if [[ -z "$UPCXX_CSUMCMD" ]]; then
warnings+="\nWARNING: The maintainer targets 'exe' and 'run' are unavailable due to\n"
warnings+="WARNING: lack of a usable checksum utility.\n"
fi
#
# HIP/hipcc setup
#
if [[ $UPCXX_HIP -eq 1 ]]; then
# PREpend to allow user to disable if needed
GASNET_CONFIGURE_ARGS="--enable-kind-hip ${GASNET_CONFIGURE_ARGS}"
HIP_HEADER="include/hip/hip_runtime_api.h"
hipcc="hipcc"
if [[ -z $HIP_HOME ]] && type -p $hipcc >/dev/null ; then # try probing hipcc
HIP_HOME="$(dirname $(dirname $(type -p $hipcc)))"
if ! [[ -f $HIP_HOME/$HIP_HEADER ]] ; then
for hip_maybe in \
$($hipcc -print-rocm-search-dirs 2>&1 | grep "search path" | cut -d: -f2) ; do
if [[ -f $hip_maybe/$HIP_HEADER ]] ; then
HIP_HOME=$hip_maybe
break
fi
done
fi
fi
if [[ -z $HIP_HOME ]] && [[ -d /opt/rocm ]] ; then
HIP_HOME=/opt/rocm # last resort, check default install dir
fi
if [[ -z $HIP_HOME ]] || ! [[ -f $HIP_HOME/$HIP_HEADER ]] ; then
echo_and_die 'Failed to find ROCm/HIP developer tools, please pass --with-hip-home=/hip/install/prefix'
else
GASNET_CONFIGURE_ARGS+=" --with-hip-home='$HIP_HOME'"
fi
CXXVERS='eval $CXX --version 2>&1'
cppflags="-I${HIP_HOME}/include"
if [[ -z $UPCXX_HIP_CPPFLAGS ]]; then
if $CXXVERS | grep -e 'Free Software Foundation' -e 'clang version' &> /dev/null ; then
# -isystem silences obnoxious warnings from ROCm headers that are not pedantic-clean
# but `-isystem /usr/include` can break `#include_next` (issue 630)
[[ "${HIP_HOME}" = '/usr' ]] || cppflags+=" -isystem ${HIP_HOME}/include"
fi
fi
case ${hip_platform} in
amd|hcc|'')
cpp_defined CXX __HIP_PLATFORM_AMD__ || UPCXX_HIP_CPPFLAGS+=' -D__HIP_PLATFORM_AMD__='
cpp_defined CXX __HIP_PLATFORM_HCC__ || UPCXX_HIP_CPPFLAGS+=' -D__HIP_PLATFORM_HCC__='
export UPCXX_HIP_LIBFLAGS=${UPCXX_HIP_LIBFLAGS:--L${HIP_HOME}/lib -lamdhip64}
;;
nvidia|nvcc)
if [[ -z $UPCXX_HIP_CPPFLAGS ]]; then
if $CXXVERS | grep -e 'Free Software Foundation' -e 'clang version' &> /dev/null ; then
# disable warnings generated by HIP-over-CUDA header: (TODO: icpc needs -wd1478 -wd303)
cppflags+=" -Wno-deprecated-declarations -Wno-return-type"
fi
fi
cpp_defined CXX __HIP_PLATFORM_NVIDIA__ || UPCXX_HIP_CPPFLAGS+=' -D__HIP_PLATFORM_NVIDIA__='
cpp_defined CXX __HIP_PLATFORM_NVCC__ || UPCXX_HIP_CPPFLAGS+=' -D__HIP_PLATFORM_NVCC__='
export UPCXX_HIP_LIBFLAGS=${UPCXX_HIP_LIBFLAGS:--L${HIP_HOME}/lib -lcudart}
UPCXX_CUDA=1 # force enable full CUDA support for simplicity
;;
*)
echo_and_die 'unrecognized argument to --with-hip-platform={amd,nvidia}'
;;
esac
UPCXX_HIP_CPPFLAGS="${cppflags} ${UPCXX_HIP_CPPFLAGS}"
[[ -z ${HIP_LIBS} ]] && HIP_LIBS=${UPCXX_HIP_LIBFLAGS}
fi