aboutsummaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorJacob Bramley <jacob.bramley@arm.com>2016-12-19 11:40:08 +0000
committerJacob Bramley <jacob.bramley@arm.com>2016-12-19 18:14:41 +0000
commit1fa6f06efd5b86bf2ea0c084b34e8297057ef867 (patch)
tree48bb5a1464875015aa257a81211ba9c38d828190 /SConstruct
parente8ce9f0ec7fe9484fca0c446ecc8a9d7929bea66 (diff)
downloadvixl-1fa6f06efd5b86bf2ea0c084b34e8297057ef867.tar.gz
Allow configuration of the CodeBuffer allocator.
Ideally, we'd like to template this somehow to avoid the use of the preprocessor, but this will work for now. Change-Id: Iba88b04a97f516ddb13a83035b078d8cf599da6c
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct30
1 files changed, 26 insertions, 4 deletions
diff --git a/SConstruct b/SConstruct
index 69d9523c..4d208452 100644
--- a/SConstruct
+++ b/SConstruct
@@ -114,6 +114,12 @@ options = {
},
'negative_testing:on' : {
'CCFLAGS' : ['-DVIXL_NEGATIVE_TESTING']
+ },
+ 'code_buffer_allocator:mmap' : {
+ 'CCFLAGS' : ['-DVIXL_CODE_BUFFER_MMAP']
+ },
+ 'code_buffer_allocator:malloc' : {
+ 'CCFLAGS' : ['-DVIXL_CODE_BUFFER_MALLOC']
}
}
@@ -166,6 +172,15 @@ def simulator_handler(env):
env['simulator'] = 'none'
+# 'mmap' is required for use with 'mprotect', which is needed for the tests
+# (when running natively), so we use it by default where we can.
+def code_buffer_allocator_handler(env):
+ directives = util.GetCompilerDirectives(env)
+ if '__linux__' in directives:
+ env['code_buffer_allocator'] = 'mmap'
+ else:
+ env['code_buffer_allocator'] = 'malloc'
+
# A validator checks the consistency of provided options against the environment.
def default_validator(env):
pass
@@ -193,9 +208,11 @@ vars_default_handlers = OrderedDict({
'target_arch' : [ 'AArch32 only if the host compiler targets a 32-bit '
'architecture - otherwise both', target_arch_handler,
target_arch_validator],
- 'simulator' : ['on if the target architectures include AArch64 but '
+ 'simulator' : [ 'on if the target architectures include AArch64 but '
'the host is not AArch64, else off',
- simulator_handler, simulator_validator ]
+ simulator_handler, simulator_validator ],
+ 'code_buffer_allocator' : [ 'mmap with __linux__, malloc otherwise',
+ code_buffer_allocator_handler, default_validator ]
})
@@ -215,13 +232,17 @@ vars = Variables()
vars.AddVariables(
EnumVariable('mode', 'Build mode',
'release', allowed_values=config.build_options_modes),
- EnumVariable('negative_testing', 'Enable negative testing (needs exceptions)',
+ EnumVariable('negative_testing',
+ 'Enable negative testing (needs exceptions)',
'off', allowed_values=['on', 'off']),
DefaultVariable('symbols', 'Include debugging symbols in the binaries',
['on', 'off']),
DefaultVariable('target_arch', 'Target architecture',
['aarch32', 'aarch64', 'both']),
DefaultVariable('simulator', 'Simulators to include', ['aarch64', 'none']),
+ DefaultVariable('code_buffer_allocator',
+ 'Configure the allocation mechanism in the CodeBuffer',
+ ['malloc', 'mmap']),
('std', 'C++ standard. The standards tested are: %s.' % \
', '.join(config.tested_cpp_standards))
)
@@ -231,7 +252,8 @@ vars.AddVariables(
# set. These are the options that should be reflected in the build directory
# path.
options_influencing_build_path = [
- 'target_arch', 'mode', 'symbols', 'CXX', 'std', 'simulator', 'negative_testing'
+ 'target_arch', 'mode', 'symbols', 'CXX', 'std', 'simulator',
+ 'negative_testing', 'code_buffer_allocator'
]