Scons checking for compiler option -
i want check in scons compiler support option (for example -fcilkplus
). way manage following sequence of operations:
env.prepend(cxxflags = ['-fcilkplus'], libs = ['cilkrts'])
then launch custom checker:
def checkcilkpluscompiler(context): test = """ #include <cilk/cilk.h> #include <assert.h> int fib(int n) { if (n < 2) return n; int = cilk_spawn fib(n-1); int b = fib(n-2); cilk_sync; return + b; } int main() { int result = fib(30); assert(result == 832040); return 0; } """ context.message('checking cilk++ compiler ... ') result = context.tryrun(test, '.cpp') context.result(result[0]) return result[0]
now if fails, have remove 2 options flags -fcilkplus
cilkrts
environment variables. there better way ?
the problem can't manage access env
context , therefore can't make clone of it.
you can use check availability of library scons follows:
env = environment() conf = configure(env) if not conf.checklib('cilkrts'): print 'did not find libcilkrts.a, exiting!' exit(1) else: env.prepend(cxxflags = ['-fcilkplus'], libs = ['cilkrts']) env = conf.finish()
you check availability of header follows:
env = environment() conf = configure(env) if conf.checkcheader('cilk/cilk.h'): env.prepend(cxxflags = ['-fcilkplus'], libs = ['cilkrts']) env = conf.finish()
update:
i realized, can access environment on configure object follows:
conf.env.append(...)
Comments
Post a Comment