Hi,

On 16/04/16 12:39, Niels Ole Salscheider wrote:
But the "None" type is not really supported and some projects (e. g. LLVM)
even forbid it. Apart from that projects might add additional flags to these
variables. They could for example add defines that enable some debug code only
in debug builds.

It would therefore make sense to set the build type to the right value so that
these flags can be included. In that case we would also have to set the default
values of all CMAKE_C{,XX}_FLAGS_$TYPE variables to sensible values that do
not include any -O flags. CMAKE_CXX_FLAGS_RELEASE would for example only
contain "-DNDEBUG".
The main problem is that we either would need a way to filter these flags, since many projects use -O3 and similar stuff, or we need to start patching those projects. And by patching I mean to introduce a way for them so that some flags are appended to the vars and some are just set as defaults without overwriting user set. cmake does easily allow that. That said, I think that there are valid cases of projects appending flags for special purposes.
For example, darktable sets:
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -ffast-math -fno-finite-math-only")

Here, we should filter -O3, as we definitely don't want that, but I think using -ffast-math and -no-finite-math-only are valid for this specific project (not in general, though).
Similarly, setting project flags for debug builds makes sense as well.

I think that patching upstream is definitely the better way, but obviously requires much more work. In the above example, it would be trivial. Just remove -O3. There is no point in setting that by the project, because cmake has that as a default anyway if the variable hasn't been set.

However, it might still be necessary to do some filtering, which I'm not sure how easy it is.
Bernd Steinhauser proposed that we should set the CMake build type based on a
build_option. What do you think?
Should mention, that the main idea behind that is to allow a proper debug build for every package that uses cmake by setting build_type=debug, as the _DEBUG flags have good defaults for that and can be adjusted by projects if necessary. We could keep the build_type=none as an option, for those that strictly want to keep the cflags they set without the projects appending flags. This would also allow us to die in pretend if for an exheres a build_type was specified that is explicitly not supported by the project, like is the case with build_type=none for llvm.

Best Regards,
Bernd

_______________________________________________
Exherbo-dev mailing list
[email protected]
http://lists.exherbo.org/mailman/listinfo/exherbo-dev

Reply via email to