Skip to content

[WIP] main/clang: enable -D_FORTIFY_SOURCE=2 on Linux by default

Sören Tempel requested to merge nmeum/aports:clang-fortify into master

See the patch file description for more information. Test using the following file:

#ifndef _FORTIFY_SOURCE
#error "_FORTIFY_SOURCE not defined"
#endif

int main(void) { return 0; }

And invoke clang as:

$ clang -Os -o test test.c

Which should work (as _FORTIFY_SOURCE is enabled by default if optimizations are requested). Compare this to:

$ clang -o test test.c
test.c:2:2: error: "_FORTIFY_SOURCE not defined"

The same behaviour can be observed when using GCC instead of Clang.

Edited by Leo

Merge request reports