-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcxxflags.jam
2440 lines (2417 loc) · 73.5 KB
/
cxxflags.jam
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
# ./compiler-options.lua -f -stl_fix,analyzer,analyzer_too_complex_warning,analyzer_verbosity,diagnostics_format,msvc_conformance,msvc_crt_secure_no_warnings,msvc_diagnostics_format,msvc_isystem,msvc_isystem_with_template_from_non_external,windows-bigobj,exceptions,other_sanitizers,pie,rtti,coverage generators/bjam.lua cxx- >> cxxflags.jam
# remove:
# reference to msvc, window intel and clang-cl
# replace:
# jln_flags by flags
#
# File generated with https://github.com/jonathanpoelen/cpp-compiler-options
# jam reference: https://www.boost.org/build/doc/html/index.html
import feature : feature ;
import modules ;
import numbers ;
import property-set ;
import string ;
import os ;
JLN_BJAM_YEAR_VERSION = [ modules.peek : JAMVERSION ] ;
feature <cxx-color> : _ default auto never always : propagated ;
# Insert extra runtime security checks to detect attempts to compromise your code
feature <cxx-control-flow> : _ default off on branch return allow-bugs : incidental ;
# Warn for implicit conversions that may alter a value
feature <cxx-conversion-warnings> : _ on default off sign conversion : propagated ;
# Warning for default label in switch which covers all enumeration values
feature <cxx-covered-switch-default-warnings> : _ on default off : propagated ;
feature <cxx-cpu> : _ default generic native : incidental ;
# Produce debugging information in the operating system's
feature <cxx-debug> : _ default off on line-tables-only gdb lldb sce : incidental ;
# Enables printing a tree-like structure showing the common and differing parts of the types
feature <cxx-diagnostics-show-template-tree> : _ default off on : propagated ;
# Prints diagnostics showing common parts of template types as "[...]"
feature <cxx-elide-type> : _ default off on : propagated ;
# Transforms some warnings into errors to comply with the standard
feature <cxx-fix-compiler-error> : _ on default off : propagated ;
feature <cxx-float-sanitizers> : _ default off on : incidental ;
feature <cxx-integer-sanitizers> : _ default off on : incidental ;
# Configure linker
feature <cxx-linker> : _ default bfd gold lld native : propagated ;
# Enable Link Time Optimization
feature <cxx-lto> : _ default off on normal fat thin : incidental ;
# Enable NDEBUG macro (disable assert macro)
feature <cxx-ndebug> : _ with-optimization-1-or-above default off on : incidental ;
# Warn when a noexcept-expression evaluates to false because of a call to a function that does not have a non-throwing exception specification (i.e. "throw()" or "noexcept") but is known by the compiler to never throw an exception.
feature <cxx-noexcept-warnings> : _ default off on : propagated ;
# Optimization level
# - 0: Not optimize
# - g: Enable debugging experience
# - 1: Optimize
# - 2: Optimize even more
# - 3: Optimize yet more
# - fast: Enables all optimization=3 and disregard strict standards compliance
# - size: Optimize for size
# - z: Optimize for size aggressively (/!\ possible slow compilation)
feature <cxx-optimization> : _ default 0 g 1 2 3 fast size z : incidental ;
# Issue all the warnings demanded by strict ISO C and ISO C++
feature <cxx-pedantic> : _ on default off as-error : incidental ;
# Specifies a memory segment that should be made read-only after relocation, if supported.
feature <cxx-relro> : _ default off on full : incidental ;
# Warn when macros "__TIME__", "__DATE__" or "__TIMESTAMP__" are encountered as they might prevent bit-wise-identical reproducible compilations
feature <cxx-reproducible-build-warnings> : _ default off on : propagated ;
# Enable sanitizers (asan, ubsan, etc)
feature <cxx-sanitizers> : _ default off on : incidental ;
feature <cxx-shadow-warnings> : _ off default on local compatible-local all : propagated ;
# Emit extra code to check for buffer overflows, such as stack smashing attacks
feature <cxx-stack-protector> : _ default off on strong all : incidental ;
# Controls the debug level of the STL
feature <cxx-stl-debug> : _ default off on allow-broken-abi allow-broken-abi-and-bugs assert-as-exception : incidental ;
# Warn for cases where adding an attribute may be beneficial
feature <cxx-suggestions> : _ default off on : propagated ;
# Warnings concerning the switch keyword
feature <cxx-switch-warnings> : _ on default off exhaustive-enum mandatory-default exhaustive-enum-and-mandatory-default : propagated ;
# Enable -Wunsafe-buffer-usage with clang
feature <cxx-unsafe-buffer-usage-warnings> : _ off default on : propagated ;
# Initialize all stack variables implicitly, including padding
# - uninitialized: Doesn't initialize any automatic variables (default behavior of Gcc and Clang)
# - pattern: Initialize automatic variables with byte-repeatable pattern (0xFE for Gcc, 0xAA for Clang)
# - zero: zero Initialize automatic variables with zeroes
feature <cxx-var-init> : _ default uninitialized pattern zero : incidental ;
# Warning level
feature <cxx-warnings> : _ on default off strict very-strict : propagated ;
# Make all or some warnings into errors
feature <cxx-warnings-as-error> : _ default off on basic : incidental ;
# Assume that the current compilation unit represents the whole program being compiled. This option should not be used in combination with lto.
feature <cxx-whole-program> : _ default off on strip-all : incidental ;
# In code that is intended to be portable to Windows-based compilers the warning helps prevent unresolved references due to the difference in the mangling of symbols declared with different class-keys
feature <cxx-windows-abi-compatibility-warnings> : _ off default on : propagated ;
feature <cxx-control-flow-incidental> : _ default off on branch return allow-bugs : incidental ;
feature <cxx-cpu-incidental> : _ default generic native : incidental ;
feature <cxx-debug-incidental> : _ default off on line-tables-only gdb lldb sce : incidental ;
feature <cxx-float-sanitizers-incidental> : _ default off on : incidental ;
feature <cxx-integer-sanitizers-incidental> : _ default off on : incidental ;
feature <cxx-lto-incidental> : _ default off on normal fat thin : incidental ;
feature <cxx-ndebug-incidental> : _ with-optimization-1-or-above default off on : incidental ;
feature <cxx-optimization-incidental> : _ default 0 g 1 2 3 fast size z : incidental ;
feature <cxx-pedantic-incidental> : _ on default off as-error : incidental ;
feature <cxx-relro-incidental> : _ default off on full : incidental ;
feature <cxx-sanitizers-incidental> : _ default off on : incidental ;
feature <cxx-stack-protector-incidental> : _ default off on strong all : incidental ;
feature <cxx-stl-debug-incidental> : _ default off on allow-broken-abi allow-broken-abi-and-bugs assert-as-exception : incidental ;
feature <cxx-var-init-incidental> : _ default uninitialized pattern zero : incidental ;
feature <cxx-warnings-as-error-incidental> : _ default off on basic : incidental ;
feature <cxx-whole-program-incidental> : _ default off on strip-all : incidental ;
feature <cxx-color-default> : default auto never always : incidental ;
feature <cxx-control-flow-default> : default off on branch return allow-bugs : incidental ;
feature <cxx-conversion-warnings-default> : on default off sign conversion : incidental ;
feature <cxx-covered-switch-default-warnings-default> : on default off : incidental ;
feature <cxx-cpu-default> : default generic native : incidental ;
feature <cxx-debug-default> : default off on line-tables-only gdb lldb sce : incidental ;
feature <cxx-diagnostics-show-template-tree-default> : default off on : incidental ;
feature <cxx-elide-type-default> : default off on : incidental ;
feature <cxx-fix-compiler-error-default> : on default off : incidental ;
feature <cxx-float-sanitizers-default> : default off on : incidental ;
feature <cxx-integer-sanitizers-default> : default off on : incidental ;
feature <cxx-linker-default> : default bfd gold lld native : incidental ;
feature <cxx-lto-default> : default off on normal fat thin : incidental ;
feature <cxx-ndebug-default> : with-optimization-1-or-above default off on : incidental ;
feature <cxx-noexcept-warnings-default> : default off on : incidental ;
feature <cxx-optimization-default> : default 0 g 1 2 3 fast size z : incidental ;
feature <cxx-pedantic-default> : on default off as-error : incidental ;
feature <cxx-relro-default> : default off on full : incidental ;
feature <cxx-reproducible-build-warnings-default> : default off on : incidental ;
feature <cxx-sanitizers-default> : default off on : incidental ;
feature <cxx-shadow-warnings-default> : off default on local compatible-local all : incidental ;
feature <cxx-stack-protector-default> : default off on strong all : incidental ;
feature <cxx-stl-debug-default> : default off on allow-broken-abi allow-broken-abi-and-bugs assert-as-exception : incidental ;
feature <cxx-suggestions-default> : default off on : incidental ;
feature <cxx-switch-warnings-default> : on default off exhaustive-enum mandatory-default exhaustive-enum-and-mandatory-default : incidental ;
feature <cxx-unsafe-buffer-usage-warnings-default> : off default on : incidental ;
feature <cxx-var-init-default> : default uninitialized pattern zero : incidental ;
feature <cxx-warnings-default> : on default off strict very-strict : incidental ;
feature <cxx-warnings-as-error-default> : default off on basic : incidental ;
feature <cxx-whole-program-default> : default off on strip-all : incidental ;
feature <cxx-windows-abi-compatibility-warnings-default> : off default on : incidental ;
rule jln-get-env ( env : values * )
{
local x = [ os.environ $(env) ] ;
if $(x)
{
if $(x) in $(values)
{
return $(x) ;
}
else
{
EXIT "Unknown '$(x)' for $(env)" : 7 ;
}
}
else
{
return "" ;
}
}
constant jln_env_color : [ jln-get-env cxx_color : default auto never always ] ;
constant jln_env_control_flow : [ jln-get-env cxx_control_flow : default off on branch return allow-bugs ] ;
constant jln_env_conversion_warnings : [ jln-get-env cxx_conversion_warnings : on default off sign conversion ] ;
constant jln_env_covered_switch_default_warnings : [ jln-get-env cxx_covered_switch_default_warnings : on default off ] ;
constant jln_env_cpu : [ jln-get-env cxx_cpu : default generic native ] ;
constant jln_env_debug : [ jln-get-env cxx_debug : default off on line-tables-only gdb lldb sce ] ;
constant jln_env_diagnostics_show_template_tree : [ jln-get-env cxx_diagnostics_show_template_tree : default off on ] ;
constant jln_env_elide_type : [ jln-get-env cxx_elide_type : default off on ] ;
constant jln_env_fix_compiler_error : [ jln-get-env cxx_fix_compiler_error : on default off ] ;
constant jln_env_float_sanitizers : [ jln-get-env cxx_float_sanitizers : default off on ] ;
constant jln_env_integer_sanitizers : [ jln-get-env cxx_integer_sanitizers : default off on ] ;
constant jln_env_linker : [ jln-get-env cxx_linker : default bfd gold lld native ] ;
constant jln_env_lto : [ jln-get-env cxx_lto : default off on normal fat thin ] ;
constant jln_env_ndebug : [ jln-get-env cxx_ndebug : with-optimization-1-or-above default off on ] ;
constant jln_env_noexcept_warnings : [ jln-get-env cxx_noexcept_warnings : default off on ] ;
constant jln_env_optimization : [ jln-get-env cxx_optimization : default 0 g 1 2 3 fast size z ] ;
constant jln_env_pedantic : [ jln-get-env cxx_pedantic : on default off as-error ] ;
constant jln_env_relro : [ jln-get-env cxx_relro : default off on full ] ;
constant jln_env_reproducible_build_warnings : [ jln-get-env cxx_reproducible_build_warnings : default off on ] ;
constant jln_env_sanitizers : [ jln-get-env cxx_sanitizers : default off on ] ;
constant jln_env_shadow_warnings : [ jln-get-env cxx_shadow_warnings : off default on local compatible-local all ] ;
constant jln_env_stack_protector : [ jln-get-env cxx_stack_protector : default off on strong all ] ;
constant jln_env_stl_debug : [ jln-get-env cxx_stl_debug : default off on allow-broken-abi allow-broken-abi-and-bugs assert-as-exception ] ;
constant jln_env_suggestions : [ jln-get-env cxx_suggestions : default off on ] ;
constant jln_env_switch_warnings : [ jln-get-env cxx_switch_warnings : on default off exhaustive-enum mandatory-default exhaustive-enum-and-mandatory-default ] ;
constant jln_env_unsafe_buffer_usage_warnings : [ jln-get-env cxx_unsafe_buffer_usage_warnings : off default on ] ;
constant jln_env_var_init : [ jln-get-env cxx_var_init : default uninitialized pattern zero ] ;
constant jln_env_warnings : [ jln-get-env cxx_warnings : on default off strict very-strict ] ;
constant jln_env_warnings_as_error : [ jln-get-env cxx_warnings_as_error : default off on basic ] ;
constant jln_env_whole_program : [ jln-get-env cxx_whole_program : default off on strip-all ] ;
constant jln_env_windows_abi_compatibility_warnings : [ jln-get-env cxx_windows_abi_compatibility_warnings : off default on ] ;
if $(JLN_BJAM_YEAR_VERSION) < 2016.00
{
import toolset ;
toolset.flags cxx-control-flow CXX_CONTROL_FLOW : <cxx-control-flow> ;
toolset.flags cxx-control-flow-incidental CXX_CONTROL_FLOW_INCIDENTAL : <cxx-control-flow-incidental> ;
toolset.flags cxx-cpu CXX_CPU : <cxx-cpu> ;
toolset.flags cxx-cpu-incidental CXX_CPU_INCIDENTAL : <cxx-cpu-incidental> ;
toolset.flags cxx-debug CXX_DEBUG : <cxx-debug> ;
toolset.flags cxx-debug-incidental CXX_DEBUG_INCIDENTAL : <cxx-debug-incidental> ;
toolset.flags cxx-float-sanitizers CXX_FLOAT_SANITIZERS : <cxx-float-sanitizers> ;
toolset.flags cxx-float-sanitizers-incidental CXX_FLOAT_SANITIZERS_INCIDENTAL : <cxx-float-sanitizers-incidental> ;
toolset.flags cxx-integer-sanitizers CXX_INTEGER_SANITIZERS : <cxx-integer-sanitizers> ;
toolset.flags cxx-integer-sanitizers-incidental CXX_INTEGER_SANITIZERS_INCIDENTAL : <cxx-integer-sanitizers-incidental> ;
toolset.flags cxx-lto CXX_LTO : <cxx-lto> ;
toolset.flags cxx-lto-incidental CXX_LTO_INCIDENTAL : <cxx-lto-incidental> ;
toolset.flags cxx-ndebug CXX_NDEBUG : <cxx-ndebug> ;
toolset.flags cxx-ndebug-incidental CXX_NDEBUG_INCIDENTAL : <cxx-ndebug-incidental> ;
toolset.flags cxx-optimization CXX_OPTIMIZATION : <cxx-optimization> ;
toolset.flags cxx-optimization-incidental CXX_OPTIMIZATION_INCIDENTAL : <cxx-optimization-incidental> ;
toolset.flags cxx-pedantic CXX_PEDANTIC : <cxx-pedantic> ;
toolset.flags cxx-pedantic-incidental CXX_PEDANTIC_INCIDENTAL : <cxx-pedantic-incidental> ;
toolset.flags cxx-relro CXX_RELRO : <cxx-relro> ;
toolset.flags cxx-relro-incidental CXX_RELRO_INCIDENTAL : <cxx-relro-incidental> ;
toolset.flags cxx-sanitizers CXX_SANITIZERS : <cxx-sanitizers> ;
toolset.flags cxx-sanitizers-incidental CXX_SANITIZERS_INCIDENTAL : <cxx-sanitizers-incidental> ;
toolset.flags cxx-stack-protector CXX_STACK_PROTECTOR : <cxx-stack-protector> ;
toolset.flags cxx-stack-protector-incidental CXX_STACK_PROTECTOR_INCIDENTAL : <cxx-stack-protector-incidental> ;
toolset.flags cxx-stl-debug CXX_STL_DEBUG : <cxx-stl-debug> ;
toolset.flags cxx-stl-debug-incidental CXX_STL_DEBUG_INCIDENTAL : <cxx-stl-debug-incidental> ;
toolset.flags cxx-var-init CXX_VAR_INIT : <cxx-var-init> ;
toolset.flags cxx-var-init-incidental CXX_VAR_INIT_INCIDENTAL : <cxx-var-init-incidental> ;
toolset.flags cxx-warnings-as-error CXX_WARNINGS_AS_ERROR : <cxx-warnings-as-error> ;
toolset.flags cxx-warnings-as-error-incidental CXX_WARNINGS_AS_ERROR_INCIDENTAL : <cxx-warnings-as-error-incidental> ;
toolset.flags cxx-whole-program CXX_WHOLE_PROGRAM : <cxx-whole-program> ;
toolset.flags cxx-whole-program-incidental CXX_WHOLE_PROGRAM_INCIDENTAL : <cxx-whole-program-incidental> ;
}
local JLN_ORIGINAL_CXX_TOOLSET = "" ;
local JLN_NORMALIZED_CXX_COMP = "" ;
local JLN_NORMALIZED_CXX_COMP_VERSION = 100000 ;
rule jln-update-normalized-compiler ( toolset : version )
{
if $(JLN_ORIGINAL_CXX_TOOLSET) != $(toolset)
{
JLN_ORIGINAL_CXX_TOOLSET = $(toolset) ;
local is_emcc = 0 ;
local is_intel = 0 ;
switch $(toolset) {
case emscripten* : is_emcc = 1 ;
case emcc* : is_emcc = 1 ;
case intel : is_intel = 1 ;
case icx* : is_intel = 1 ;
case icpx* : is_intel = 1 ;
case dpcpp* : is_intel = 1 ;
}
if $(is_emcc) = 1 {
JLN_NORMALIZED_CXX_COMP = clang-emcc ;
# get clang version. Assume emcc exists
version = [ MATCH "clang version ([0-9]+\\.[0-9]+\\.[0-9]+)" : [ SHELL "emcc -v 2>&1" ] ] ;
}
# icx / icpx
else if $(is_intel) = 1 {
JLN_NORMALIZED_CXX_COMP = clang ;
switch $(version) {
case 2021* : JLN_NORMALIZED_CXX_COMP_VERSION = 1200000 ;
case 2022* : JLN_NORMALIZED_CXX_COMP_VERSION = 1400000 ;
case 2023* : JLN_NORMALIZED_CXX_COMP_VERSION = 1600000 ;
case 2024* : JLN_NORMALIZED_CXX_COMP_VERSION = 1800000 ;
case 2025* : JLN_NORMALIZED_CXX_COMP_VERSION = 2000000 ;
case 2026* : JLN_NORMALIZED_CXX_COMP_VERSION = 2200000 ;
case 2027* : JLN_NORMALIZED_CXX_COMP_VERSION = 2400000 ;
case 2028* : JLN_NORMALIZED_CXX_COMP_VERSION = 2600000 ;
case 2029* : JLN_NORMALIZED_CXX_COMP_VERSION = 2800000 ;
case 2030* : JLN_NORMALIZED_CXX_COMP_VERSION = 3000000 ;
}
}
else {
# TODO `version` is not the real version.
# For toolset=gcc-5, version is 5 ; for clang-scan, version is ''
JLN_NORMALIZED_CXX_COMP = $(toolset) ;
version = [ MATCH "^[^0-9]*(.*)$" : $(version) ] ;
if ! $(version) {
version = [ MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" : [ SHELL "$(toolset) --version" ] ] ;
}
}
if $(is_intel) = 0 {
local match = [ MATCH "^([0-9]+)(\\.([0-9]+))?" : $(version) ] ;
local major = $(match[1]) ;
local minor = [ MATCH "(.....)$" : [ string.join 00000 $(match[3]) ] ] ;
JLN_NORMALIZED_CXX_COMP_VERSION = $(major)$(minor) ;
}
}
}
rule jln-get-value ( ps : opt : env )
{
local x = [ $(ps).get <$(opt)> ] ;
if $(x) = "_"
{
x = $(env) ;
if $(x) = ""
{
x = [ $(ps).get <$(opt)-default> ] ;
}
}
return $(x) ;
}
rule jln-get-value2 ( ps : opt : iopt : env )
{
local x = [ $(ps).get <$(opt)> ] ;
if $(x) = "_"
{
x = [ $(ps).get <$(iopt)> ] ;
if $(x) = "_"
{
x = $(env) ;
if $(x) = ""
{
x = [ $(ps).get <$(opt)-default> ] ;
}
}
}
return $(x) ;
}
rule flags ( properties * )
{
local ps = [ property-set.create $(properties) ] ;
local toolset = [ $(ps).get <toolset> ] ;
local original_version = [ $(ps).get <toolset-$(toolset):version> ] ;
jln-update-normalized-compiler $(toolset) : $(original_version) ;
local linker = [ $(ps).get <linker> ] ;
local flags = ;
if $(JLN_BJAM_YEAR_VERSION) >= 2016.00
{
flags +=
<relevant>cxx-control-flow
<relevant>cxx-cpu
<relevant>cxx-debug
<relevant>cxx-float-sanitizers
<relevant>cxx-integer-sanitizers
<relevant>cxx-lto
<relevant>cxx-ndebug
<relevant>cxx-optimization
<relevant>cxx-pedantic
<relevant>cxx-relro
<relevant>cxx-sanitizers
<relevant>cxx-stack-protector
<relevant>cxx-stl-debug
<relevant>cxx-var-init
<relevant>cxx-warnings-as-error
<relevant>cxx-whole-program
;
}
local x_color = [ jln-get-value $(ps) : cxx-color : $(jln_env_color) ] ;
local x_control_flow = [ jln-get-value2 $(ps) : cxx-control-flow : cxx-control-flow-incidental : $(jln_env_control_flow) ] ;
local x_conversion_warnings = [ jln-get-value $(ps) : cxx-conversion-warnings : $(jln_env_conversion_warnings) ] ;
local x_covered_switch_default_warnings = [ jln-get-value $(ps) : cxx-covered-switch-default-warnings : $(jln_env_covered_switch_default_warnings) ] ;
local x_cpu = [ jln-get-value2 $(ps) : cxx-cpu : cxx-cpu-incidental : $(jln_env_cpu) ] ;
local x_debug = [ jln-get-value2 $(ps) : cxx-debug : cxx-debug-incidental : $(jln_env_debug) ] ;
local x_diagnostics_show_template_tree = [ jln-get-value $(ps) : cxx-diagnostics-show-template-tree : $(jln_env_diagnostics_show_template_tree) ] ;
local x_elide_type = [ jln-get-value $(ps) : cxx-elide-type : $(jln_env_elide_type) ] ;
local x_fix_compiler_error = [ jln-get-value $(ps) : cxx-fix-compiler-error : $(jln_env_fix_compiler_error) ] ;
local x_float_sanitizers = [ jln-get-value2 $(ps) : cxx-float-sanitizers : cxx-float-sanitizers-incidental : $(jln_env_float_sanitizers) ] ;
local x_integer_sanitizers = [ jln-get-value2 $(ps) : cxx-integer-sanitizers : cxx-integer-sanitizers-incidental : $(jln_env_integer_sanitizers) ] ;
local x_linker = [ jln-get-value $(ps) : cxx-linker : $(jln_env_linker) ] ;
local x_lto = [ jln-get-value2 $(ps) : cxx-lto : cxx-lto-incidental : $(jln_env_lto) ] ;
local x_ndebug = [ jln-get-value2 $(ps) : cxx-ndebug : cxx-ndebug-incidental : $(jln_env_ndebug) ] ;
local x_noexcept_warnings = [ jln-get-value $(ps) : cxx-noexcept-warnings : $(jln_env_noexcept_warnings) ] ;
local x_optimization = [ jln-get-value2 $(ps) : cxx-optimization : cxx-optimization-incidental : $(jln_env_optimization) ] ;
local x_pedantic = [ jln-get-value2 $(ps) : cxx-pedantic : cxx-pedantic-incidental : $(jln_env_pedantic) ] ;
local x_relro = [ jln-get-value2 $(ps) : cxx-relro : cxx-relro-incidental : $(jln_env_relro) ] ;
local x_reproducible_build_warnings = [ jln-get-value $(ps) : cxx-reproducible-build-warnings : $(jln_env_reproducible_build_warnings) ] ;
local x_sanitizers = [ jln-get-value2 $(ps) : cxx-sanitizers : cxx-sanitizers-incidental : $(jln_env_sanitizers) ] ;
local x_shadow_warnings = [ jln-get-value $(ps) : cxx-shadow-warnings : $(jln_env_shadow_warnings) ] ;
local x_stack_protector = [ jln-get-value2 $(ps) : cxx-stack-protector : cxx-stack-protector-incidental : $(jln_env_stack_protector) ] ;
local x_stl_debug = [ jln-get-value2 $(ps) : cxx-stl-debug : cxx-stl-debug-incidental : $(jln_env_stl_debug) ] ;
local x_suggestions = [ jln-get-value $(ps) : cxx-suggestions : $(jln_env_suggestions) ] ;
local x_switch_warnings = [ jln-get-value $(ps) : cxx-switch-warnings : $(jln_env_switch_warnings) ] ;
local x_unsafe_buffer_usage_warnings = [ jln-get-value $(ps) : cxx-unsafe-buffer-usage-warnings : $(jln_env_unsafe_buffer_usage_warnings) ] ;
local x_var_init = [ jln-get-value2 $(ps) : cxx-var-init : cxx-var-init-incidental : $(jln_env_var_init) ] ;
local x_warnings = [ jln-get-value $(ps) : cxx-warnings : $(jln_env_warnings) ] ;
local x_warnings_as_error = [ jln-get-value2 $(ps) : cxx-warnings-as-error : cxx-warnings-as-error-incidental : $(jln_env_warnings_as_error) ] ;
local x_whole_program = [ jln-get-value2 $(ps) : cxx-whole-program : cxx-whole-program-incidental : $(jln_env_whole_program) ] ;
local x_windows_abi_compatibility_warnings = [ jln-get-value $(ps) : cxx-windows-abi-compatibility-warnings : $(jln_env_windows_abi_compatibility_warnings) ] ;
if $(x_ndebug) != "default"
{
if $(x_ndebug) = "off"
{
flags +=
<cxxflags>"-UNDEBUG"
;
}
else
{
if $(x_ndebug) = "on"
{
flags +=
<cxxflags>"-DNDEBUG"
;
}
else
{
if $(x_optimization) != "default"
{
if ! ( ( $(x_optimization) = "0" || $(x_optimization) = "g" ) )
{
flags +=
<cxxflags>"-DNDEBUG"
;
}
}
}
}
}
if ( $(JLN_NORMALIZED_CXX_COMP) = "gcc" || $(JLN_NORMALIZED_CXX_COMP) = "clang" || $(JLN_NORMALIZED_CXX_COMP) = "clang-emcc" )
{
if $(x_warnings) != "default"
{
if $(x_warnings) = "off"
{
flags +=
<cxxflags>"-w"
;
}
else
{
if $(JLN_NORMALIZED_CXX_COMP) = "gcc"
{
flags +=
<cxxflags>"-Wall"
<cxxflags>"-Wextra"
<cxxflags>"-Wcast-align"
<cxxflags>"-Wcast-qual"
<cxxflags>"-Wdisabled-optimization"
<cxxflags>"-Wfloat-equal"
<cxxflags>"-Wformat-security"
<cxxflags>"-Wformat=2"
<cxxflags>"-Winvalid-pch"
<cxxflags>"-Wmissing-include-dirs"
<cxxflags>"-Wpacked"
<cxxflags>"-Wredundant-decls"
<cxxflags>"-Wundef"
<cxxflags>"-Wunused-macros"
<cxxflags>"-Wpointer-arith"
<cxxflags>"-Wmissing-declarations"
<cxxflags>"-Wnon-virtual-dtor"
<cxxflags>"-Wold-style-cast"
<cxxflags>"-Woverloaded-virtual"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 400007 ]
{
flags +=
<cxxflags>"-Wsuggest-attribute=noreturn"
<cxxflags>"-Wzero-as-null-pointer-constant"
<cxxflags>"-Wlogical-op"
<cxxflags>"-Wvector-operation-performance"
<cxxflags>"-Wdouble-promotion"
<cxxflags>"-Wtrampolines"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 400008 ]
{
flags +=
<cxxflags>"-Wuseless-cast"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 400009 ]
{
flags +=
<cxxflags>"-Wconditionally-supported"
<cxxflags>"-Wfloat-conversion"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 500001 ]
{
flags +=
<cxxflags>"-Wformat-signedness"
<cxxflags>"-Warray-bounds=2"
<cxxflags>"-Wstrict-null-sentinel"
<cxxflags>"-Wsuggest-override"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 600001 ]
{
flags +=
<cxxflags>"-Wduplicated-cond"
<cxxflags>"-Wnull-dereference"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 700000 ]
{
flags +=
<cxxflags>"-Waligned-new"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 700001 ]
{
flags +=
<cxxflags>"-Walloc-zero"
<cxxflags>"-Walloca"
<cxxflags>"-Wformat-overflow=2"
<cxxflags>"-Wduplicated-branches"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 800000 ]
{
flags +=
<cxxflags>"-Wclass-memaccess"
;
if ( $(x_warnings) = "strict" || $(x_warnings) = "very-strict" )
{
flags +=
<cxxflags>"-Wcast-align=strict"
;
}
}
}
}
}
}
}
}
}
}
else
{
flags +=
<cxxflags>"-Weverything"
<cxxflags>"-Wno-documentation"
<cxxflags>"-Wno-documentation-unknown-command"
<cxxflags>"-Wno-newline-eof"
<cxxflags>"-Wno-c++98-compat"
<cxxflags>"-Wno-c++98-compat-pedantic"
<cxxflags>"-Wno-padded"
<cxxflags>"-Wno-global-constructors"
<cxxflags>"-Wno-weak-vtables"
<cxxflags>"-Wno-exit-time-destructors"
;
if ! ( ( $(x_switch_warnings) = "off" || $(x_switch_warnings) = "exhaustive-enum" || $(x_switch_warnings) = "exhaustive-enum-and-mandatory-default" ) )
{
flags +=
<cxxflags>"-Wno-switch-enum"
;
}
if $(x_covered_switch_default_warnings) = "default"
{
flags +=
<cxxflags>"-Wno-covered-switch-default"
;
}
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 300009 ]
{
flags +=
<cxxflags>"-Wno-undefined-var-template"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 500000 ]
{
flags +=
<cxxflags>"-Wno-inconsistent-missing-destructor-override"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 900000 ]
{
flags +=
<cxxflags>"-Wno-ctad-maybe-unsupported"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 1000000 ]
{
flags +=
<cxxflags>"-Wno-c++20-compat"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 1100000 ]
{
flags +=
<cxxflags>"-Wno-suggest-destructor-override"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 1600000 ]
{
if $(x_unsafe_buffer_usage_warnings) = "default"
{
flags +=
<cxxflags>"-Wno-unsafe-buffer-usage"
;
}
}
}
}
}
}
}
}
}
}
if $(JLN_NORMALIZED_CXX_COMP) = "gcc"
{
if $(x_switch_warnings) != "default"
{
if $(x_switch_warnings) = "on"
{
flags +=
<cxxflags>"-Wswitch"
;
}
else
{
if $(x_switch_warnings) = "exhaustive-enum"
{
flags +=
<cxxflags>"-Wswitch-enum"
;
}
else
{
if $(x_switch_warnings) = "mandatory-default"
{
flags +=
<cxxflags>"-Wswitch-default"
;
}
else
{
if $(x_switch_warnings) = "exhaustive-enum-and-mandatory-default"
{
flags +=
<cxxflags>"-Wswitch-default"
<cxxflags>"-Wswitch-enum"
;
}
else
{
flags +=
<cxxflags>"-Wno-switch"
<cxxflags>"-Wno-switch-enum"
<cxxflags>"-Wno-switch-default"
;
}
}
}
}
}
}
else
{
if $(x_switch_warnings) != "default"
{
if ( $(x_switch_warnings) = "on" || $(x_switch_warnings) = "mandatory-default" )
{
flags +=
<cxxflags>"-Wswitch"
;
}
else
{
if ( $(x_switch_warnings) = "exhaustive-enum" || $(x_switch_warnings) = "exhaustive-enum-and-mandatory-default" )
{
flags +=
<cxxflags>"-Wswitch"
<cxxflags>"-Wswitch-enum"
;
}
else
{
flags +=
<cxxflags>"-Wno-switch"
<cxxflags>"-Wno-switch-enum"
;
}
}
}
if $(x_covered_switch_default_warnings) != "default"
{
if $(x_covered_switch_default_warnings) = "off"
{
flags +=
<cxxflags>"-Wno-covered-switch-default"
;
}
else
{
flags +=
<cxxflags>"-Wcovered-switch-default"
;
}
}
}
if $(x_unsafe_buffer_usage_warnings) != "default"
{
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 1600000 ]
{
if $(x_unsafe_buffer_usage_warnings) = "off"
{
flags +=
<cxxflags>"-Wno-unsafe-buffer-usage"
;
}
else
{
flags +=
<cxxflags>"-Wunsafe-buffer-usage"
;
}
}
}
if $(x_diagnostics_show_template_tree) != "default"
{
if ( ( $(JLN_NORMALIZED_CXX_COMP) = "gcc" && ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 800000 ] ) || $(JLN_NORMALIZED_CXX_COMP) = "clang" )
{
if $(x_diagnostics_show_template_tree) = "on"
{
flags +=
<cxxflags>"-fdiagnostics-show-template-tree"
;
}
else
{
flags +=
<cxxflags>"-fno-diagnostics-show-template-tree"
;
}
}
}
if $(x_elide_type) != "default"
{
if $(x_elide_type) = "on"
{
if ( $(JLN_NORMALIZED_CXX_COMP) = "gcc" && ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 800000 ] )
{
flags +=
<cxxflags>"-felide-type"
;
}
}
else
{
if ( ( $(JLN_NORMALIZED_CXX_COMP) = "gcc" && ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 800000 ] ) || ( $(JLN_NORMALIZED_CXX_COMP) = "clang" && ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 300004 ] ) )
{
flags +=
<cxxflags>"-fno-elide-type"
;
}
}
}
if $(x_var_init) != "default"
{
if ( ( $(JLN_NORMALIZED_CXX_COMP) = "gcc" && ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 1200000 ] ) || ( $(JLN_NORMALIZED_CXX_COMP) = "clang" && ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 800000 ] ) )
{
if $(JLN_NORMALIZED_CXX_COMP) = "clang"
{
flags +=
<cxxflags>"-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang"
;
}
if $(x_var_init) = "pattern"
{
flags +=
<cxxflags>"-ftrivial-auto-var-init=pattern"
;
}
else
{
if $(x_var_init) = "zero"
{
flags +=
<cxxflags>"-ftrivial-auto-var-init=zero"
;
}
else
{
flags +=
<cxxflags>"-ftrivial-auto-var-init=uninitialized"
;
}
}
}
}
if $(x_windows_abi_compatibility_warnings) != "default"
{
if ( ( $(JLN_NORMALIZED_CXX_COMP) = "gcc" && ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 1000000 ] ) || $(JLN_NORMALIZED_CXX_COMP) = "clang" || $(JLN_NORMALIZED_CXX_COMP) = "clang-emcc" )
{
if $(x_windows_abi_compatibility_warnings) = "on"
{
flags +=
<cxxflags>"-Wmismatched-tags"
;
}
else
{
flags +=
<cxxflags>"-Wno-mismatched-tags"
;
}
}
}
if $(x_warnings_as_error) != "default"
{
if $(x_warnings_as_error) = "on"
{
flags +=
<cxxflags>"-Werror"
;
}
else
{
if $(x_warnings_as_error) = "basic"
{
flags +=
<cxxflags>"-Werror=return-type"
<cxxflags>"-Werror=init-self"
;
if $(JLN_NORMALIZED_CXX_COMP) = "gcc"
{
flags +=
<cxxflags>"-Werror=div-by-zero"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 500001 ]
{
flags +=
<cxxflags>"-Werror=array-bounds"
<cxxflags>"-Werror=logical-op"
<cxxflags>"-Werror=logical-not-parentheses"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 700000 ]
{
flags +=
<cxxflags>"-Werror=literal-suffix"
;
}
}
}
else
{
flags +=
<cxxflags>"-Werror=array-bounds"
<cxxflags>"-Werror=division-by-zero"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 300004 ]
{
flags +=
<cxxflags>"-Werror=logical-not-parentheses"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 300006 ]
{
flags +=
<cxxflags>"-Werror=delete-incomplete"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 600000 ]
{
flags +=
<cxxflags>"-Werror=user-defined-literals"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 700000 ]
{
flags +=
<cxxflags>"-Werror=dynamic-class-memaccess"
;
}
}
}
}
}
}
else
{
flags +=
<cxxflags>"-Wno-error"
;
}
}
}
if $(x_suggestions) != "default"
{
if $(x_suggestions) != "off"
{
if $(JLN_NORMALIZED_CXX_COMP) = "gcc"
{
flags +=
<cxxflags>"-Wsuggest-attribute=pure"
<cxxflags>"-Wsuggest-attribute=const"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 500000 ]
{
flags +=
<cxxflags>"-Wsuggest-final-types"
<cxxflags>"-Wsuggest-final-methods"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 500001 ]
{
flags +=
<cxxflags>"-Wnoexcept"
;
}
}
}
}
}
if $(x_sanitizers) != "default"
{
if $(x_sanitizers) = "off"
{
flags +=
<cxxflags>"-fno-sanitize=all"
<linkflags>"-fno-sanitize=all"
;
}
else
{
if ( $(JLN_NORMALIZED_CXX_COMP) = "clang" || $(JLN_NORMALIZED_CXX_COMP) = "clang-emcc" )
{
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 300001 ]
{
flags +=
<cxxflags>"-fsanitize=undefined"
<cxxflags>"-fsanitize=address"
<cxxflags>"-fsanitize-address-use-after-scope"
<cxxflags>"-fno-omit-frame-pointer"
<cxxflags>"-fno-optimize-sibling-calls"
<linkflags>"-fsanitize=undefined"
<linkflags>"-fsanitize=address"
;
if $(JLN_NORMALIZED_CXX_COMP) = "clang"
{
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 300004 ]
{
flags +=
<cxxflags>"-fsanitize=leak"
<linkflags>"-fsanitize=leak"
;
}
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 600000 ]
{
if $(x_stack_protector) != "default"
{
if $(x_stack_protector) != "off"
{
flags +=
<cxxflags>"-fsanitize-minimal-runtime"
;
}
}
}
}
}
}
else
{
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 400008 ]
{
flags +=
<cxxflags>"-fsanitize=address"
<cxxflags>"-fno-omit-frame-pointer"
<cxxflags>"-fno-optimize-sibling-calls"
<linkflags>"-fsanitize=address"
;
if ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 400009 ]
{
flags +=
<cxxflags>"-fsanitize=undefined"
<cxxflags>"-fsanitize=leak"
<linkflags>"-fsanitize=undefined"
<linkflags>"-fsanitize=leak"
;
}
}
}
}
}
if $(x_control_flow) != "default"
{
if $(JLN_NORMALIZED_CXX_COMP) = "clang-emcc"
{
if $(x_control_flow) = "off"
{
flags +=
<linkflags>"-sASSERTIONS=0"
<linkflags>"-sSAFE_HEAP=0"
;
}
else
{
flags +=
<linkflags>"-sASSERTIONS=1"
<linkflags>"-sDEMANGLE_SUPPORT=1"
;
if ! ( ( $(x_sanitizers) = "on" ) )
{
flags +=
<linkflags>"-sSAFE_HEAP=1"
;
}
}
}
else
{
if $(x_control_flow) = "off"
{
if ( $(JLN_NORMALIZED_CXX_COMP) = "gcc" && ! [ numbers.less $(JLN_NORMALIZED_CXX_COMP_VERSION) 800000 ] )
{
flags +=
<cxxflags>"-fcf-protection=none"
;
}
else
{
flags +=
<cxxflags>"-fno-sanitize=cfi"
<cxxflags>"-fcf-protection=none"
<cxxflags>"-fno-sanitize-cfi-cross-dso"
<linkflags>"-fno-sanitize=cfi"