You are not logged in.

#1 2021-03-24 22:58:57

loqs
Member
Registered: 2014-03-06
Posts: 17,196

[SOLVED] Understanding Arch's proposed new buildflags

After reading through https://lists.archlinux.org/pipermail/a … 30382.html and https://gitlab.archlinux.org/archlinux/ … ts/3/diffs

I tried testing with the following
a.c

void main() {}
$ gcc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS -Werror=format-security -fstack-clash-protection -fcf-protection  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now a.c
cc1: error: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Werror=format-security]
cc1: some warnings being treated as errors
$ echo $?
1

And no a.out is generated

Removing -Wformat-security

gcc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS -fstack-clash-protection -fcf-protection  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now a.c
$ echo $?
0

And a.out is produced.

Adding -Wall which include -Wformat produces:

gcc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -fstack-clash-protection -fcf-protection  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now a.c
a.c:1:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
    1 | void main() {}
      |      ^~~~
$ echo $?
0

And a.out is produced.

So I can not make the flags work without modification.
Edit:
Fixed when implemented in [1] by the addition of -Wformat.

[1] https://github.com/archlinux/svntogit-p … f6891801fc

Last edited by loqs (2021-03-31 03:01:52)

Offline

Board footer

Powered by FluxBB