1 % (c) 2009-2025 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
2 % Heinrich Heine Universitaet Duesseldorf
3 % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
4
5 :- module(compile_time_flags,
6 [compile_time_flag/1,
7 compile_time_flags/1,
8 relevant_prolog_flags/1
9 ]).
10
11 % compile time flags can be set from the command line for SICStus Prolog
12 % e.g., -Dprob_safe_mode=true when starting ProB from source or when generating the .sav file in the Makefile
13
14 :- use_module(module_information,[module_info/2]).
15
16 :- module_info(group,infrastructure).
17 :- module_info(description,'This module describes the possible compile-time flags of ProB.').
18
19 compile_time_flags(list(Flags)) :- % list wrapper for Tcl
20 findall(Flag, compile_time_flag(Flag), Flags).
21
22
23 :- load_files(library(system), [when(compile_time), imports([environ/2])]).
24 :- if(environ(prob_release,true)).
25 compile_time_flag(prob_release).
26 % set when building an official build of probcli or ProB Tcl/Tk
27 % excludes Tcl benchmarks, unit tests
28 :- endif.
29 :- if(environ(prob_safe_mode,true)).
30 compile_time_flag(prob_safe_mode).
31 % perform additional checks
32 % check_ast: check AST ground, check used_id infos for quantifiers...)
33 % check typing in equal_object, variable clashes in comprehension_set, call_residue check in my_findall,...
34 :- endif.
35 :- if(environ(prob_core_only,true)).
36 compile_time_flag(prob_core_only).
37 % probcli only contains core modules, many extensions are not included
38 :- endif.
39 :- if(environ(plspec_patch_libraries,true)).
40 compile_time_flag(plspec_patch_libraries).
41 % use plspec to check calls to ordsets, avl and lists libraries
42 :- endif.
43 :- if(environ(prob_data_validation_mode,true)).
44 compile_time_flag(prob_data_validation_mode).
45 % prevent certain instantiations of sets on the assumption that we do not need powerful constraint solving
46 % not really supported anymore; probably not worth the fact that all regression tests run without this flag
47 :- endif.
48 :- if(environ(no_wd_checking,true)).
49 compile_time_flag(no_wd_checking).
50 % disable Well-Definedness checking for function applications
51 :- endif.
52 :- if(environ(prob_profile,true)).
53 compile_time_flag(prob_profile).
54 % store profile information for operations and invariant checking; is now controlled by prob_profiling_on preference
55 % but can be completely turned off by setting prob_profile to false
56 :- endif.
57 :- if(environ(prob_logging_mode,true)).
58 compile_time_flag(prob_logging_mode).
59 % automatically log probcli (add -ll command-line switch)
60 :- endif.
61 :- if(environ(no_terminal_colors,true)).
62 compile_time_flag(no_terminal_colors).
63 % disable terminal colors, can also be influence by setting NO_COLOR environment variable
64 :- endif.
65 :- if(environ(partially_evaluate,true)).
66 compile_time_flag(partially_evaluate).
67 :- endif.
68 :- if(environ(partially_evaluate_compile,true)).
69 compile_time_flag(partially_evaluate_compile).
70 :- endif.
71 :- if(environ(no_interrupts,true)).
72 compile_time_flag(no_interrupts).
73 % do not treat CTRL-C user_interrupts
74 :- endif.
75 :- if(environ(prob_noopt_mode,true)).
76 compile_time_flag(prob_noopt_mode).
77 % now While Loop optimisation
78 :- endif.
79 :- if(environ(prob_debug_flag,true)).
80 compile_time_flag(prob_debug_flag).
81 % additional debugging performed/enabled and checking of performance issues at the B Level
82 :- endif.
83 :- if(environ(prob_debug_watch_flag,true)).
84 compile_time_flag(prob_debug_watch_flag).
85 % watch certain predicate/expression computations precisely and report if they take too long
86 % performs monitoring at a lower level closer to Prolog than prob_debug_flag
87 :- endif.
88 :- if(environ(prob_enter_debugger_upon_error,true)).
89 compile_time_flag(prob_enter_debugger_upon_error).
90 % enter SICStus debugger when exception/error occurs
91 :- endif.
92 :- if(environ(prob_use_timer,true)).
93 compile_time_flag(prob_use_timer).
94 % use microsecond timer
95 :- endif.
96 :- if(environ(prob_src_profile,true)).
97 compile_time_flag(prob_src_profile).
98 % perform profiling at B source level in source_profiler.pl,
99 % now controlled by preference prob_source_profiling_on, but -Dprob_src_profile=false can disable it
100 :- endif.
101 :- if(environ(prob_myheap,false)).
102 compile_time_flag(prob_myheap_false).
103 % do not use C++ priority queue
104 :- endif.
105 :- if(environ(prob_c_counter,false)).
106 compile_time_flag(prob_c_counter_false).
107 % do not use C++ counter
108 :- endif.
109 :- if(environ(disable_chr,true)).
110 compile_time_flag(disable_chr). % do not include CHR library at all
111 :- endif.
112 :- if(environ(enable_time_out_for_constraints,true)).
113 compile_time_flag(enable_time_out_for_constraints). % use time_out for posting constraints
114 :- endif.
115 :- if(environ('SP_JIT',disabled)).
116 compile_time_flag('SP_JIT=disabled').
117 :- endif.
118 :- if(environ('SP_JIT',yes)).
119 compile_time_flag('SP_JIT=yes'). % this is the default
120 :- endif.
121 :- if(environ('SP_JIT',no)).
122 compile_time_flag('SP_JIT=no').
123 :- endif.
124 :- if(environ('SP_JIT_COUNTER_LIMIT',_)).
125 compile_time_flag('SP_JIT_COUNTER_LIMIT_SET'). % default is 0
126 :- endif.
127 :- if(environ('SP_JIT_CLAUSE_LIMIT',_)).
128 compile_time_flag('SP_JIT_CLAUSE_LIMIT_SET'). % default is 1024
129 :- endif.
130 :- if(environ('SP_SPTI_PATH',verbose)).
131 compile_time_flag('SP_SPTI_PATH=verbose'). % can be set to verbose
132 :- endif.
133 :- if(environ('SP_TIMEOUT_IMPLEMENTATON',legacy)).
134 % Needed with SICStus 4.4.0 to work around an issue with nested timeouts.
135 % Should have no effect on any other SICStus version.
136 % This is not actually a compile-time flag - it only takes effect when set at runtime.
137 compile_time_flag('SP_TIMEOUT_IMPLEMENTATON=legacy').
138 :- endif.
139
140 compile_time_flag(_) :- fail.
141
142
143 relevant_prolog_flags(Flags) :-
144 findall(Flag/Val, (relevant_flag(Flag),current_prolog_flag(Flag,Val)), Flags).
145
146 relevant_flag(dialect).
147 relevant_flag(version_data).
148 relevant_flag(platform_data).
149 relevant_flag(profiling).
150 relevant_flag(system_type).
151 relevant_flag(host_type).
152