-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwscript
2166 lines (1973 loc) · 99.1 KB
/
wscript
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
#-*- mode: python; coding: utf-8-unix -*-
#
# USAGE:
# ./waf distclean configure
# ./waf [action]_[stage-char][gc-name][_d for debug build]
# [action] is one of ( build | clean | install )
# [stage-char] is one of ( i | a | b | c )
# [gc-name] is one of ( boehm | mps ) --- mps needs special support
# [_d] Sets up debug build
#
# examples:
# ./waf build_cboehm # build cboehm
# ./waf install_cboehm # build and install cboehm
# ./waf build_aboehm # useful for debugging build system - build only aclasp
# ./waf build_iboehm # useful to build C++ without rebuilding CL code -
# # If done carefully this can be used to quickly test C++ code
#
# to run with low priority, you can prefix with:
# nice -n 19 ionice --class 3 ./waf --jobs 2 ...
#
#
# ./waf build_fboehm # will build most of clasp,
# except the most memory hungry linking tasks at the end
#
# NOTE: please observe the following best practices:
#
# - do *not* use waf's ant_glob (you can shoot yourself in the feet
# with it, leading to tasks getting redone unnecessarily)
# - in emacs, you may want to: (add-to-list 'auto-mode-alist '("wscript\\'" . python-mode))
# - waf constructs have strange names; it's better not to assume that you know what something is or does based solely on its name.
# e.g. node.change_ext() returns a new node instance... you've been warned!
import os, sys, logging
import time, datetime
import glob
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from waflib import Utils, Logs, Task, TaskGen
import waflib.Options
from waflib.Tools import c_preproc
# clang_compilation_database is needed by the static analyzer
from waflib.extras import clang_compilation_database
from waflib.Tools.compiler_cxx import cxx_compiler
from waflib.Tools.compiler_c import c_compiler
from waflib.Errors import ConfigurationError
sys.path.append('tools-for-build/')
sys.dont_write_bytecode = True # avoid littering the dirs with .pyc files
from build_file_lists import *
from wscript_utils import *
# Let's not depend on the locale setting of the host, set it explicitly.
os.environ['LC_ALL'] = os.environ['LANG'] = "C"
# This function enables extra command line options for ./waf --help
def options(ctx):
ctx.recurse('extensions')
ctx.load('compiler_cxx')
ctx.load('compiler_c')
ctx.add_option('-d', '--debug', default = False, action = 'store_true', dest = 'DEBUG_WHILE_BUILDING',
help = 'Enable debugging during the build itself.')
ctx.add_option('--commands', '--print-commands', '--dump-commands', action = 'store_true', dest = 'PRINT_EXTERNAL_COMMANDS',
help = 'Print the copy-paste ready command line of the external programs that the build process spawns.')
ctx.add_option('--noscrape', '--no-scrape', default = True, action = 'store_false', dest = 'RUN_THE_SCRAPER',
help = 'Skip the running of the scraper.')
ctx.add_option('--load-cclasp', action = 'store_true', dest = 'LOAD_CCLASP',
help = '? Probably some debugging helper to start a REPL with cclasp loaded...')
ctx.add_option('--enable-mpi', action = 'store_true', dest = 'enable_mpi',
help = 'Build OpenMPI version of iclasp and cclasp')
ctx.add_option('--mpi-path', action = 'store', dest = 'mpi_path',
help = 'Build OpenMPI version of iclasp and cclasp, provide the path to mpicc and mpic++')
ctx.add_option('--enable-mpi', action = 'store_true', dest = 'enable_mpi',
help = 'Build OpenMPI version of iclasp and cclasp')
#
# Global variables for the build
#
top = '.'
out = 'build'
APP_NAME = 'clasp'
LLVM_VERSION = 9
CLANG_SPECIFIC_VERSION = "9.0.0_1"
STAGE_CHARS = [ 'r', 'i', 'a', 'b', 'f', 'c', 'd' ]
# Full LTO -flto
# thin LTO -flto=thin
LTO_OPTION = "-flto=thin"
GCS_NAMES = [ 'boehm',
'mpsprep',
'mps' ]
CLANG_LIBRARIES = [
'clangASTMatchers',
'clangDynamicASTMatchers',
'clangIndex',
'clangTooling',
'clangFormat',
'clangToolingInclusions',
'clangToolingCore',
'clangBasic',
'clangCodeGen',
'clangDriver',
'clangFrontend',
'clangFrontendTool',
'clangCodeGen',
'clangRewriteFrontend',
'clangARCMigrate',
'clangStaticAnalyzerFrontend',
'clangFrontend',
'clangDriver',
'clangParse',
'clangSerialization',
'clangSema',
'clangEdit',
'clangStaticAnalyzerCheckers',
'clangStaticAnalyzerCore',
'clangAnalysis',
'clangAST',
'clangRewrite',
'clangLex',
'clangBasic'
]
#CLANG_LIBRARIES = [ 'clang-cpp' ]
# LLVM_LIBRARIES = [ 'LLVM' ]
BOOST_LIBRARIES = [
'boost_filesystem',
'boost_date_time',
'boost_system']
VALID_OPTIONS = [
# point to the llvm-config executable - this tells the build system which clang to use
# Default on macOS = /usr/local/opt/llvm@%s/bin/llvm-config'%LLVM_VERSION - brew installed
# Default on linux = it searches your path
"LLVM_CONFIG_BINARY",
"LLVM_VERSION_OVERRIDE",
# To link to the debug versions of the LLVM libraries, set a path here to the llvm-config binary of the LLVM debug build
"LLVM_CONFIG_BINARY_FOR_LIBS",
# point to where you want to install clasp - this has to be defined before ./waf configure
"PREFIX",
# Path to sbcl
"SBCL",
# What do you want to call clasp?
"CLASP",
# Build clasp in parallel
# default = True
"USE_PARALLEL_BUILD",
# build with fork redirecting output: default = True
"USE_BUILD_FORK_REDIRECT_OUTPUT",
# Use lld only on Linux when CLASP_BUILD_MODE is "bitcode" - it's faster than ld
# default = True
"USE_LLD",
# Add additional CPPFLAGS
"CPPFLAGS",
# Add additional includes
"INCLUDES",
# Add additional link flags
"LINKFLAGS",
# Define how clasp is built - can be one of "bitcode" or "object".
# If "bitcode" then C++ and CL compiles to bitcode and thinLTO is used to link everything.
# this gives the fastest product but linking takes a long time.
# If "object" then C++ and CL produce object files and regular linking is used.
# This is probably not as fast as bitcode (maybe a few percent slower) but it links fast.
# If "faso" then CL generates faso files.
# This is good for development.
# Default = "object"
"CLASP_BUILD_MODE",
# Use compile-file-praallel once everything is built - by default this is False
"USE_COMPILE_FILE_PARALLEL",
# Tell clasp that GC_enumerate_reachable_objects_inner is available
"BOEHM_GC_ENUMERATE_REACHABLE_OBJECTS_INNER_AVAILABLE",
# Set the version name of clasp - this is used when building the docker image to give a predictable
# version name. Usually the version is calculated from the git hash
"CLASP_VERSION",
# Set if on macOS libffi is required. On macOS we can build with brew installed llvm
# but brew installed llvm has libffi as a dependency and doesn't report that when you invoke llvm-config --libs!!!
# This is a bug in llvm-config and has to be fixed upstream.
# Default = True
"REQUIRE_LIBFFI",
# If waf doesn't recognize the OS then use this option (darwin|linux|freebsd)
"DEST_OS",
# Turn on debug options
"DEBUG_OPTIONS",
# Turn on address sanitizer
"ADDRESS_SANITIZER",
# Turn on address sanitizer
"THREAD_SANITIZER",
# Link libraries statically vs dynamically
"LINK_STATIC"
]
DEBUG_OPTIONS = [
"DEBUG_DTREE_INTERPRETER", # Generate dtree interpreter log
"DEBUG_DTRACE_LOCK_PROBE", # Add a Dtrace probe for mutex lock acquisition
"DEBUG_STACKMAPS", # print messages about stackmap registration
"DEBUG_ASSERT", # Turn on DEBUG_ASSERT
"DEBUG_ASSERT_TYPE_CAST", # Turn on type checking when passing arguments
"SOURCE_DEBUG", # Allow LOG messages to print - works with CLASP_DEBUG environment variable
"DEBUG_JIT_LOG_SYMBOLS", # Generate a log of JITted symbols in /tmp/clasp-symbols-<pid>
"DEBUG_GUARD", # Add guards around allocated objects
"DEBUG_GUARD_VALIDATE", # add simple checks of guards (fast)
"DEBUG_GUARD_EXHAUSTIVE_VALIDATE", #add exhaustive, slow, checks of guards
"DEBUG_TRACE_INTERPRETED_CLOSURES", # Count how many interpreted closures are evaluated
"DEBUG_ENVIRONMENTS",
"DEBUG_RELEASE", # Turn off optimization for a few C++ functions; undef this to optimize everything
"DEBUG_CACHE", # Debug the dispatch caches - see cache.cc
"DEBUG_BITUNIT_CONTAINER", # prints debug info for bitunit containers
"DEBUG_LEXICAL_DEPTH", # Generate tests for lexical closure depths
"DEBUG_FLOW_TRACKER", # record small backtraces to track flow
"DEBUG_DYNAMIC_BINDING_STACK", # dynamic variable binding debugging
"DEBUG_VALUES", # turn on printing (values x y z) values when core:*debug-values* is not nil
"DEBUG_IHS",
"DEBUG_TRACK_UNWINDS", # Count cc_unwind calls and report in TIME
"DEBUG_NO_UNWIND", # debug intrinsics that say they don't unwind but actually do
"DEBUG_STARTUP",
## Generate per-thread logs in /tmp/dispatch-history/** of the slow path of fastgf
"DEBUG_REHASH_COUNT", # Keep track of the number of times each hash table has been rehashed
"DEBUG_MONITOR", # generate logging messages to a file in /tmp for non-hot code
"DEBUG_MONITOR_SUPPORT", # Must be enabled with other options - do this automatically?
"DEBUG_MEMORY_PROFILE", # Profile memory allocations total size and counter
"DEBUG_BCLASP_LISP", # Generate debugging frames for all bclasp code - like declaim
"DEBUG_CCLASP_LISP", # Generate debugging frames for all cclasp code - like declaim (default on)
"DISABLE_DEBUG_CCLASP_LISP", # turn OFF debugging frames for cclasp code
"DEBUG_COUNT_ALLOCATIONS", # count per-thread allocations of instances of classes
"DEBUG_COMPILER", # Turn on compiler debugging
"DEBUG_VERIFY_MODULES", # Verify LLVM modules before using them
"DEBUG_LONG_CALL_HISTORY", # The GF call histories used to blow up - this triggers an error if they get too long
"DEBUG_BOUNDS_ASSERT", # check bounds
"DEBUG_GFDISPATCH", # debug call history manipulation
"DEBUG_FASTGF", # generate slow gf dispatch logging and write out dispatch functions to /tmp/dispatch-history-**
"DEBUG_SLOT_ACCESSORS", # GF accessors have extra debugging added to them
"DEBUG_THREADS",
"DEBUG_ENSURE_VALID_OBJECT", #Defines ENSURE_VALID_OBJECT(x)->x macro - sprinkle these around to run checks on objects
"DEBUG_QUICK_VALIDATE", # quick/cheap validate if on and comprehensive validate if not
"DEBUG_MPS_SIZE", # check that the size of the MPS object will be calculated properly by obj_skip
"DEBUG_MPS_UNDERSCANNING", # Very expensive - does a mps_arena_collect/mps_arena_release for each allocation
"DEBUG_DONT_OPTIMIZE_BCLASP", # Optimize bclasp by editing llvm-ir
"DEBUG_RECURSIVE_ALLOCATIONS",
"DEBUG_LLVM_OPTIMIZATION_LEVEL_0",
"DEBUG_SLOW", # Code runs slower due to checks - undefine to remove checks
"USE_HUMAN_READABLE_BITCODE",
"DEBUG_COMPILE_FILE_OUTPUT_INFO",
"DISABLE_CST", # build the AST version of the compiler
"CST", # build the CST version of the compiler (default)
"CONFIG_VAR_COOL" # mps setting
]
def macos_version(cfg):
result = get_macosx_version(cfg)
print("result = %s" % result)
def build_extension(bld):
log.pprint('BLUE', "build_extension()")
bld.recurse("extensions")
def grovel(bld):
bld.recurse("extensions")
def fetch_git_revision(path, url, revision = "", label = "master"):
log.info("Git repository %s url: %s\n revision: %s label: %s\n" % (path, url, revision, label))
ret = os.system("./tools-for-build/fetch-git-revision.sh '%s' '%s' '%s' '%s'" % (path, url, revision, label))
if ( ret != 0 ):
raise Exception("Failed to fetch git url %s" % url)
def generate_output_filename(names):
if (names==[]):
return "source-dir:src;main;clasp_gc.cc"
else:
return "source-dir:src;main;clasp_gc_cando.cc"
def update_dependencies(cfg):
# Specifying only label = "some-tag" will check out that tag into a "detached head", but
# specifying both label = "master" and revision = "some-tag" will stay on master and reset to that revision.
log.pprint('BLUE', 'update_dependencies()')
# fetch_git_revision("src/lisp/kernel/contrib/sicl",
# "https://github.com/robert-strandh/SICL.git",
# "master")
fetch_git_revision("src/lisp/kernel/contrib/sicl",
"https://github.com/Bike/SICL.git",
"8aa81006a8aa3cb920ebff6231f9e10e1d76dafc")
fetch_git_revision("src/lisp/kernel/contrib/Concrete-Syntax-Tree",
"https://github.com/s-expressionists/Concrete-Syntax-Tree.git",
"f4100714fd90805ba30221dc8dafa5a99f3cf6a0")
fetch_git_revision("src/lisp/kernel/contrib/closer-mop",
"https://github.com/pcostanza/closer-mop.git",
"d4d1c7aa6aba9b4ac8b7bb78ff4902a52126633f")
fetch_git_revision("src/lisp/kernel/contrib/Acclimation",
"https://github.com/robert-strandh/Acclimation.git",
"dd15c86b0866fc5d8b474be0da15c58a3c04c45c")
fetch_git_revision("src/lisp/kernel/contrib/Eclector",
"https://github.com/clasp-developers/Eclector.git",
"363c495ea3c4dc11274cccb1964ab95ab53b3966")
#"66cf5e2370eef4be659212269272a5e79a82fa1c")
# "7b63e7bbe6c60d3ad3413a231835be6f5824240a") works with AST clasp
fetch_git_revision("src/lisp/kernel/contrib/alexandria",
"https://github.com/clasp-developers/alexandria.git",
"e5c54bc30b0887c237bde2827036d17315f88737")
fetch_git_revision("src/mps",
"https://github.com/Ravenbrook/mps.git",
#DLM says this will be faster.
# label = "master", revision = "b1cc9aa5f87f2619ff675c8756e83211865419de")
# Very recent branch - may have problems
# label = "master", revision = "b5be454728c2ac58b9cb2383360ed0366a7e4115")
#First branch that supported fork
# label = "master", revision = "46e0a8d77ac470282de7300f5eaf471ca2fbee05")
# David set up this branch/2018-08-18/exp-strategy-2 for clasp
"b8a05a3846430bc36c8200f24d248c8293801503")
fetch_git_revision("src/lisp/modules/asdf",
"https://gitlab.common-lisp.net/asdf/asdf.git",
# "1cae71bdf0afb0f57405c5e8b7e8bf0aeee8eef8")
label = "master", revision = "3.3.3.5")
os.system("(cd src/lisp/modules/asdf; ${MAKE-make} --quiet)")
# run this from a completely cold system with:
# ./waf distclean configure
# ./waf build_impsprep
# ./waf analyze_clasp
# This is the static analyzer - formerly called 'redeye'
def analyze_clasp(cfg):
cfg.extensions_clasp_gc_names = []
log.debug("analyze_clasp about to recurse\n")
cfg.recurse('extensions')
print("In analyze_clasp cfg.extensions_clasp_gc_names = %s" % cfg.extensions_clasp_gc_names)
log.debug("cfg.extensions_clasp_gc_names = %s\n", cfg.extensions_clasp_gc_names)
output_file = generate_output_filename(cfg.extensions_clasp_gc_names)
run_search = '(run-search "%s")' % output_file
run_program_echo("build/boehm/iclasp-boehm",
"--feature", "ignore-extensions",
"--load", "sys:modules;clasp-analyzer;run-serial-analyzer.lisp",
"--eval", run_search,
"--eval", "(core:quit)")
print("\n\n\n----------------- proceeding with static analysis --------------------")
def test(cfg):
log.debug("Execute regression tests\n")
run_program_echo("build/clasp",
"--feature", "ignore-extensions",
"--load", "sys:regression-tests;run-all.lisp",
"--eval", "(progn (format t \"~%Test done~%\")(core:quit))")
log.debug("Done regression tests\n")
def tests(cfg):
test(cfg)
def stage_value(ctx,s):
if ( s == 'r' ):
sval = -1
elif ( s == 'i' ):
sval = 0
elif ( s == 'a' ):
sval = 1
elif ( s == 'b' ):
sval = 2
elif ( s == 'c' ):
sval = 4
elif ( s == 'd' ):
sval = 5
elif ( s == 'f' ):
sval = 3
elif ( s == 'rebuild' ):
sval = 0
elif ( s == 'dangerzone' ):
sval = 0
else:
ctx.fatal("Illegal stage: %s" % s)
return sval
# Called for each variant, at the end of the configure phase
def configure_common(cfg,variant):
# include_path = "%s/%s/%s/src/include/clasp/main/" % (cfg.path.abspath(),out,variant.variant_dir()) #__class__.__name__)
# cfg.env.append_value("CXXFLAGS", ['-I%s' % include_path])
# cfg.env.append_value("CFLAGS", ['-I%s' % include_path])
# These will end up in build/config.h
cfg.define("EXECUTABLE_NAME",variant.executable_name())
if (cfg.env.PREFIX):
pass
else:
cfg.env.PREFIX = "/opt/clasp"
cfg.define("PREFIX",cfg.env.PREFIX)
assert os.path.isdir(cfg.env.LLVM_BIN_DIR)
log.info("cfg.env.PREFIX is %s" % cfg.env.PREFIX)
cfg.define("CLASP_CLANG_PATH", os.path.join(cfg.env.LLVM_BIN_DIR, "clang"))
cfg.define("APP_NAME",APP_NAME)
cfg.define("BITCODE_NAME",variant.bitcode_name())
cfg.define("VARIANT_NAME",variant.variant_name())
cfg.define("BUILD_STLIB", libraries_as_link_flags_as_string(cfg.env.STLIB_ST,cfg.env.STLIB))
cfg.define("BUILD_LIB", libraries_as_link_flags_as_string(cfg.env.LIB_ST,cfg.env.LIB))
log.debug("cfg.env.LINKFLAGS = %s", cfg.env.LINKFLAGS)
log.debug("cfg.env.LDFLAGS = %s", cfg.env.LDFLAGS)
cfg.define("BUILD_LINKFLAGS", ' '.join(cfg.env.LINKFLAGS) + ' ' + ' '.join(cfg.env.LDFLAGS))
def module_fasl_extension(bld,name):
if (bld.env.USE_COMPILE_FILE_PARALLEL or bld.env.CLASP_BUILD_MODE=='faso'):
return "%s.fasp" % name
else:
return "%s.fasl" % name
def generate_dwarf(bld):
if (bld.env["DEST_OS"] == DARWIN_OS):
if (bld.env.USE_COMPILE_FILE_PARALLEL):
return False
else:
return True
else:
return False
def setup_clang_compiler(cfg,variant):
cfg.env.COMPILER_CC="clang"
cfg.env.COMPILER_CXX="clang++"
cfg.env.CC = cfg.find_program(cfg.env.COMPILER_CC,quiet=True)
cfg.env.CXX = cfg.find_program(cfg.env.COMPILER_CXX,quiet=True)
cfg.env.LINK_CC = cfg.env.CC
cfg.env.LINK_CXX = cfg.env.CXX
def setup_mpi_compiler(cfg,variant):
cfg.env.COMPILER_CC="mpicc"
cfg.env.COMPILER_CXX="mpic++"
cfg.env.CC = cfg.find_program(cfg.env.COMPILER_CC,quiet=True)
cfg.env.CXX = cfg.find_program(cfg.env.COMPILER_CXX,quiet=True)
cfg.env.LINK_CC = cfg.env.CC
cfg.env.LINK_CXX = cfg.env.CXX
class variant(object):
build_with_debug_info = False
def debug_extension(self):
return "-d" if self.build_with_debug_info else ""
def debug_dir_extension(self):
return "_d" if self.build_with_debug_info else ""
def mpi_extension(self):
return "-mpi" if self.enable_mpi else ""
def mpi_dir_extension(self):
return "_mpi" if self.enable_mpi else ""
def executable_name(self,stage=None):
if ( stage == None ):
use_stage = self.stage_char
else:
use_stage = stage
if (not (use_stage>='a' and use_stage <= 'z')):
raise Exception("Bad stage: %s"% use_stage)
return '%s%s-%s%s%s' % (use_stage,APP_NAME,self.gc_name,self.mpi_extension(),self.debug_extension())
def fasl_name(self,build,stage=None):
if ( stage == None ):
use_stage = self.stage_char
else:
use_stage = stage
if (not (use_stage>='a' and use_stage <= 'z')):
raise Exception("Bad stage: %s"% use_stage)
if (build.env.CLASP_BUILD_MODE == 'fasl'):
return build.path.find_or_declare('fasl/%s%s-%s%s%s-image.lfasl' % (use_stage,APP_NAME,self.gc_name,self.mpi_extension(),self.debug_extension()))
elif (build.env.CLASP_BUILD_MODE == 'faso'):
return build.path.find_or_declare('fasl/%s%s-%s%s%s-image.fasp' % (use_stage,APP_NAME,self.gc_name,self.mpi_extension(),self.debug_extension()))
else:
return build.path.find_or_declare('fasl/%s%s-%s%s%s-image.fasl' % (use_stage,APP_NAME,self.gc_name,self.mpi_extension(),self.debug_extension()))
def fasl_dir(self, stage=None):
if ( stage == None ):
use_stage = self.stage_char
else:
use_stage = stage
return 'fasl/%s%s-%s%s-bitcode' % (use_stage,APP_NAME,self.gc_name,self.mpi_extension())
def common_lisp_output_name_list(self,build,input_files,stage=None,variant=None):
if ( stage == None ):
use_stage = self.stage_char
else:
use_stage = stage
if (not (use_stage>='a' and use_stage <= 'z')):
raise Exception("Bad stage: %s"% use_stage)
name = 'fasl/%s%s-%s-common-lisp' % (use_stage,APP_NAME,self.gc_name)
nodes = waf_nodes_for_object_files(build,input_files,self.fasl_dir(stage=use_stage))
return nodes
def variant_dir(self):
return "%s%s%s"%(self.gc_name,self.mpi_dir_extension(),self.debug_dir_extension())
def variant_name(self):
if (self.enable_mpi):
mpi_part = "-mpi"
else:
mpi_part = ""
return "%s%s" % (self.gc_name,mpi_part)
def bitcode_name(self):
return "%s%s"%(self.variant_name(),self.debug_extension())
def cxx_all_bitcode_name(self):
return 'fasl/%s-all-cxx.a' % self.bitcode_name()
def inline_bitcode_archive_name(self,name):
return 'fasl/%s-%s-cxx.a' % (self.bitcode_name(),name)
def inline_bitcode_name(self,name):
return 'fasl/%s-%s-cxx.bc' % (self.bitcode_name(),name)
def configure_for_release(self,cfg):
cfg.define("_RELEASE_BUILD",1)
cfg.env.append_value('CXXFLAGS', [ '-O3', '-g', '-fPIC' ])
cfg.env.append_value('CFLAGS', [ '-O3', '-g', '-fPIC' ])
cfg.define("ALWAYS_INLINE_MPS_ALLOCATIONS",1)
if (os.getenv("CLASP_RELEASE_CXXFLAGS") != None):
cfg.env.append_value('CXXFLAGS', os.getenv("CLASP_RELEASE_CXXFLAGS").split() )
if (os.getenv("CLASP_RELEASE_LINKFLAGS") != None):
cfg.env.append_value('LINKFLAGS', os.getenv("CLASP_RELEASE_LINKFLAGS").split())
def configure_for_debug(self,cfg):
cfg.define("_DEBUG_BUILD",1)
cfg.define("DEBUG_ASSERT",1)
cfg.define("DEBUG_BOUNDS_ASSERT",1)
# cfg.define("DEBUG_ASSERT_TYPE_CAST",1) # checks runtime type casts
cfg.define("CONFIG_VAR_COOL",1)
# cfg.env.append_value('CXXFLAGS', [ '-O0', '-g' ])
cfg.env.append_value('CXXFLAGS', [ '-O0', '-g' ])
log.debug("cfg.env.LTO_FLAG = %s", cfg.env.LTO_FLAG)
if (cfg.env.LTO_FLAG):
cfg.env.append_value('LDFLAGS', [ '-Wl','-mllvm', '-O0', '-g' ])
cfg.env.append_value('CFLAGS', [ '-O0', '-g', '-fPIC' ])
if (os.getenv("CLASP_DEBUG_CXXFLAGS") != None):
cfg.env.append_value('CXXFLAGS', os.getenv("CLASP_DEBUG_CXXFLAGS").split() )
if (os.getenv("CLASP_DEBUG_LINKFLAGS") != None):
cfg.env.append_value('LINKFLAGS', os.getenv("CLASP_DEBUG_LINKFLAGS").split())
def common_setup(self,cfg):
if self.build_with_debug_info:
self.configure_for_debug(cfg)
else:
self.configure_for_release(cfg)
configure_common(cfg, self)
cfg.write_config_header("%s/config.h"%self.variant_dir(),remove=True)
class boehm_base(variant):
gc_name = 'boehm'
enable_mpi = False
def configure_variant(self,cfg,env_copy):
cfg.define("USE_BOEHM",1)
setup_clang_compiler(cfg,self)
if (cfg.env['DEST_OS'] == DARWIN_OS ):
log.debug("boehm_base cfg.env.LTO_FLAG = %s", cfg.env.LTO_FLAG)
if (cfg.env.LTO_FLAG):
cfg.env.append_value('LDFLAGS', '-Wl,-object_path_lto,%s_lib.lto.o' % self.executable_name())
log.info("Setting up boehm library cfg.env.STLIB_BOEHM = %s ", cfg.env.STLIB_BOEHM)
log.info("Setting up boehm library cfg.env.LIB_BOEHM = %s", cfg.env.LIB_BOEHM)
if (cfg.env.LIB_BOEHM == [] ):
cfg.env.append_value('STLIB',cfg.env.STLIB_BOEHM)
else:
cfg.env.append_value('LIB',cfg.env.LIB_BOEHM)
self.common_setup(cfg)
class boehm(boehm_base):
def configure_variant(self,cfg,env_copy):
cfg.setenv(self.variant_dir(), env=env_copy.derive())
super(boehm,self).configure_variant(cfg,env_copy)
class boehm_d(boehm_base):
build_with_debug_info = True
def configure_variant(self,cfg,env_copy):
cfg.setenv("boehm_d", env=env_copy.derive())
super(boehm_d,self).configure_variant(cfg,env_copy)
class mps_base(variant):
enable_mpi = False
def configure_variant(self,cfg,env_copy):
cfg.define("USE_MPS",1)
setup_clang_compiler(cfg,self)
if (cfg.env['DEST_OS'] == DARWIN_OS ):
if (cfg.env.LTO_FLAG):
cfg.env.append_value('LDFLAGS', '-Wl,-object_path_lto,%s_lib.lto.o' % self.executable_name())
self.common_setup(cfg)
class mpsprep(mps_base):
gc_name = 'mpsprep'
def configure_variant(self,cfg,env_copy):
cfg.setenv("mpsprep", env=env_copy.derive())
cfg.define("RUNNING_GC_BUILDER",1)
super(mpsprep,self).configure_variant(cfg,env_copy)
class mpsprep_d(mps_base):
gc_name = 'mpsprep'
build_with_debug_info = True
def configure_variant(self,cfg,env_copy):
cfg.setenv("mpsprep_d", env=env_copy.derive())
cfg.define("RUNNING_GC_BUILDER",1)
super(mpsprep_d,self).configure_variant(cfg,env_copy)
class mps(mps_base):
gc_name = 'mps'
def configure_variant(self,cfg,env_copy):
cfg.setenv("mps", env=env_copy.derive())
super(mps,self).configure_variant(cfg,env_copy)
class mps_d(mps_base):
gc_name = 'mps'
build_with_debug_info = True
def configure_variant(self,cfg,env_copy):
cfg.setenv("mps_d", env=env_copy.derive())
super(mps_d,self).configure_variant(cfg,env_copy)
class iboehm(boehm):
stage_char = 'i'
class aboehm(boehm):
stage_char = 'a'
class bboehm(boehm):
stage_char = 'b'
class cboehm(boehm):
stage_char = 'c'
class iboehm_d(boehm_d):
stage_char = 'i'
class aboehm_d(boehm_d):
stage_char = 'a'
class bboehm_d(boehm_d):
stage_char = 'b'
class cboehm_d(boehm_d):
stage_char = 'c'
class imps(mps):
stage_char = 'i'
class amps(mps):
stage_char = 'a'
class bmps(mps):
stage_char = 'b'
class cmps(mps):
stage_char = 'c'
class imps_d(mps_d):
stage_char = 'i'
class amps_d(mps_d):
stage_char = 'a'
class bmps_d(mps_d):
stage_char = 'b'
class cmps_d(mps_d):
stage_char = 'c'
class impsprep(mpsprep):
stage_char = 'i'
class ampsprep(mpsprep):
stage_char = 'a'
class bmpsprep(mpsprep):
stage_char = 'b'
class cmpsprep(mpsprep):
stage_char = 'c'
class impsprep_d(mpsprep_d):
stage_char = 'i'
class ampsprep_d(mpsprep_d):
stage_char = 'a'
class bmpsprep_d(mpsprep_d):
stage_char = 'b'
class cmpsprep_d(mpsprep_d):
stage_char = 'c'
###### MPI versions
class boehm_mpi_base(variant):
gc_name = 'boehm'
enable_mpi = True
def configure_variant(self,cfg,env_copy):
cfg.define("USE_BOEHM",1)
cfg.define("USE_MPI",1)
setup_mpi_compiler(cfg,self)
if (cfg.env['DEST_OS'] == DARWIN_OS ):
log.debug("boehm_mpi_base cfg.env.LTO_FLAG = %s", cfg.env.LTO_FLAG)
if (cfg.env.LTO_FLAG):
cfg.env.append_value('LDFLAGS', '-Wl,-object_path_lto,%s_lib.lto.o' % self.executable_name())
log.info("Setting up boehm library cfg.env.STLIB_BOEHM = %s ", cfg.env.STLIB_BOEHM)
log.info("Setting up boehm library cfg.env.LIB_BOEHM = %s", cfg.env.LIB_BOEHM)
if (cfg.env.LIB_BOEHM == [] ):
cfg.env.append_value('STLIB',cfg.env.STLIB_BOEHM)
else:
cfg.env.append_value('LIB',cfg.env.LIB_BOEHM)
self.common_setup(cfg)
class boehm_mpi(boehm_mpi_base):
def configure_variant(self,cfg,env_copy):
cfg.setenv(self.variant_dir(), env=env_copy.derive())
super(boehm_mpi,self).configure_variant(cfg,env_copy)
class boehm_mpi_d(boehm_mpi_base):
build_with_debug_info = True
def configure_variant(self,cfg,env_copy):
cfg.setenv("boehm_mpi_d", env=env_copy.derive())
super(boehm_mpi_d,self).configure_variant(cfg,env_copy)
class mps_mpi_base(variant):
enable_mpi = True
def configure_variant(self,cfg,env_copy):
cfg.define("USE_MPS",1)
cfg.define("USE_MPI",1)
setup_mpi_compiler(cfg,self)
if (cfg.env['DEST_OS'] == DARWIN_OS ):
if (cfg.env.LTO_FLAG):
cfg.env.append_value('LDFLAGS', '-Wl,-object_path_lto,%s_lib.lto.o' % self.executable_name())
self.common_setup(cfg)
class mpsprep_mpi(mps_mpi_base):
gc_name = 'mpsprep'
def configure_variant(self,cfg,env_copy):
cfg.setenv("mpsprep_mpi", env=env_copy.derive())
cfg.define("RUNNING_GC_BUILDER",1)
super(mpsprep_mpi,self).configure_variant(cfg,env_copy)
class mpsprep_mpi_d(mps_mpi_base):
gc_name = 'mpsprep'
build_with_debug_info = True
def configure_variant(self,cfg,env_copy):
cfg.setenv("mpsprep_mpi_d", env=env_copy.derive())
cfg.define("RUNNING_GC_BUILDER",1)
super(mpsprep_mpi_d,self).configure_variant(cfg,env_copy)
class mps_mpi(mps_mpi_base):
gc_name = 'mps'
def configure_variant(self,cfg,env_copy):
cfg.setenv("mps_mpi", env=env_copy.derive())
super(mps_mpi,self).configure_variant(cfg,env_copy)
class mps_mpi_d(mps_mpi_base):
gc_name = 'mps'
build_with_debug_info = True
def configure_variant(self,cfg,env_copy):
cfg.setenv("mps_mpi_d", env=env_copy.derive())
super(mps_mpi_d,self).configure_variant(cfg,env_copy)
class iboehm_mpi(boehm_mpi):
stage_char = 'i'
class aboehm_mpi(boehm_mpi):
stage_char = 'a'
class bboehm_mpi(boehm_mpi):
stage_char = 'b'
class cboehm_mpi(boehm_mpi):
stage_char = 'c'
class iboehm_mpi_d(boehm_mpi_d):
stage_char = 'i'
class aboehm_mpi_d(boehm_mpi_d):
stage_char = 'a'
class bboehm_mpi_d(boehm_mpi_d):
stage_char = 'b'
class cboehm_mpi_d(boehm_mpi_d):
stage_char = 'c'
class imps_mpi(mps_mpi):
stage_char = 'i'
class amps_mpi(mps_mpi):
stage_char = 'a'
class bmps_mpi(mps_mpi):
stage_char = 'b'
class cmps_mpi(mps_mpi):
stage_char = 'c'
class imps_mpi_d(mps_mpi_d):
stage_char = 'i'
class amps_mpi_d(mps_mpi_d):
stage_char = 'a'
class bmps_mpi_d(mps_mpi_d):
stage_char = 'b'
class cmps_mpi_d(mps_mpi_d):
stage_char = 'c'
class impsprep_mpi(mpsprep_mpi):
stage_char = 'i'
class ampsprep_mpi(mpsprep_mpi):
stage_char = 'a'
class bmpsprep_mpi(mpsprep_mpi):
stage_char = 'b'
class cmpsprep_mpi(mpsprep_mpi):
stage_char = 'c'
class impsprep_mpi_d(mpsprep_mpi_d):
stage_char = 'i'
class ampsprep_mpi_d(mpsprep_mpi_d):
stage_char = 'a'
class bmpsprep_mpi_d(mpsprep_mpi_d):
stage_char = 'b'
class cmpsprep_mpi_d(mpsprep_mpi_d):
stage_char = 'c'
def configure(cfg):
def update_exe_search_path(cfg):
log.info("DEST_OS = %s" % cfg.env['DEST_OS'])
llvm_config_binary = cfg.env.LLVM_CONFIG_BINARY
if (len(llvm_config_binary) == 0):
if (cfg.env['DEST_OS'] == DARWIN_OS ):
llvm_paths = glob.glob("/usr/local/Cellar/llvm/%s*" % LLVM_VERSION)
if (len(llvm_paths) >= 1):
llvm_config_binary = "%s/bin/llvm-config" % llvm_paths[0]
else:
raise Exception("You need to install llvm@%s" % LLVM_VERSION)
log.info("On darwin looking for %s" % llvm_config_binary)
print("On darwin looking for %s" % llvm_config_binary)
else:
try:
llvm_config_binary = cfg.find_program('llvm-config-%s.0'%LLVM_VERSION)
except cfg.errors.ConfigurationError:
cfg.to_log('llvm-config-%s.0 was not found (ignoring)'%LLVM_VERSION)
try:
llvm_config_binary = cfg.find_program('llvm-config-%s'%LLVM_VERSION)
except cfg.errors.ConfigurationError:
cfg.to_log('llvm-config-%s was not found (ignoring)'%LLVM_VERSION)
try:
llvm_config_binary = cfg.find_program('llvm-config%s0'%LLVM_VERSION)
except cfg.errors.ConfigurationError:
cfg.to_log('llvm-config%s0 was not found (ignoring)'%LLVM_VERSION)
# Let's fail if no llvm-config binary has been found
llvm_config_binary = cfg.find_program('llvm-config')
llvm_config_binary = llvm_config_binary[0]
log.info("On %s looking for %s" % (cfg.env['DEST_OS'],llvm_config_binary))
cfg.env["LLVM_CONFIG_BINARY"] = llvm_config_binary
log.info("Using llvm-config binary: %s", cfg.env.LLVM_CONFIG_BINARY)
# Let's prefix the OS's binary search PATH with the configured LLVM bin dir.
# TODO Maybe it would be better to handle full binary paths explicitly -- if possible at all.
path = os.getenv("PATH").split(os.pathsep)
externals_bin_dir = run_llvm_config(cfg, "--bindir")
path.insert(0, externals_bin_dir)
cfg.environ["PATH"] = os.pathsep.join(path)
log.info("PATH has been prefixed with '%s'", externals_bin_dir)
assert os.path.isdir(externals_bin_dir), "Please provide a valid LLVM_CONFIG_BINARY. See the 'wscript.config.template' file."
def check_externals_clasp_version(cfg):
log.debug("check_externals_clasp_version begins, cfg.env.LLVM_CONFIG_BINARY = %s", cfg.env.LLVM_CONFIG_BINARY)
if (not "externals-clasp" in cfg.env.LLVM_CONFIG_BINARY):
return
fin = open(run_llvm_config(cfg, "--prefix") + "/../../makefile", "r")
externals_clasp_llvm_hash = "0bc70c306ccbf483a029a25a6fd851bc332accff" # update this when externals-clasp is updated
correct_version = False
for x in fin:
if (externals_clasp_llvm_hash in x):
correct_version = True
fin.close()
if (not correct_version):
raise Exception("You do not have the correct version of externals-clasp installed - you need the one with the LLVM_COMMIT=%s" % externals_clasp_llvm_hash)
def load_local_config(cfg):
local_environment = {}
if os.path.isfile("./wscript.config"):
log.debug("local_environment = %s", local_environment)
exec(open("./wscript.config").read(), globals(), local_environment)
for key in local_environment.keys():
if (not key in VALID_OPTIONS):
raise Exception("%s is an INVALID wscript.config option - valid options are: %s" % (key, VALID_OPTIONS))
else:
log.info("wscript.config option %s = %s", key, local_environment[key])
cfg.env.update(local_environment)
#
# This is where configure(cfg) starts
#
log.pprint("BLUE", "cfg.options.enable_mpi = %s" % cfg.options.enable_mpi)
log.pprint('BLUE', 'configure()')
linker_in_use = "not specifically specified"
cfg.env["BUILD_ROOT"] = os.path.abspath(top) # KLUDGE there should be a better way than this
load_local_config(cfg)
if ("DISABLE_CST" in cfg.env.DEBUG_OPTIONS):
pass
else:
cfg.define("CST",1)
if ("CST" not in cfg.env.DEBUG_OPTIONS):
cfg.env.DEBUG_OPTIONS.append("CST")
if ("DISABLE_DEBUG_CCLASP_LISP" in cfg.env.DEBUG_OPTIONS):
pass
else:
cfg.define("DEBUG_CCLASP_LISP",1)
if ("DEBUG_CCLASP_LISP" not in cfg.env.DEBUG_OPTIONS):
cfg.env.DEBUG_OPTIONS.append(["DEBUG_CCLASP_LISP"])
cfg.load("why")
cfg.check_waf_version(mini = '1.7.5')
cfg.env['DEST_OS'] = cfg.env['DEST_OS'] or Utils.unversioned_sys_platform()
update_exe_search_path(cfg)
run_llvm_config(cfg, "--version") # make sure we fail early
check_externals_clasp_version(cfg)
if (cfg.env.LLVM_CONFIG_BINARY_FOR_LIBS):
log.warn("Using a separate llvm-config binary for linking with the LLVM libs: %s", cfg.env.LLVM_CONFIG_BINARY_FOR_LIBS)
else:
log.debug("Using the same llvm-config binary for linking with the LLVM libs: %s", cfg.env.LLVM_CONFIG_BINARY)
cfg.env["LLVM_CONFIG_BINARY_FOR_LIBS"] = cfg.env.LLVM_CONFIG_BINARY
if (cfg.env.LLVM5_ORC_NOTIFIER_PATCH):
cfg.define("LLVM5_ORC_NOTIFIER_PATCH",1)
if (cfg.env.USE_PARALLEL_BUILD == False):
pass
else:
cfg.env.USE_PARALLEL_BUILD = True
cfg.define("USE_PARALLEL_BUILD",1)
if (cfg.env.USE_BUILD_FORK_REDIRECT_OUTPUT == False):
pass
else:
cfg.env.USE_BUILD_FORK_REDIRECT_OUTPUT = True
cfg.define("USE_BUILD_FORK_REDIRECT_OUTPUT",1)
cfg.env["LLVM_BIN_DIR"] = run_llvm_config(cfg, "--bindir")
cfg.env["LLVM_AR_BINARY"] = "%s/llvm-ar" % cfg.env.LLVM_BIN_DIR
# cfg.env["LLVM_AR_BINARY"] = cfg.find_program("llvm-ar", var = "LLVM_AR")[0]
cfg.env["GIT_BINARY"] = cfg.find_program("git", var = "GIT")[0]
log.debug("cfg.env['CLASP_BUILD_MODE'] = %s", cfg.env['CLASP_BUILD_MODE'])
# apply the default
if (cfg.env['CLASP_BUILD_MODE']==[]):
if (cfg.env['DEST_OS'] == DARWIN_OS ):
cfg.env['CLASP_BUILD_MODE'] = 'faso'
else:
cfg.env['CLASP_BUILD_MODE'] = 'object'
if ((cfg.env['CLASP_BUILD_MODE'] =='bitcode')):
cfg.define("CLASP_BUILD_MODE",2) # thin-lto
cfg.env.CLASP_BUILD_MODE = 'bitcode'
cfg.env.LTO_FLAG = LTO_OPTION
elif ( cfg.env['CLASP_BUILD_MODE']=='object'):
cfg.define("CLASP_BUILD_MODE",1) # object files
cfg.env.CLASP_BUILD_MODE = 'object'
cfg.env.LTO_FLAG = []
elif (cfg.env['CLASP_BUILD_MODE']=='faso'):
cfg.define("CLASP_BUILD_MODE",3) # object files
cfg.env.CLASP_BUILD_MODE = 'faso'
cfg.env.LTO_FLAG = []
elif (cfg.env['CLASP_BUILD_MODE']=='fasl'):
cfg.define("CLASP_BUILD_MODE",0) # object files
cfg.env.CLASP_BUILD_MODE = 'fasl'
cfg.env.LTO_FLAG = []
else:
raise Exception("CLASP_BUILD_MODE can only be 'thinlto'(default), 'lto', or 'object' - you provided %s" % cfg.env['CLASP_BUILD_MODE'])
log.info("default cfg.env.CLASP_BUILD_MODE = %s, final cfg.env.LTO_FLAG = '%s'", cfg.env.CLASP_BUILD_MODE, cfg.env.LTO_FLAG)
# default for USE_COMPILE_FILE_PARALLEL for Darwin is True - otherwise False
if (not 'USE_COMPILE_FILE_PARALLEL' in cfg.env):
if (cfg.env['DEST_OS'] == DARWIN_OS ):
# by default only MacOS has USE_COMPILE_FILE_PARALLEL=True
cfg.env['USE_COMPILE_FILE_PARALLEL'] = True
elif (cfg.env['DEST_OS'] == LINUX_OS ):
cfg.env['USE_COMPILE_FILE_PARALLEL'] = True
elif (cfg.env['DEST_OS'] == FREEBSD_OS ):
# cracauer todo
cfg.env['USE_COMPILE_FILE_PARALLEL'] = True
else:
raise Exception("Unknown OS %s"%cfg.env['DEST_OS'])
log.debug("cfg.env['USE_COMPILE_FILE_PARALLEL'] = %s", cfg.env['USE_COMPILE_FILE_PARALLEL'])
if ((not 'USE_COMPILE_FILE_PARALLEL' in cfg.env) or cfg.env['USE_COMPILE_FILE_PARALLEL'] ):
cfg.define("USE_COMPILE_FILE_PARALLEL",1)
cfg.env.USE_COMPILE_FILE_PARALLEL = True
else:
cfg.define("USE_COMPILE_FILE_PARALLEL",0)
cfg.env.USE_COMPILE_FILE_PARALLEL = False
cur_clang_version = run_llvm_config(cfg, "--version")
log.debug("cur_clang_version = %s", cur_clang_version)
llvm_version_test = not ("LLVM_VERSION_OVERRIDE" in cfg.env)
if (llvm_version_test and (int(cur_clang_version[0]) != LLVM_VERSION)):
raise Exception("You must have clang/llvm version %d installed - you have %s" % (LLVM_VERSION, cur_clang_version[0]) )
# find a lisp for the scraper
if not cfg.env.SCRAPER_LISP:
cfg.env["SBCL"] = cfg.find_program("sbcl", var = "SBCL")[0]
cfg.env["SCRAPER_LISP"] = [cfg.env.SBCL,
'--noinform', '--dynamic-space-size', '2048', '--lose-on-corruption', '--disable-ldb', '--end-runtime-options',
'--disable-debugger', '--no-userinit', '--no-sysinit']
global cxx_compiler, c_compiler
cxx_compiler['linux'] = ["clang++"]
c_compiler['linux'] = ["clang"]
cfg.load('compiler_cxx')
cfg.load('compiler_c')
### Without these checks the following error happens: AttributeError: 'BuildContext' object has no attribute 'variant_obj'
cfg.env.append_value('LINKFLAGS', "-L/opt/clasp-support/lib")
cfg.env.append_value('INCLUDES', "/opt/clasp-support/include")
if (cfg.env['DEST_OS'] == DARWIN_OS ):
cfg.env.append_value('LINKFLAGS', "-L/usr/local/lib");
cfg.env.append_value('INCLUDES', "/usr/local/include" )
cfg.check_cxx(lib='gmpxx gmp'.split(), cflags='-Wall', uselib_store='GMP')
cfg.check_cxx(lib='ffi', cflags='-Wall', uselib_store='FFI')
try:
cfg.check_cxx(stlib='gc', cflags='-Wall', uselib_store='BOEHM')
except ConfigurationError:
cfg.check_cxx(lib='gc', cflags='-Wall', uselib_store='BOEHM')
#libz
cfg.check_cxx(lib='z', cflags='-Wall', uselib_store='Z')
if (cfg.env['DEST_OS'] == LINUX_OS or cfg.env['DEST_OS'] == FREEBSD_OS):
cfg.check_cxx(lib='dl', cflags='-Wall', uselib_store='DL')
cfg.check_cxx(lib='elf', cflags='-Wall', uselib_store='ELF')
cfg.check_cxx(lib='ncurses', cflags='-Wall', uselib_store='NCURSES')
# cfg.check_cxx(stlib='lldb', cflags='-Wall', uselib_store='LLDB')
cfg.check_cxx(lib='m', cflags='-Wall', uselib_store='M')
if (cfg.env['REQUIRE_LIBFFI'] == []):
cfg.env['REQUIRE_LIBFFI'] = True
if (cfg.env['DEST_OS'] == DARWIN_OS and cfg.env['REQUIRE_LIBFFI'] == True):
cfg.check_cxx(lib='ffi', cflags='-Wall', uselib_store="FFI")
elif (cfg.env['DEST_OS'] == LINUX_OS ):
cfg.check_cxx(lib='bsd', cflags='-Wall', uselib_store='BSD')
# cfg.check_cxx(lib='gcc_s', cflags='-Wall', uselib_store="GCC_S")
# cfg.check_cxx(lib='unwind-x86_64', cflags='-Wall', uselib_store='UNWIND_X86_64')
# cfg.check_cxx(lib='unwind', cflags='-Wall', uselib_store='UNWIND')