forked from weidai11/cryptopp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cryptest.sh
executable file
·7116 lines (5933 loc) · 241 KB
/
cryptest.sh
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
#!/usr/bin/env bash
# cryptest.sh - written and placed in public domain by Jeffrey Walton and Uri Blumenthal.
# This is a test script that can be used on some Linux/Unix/Apple machines to automate building the
# library and running the self test with various combinations of flags, options, and conditions.
# For more details, see http://cryptopp.com/wiki/cryptest.sh.
# To run the script, simply perform the following:
# ./cryptest.sh
# If you want to test a particular compiler, like clang++ or icpc, issue:
# CXX=clang++ ./cryptest.sh
# CXX=/opt/intel/bin/icpc ./cryptest.sh
# CXX=/opt/solstudio12.2/bin/CC ./cryptest.sh
# The script ignores CXXFLAGS. You can add CXXFLAGS, like -mcpu or -mtune, through USER_CXXFLAGS:
# USER_CXXFLAGS=-Wall ./cryptest.sh
# USER_CXXFLAGS="-Wall -Wextra" ./cryptest.sh
# The fastest results (in running time) will most likely omit Valgrind and Benchmarks because
# significantly increase execution time:
# HAVE_VALGRIND=0 WANT_BENCHMARKS=0 ./cryptest.sh
# Using 'fast' is shorthand for HAVE_VALGRIND=0 WANT_BENCHMARKS=0:
# ./cryptest.sh fast
# You can reduce CPU load with the following. It will use half the number of CPU cores
# rather than all of them. Its useful at places like the GCC Compile Farm, where being nice is policy.
# ./cryptest.sh nice
# Keep the noise down
# shellcheck disable=SC2181
############################################
# Set to suite your taste
if [[ (-z "$TEST_RESULTS") ]]; then
TEST_RESULTS=cryptest-result.txt
fi
if [[ (-z "$BENCHMARK_RESULTS") ]]; then
BENCHMARK_RESULTS=cryptest-bench.txt
fi
if [[ (-z "$WARN_RESULTS") ]]; then
WARN_RESULTS=cryptest-warn.txt
fi
if [[ (-z "$INSTALL_RESULTS") ]]; then
INSTALL_RESULTS=cryptest-install.txt
fi
# Remove previous test results
rm -f "$TEST_RESULTS" > /dev/null 2>&1
touch "$TEST_RESULTS"
rm -f "$BENCHMARK_RESULTS" > /dev/null 2>&1
touch "$BENCHMARK_RESULTS"
rm -f "$WARN_RESULTS" > /dev/null 2>&1
touch "$WARN_RESULTS"
rm -f "$INSTALL_RESULTS" > /dev/null 2>&1
touch "$INSTALL_RESULTS"
# Avoid CRYPTOPP_DATA_DIR in this shell (it is tested below)
unset CRYPTOPP_DATA_DIR
# Avoid Malloc and Scribble guards on OS X (they are tested below)
unset MallocScribble MallocPreScribble MallocGuardEdges
# List of tests performed
TEST_LIST=()
############################################
# Setup tools and platforms
GREP=grep
SED=sed
AWK=awk
MAKE=make
DISASS=objdump
DISASSARGS=("--disassemble")
# Fixup, Solaris and friends
if [[ (-d /usr/xpg4/bin) ]]; then
SED=/usr/xpg4/bin/sed
AWK=/usr/xpg4/bin/awk
GREP=/usr/xpg4/bin/grep
elif [[ (-d /usr/bin/posix) ]]; then
SED=/usr/bin/posix/sed
AWK=/usr/bin/posix/awk
GREP=/usr/bin/posix/grep
fi
# Fixup, Solaris and BSDs
if [[ $(command -v gmake 2>/dev/null) ]]; then
MAKE="gmake"
else
MAKE="make"
fi
THIS_SYSTEM=$(uname -s 2>&1)
IS_AIX=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c aix)
IS_DARWIN=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c darwin)
IS_LINUX=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c linux)
IS_CYGWIN=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c cygwin)
IS_MINGW=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c mingw)
IS_OPENBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c openbsd)
IS_DRAGONFLY=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c dragonfly)
IS_FREEBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c freebsd)
IS_NETBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c netbsd)
IS_SOLARIS=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c sunos)
IS_BSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c bsd)
IS_DEBIAN=$(lsb_release -a 2>&1 | "$GREP" -i -c debian)
IS_FEDORA=$(lsb_release -a 2>&1 | "$GREP" -i -c fedora)
IS_UBUNTU=$(lsb_release -a 2>&1 | "$GREP" -i -c ubuntu)
THIS_MACHINE=$(uname -m 2>&1)
IS_X86=$(echo -n "$THIS_MACHINE" | "$GREP" -i -c -E "(i386|i486|i686|i686)")
IS_X64=$(echo -n "$THIS_MACHINE" | "$GREP" -i -c -E "(amd64|x86_64)")
IS_PPC32=$(echo -n "$THIS_MACHINE" | "$GREP" -v "64" | "$GREP" -i -c -E "(Power|PPC)")
IS_PPC64=$(echo -n "$THIS_MACHINE" | "$GREP" -i -c -E "(Power64|PPC64)")
IS_ARM32=$(echo -n "$THIS_MACHINE" | "$GREP" -v "64" | "$GREP" -i -c -E "(arm|aarch32)")
IS_ARM64=$(echo -n "$THIS_MACHINE" | "$GREP" -i -c -E "(arm64|aarch64)")
IS_S390=$(echo -n "$THIS_MACHINE" | "$GREP" -i -c "s390")
IS_SPARC=$(echo -n "$THIS_MACHINE" | "$GREP" -i -c "sparc")
IS_X32=0
# Fixup
if [[ "$IS_SOLARIS" -ne "0" ]]; then
DISASS=dis
DISASSARGS=()
fi
# Fixup
if [[ "$IS_DARWIN" -ne 0 ]]; then
DISASS=otool
DISASSARGS=("-tV")
fi
# CPU features and flags
if [[ ("$IS_X86" -ne "0" || "$IS_X64" -ne "0") ]]; then
if [[ ("$IS_DARWIN" -ne "0") ]]; then
X86_CPU_FLAGS=$(sysctl machdep.cpu.features 2>&1 | cut -f 2 -d ':')
elif [[ ("$IS_SOLARIS" -ne "0") ]]; then
X86_CPU_FLAGS=$(isainfo -v 2>/dev/null)
elif [[ ("$IS_FREEBSD" -ne "0") ]]; then
X86_CPU_FLAGS=$(grep Features /var/run/dmesg.boot)
elif [[ ("$IS_DRAGONFLY" -ne "0") ]]; then
X86_CPU_FLAGS=$(dmesg | grep Features)
else
X86_CPU_FLAGS="$($AWK '{IGNORECASE=1}{if ($1 == "flags"){print;exit}}' < /proc/cpuinfo | cut -f 2 -d ':')"
fi
elif [[ ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") ]]; then
if [[ ("$IS_DARWIN" -ne "0") ]]; then
ARM_CPU_FLAGS="$(sysctl machdep.cpu.features 2>&1 | cut -f 2 -d ':')"
else
ARM_CPU_FLAGS="$($AWK '{IGNORECASE=1}{if ($1 == "Features"){print;exit}}' < /proc/cpuinfo | cut -f 2 -d ':')"
fi
fi
for ARG in "$@"
do
# Recognize "fast" and "quick", which does not perform tests that take more time to execute
if [[ ($("$GREP" -ix "fast" <<< "$ARG") || $("$GREP" -ix "quick" <<< "$ARG")) ]]; then
HAVE_VALGRIND=0
WANT_BENCHMARKS=0
# Recognize "farm" and "nice", which uses 1/2 the CPU cores in accordance with GCC Compile Farm policy
elif [[ ($("$GREP" -ix "farm" <<< "$ARG") || $("$GREP" -ix "nice" <<< "$ARG")) ]]; then
WANT_NICE=1
elif [[ ($("$GREP" -ix "orig" <<< "$ARG") || $("$GREP" -ix "original" <<< "$ARG") || $("$GREP" -ix "config.h" <<< "$ARG")) ]]; then
git checkout config.h > /dev/null 2>&1
else
echo "Unknown option $ARG"
fi
done
# We need to use the C++ compiler to determine feature availablility. Otherwise
# mis-detections occur on a number of platforms.
if [[ ((-z "$CXX") || ("$CXX" == "gcc")) ]]; then
if [[ ("$CXX" == "gcc") ]]; then
CXX="g++"
elif [[ "$IS_DARWIN" -ne "0" ]]; then
CXX="c++"
elif [[ "$IS_SOLARIS" -ne "0" ]]; then
if [[ (-e "/opt/developerstudio12.5/bin/CC") ]]; then
CXX="/opt/developerstudio12.5/bin/CC"
elif [[ (-e "/opt/solarisstudio12.4/bin/CC") ]]; then
CXX="/opt/solarisstudio12.4/bin/CC"
elif [[ (-e "/opt/solarisstudio12.3/bin/CC") ]]; then
CXX="/opt/solarisstudio12.3/bin/CC"
elif [[ (-e "/opt/solstudio12.2/bin/CC") ]]; then
CXX="/opt/solstudio12.2/bin/CC"
elif [[ (-e "/opt/solstudio12.1/bin/CC") ]]; then
CXX="/opt/solstudio12.1/bin/CC"
elif [[ (-e "/opt/solstudio12.0/bin/CC") ]]; then
CXX="/opt/solstudio12.0/bin/CC"
elif [[ $(command -v CC 2>/dev/null) ]]; then
CXX="CC"
elif [[ $(command -v g++ 2>/dev/null) ]]; then
CXX="g++"
else
CXX=CC
fi
elif [[ $(command -v g++ 2>/dev/null) ]]; then
CXX="g++"
else
CXX="c++"
fi
fi
SUN_COMPILER=$("$CXX" -V 2>&1 | "$GREP" -i -c -E "CC: (Sun|Studio)")
GCC_COMPILER=$("$CXX" --version 2>&1 | "$GREP" -i -v "clang" | "$GREP" -i -c -E "(gcc|g\+\+)")
XLC_COMPILER=$("$CXX" -qversion 2>&1 | "$GREP" -i -c "IBM XL")
INTEL_COMPILER=$("$CXX" --version 2>&1 | "$GREP" -i -c "\(icc\)")
MACPORTS_COMPILER=$("$CXX" --version 2>&1 | "$GREP" -i -c "MacPorts")
CLANG_COMPILER=$("$CXX" --version 2>&1 | "$GREP" -i -c "clang")
GNU_LINKER=$(ld --version 2>&1 | "$GREP" -i -c "GNU ld")
if [[ ("$SUN_COMPILER" -eq "0") ]]; then
AMD64=$("$CXX" -dM -E - </dev/null 2>/dev/null | "$GREP" -i -c -E "(__x64_64__|__amd64__)")
ILP32=$("$CXX" -dM -E - </dev/null 2>/dev/null | "$GREP" -i -c -E "(__ILP32__|__ILP32)")
if [[ ("$AMD64" -ne "0") && ("$ILP32" -ne "0") ]]; then
IS_X32=1
fi
fi
# Now that the compiler is fixed, determine the compiler version for fixups
GCC_51_OR_ABOVE=$("$CXX" -v 2>&1 | "$GREP" -i -c -E 'gcc version (5\.[1-9]|[6-9])')
GCC_48_COMPILER=$("$CXX" -v 2>&1 | "$GREP" -i -c -E 'gcc version 4\.8')
SUNCC_510_OR_ABOVE=$("$CXX" -V 2>&1 | "$GREP" -c -E "CC: (Sun|Studio) .* (5\.1[0-9]|5\.[2-9]|[6-9]\.)")
SUNCC_511_OR_ABOVE=$("$CXX" -V 2>&1 | "$GREP" -c -E "CC: (Sun|Studio) .* (5\.1[1-9]|5\.[2-9]|[6-9]\.)")
# Fixup, bad code generation
if [[ ("$SUNCC_510_OR_ABOVE" -ne "0") ]]; then
HAVE_O5=0
HAVE_OFAST=0
fi
# GCC compile farm is mounted RO
if [[ (-z "$TMPDIR") ]]; then
if [[ (-d "/tmp") ]] && [[ $(touch "/tmp/ok-to-delete" &>/dev/null) ]]; then
TMPDIR=/tmp
elif [[ (-d "/temp") ]]; then
TMPDIR=/temp
elif [[ (-d "$HOME/tmp") ]]; then
TMPDIR="$HOME/tmp"
else
echo "Please set TMPDIR to a valid directory"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
fi
# Make temp if it does not exist
mkdir -p "$TMPDIR" &>/dev/null
# Sun Studio does not allow '-x c++'. Copy it here...
rm -f adhoc.cpp > /dev/null 2>&1
cp adhoc.cpp.proto adhoc.cpp
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_CXX17") ]]; then
HAVE_CXX17=0
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++17 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_CXX17=1
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_GNU17") ]]; then
HAVE_GNU17=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++17 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_GNU17=1
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_CXX20") ]]; then
HAVE_CXX20=0
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++20 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_CXX20=1
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_GNU20") ]]; then
HAVE_GNU20=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++20 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_GNU20=1
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_CXX14") ]]; then
HAVE_CXX14=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++14 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_CXX14=1
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_GNU14") ]]; then
HAVE_GNU14=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++14 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_GNU14=1
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_CXX11") ]]; then
HAVE_CXX11=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++11 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_CXX11=1
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_GNU11") ]]; then
HAVE_GNU11=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++11 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_GNU11=1
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_CXX03") ]]; then
HAVE_CXX03=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++03 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_CXX03=1
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_GNU03") ]]; then
HAVE_GNU03=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++03 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_GNU03=1
fi
fi
# Use a fallback strategy so OPT_O0 can be used with DEBUG_CXXFLAGS
OPT_O0=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O0 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
OPT_O0=-O0
else
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO0 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
OPT_O0=-xO0
fi
fi
# Use a fallback strategy so OPT_O1 can be used with VALGRIND_CXXFLAGS
OPT_O1=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O1 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O1=1
OPT_O1=-O1
else
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO1 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O1=1
OPT_O1=-xO1
fi
fi
# https://github.com/weidai11/cryptopp/issues/588
OPT_O2=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O2 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O2=1
OPT_O2=-O2
else
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO2 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O2=1
OPT_O2=-xO2
fi
fi
# Use a fallback strategy so OPT_O3 can be used with RELEASE_CXXFLAGS
OPT_O3=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O3 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O3=1
OPT_O3=-O3
else
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO3 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O3=1
OPT_O3=-xO3
fi
fi
# Hit or miss, mostly hit
if [[ ( (-z "$HAVE_O5") && ("$CLANG_COMPILER" -eq "0") ) ]]; then
HAVE_O5=0
OPT_O5=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O5 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O5=1
OPT_O5=-O5
else
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO5 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O5=1
OPT_O5=-xO5
fi
fi
fi
# Hit or miss, mostly hit
if [[ (-z "$HAVE_OS") ]]; then
HAVE_OS=0
OPT_OS=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -Os adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_OS=1
OPT_OS=-Os
fi
fi
# Hit or miss, mostly hit
if [[ (-z "$HAVE_OFAST") ]]; then
HAVE_OFAST=0
OPT_OFAST=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -Ofast adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_OFAST=1
OPT_OFAST=-Ofast
fi
fi
# Use a fallback strategy so OPT_G2 can be used with RELEASE_CXXFLAGS
OPT_G2=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -g2 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
OPT_G2=-g2
else
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -g adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
OPT_G2=-g
fi
fi
# Use a fallback strategy so OPT_G3 can be used with DEBUG_CXXFLAGS
OPT_G3=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -g3 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
OPT_G3=-g3
else
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -g adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
OPT_G3=-g
fi
fi
# Cygwin and noisy compiles
OPT_PIC=
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_PIC") ]]; then
HAVE_PIC=0
PIC_PROBLEMS=$("$CXX" -DCRYPTOPP_ADHOC_MAIN -fPIC adhoc.cpp -o "$TMPDIR/adhoc.exe" 2>&1 | "$GREP" -i -c -E '(warning|error)')
if [[ "$PIC_PROBLEMS" -eq "0" ]]; then
HAVE_PIC=1
OPT_PIC=-fPIC
if [[ ("$XLC_COMPILER" -eq "1") ]]; then
OPT_PIC=-qpic
fi
fi
fi
# GCC 4.8; Clang 3.4
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_UBSAN") ]]; then
HAVE_UBSAN=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -fsanitize=undefined adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
"$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_UBSAN=1
fi
fi
fi
# GCC 4.8; Clang 3.4
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_ASAN") ]]; then
HAVE_ASAN=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -fsanitize=address adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
"$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_ASAN=1
fi
fi
fi
# GCC 6.0; maybe Clang
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_BSAN") ]]; then
HAVE_BSAN=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -fsanitize=bounds-strict adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
"$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_BSAN=1
fi
fi
fi
# GCC 8.0; maybe Clang?
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_CET") ]]; then
HAVE_CET=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -fcf-protection=full -mcet adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
"$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_CET=1
fi
fi
fi
# Meltdown and Specter. This is the Reptoline fix
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_REPTOLINE") ]]; then
HAVE_REPTOLINE=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -mfunction-return=thunk -mindirect-branch=thunk adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
"$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_REPTOLINE=1
fi
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_OMP") ]]; then
HAVE_OMP=0
if [[ "$GCC_COMPILER" -ne "0" ]]; then
"$CXX" -DCRYPTOPP_ADHOC_MAIN -fopenmp -O3 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_OMP=1
OMP_FLAGS=(-fopenmp -O3)
fi
elif [[ "$INTEL_COMPILER" -ne "0" ]]; then
"$CXX" -DCRYPTOPP_ADHOC_MAIN -openmp -O3 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_OMP=1
OMP_FLAGS=(-openmp -O3)
fi
elif [[ "$CLANG_COMPILER" -ne "0" ]]; then
"$CXX" -DCRYPTOPP_ADHOC_MAIN -fopenmp=libomp -O3 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_OMP=1
OMP_FLAGS=(-fopenmp=libomp -O3)
fi
elif [[ "$SUN_COMPILER" -ne "0" ]]; then
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xopenmp=parallel -xO3 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_OMP=1
OMP_FLAGS=(-xopenmp=parallel -xO3)
fi
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_INTEL_MULTIARCH") ]]; then
HAVE_INTEL_MULTIARCH=0
if [[ ("$IS_DARWIN" -ne "0") && ("$IS_X86" -ne "0" || "$IS_X64" -ne "0") ]]; then
"$CXX" -DCRYPTOPP_ADHOC_MAIN -arch i386 -arch x86_64 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_INTEL_MULTIARCH=1
fi
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_PPC_MULTIARCH") ]]; then
HAVE_PPC_MULTIARCH=0
if [[ ("$IS_DARWIN" -ne "0") && ("$IS_PPC32" -ne "0" || "$IS_PPC64" -ne "0") ]]; then
"$CXX" -DCRYPTOPP_ADHOC_MAIN -arch ppc -arch ppc64 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_PPC_MULTIARCH=1
fi
fi
fi
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ (-z "$HAVE_X32") ]]; then
HAVE_X32=0
if [[ "$IS_X32" -ne "0" ]]; then
"$CXX" -DCRYPTOPP_ADHOC_MAIN -mx32 adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_X32=1
fi
fi
fi
# Hit or miss, mostly hit
if [[ (-z "$HAVE_NATIVE_ARCH") ]]; then
HAVE_NATIVE_ARCH=0
rm -f "$TMPDIR/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -march=native adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_NATIVE_ARCH=1
fi
fi
# ld-gold linker testing
if [[ (-z "$HAVE_LDGOLD") ]]; then
HAVE_LDGOLD=0
LD_GOLD=$(command -v ld.gold 2>/dev/null)
ELF_FILE=$(command -v file 2>/dev/null)
if [[ (! -z "$LD_GOLD") && (! -z "$ELF_FILE") ]]; then
LD_GOLD=$(file "$LD_GOLD" | cut -d":" -f 2 | "$GREP" -i -c "elf")
if [[ ("$LD_GOLD" -ne "0") ]]; then
"$CXX" -DCRYPTOPP_ADHOC_MAIN -fuse-ld=gold adhoc.cpp -o "$TMPDIR/adhoc.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_LDGOLD=1
fi
fi
fi
fi
# ARMv7 and ARMv8, including NEON, CRC32 and Crypto extensions
if [[ ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") ]]; then
if [[ (-z "$HAVE_ARMV7A" && "$IS_ARM32" -ne "0") ]]; then
HAVE_ARMV7A=$(echo -n "$ARM_CPU_FLAGS" | "$GREP" -i -c 'neon')
if [[ ("$HAVE_ARMV7A" -gt "0") ]]; then HAVE_ARMV7A=1; fi
fi
if [[ (-z "$HAVE_ARMV8A" && ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0")) ]]; then
HAVE_ARMV8A=$(echo -n "$ARM_CPU_FLAGS" | "$GREP" -i -c -E '(asimd|crc|crypto)')
if [[ ("$HAVE_ARMV8A" -gt "0") ]]; then HAVE_ARMV8A=1; fi
fi
if [[ (-z "$HAVE_ARM_VFPV3") ]]; then
HAVE_ARM_VFPV3=$(echo -n "$ARM_CPU_FLAGS" | "$GREP" -i -c 'vfpv3')
if [[ ("$HAVE_ARM_VFPV3" -gt "0") ]]; then HAVE_ARM_VFPV3=1; fi
fi
if [[ (-z "$HAVE_ARM_VFPV4") ]]; then
HAVE_ARM_VFPV4=$(echo -n "$ARM_CPU_FLAGS" | "$GREP" -i -c 'vfpv4')
if [[ ("$HAVE_ARM_VFPV4" -gt "0") ]]; then HAVE_ARM_VFPV4=1; fi
fi
if [[ (-z "$HAVE_ARM_VFPV5") ]]; then
HAVE_ARM_VFPV5=$(echo -n "$ARM_CPU_FLAGS" | "$GREP" -i -c 'fpv5')
if [[ ("$HAVE_ARM_VFPV5" -gt "0") ]]; then HAVE_ARM_VFPV5=1; fi
fi
if [[ (-z "$HAVE_ARM_VFPD32") ]]; then
HAVE_ARM_VFPD32=$(echo -n "$ARM_CPU_FLAGS" | "$GREP" -i -c 'vfpd32')
if [[ ("$HAVE_ARM_VFPD32" -gt "0") ]]; then HAVE_ARM_VFPD32=1; fi
fi
if [[ (-z "$HAVE_ARM_NEON") ]]; then
HAVE_ARM_NEON=$(echo -n "$ARM_CPU_FLAGS" | "$GREP" -i -c 'neon')
if [[ ("$HAVE_ARM_NEON" -gt "0") ]]; then HAVE_ARM_NEON=1; fi
fi
if [[ (-z "$HAVE_ARM_CRYPTO") ]]; then
HAVE_ARM_CRYPTO=$(echo -n "$ARM_CPU_FLAGS" | "$GREP" -i -c -E '(aes|pmull|sha1|sha2)')
if [[ ("$HAVE_ARM_CRYPTO" -gt "0") ]]; then HAVE_ARM_CRYPTO=1; fi
fi
if [[ (-z "$HAVE_ARM_CRC") ]]; then
HAVE_ARM_CRC=$(echo -n "$ARM_CPU_FLAGS" | "$GREP" -i -c 'crc32')
if [[ ("$HAVE_ARM_CRC" -gt "0") ]]; then HAVE_ARM_CRC=1; fi
fi
fi
# Valgrind testing of C++03, C++11, C++14 and C++17 binaries. Valgrind tests take a long time...
if [[ (-z "$HAVE_VALGRIND") ]]; then
if [[ $(command -v valgrind 2>/dev/null) ]]; then
HAVE_VALGRIND=1
fi
fi
# Try to find a symbolizer for Asan
if [[ (-z "$HAVE_SYMBOLIZE") && (! -z "$ASAN_SYMBOLIZER_PATH") ]]; then
# Sets default value
if [[ $(command -v asan_symbolize 2>/dev/null) ]]; then
HAVE_SYMBOLIZE=1
fi
if [[ (("$HAVE_SYMBOLIZE" -ne "0") && (-z "$ASAN_SYMBOLIZE")) ]]; then
ASAN_SYMBOLIZE=asan_symbolize
fi
# Clang implicitly uses ASAN_SYMBOLIZER_PATH; set it if its not set.
if [[ (-z "$ASAN_SYMBOLIZER_PATH") ]]; then
if [[ $(command -v llvm-symbolizer 2>/dev/null) ]]; then
LLVM_SYMBOLIZER_FOUND=1;
fi
if [[ ("$LLVM_SYMBOLIZER_FOUND" -ne "0") ]]; then
ASAN_SYMBOLIZER_PATH=$(command -v llvm-symbolizer)
export ASAN_SYMBOLIZER_PATH
fi
fi
fi
# Used to disassemble object modules so we can verify some aspects of code generation
if [[ (-z "$HAVE_DISASS") ]]; then
echo "int main(int argc, char* argv[]) {return 0;}" > "$TMPDIR/test.cc"
"$CXX" "$TMPDIR/test.cc" -o "$TMPDIR/test.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
"$DISASS" "${DISASSARGS[@]}" "$TMPDIR/test.exe" > /dev/null 2>&1
if [[ "$?" -eq "0" ]]; then
HAVE_DISASS=1
else
HAVE_DISASS=0
fi
fi
fi
# LD_LIBRARY_PATH and DYLD_LIBRARY_PATH
if [[ "$IS_LINUX" -ne "0" || "$IS_SOLARIS" -ne "0" || "$IS_BSD" -ne "0" ]]; then
HAVE_LD_LIBRARY_PATH=1
fi
if [[ "$IS_DARWIN" -ne "0" ]]; then
HAVE_DYLD_LIBRARY_PATH=1
fi
# Fixup... GCC 4.8 ASAN produces false positives under ARM
if [[ ( ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") && "$GCC_48_COMPILER" -ne "0") ]]; then
HAVE_ASAN=0
fi
# Benchmarks take a long time...
if [[ (-z "$WANT_BENCHMARKS") ]]; then
WANT_BENCHMARKS=1
fi
# IBM XL C/C++ compiler fixups. Not sure why it fails to return non-0 on failure...
if [[ "$XLC_COMPILER" -ne "0" ]]; then
HAVE_CXX03=0
HAVE_GNU03=0
HAVE_CXX11=0
HAVE_GNU11=0
HAVE_CXX14=0
HAVE_GNU14=0
HAVE_CXX17=0
HAVE_GNU17=0
HAVE_CXX20=0
HAVE_GNU20=0
HAVE_OMP=0
HAVE_CET=0
HAVE_REPTOLINE=0
HAVE_ASAN=0
HAVE_BSAN=0
HAVE_UBSAN=0
HAVE_LDGOLD=0
fi
############################################
# System information
echo | tee -a "$TEST_RESULTS"
if [[ "$IS_LINUX" -ne "0" ]]; then
echo "IS_LINUX: $IS_LINUX" | tee -a "$TEST_RESULTS"
elif [[ "$IS_CYGWIN" -ne "0" ]]; then
echo "IS_CYGWIN: $IS_CYGWIN" | tee -a "$TEST_RESULTS"
elif [[ "$IS_MINGW" -ne "0" ]]; then
echo "IS_MINGW: $IS_MINGW" | tee -a "$TEST_RESULTS"
elif [[ "$IS_SOLARIS" -ne "0" ]]; then
echo "IS_SOLARIS: $IS_SOLARIS" | tee -a "$TEST_RESULTS"
elif [[ "$IS_DARWIN" -ne "0" ]]; then
echo "IS_DARWIN: $IS_DARWIN" | tee -a "$TEST_RESULTS"
elif [[ "$IS_AIX" -ne "0" ]]; then
echo "IS_AIX: $IS_AIX" | tee -a "$TEST_RESULTS"
fi
if [[ "$IS_PPC64" -ne "0" ]]; then
echo "IS_PPC64: $IS_PPC64" | tee -a "$TEST_RESULTS"
elif [[ "$IS_PPC32" -ne "0" ]]; then
echo "IS_PPC32: $IS_PPC32" | tee -a "$TEST_RESULTS"
fi
if [[ "$IS_ARM64" -ne "0" ]]; then
echo "IS_ARM64: $IS_ARM64" | tee -a "$TEST_RESULTS"
elif [[ "$IS_ARM32" -ne "0" ]]; then
echo "IS_ARM32: $IS_ARM32" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_ARMV7A" -ne "0" ]]; then
echo "HAVE_ARMV7A: $HAVE_ARMV7A" | tee -a "$TEST_RESULTS"
elif [[ "$HAVE_ARMV8A" -ne "0" ]]; then
echo "HAVE_ARMV8A: $HAVE_ARMV8A" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_ARM_NEON" -ne "0" ]]; then
echo "HAVE_ARM_NEON: $HAVE_ARM_NEON" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_ARM_VFPD32" -ne "0" ]]; then
echo "HAVE_ARM_VFPD32: $HAVE_ARM_VFPD32" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_ARM_VFPV3" -ne "0" ]]; then
echo "HAVE_ARM_VFPV3: $HAVE_ARM_VFPV3" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_ARM_VFPV4" -ne "0" ]]; then
echo "HAVE_ARM_VFPV4: $HAVE_ARM_VFPV4" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_ARM_CRC" -ne "0" ]]; then
echo "HAVE_ARM_CRC: $HAVE_ARM_CRC" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_ARM_CRYPTO" -ne "0" ]]; then
echo "HAVE_ARM_CRYPTO: $HAVE_ARM_CRYPTO" | tee -a "$TEST_RESULTS"
fi
if [[ "$IS_X32" -ne "0" ]]; then
echo "IS_X32: $IS_X32" | tee -a "$TEST_RESULTS"
elif [[ "$IS_X64" -ne "0" ]]; then
echo "IS_X64: $IS_X64" | tee -a "$TEST_RESULTS"
elif [[ "$IS_X86" -ne "0" ]]; then
echo "IS_X86: $IS_X86" | tee -a "$TEST_RESULTS"
fi
if [[ "$IS_S390" -ne "0" ]]; then
echo "IS_S390: $IS_S390" | tee -a "$TEST_RESULTS"
fi
# C++03, C++11, C++14 and C++17
echo | tee -a "$TEST_RESULTS"
echo "HAVE_CXX03: $HAVE_CXX03" | tee -a "$TEST_RESULTS"
echo "HAVE_GNU03: $HAVE_GNU03" | tee -a "$TEST_RESULTS"
echo "HAVE_CXX11: $HAVE_CXX11" | tee -a "$TEST_RESULTS"
echo "HAVE_GNU11: $HAVE_GNU11" | tee -a "$TEST_RESULTS"
if [[ ("$HAVE_CXX14" -ne "0" || "$HAVE_CXX17" -ne "0" || "$HAVE_CXX20" -ne "0" || "$HAVE_GNU14" -ne "0" || "$HAVE_GNU17" -ne "0" || "$HAVE_GNU20" -ne "0") ]]; then
echo "HAVE_CXX14: $HAVE_CXX14" | tee -a "$TEST_RESULTS"
echo "HAVE_GNU14: $HAVE_GNU14" | tee -a "$TEST_RESULTS"
echo "HAVE_CXX17: $HAVE_CXX17" | tee -a "$TEST_RESULTS"
echo "HAVE_GNU17: $HAVE_GNU17" | tee -a "$TEST_RESULTS"
echo "HAVE_CXX20: $HAVE_CXX20" | tee -a "$TEST_RESULTS"
echo "HAVE_GNU20: $HAVE_GNU20" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_LDGOLD" -ne "0" ]]; then
echo "HAVE_LDGOLD: $HAVE_LDGOLD" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_UNIFIED_ASM" -ne "0" ]]; then
echo "HAVE_UNIFIED_ASM: $HAVE_UNIFIED_ASM" | tee -a "$TEST_RESULTS"
fi
# -O3, -O5 and -Os
echo | tee -a "$TEST_RESULTS"
echo "OPT_O2: $OPT_O2" | tee -a "$TEST_RESULTS"
echo "OPT_O3: $OPT_O3" | tee -a "$TEST_RESULTS"
if [[ (! -z "$OPT_O5") || (! -z "$OPT_OS") || (! -z "$OPT_OFAST") ]]; then
echo "OPT_O5: $OPT_O5" | tee -a "$TEST_RESULTS"
echo "OPT_OS: $OPT_OS" | tee -a "$TEST_RESULTS"
echo "OPT_OFAST: $OPT_OFAST" | tee -a "$TEST_RESULTS"
fi
# Tools available for testing
echo | tee -a "$TEST_RESULTS"
if [[ ((! -z "$HAVE_OMP") && ("$HAVE_OMP" -ne "0")) ]]; then echo "HAVE_OMP: $HAVE_OMP" | tee -a "$TEST_RESULTS"; fi
echo "HAVE_ASAN: $HAVE_ASAN" | tee -a "$TEST_RESULTS"
if [[ ("$HAVE_ASAN" -ne "0") && (! -z "$ASAN_SYMBOLIZE") ]]; then echo "ASAN_SYMBOLIZE: $ASAN_SYMBOLIZE" | tee -a "$TEST_RESULTS"; fi
echo "HAVE_UBSAN: $HAVE_UBSAN" | tee -a "$TEST_RESULTS"
echo "HAVE_BSAN: $HAVE_BSAN" | tee -a "$TEST_RESULTS"
echo "HAVE_CET: $HAVE_CET" | tee -a "$TEST_RESULTS"
echo "HAVE_REPTOLINE: $HAVE_REPTOLINE" | tee -a "$TEST_RESULTS"
echo "HAVE_VALGRIND: $HAVE_VALGRIND" | tee -a "$TEST_RESULTS"
# HAVE_REPTOLINE is for Meltdown and Spectre option testing, called Reptoline (play on trampoline)
if [[ "$HAVE_INTEL_MULTIARCH" -ne "0" ]]; then
echo "HAVE_INTEL_MULTIARCH: $HAVE_INTEL_MULTIARCH" | tee -a "$TEST_RESULTS"
fi
if [[ "$HAVE_PPC_MULTIARCH" -ne "0" ]]; then
echo "HAVE_PPC_MULTIARCH: $HAVE_PPC_MULTIARCH" | tee -a "$TEST_RESULTS"
fi
############################################
# CPU is logical count, memory is in MiB. Low resource boards have
# fewer than 4 cores and 1GB or less memory. We use this to
# determine if we can build in parallel without an OOM kill.
CPU_COUNT=1
MEM_SIZE=512
if [[ ("$IS_SPARC" -ne "0") && ("$IS_LINUX" -ne "0") ]]; then
CPU_COUNT="$($GREP -E 'CPU.*' /proc/cpuinfo | cut -f 1 -d ':' | $SED 's|CPU||g' | sort -n | tail -1)"
MEM_SIZE="$($GREP "MemTotal" < /proc/meminfo | $AWK '{print int($2/1024)}')"
elif [[ (-e "/proc/cpuinfo") && (-e "/proc/meminfo") ]]; then
CPU_COUNT="$($GREP -c -E "^processor" < /proc/cpuinfo)"
MEM_SIZE="$($GREP "MemTotal" < /proc/meminfo | $AWK '{print int($2/1024)}')"
elif [[ "$IS_DARWIN" -ne "0" ]]; then
CPU_COUNT="$(sysctl -a 2>&1 | $GREP "hw.availcpu" | $AWK '{print $3; exit}')"
MEM_SIZE="$(sysctl -a 2>&1 | $GREP "hw.memsize" | $AWK '{print int($3/1024/1024); exit;}')"
elif [[ "$IS_SOLARIS" -ne "0" ]]; then
CPU_COUNT="$(psrinfo 2>/dev/null | wc -l | $AWK '{print $1}')"
MEM_SIZE="$(prtconf 2>/dev/null | $GREP "Memory" | $AWK '{print int($3)}')"
elif [[ "$IS_AIX" -ne "0" ]]; then
CPU_COUNT="$(bindprocessor -q 2>/dev/null | cut -f 2 -d ":" | wc -w | $AWK '{print $1}')"
MEM_SIZE="$(prtconf -m 2>/dev/null | $GREP "MB" | $AWK '{print int($3); exit;}')"
fi
# Benchmarks expect frequency in GiHz.
CPU_FREQ=0.5
if [[ (-e "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq") ]]; then
CPU_FREQ="$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)"
CPU_FREQ="$(echo $CPU_FREQ | $AWK '{print $0/1024/1024; exit}')"
elif [[ (-e "/proc/cpuinfo") ]]; then
CPU_FREQ="$($GREP 'MHz' < /proc/cpuinfo | $AWK '{print $4; exit}')"
if [[ -z "$CPU_FREQ" ]]; then CPU_FREQ=512; fi
CPU_FREQ="$(echo $CPU_FREQ | $AWK '{print $0/1024}')"
elif [[ "$IS_DARWIN" -ne "0" ]]; then
CPU_FREQ="$(sysctl -a 2>&1 | $GREP "hw.cpufrequency" | $AWK '{print ($3); exit;}')"
CPU_FREQ="$(echo $CPU_FREQ | $AWK '{print $0/1024/1024/1024}')"
elif [[ "$IS_SOLARIS" -ne "0" ]]; then
CPU_FREQ="$(psrinfo -v 2>/dev/null | $GREP "MHz" | $AWK '{print $6; exit;}')"
CPU_FREQ="$(echo $CPU_FREQ | $AWK '{print $0/1024}')"
elif [[ "$IS_AIX" -ne "0" ]]; then
CPU_FREQ="$(prtconf -s 2>/dev/null | $GREP "MHz" | $AWK '{print $4; exit;}')"
CPU_FREQ="$(echo $CPU_FREQ | $AWK '{print $0/1024}')"
fi
# Some ARM devboards cannot use 'make -j N', even with multiple cores and RAM
# An 8-core Cubietruck Plus with 2GB RAM experiences OOM kills with '-j 2'.
HAVE_SWAP=1
if [[ "$IS_LINUX" -ne "0" ]]; then
if [[ (-e "/proc/meminfo") ]]; then
SWAP_SIZE="$($GREP 'SwapTotal' < /proc/meminfo | "$AWK" '{print $2}')"
if [[ "$SWAP_SIZE" -eq "0" ]]; then
HAVE_SWAP=0
fi
else
HAVE_SWAP=0
fi
fi
echo | tee -a "$TEST_RESULTS"
echo "CPU: $CPU_COUNT logical" | tee -a "$TEST_RESULTS"
echo "FREQ: $CPU_FREQ GHz" | tee -a "$TEST_RESULTS"
echo "MEM: $MEM_SIZE MB" | tee -a "$TEST_RESULTS"
if [[ ("$CPU_COUNT" -ge "2" && "$MEM_SIZE" -ge "1280" && "$HAVE_SWAP" -ne "0") ]]; then
if [[ ("$WANT_NICE" -eq "1") ]]; then
CPU_COUNT=$(echo -n "$CPU_COUNT 2" | "$AWK" '{print int($1/$2)}')
fi
MAKEARGS=(-j "$CPU_COUNT")
echo "Using $MAKE -j $CPU_COUNT"
fi
############################################
GIT_REPO=$(git branch 2>&1 | "$GREP" -v "fatal" | wc -l | "$AWK" '{print $1; exit;}')
if [[ "$GIT_REPO" -ne "0" ]]; then
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
GIT_HASH=$(git rev-parse HEAD 2>/dev/null | cut -c 1-16)
fi
echo | tee -a "$TEST_RESULTS"
if [[ ! -z "$GIT_BRANCH" ]]; then
echo "Git branch: $GIT_BRANCH (commit $GIT_HASH)" | tee -a "$TEST_RESULTS"
fi
if [[ ("$SUN_COMPILER" -ne "0") ]]; then
"$CXX" -V 2>&1 | "$SED" 's|CC:|Compiler:|g' | head -1 | tee -a "$TEST_RESULTS"
elif [[ ("$XLC_COMPILER" -ne "0") ]]; then
echo "Compiler: $($CXX -qversion | head -1)" | tee -a "$TEST_RESULTS"
else
echo "Compiler: $($CXX --version | head -1)" | tee -a "$TEST_RESULTS"
fi
CXX_PATH=$(command -v "$CXX" 2>/dev/null)
CXX_SYMLINK=$(ls -l "$CXX_PATH" 2>/dev/null | "$GREP" -c '\->' | "$AWK" '{print $1}')
if [[ ("$CXX_SYMLINK" -ne "0") ]]; then CXX_PATH="$CXX_PATH (symlinked)"; fi
echo "Pathname: $CXX_PATH" | tee -a "$TEST_RESULTS"
############################################