1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

30 Commits

Author SHA1 Message Date
Marian Buschsieweke
1c7e660973
buildsystem: only expose CPU_RAM_BASE & SIZE when known
This gets rid of the following ugly warnings:

    /bin/sh: 1: arithmetic expression: expecting primary: ""
2023-06-24 23:35:14 +02:00
Teufelchen1
791d4e3a4d buildsystem: Always expose CPU_RAM_BASE & SIZE flags 2023-06-20 12:16:06 +02:00
Marian Buschsieweke
2b2506c052
build system: Fix linker feature test with newlib 4.3.0
Before the build system used something like

    echo "int main(){} void _exit(int n) {(void)n;while(1);}" | LC_ALL=C $(LINK) -xc - -o /dev/null -lc -Wall -Wextra -pedantic <FLAGS_TO_TEST>

to check for flags supported by the compiler (used as linker frontend).
This however no longer works with newlib 4.3.0, which requires the
symbols `_sbrk_r`, `_close_r`, `_lseek_r`, `_read_r`, and `_write_r` to
be present. Instead, now a new file `minimal_linkable.c` was added that
adds all the missing symbols and is used in the linker feature tests
instead.
2023-02-02 20:47:37 +01:00
Benjamin Valentin
71b1689407 makefiles/cflags.inc.mk: don't include absolute path in __FILE__ macro 2022-11-15 15:28:54 +01:00
Marian Buschsieweke
67ba1a0cb7
makefiles/cflags.inc.mk: add -z noexecstack to link flags
GCC on some platforms does need an executable stack to generate
trampoline code, but use of nested functions is not allowed in
RIOT's code base anyway.
2022-11-07 15:02:03 +01:00
Marian Buschsieweke
16df27c51d
makefiles/cflags.inc.mk: Add -Wno-missing-field-initializers to CXXFLAGS
This allows including C headers from C++. It sadly reduced the
diagnostics on C++ code as well, were there warning may make sense as
unintended side effect. We may be able to drop that later on, when more
C APIs are properly wrapped in native C++ APIs, so that C headers do no
longer need to be compatible with C++ compilers.
2022-10-27 14:28:06 +02:00
1547d2f075 make: add -ffunction-sections -fdata-sections to LINKFLAGS if LTO=1 2022-02-15 12:28:16 +01:00
Gunar Schorcht
181f6423ae makefiles/cflags: enable C++14 by default 2022-01-06 11:15:23 +01:00
Marian Buschsieweke
63b54b5e84
makefiles/cflags.inc.mk: Add -Wcast-align 2021-12-03 14:22:17 +01:00
Benjamin Valentin
95f814b5da CODING_CONVENTIONS.md: default to C11
The standard is 9 years old now, it is well supported in all mayor compilers.
In fact, features of the 'new' standard are already used in RIOT (std_atomic).

Let's make it the default and adapt the Makefiles accordingly.
2021-02-14 14:28:13 +01:00
Marian Buschsieweke
01382dc4ad
makefiles: Add -fwrapv to CFLAGS
This commit makes overflow of signed integers to behave as expected by at 90%
of the C developers, even though overflow of signed integers are strictly
undefined behavior.

Note: Please do not add code relying on a specific behavior for the overflow of
      signed integers, even though `-fwrpav` will make that code work. This is
      intended to mitigate the risk of bugs in overflow checks being exploited,
      not to encourage adding new bugs.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475 for details and see
http://c-faq.com/misc/intovf.html on how to implement overflow checks properly.
2021-01-25 13:35:43 +01:00
Leandro Lanzieri
81cb769cad
makefiles: avoid building archives when compiling 2020-09-04 15:01:10 +02:00
Francisco Molina
4b8d776576 makefiles/cflags.inc.mk: set unless deactivated
`fdiagnostics-color` defaults to on only on a color capable terminal,
so it can be activated unles CC_NOCOLOR=1.
2020-01-10 08:58:54 +01:00
Juan Carrano
24ddf285d2 Makefile.base: use thin static archives.
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 %        |
2019-09-10 11:21:42 +02:00
Juan Carrano
63c475cd4d toolchain/cflags: enable dwarf compression.
Use the -gz option to compress ELF sections containing DWARF information.
This saves around 50% of disk space, without any side effects.

