Open hiker opened 2 months ago
Suggested implementation details:
-traceback
, so this would be added as generic flag)
fast_debug
would inherit from generic
. The memory-debug
would inherit from fast-debug
and add memory-specific flags. And optimised
might inherit from fast_debug
, but add -O3
(or so). Very flexible (relying that the flags will be interpreted left to right. E.g. in the optimised example, the flag string would be -g -O0 ... -O3
, with O3
being the effective flag.mode
parameter (str). We could consider a consistency check at some stage (the mode specified in the BuildConfig must indeed be defined in the compiler used)compilation_flags = self.flags.get_flags(config, input_file)
.get_flags
call above). Details (including implementation :) ) can be taken from the existing Fab implementation (or we could use the current implementation as a base if suitable).The implementation can be done in several smaller steps:
Originally, it would have been feasible to implement the flags as class/static variables (meaning if you inherit from a compiler, you would also get the flags). Just to clarify, the variables should be stored in the instances (taken from the ToolRepository). This is a requirement for the upcoming proper compiler wrapper, which allows us to do:
gcc = Gcc()
mpicc = Mpicc(gcc)
assert gcc.flags == []
assert mpicc.flags == []
# Setting flags in gcc must become visible in the wrapper compiler:
gcc.add_flags(["-a", "-b"])
assert gcc.flags == ["-a", "-b"]
assert mpicc.flags == ["-a", "-b"]
Basically, a site can just take the (say) ifort compiler from the tool repository, add whatever flags it wants to add (with all the flexibility added here). But if an app then select to use mpif90
based on ifort, it will automatically get the site-specific flags. Of if a site doesn't use mpif90, but mpiifort for intel, it can just declare mpiifort based on intel, and will also get the flags.
It would also allow an application to define more than one (say) ifort compiler with different flags ... though I can't see a good use case for that :)
The new compiler class introduces a separate Flag class, in addition to the existing AddFlags and FlagsConfig.
The Flags and FlagsConfig classes should be combined into one, allowing conditional (AddFlags) and unconditional flags to be used in one object. Additionally to path-specific flags, we need to: