By running make compile-commands a `compile_commands.json` in the RIOT base
directory. With the environment variable `COMPILE_COMMANDS` the path of
this file can be changed to a custom location.
The `compile_commands.json` will contain the exact compile command, but
as additional flag `-I/usr/$(TARGET)/include` is added to work around
`clangd` not being able to locate the newlib system headers. The
additional includes can be overwritten using the environment variable
`COMPILE_COMMANDS_EXTRA_INCLUDES`.
If external modules use C++ code and forget to require the `cpp` feature,
linking will still take places using $(CC). This commit adds a check if C++ code
was detected without the feature `cpp` being used, now the build is aborted
with a helpful error message rather than a linker error.
With #10970 only existing *.c files will be added to SRC when using
the SUBMODULES mechanism, so SUBMODULES_NOFORCE (used to filter out
non existing source files) is now redundant so remove the usage.
When providing a pseudo-submodule for a module already using the
`SUBMODULES` mechanism to provide submodules, it is not possible to
create a true pseudo-module as submodule (i.e. one without any code on
its own), since the build system currently always expects there to be a
C file `module_submodule.c`.
This removes this requirement.
This adds a check to decide if Kconfig should run on a build. It will
run if any of the following conditions is true:
- A file with '.config' extension is present in the application folder
- A 'Kconfig' file is present in the application folder
- A previous configuration file is present (e.g. from a previous call to
menuconfig)
- menuconfig is being called
This assumes that Kconfig will not generate any default configurations
just from the Kconfig files outside the application folder (i.e. module
configuration via Kconfig is disabled by default). Should this change,
the check would not longer be valid, and Kconfig would have to run on
every build.
- The autoconf.h header file, generated with the current Kconfig
configurations, is added as a build dependency.
- autoconf.h depends on the proper tool (genconfig) and a Kconfig.dep
which contains the dependencies for the given application and board,
this is generated from $(USEMODULE).
- The menuconfig target is added, to allow the configuration of modules
using the Kconfig system.
By passing the -MT flag with the absolute path to the object we make
sure that the compiler generates dependency files with rules that match
our building rules.
This fixes the following issues:
* Use of 'realpath' not supported on mac
* Call of 'realpath' once for each file instead of one per archive
* Do not trigger 'llvm-ar' bug when invoked in the object directory.
llvm-ar rcTs ../m.a obj.o # Bugged
llvm-ar rcTs m.a m/obj.o # working
Using relative path linking is required to have a valid thin archive
path in the host when build in docker.
Normal, or thick archives contain a copy of the object code. Thin
archives, on the contrary, are just an index to the .o files.
This patch does two things:
1. Change ARFLAGS to enable the "T" options.
2. Call AR with all relative paths.
The second step is necessary because the build system handles all
absolute paths. If the index in the thin archive contains absolute
paths, archives created in docker are no usable outside, and moving
the objects breaks the archive.
If all arguments to AR are relative, the resulting archive contains
filenames *relative to the .a file* and nothing should break as long
as the relative location of the .a and .o remains unchanged.
Compilation time is unchanged, but disc usage is reduced by approximately
50%. These are the result of a full RIOT build:
| Thin Archive | no | yes | Savings (%) |
| -------------- | ------: | ----: | ----------- |
| pkg (10e6 KiB) | 1 790 | 905 | 49% |
| Non pkg | 71 | 71 | 1% |
| Total | 1 812 | 976 | 46 % |
AR incrementally adds file without removing files.
If a c file is deleted or disabled(submodule removal) it is not removed from
archive and still ends up in the final elf file.
This fix removes the need to do 'make clean' for this case.
However it will break cases where an APPLICATION and a MODULE or two modules
have the same name and only worked because source files names where different.
Assembly files '.S' are compiled with a subset of CFLAGS.
This means also `-include '$(RIOTBUILD_CONFIG_HEADER_C)'` so they should be
recompiled when it updates.