See https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Debugging-Options.html#Debugging-Options
for more infomation on this option.

Some platforms have an outdated toolchain that does not support -gz so
the flag is blacklisted there. Even then, the results are quite impressive.

I used @cladmi's `buildtest` branch (https://github.com/cladmi/RIOT/tree/wip/du/buildtest)
with this change and compiled the `examples/default` application:

```
$ BUILD_IN_DOCKER=1 DOCKER="sudo docker" make -C examples/default buildtest-indocker
```

The size was obtained with:

```
$ find output -name "*.bin.bindirsize" -type f -exec tail  -n1 '{}' \; | cut -f 1 | awk '{s+=$1} END {printf "%.0f", s}'
```

Results:

- Vanilla: 10328112 KB (~10GB).
- with -gz: 4982788 KB (~5GB).

This was inspired by #8496.
2019-09-02 14:43:26 +02:00
Gaëtan Harter
909552e3c0
makefiles/cflags.inc.mk: change optional CFLAGS to 'OPTIONAL_CFLAGS'
Update the optional flags to use 'OPTIONAL_CFLAGS' instead of evaluating
everytime.

They are now blacklisted by architecture/toolchain according to the
current docker reference image.
2019-08-29 17:43:54 +02:00
Gaëtan Harter
785f868ee0
makefiles/cflags.inc.mk: handle optional cflags
Handle declaring OPTIONAL_CFLAGS and blacklisting them with
OPTIONAL_CFLAGS_BLACKLIST.

This should replace checking everytime if options are supported.
2019-08-29 17:43:54 +02:00
Gaëtan Harter
a99dd332cc
cflags.inc.mk: fix cflags test for llvm
gcc does an error but not clang, so add -Werror.
2018-07-19 18:59:20 +02:00
Joakim Nohlgård
3c23c95b6f
cflags: add -Wformat=2 -Wformat-overflow -Wformat-truncation 2018-07-18 15:29:06 +02:00
Joakim Nohlgård
843cec5cbd
makefiles/cflags.inc.mk: Use a template for CFLAGS testing 2018-07-10 16:51:29 +02:00
Joakim Nohlgård
a71ef652e7
makefiles/cflags.inc.mk: move excluded patterns out of conditional
The excluded patterns can always be defined as they only set `CFLAGS` that
should not be passed to `CXX`.

This prepares for replacing the cflags support detection by a function.
2018-07-10 16:48:37 +02:00
Joakim Nohlgård
be2169d587
makefiles/cflags.inc.mk: Remove WERROR duplicate handling
WERROR already sets -Werror so this is not necessary.
2018-07-10 16:47:42 +02:00
Joakim Nohlgård
b36afc3964 make: Clean up WERROR handling 2018-06-26 12:50:02 +02:00
Gaëtan Harter
08ff1b73a2
makefiles/cflags.inc.mk: add -Wmissing-include-dirs flag
Warn if a user-supplied include directory does not exist.
2018-06-12 14:08:33 +02:00
61f1b941ce make: replace curly braces with parenthesis 2018-03-22 20:43:15 +01:00
Xavier Clive
c6af3f733d make: Do not attempt to use color if the terminal cannot support it 2017-11-16 20:04:18 +01:00
Hauke Petersen
09ab7cb0a8 make: allow for disabling colored compiler output 2017-08-07 10:20:30 +02:00
Hauke Petersen
2811adc092 cflags: add -fdiagnostics-color if supported 2017-07-10 16:32:23 +02:00
Loïc Dauphin
220ed6558e makefiles: make -Werror flags dependent of WERROR 2017-06-23 14:11:08 +02:00
Joakim Nohlgård
339a4da9dc Makefiles: move to new directory /makefiles 2017-04-04 15:11:54 +02:00