@@ -26,6 +26,10 @@ TEMPLATED_SUPPORTED_LANGUAGES = ['C++', 'Java', 'D', 'Swift', 'Vox', 'Rust', 'Zi
26
26
SUPPORTED_OPERATIONS = ['Check' , 'Compile' , 'Build' ]
27
27
DEFAULT_PROGRAM_NAME = 'main'
28
28
29
+ C_EXES = ['tcc' , 'gcc' , 'clang' ,]
30
+ D_EXES = ['dmd' , 'ldmd2' , 'gdc' ,]
31
+ RUST_EXES = ['rustc' ]
32
+
29
33
C_WARN_FLAGS = ['-Wall' , '-Wextra' , '-Wno-c++11-extensions' ]
30
34
31
35
RUSTC_NO_WARNINGS_FLAGS = ['-A' , 'warnings' ] # flags that disable warnings for `rustc`
@@ -36,9 +40,9 @@ JULIA_COMPILE_FLAGS = ['-O0'] # See: https://github.com/JuliaLang/julia/issues/
36
40
37
41
ROOT_PATH = 'generated'
38
42
RANGE = range (5 , 15 )
39
- VERSIONS = ["" ] + [f"-{ i } " for i in RANGE ]
43
+ VERSIONS = ['' ] + [f"-{ i } " for i in RANGE ]
40
44
41
- HOME = os .path .expanduser ("~" ) # instead of home = os.getenv('HOME') that doesn’t work on Windows
45
+ HOME = os .path .expanduser ('~' ) # instead of home = os.getenv('HOME') that doesn’t work on Windows
42
46
43
47
44
48
class Row : # TODO use
@@ -309,18 +313,17 @@ def main():
309
313
split = language_exes_spec .split (':' )
310
314
if len (split ) == 2 :
311
315
language = split [0 ]
312
- exes = split [1 ]
316
+ exes = split [1 ]. split ( ',' )
313
317
else :
314
318
language = split [0 ]
315
- exes = Null
319
+ exes = []
316
320
if language not in SUPPORTED_LANGUAGES :
317
321
print ('Warning: Ignoring unsupported language ' + language )
318
322
continue
319
323
if language in args .language_exes :
320
- args .language_exes [language ] += tuple ( exes . split ( ',' ))
324
+ args .language_exes [language ] += exes
321
325
else :
322
- args .language_exes [language ] = tuple (exes .split (',' ))
323
- print ("args.language_exes:" , args .language_exes )
326
+ args .language_exes [language ] = exes
324
327
325
328
args .operations = list (map (lambda x : x .capitalize (), args .operations .split (',' ))) # into a list of capitalized names
326
329
filtered_operations = []
@@ -444,9 +447,9 @@ def main():
444
447
print (markdown_table (TABLE_TITLES , results ))
445
448
446
449
447
- def match_lang (args , lang , exe_name ):
450
+ def match_lang_exe (args , lang , exe_name ):
448
451
try :
449
- if exe_name not in args .language_exes [lang ]:
452
+ if args . language_exes [ lang ] and exe_name not in args .language_exes [lang ]:
450
453
return None
451
454
except KeyError :
452
455
pass
@@ -456,7 +459,7 @@ def match_lang(args, lang, exe_name):
456
459
def benchmark_Ada_using_gcc (results , lang , code_paths , args , op , templated ):
457
460
exe_flags = ['compile' ] if op == 'Build' else ['check' ]
458
461
for gcc_version in VERSIONS :
459
- exe = match_lang (args , lang , 'gnat' + str (gcc_version ))
462
+ exe = match_lang_exe (args , lang , 'gnat' + str (gcc_version ))
460
463
if exe :
461
464
version = get_version (sp .run ([exe , '--version' ], stdout = sp .PIPE ))
462
465
compile_file (code_paths ,
@@ -491,7 +494,7 @@ def benchmark_C_using_cproc(results, lang, code_paths, args, op, templated):
491
494
return False
492
495
else :
493
496
return None
494
- exe = match_lang (args , lang , 'cproc' )
497
+ exe = match_lang_exe (args , lang , 'cproc' )
495
498
if exe :
496
499
version = 'unknown'
497
500
compile_file (code_paths ,
@@ -519,7 +522,7 @@ def benchmark_C_using_tcc(results, lang, code_paths, args, op, templated):
519
522
out_flag_and_exe = ['-o' , out_binary (lang )]
520
523
else :
521
524
return None
522
- exe = match_lang (args , lang , 'tcc' )
525
+ exe = match_lang_exe (args , lang , 'tcc' )
523
526
if exe :
524
527
version = get_version (sp .run ([exe , '-v' ], stdout = sp .PIPE ))
525
528
compile_file (code_paths ,
@@ -556,9 +559,9 @@ def benchmark_C_and_Cxx_using_gcc(results, lang, code_paths, args, op, templated
556
559
return none
557
560
for gcc_version in VERSIONS :
558
561
if lang == 'C' :
559
- exe = match_lang (args , lang , 'gcc' + str (gcc_version ))
562
+ exe = match_lang_exe (args , lang , 'gcc' + str (gcc_version ))
560
563
elif lang == 'C++' :
561
- exe = match_lang (args , lang , 'g++' + str (gcc_version ))
564
+ exe = match_lang_exe (args , lang , 'g++' + str (gcc_version ))
562
565
else :
563
566
return None
564
567
if exe :
@@ -583,9 +586,9 @@ def benchmark_C_and_Cxx_using_clang(results, lang, code_paths, args, op, templat
583
586
C_CLANG_FLAGS = C_WARN_FLAGS + ['-fno-color-diagnostics' , '-fno-caret-diagnostics' , '-fno-diagnostics-show-option' ]
584
587
for clang_version in VERSIONS :
585
588
if lang == 'C' :
586
- exe = match_lang (args , lang , 'clang' + str (clang_version ))
589
+ exe = match_lang_exe (args , lang , 'clang' + str (clang_version ))
587
590
elif lang == 'C++' :
588
- exe = match_lang (args , lang , 'clang' + str (clang_version ))
591
+ exe = match_lang_exe (args , lang , 'clang' + str (clang_version ))
589
592
else :
590
593
return None
591
594
if exe :
@@ -621,54 +624,57 @@ def benchmark_D(results, code_paths, args, op, templated, use_dips):
621
624
else :
622
625
return None
623
626
624
- # dmd
625
- exe = match_lang (args , lang , 'dmd' )
626
- if exe :
627
- version = get_version (sp .run ([exe , '--version' ], stdout = sp .PIPE ))
628
- compile_file (code_paths = code_paths ,
629
- out_flag_and_exe = ['-of=' + out_binary (lang )] if op == 'Build' else [],
630
- exe = exe ,
631
- runner = True ,
632
- exe_flags = d_flags + exe_flags ,
633
- args = args ,
634
- op = op ,
635
- compiler_version = version ,
636
- lang = lang ,
637
- templated = templated ,
638
- results = results )
639
-
640
- # ldmd2
641
- exe = match_lang (args , lang , 'ldmd2' )
642
- if exe :
643
- version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[6 ][1 :- 2 ]
644
- compile_file (code_paths = code_paths ,
645
- out_flag_and_exe = ['-of=' + out_binary (lang )] if op == 'Build' else [],
646
- exe = exe ,
647
- runner = True ,
648
- exe_flags = d_flags + exe_flags ,
649
- args = args ,
650
- op = op ,
651
- compiler_version = version ,
652
- lang = lang ,
653
- templated = templated ,
654
- results = results )
627
+ try :
628
+ exes = args .language_exes [lang ]
629
+ except KeyError :
630
+ return
631
+ if not exes :
632
+ exes = D_EXES
655
633
656
- # gdc
657
- exe = match_lang (args , lang , 'gdc' )
658
- if exe :
659
- exe_flags = ['-fsyntax-only' ] if op == 'Check' else []
660
- version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[3 ]
661
- compile_file (code_paths = code_paths ,
662
- out_flag_and_exe = ['-o' + out_binary (lang )] if op == 'Build' else [],
663
- exe = exe ,
664
- runner = True ,
665
- exe_flags = exe_flags ,
666
- args = args ,
667
- op = op ,
668
- compiler_version = version ,
669
- lang = lang ,
670
- templated = templated ,
671
- results = results )
634
+ # dmd
635
+ for exe in filter (lambda exe : which (exe ), exes ):
636
+ if not which (exe ):
637
+ continue
638
+ if exe .startswith ('dmd' ):
639
+ version = get_version (sp .run ([exe , '--version' ], stdout = sp .PIPE ))
640
+ compile_file (code_paths = code_paths ,
641
+ out_flag_and_exe = ['-of=' + out_binary (lang )] if op == 'Build' else [],
642
+ exe = exe ,
643
+ runner = True ,
644
+ exe_flags = d_flags + exe_flags ,
645
+ args = args ,
646
+ op = op ,
647
+ compiler_version = version ,
648
+ lang = lang ,
649
+ templated = templated ,
650
+ results = results )
651
+ elif exe .startswith ('ldmd2' ):
652
+ version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[6 ][1 :- 2 ]
653
+ compile_file (code_paths = code_paths ,
654
+ out_flag_and_exe = ['-of=' + out_binary (lang )] if op == 'Build' else [],
655
+ exe = exe ,
656
+ runner = True ,
657
+ exe_flags = d_flags + exe_flags ,
658
+ args = args ,
659
+ op = op ,
660
+ compiler_version = version ,
661
+ lang = lang ,
662
+ templated = templated ,
663
+ results = results )
664
+ elif exe .startswith ('gdc' ):
665
+ exe_flags = ['-fsyntax-only' ] if op == 'Check' else []
666
+ version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[3 ]
667
+ compile_file (code_paths = code_paths ,
668
+ out_flag_and_exe = ['-o' + out_binary (lang )] if op == 'Build' else [],
669
+ exe = exe ,
670
+ runner = True ,
671
+ exe_flags = exe_flags ,
672
+ args = args ,
673
+ op = op ,
674
+ compiler_version = version ,
675
+ lang = lang ,
676
+ templated = templated ,
677
+ results = results )
672
678
673
679
674
680
def benchmark_Vox (results , code_paths , args , op , templated ):
@@ -683,7 +689,7 @@ def benchmark_Vox(results, code_paths, args, op, templated):
683
689
out_flag_and_exe = ['--of=' + out_binary (lang )]
684
690
else :
685
691
return None
686
- exe = match_lang (args , lang , 'vox' )
692
+ exe = match_lang_exe (args , lang , 'vox' )
687
693
if exe :
688
694
compile_file (code_paths ,
689
695
out_flag_and_exe = out_flag_and_exe ,
@@ -700,7 +706,7 @@ def benchmark_Vox(results, code_paths, args, op, templated):
700
706
701
707
def benchmark_Mono (results , code_paths , args , op , templated ):
702
708
lang = 'C#'
703
- exe = match_lang (args , lang , 'mcs' )
709
+ exe = match_lang_exe (args , lang , 'mcs' )
704
710
if exe :
705
711
exe_flags = ['-target:exe' ] + ([] if op == 'Build' else ['' ])
706
712
version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[4 ]
@@ -739,7 +745,7 @@ def benchmark_Go_using_go(results, code_paths, args, op, templated):
739
745
out_flag_and_exe = []
740
746
else :
741
747
return None
742
- exe = match_lang (args , lang , exe )
748
+ exe = match_lang_exe (args , lang , exe )
743
749
if exe :
744
750
compile_file (code_paths ,
745
751
out_flag_and_exe = out_flag_and_exe ,
@@ -757,7 +763,7 @@ def benchmark_Go_using_go(results, code_paths, args, op, templated):
757
763
def benchmark_Go_using_gccgo (results , code_paths , args , op , templated ):
758
764
lang = 'Go'
759
765
for gccgo_version in VERSIONS :
760
- exe = match_lang (args , lang , 'gccgo' + str (gccgo_version ))
766
+ exe = match_lang_exe (args , lang , 'gccgo' + str (gccgo_version ))
761
767
if exe :
762
768
version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[3 ]
763
769
compile_file (code_paths ,
@@ -775,7 +781,7 @@ def benchmark_Go_using_gccgo(results, code_paths, args, op, templated):
775
781
776
782
def benchmark_Swift (results , code_paths , args , op , templated ):
777
783
lang = 'Swift'
778
- exe = (match_lang (args , lang , 'swiftc' ) or
784
+ exe = (match_lang_exe (args , lang , 'swiftc' ) or
779
785
which (os .path .join (HOME , '.local/swift-5.3.3-RELEASE-ubuntu20.04/usr/bin/swiftc' )))
780
786
if op == 'Build' :
781
787
exe_flags = ['' ]
@@ -801,9 +807,9 @@ def benchmark_Swift(results, code_paths, args, op, templated):
801
807
def benchmark_OCaml (results , code_paths , args , op , templated , bytecode ):
802
808
lang = 'OCaml'
803
809
if bytecode :
804
- exe = match_lang (args , lang , 'ocamlc' )
810
+ exe = match_lang_exe (args , lang , 'ocamlc' )
805
811
else :
806
- exe = match_lang (args , lang , 'ocamlopt' )
812
+ exe = match_lang_exe (args , lang , 'ocamlopt' )
807
813
if exe :
808
814
version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[0 ]
809
815
compile_file (code_paths ,
@@ -823,7 +829,7 @@ def benchmark_OCaml(results, code_paths, args, op, templated, bytecode):
823
829
824
830
def benchmark_V (results , code_paths , args , op , templated ):
825
831
lang = 'V' # vlang.io
826
- exe = match_lang (args , lang , 'v' )
832
+ exe = match_lang_exe (args , lang , 'v' )
827
833
if exe :
828
834
version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[1 ]
829
835
vlang_backends = ['native' , 'c' , 'js' , 'x64' , 'v2' , 'experimental' ]
@@ -842,7 +848,7 @@ def benchmark_V(results, code_paths, args, op, templated):
842
848
843
849
def benchmark_C3 (results , code_paths , args , op , templated ):
844
850
lang = 'C3'
845
- exe = (match_lang (args , lang , 'c3c' ) or
851
+ exe = (match_lang_exe (args , lang , 'c3c' ) or
846
852
which (os .path .join (HOME , 'ware/c3c/build/c3c' )))
847
853
if exe :
848
854
exe_flags = ['-O0' ]
@@ -870,7 +876,7 @@ def benchmark_C3(results, code_paths, args, op, templated):
870
876
871
877
def benchmark_Zig (results , code_paths , args , op , templated ):
872
878
lang = 'Zig'
873
- exe = match_lang (args , lang , 'zig' )
879
+ exe = match_lang_exe (args , lang , 'zig' )
874
880
if exe :
875
881
version = sp .run ([exe , 'version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[0 ]
876
882
compile_file (code_paths ,
@@ -887,7 +893,7 @@ def benchmark_Zig(results, code_paths, args, op, templated):
887
893
888
894
def benchmark_Nim (results , code_paths , args , op , templated , exe_flags = None ):
889
895
lang = 'Nim'
890
- exe = match_lang (args , lang , 'nim' )
896
+ exe = match_lang_exe (args , lang , 'nim' )
891
897
892
898
tcc_exe = which ('tcc' )
893
899
exe_flags = ['--hints:off' , '--checks:off' , '--stacktrace:off' ] + ([('--cc:tcc' )] if tcc_exe else [])
@@ -930,12 +936,18 @@ def benchmark_Rust(results, code_paths, args, op, templated):
930
936
else :
931
937
rustup_channels = [None ]
932
938
939
+ try :
940
+ exes = args .language_exes [lang ]
941
+ except KeyError :
942
+ return
943
+ if not exes :
944
+ exes = RUST_EXES
945
+
933
946
for channel in rustup_channels :
934
947
if rustup_exe is not None :
935
948
set_rustup_channel (channel )
936
949
937
- exe = match_lang (args , lang , 'rustc' )
938
- if exe :
950
+ for exe in exes :
939
951
version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[1 ]
940
952
if op == 'Check' :
941
953
# `cargo check` uses `rustc --emit=metadata`
@@ -960,7 +972,7 @@ def benchmark_Rust(results, code_paths, args, op, templated):
960
972
961
973
def benchmark_Java (results , code_paths , args , op , templated ):
962
974
lang = 'Java'
963
- exe = match_lang (args , lang , 'javac' )
975
+ exe = match_lang_exe (args , lang , 'javac' )
964
976
if exe :
965
977
try :
966
978
task = sp .run ([exe , '-version' ],
@@ -986,7 +998,7 @@ def benchmark_Java(results, code_paths, args, op, templated):
986
998
987
999
def benchmark_Pareas (results , code_paths , args , op , templated ):
988
1000
lang = 'Pareas'
989
- exe = match_lang (args , lang , 'pareas' )
1001
+ exe = match_lang_exe (args , lang , 'pareas' )
990
1002
if exe :
991
1003
compile_file (code_paths ,
992
1004
out_flag_and_exe = ['-o' , out_binary (lang )],
@@ -1003,7 +1015,7 @@ def benchmark_Pareas(results, code_paths, args, op, templated):
1003
1015
1004
1016
def benchmark_Julia (results , code_paths , args , op , templated ):
1005
1017
lang = 'Julia'
1006
- exe = match_lang (args , lang , 'julia' )
1018
+ exe = match_lang_exe (args , lang , 'julia' )
1007
1019
if exe :
1008
1020
version = sp .run ([exe , '--version' ], stdout = sp .PIPE ).stdout .decode ('utf-8' ).split ()[2 ]
1009
1021
compile_file (code_paths ,
0 commit comments