Le jeu. 30 avr. 2020 à 10:40, Nikolaus Waxweiler <
address@hidden> a écrit :
One thing regarding build systems and IDE/tool integration:
Cmake and others can generate a
https://clang.llvm.org/docs/JSONCompilationDatawas a portabililty nightmarebase.html that help
tools like static analyzers and language servers and IDEs parse
projects. It's very nice have when you hack on something.
It also means that you have to have an entry for every single .c file,
unless I'm missing something. FreeType bundles several .c files into
bigger .c files, breaking the database. Werner mentioned that this is
done because older compilers have worse inlining or dead code
elimination or something like that. It would still be nice to have the
database.
The wrapper source files are used for two reasons:
1) Speed up compilation (though this is less of an issue with today's powerful CPUs and multiple cores)
2) Much better / smaller generated machine code, because all FT_LOCAL functions are really "static" and can be freely inlined by the simplest compiler.
Getting the same level of optimization without wrappers requires link-time-optimization (LTO), which may or may not be available depending on the toolchain you're using, and cannot always be enabled by projects embedding the library for multiple reasons (LTO is super slow, ThinLTO makes it slightly better, but only if you use Clang, etc).
Apart from that, it would be easy to write a script to generate the proper compilation database from the
rules.mk/module.mk file with the patches I've submitted to the mailing list (in another thread).
Also other tools can output such a database (e.g. GN has --export-compile-commands=default for example, not sure about Meson).