You are not logged in.

#1 2018-03-15 22:53:14

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Get gcc to show all the CFLAGS including those auto set? [SOLVED]

How can one get gcc to show all of the C(XX)FLAGS it is using on a build including ones that are autoset or set as a defaults by virtue of another switch?

Last edited by graysky (2018-03-16 19:32:28)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2018-03-15 23:07:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,525
Website

Re: Get gcc to show all the CFLAGS including those auto set? [SOLVED]

You likely want to check the -Q and --help=* flags, e.g.:

gcc -Q --help=optimizers

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-03-16 03:29:41

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Get gcc to show all the CFLAGS including those auto set? [SOLVED]

What is your goal here? Are you trying to debug a build? Do you want to show this in the buildsystem progress? Do you want to inspect the contents of a binary and find out what options it was built with?

You can always use -v which will tell you, well, way too much information. Or -###

Either one shows you the COLLECT_GCC_OPTIONS as well as the actual cc1 command line that would be generated and the ./configure command line used to build your gcc compiler.

See the Gentoo wiki discussion around choosing compiler flags (and knowing which ones you are already using): https://wiki.gentoo.org/wiki/GCC_optimization#-march


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#4 2018-03-16 09:17:20

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: Get gcc to show all the CFLAGS including those auto set? [SOLVED]

Thanks for the replies and links, guys.  My goal is to simple see (prove they have been called) any options that are activated by compiling with -march=haswell in /etc/makepkg.conf leaving the other default CFLAGS in place.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#5 2018-03-16 11:05:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,525
Website

Re: Get gcc to show all the CFLAGS including those auto set? [SOLVED]

Oh, well that's a much more specific question:

https://stackoverflow.com/questions/547 … l-activate


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2018-03-16 19:32:19

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: Get gcc to show all the CFLAGS including those auto set? [SOLVED]

Thanks again, guys.  This is what I wanted to see.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#7 2018-03-16 20:22:43

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: Get gcc to show all the CFLAGS including those auto set? [SOLVED]

Eschwartz wrote:

What is your goal here? Are you trying to debug a build? Do you want to show this in the buildsystem progress? Do you want to inspect the contents of a binary and find out what options it was built with?

Actually... I can answer 'yes' to two of these questions:

1) Do you want to show this in the buildsystem progress? I believe the answer is to add the -v switch at build time, yes?
2) Do you want to inspect the contents of a binary and find out what options it was built with?  Yes, that would be cool to see as well.

Thanks.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#8 2018-03-18 14:14:29

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Get gcc to show all the CFLAGS including those auto set? [SOLVED]

graysky wrote:
Eschwartz wrote:

What is your goal here? Are you trying to debug a build? Do you want to show this in the buildsystem progress? Do you want to inspect the contents of a binary and find out what options it was built with?

Actually... I can answer 'yes' to two of these questions:

1) Do you want to show this in the buildsystem progress? I believe the answer is to add the -v switch at build time, yes?
2) Do you want to inspect the contents of a binary and find out what options it was built with?  Yes, that would be cool to see as well.

Thanks.

Well, ideally the build system will already verbosely print the command line it is executing. This doesn't show the options that gcc was configured to enable by default, of course. So -v would do that, at least by virtue of printing the configure line from the gcc PKGBUILD itself... but that would take some parsing. It does also show you the resolved FLAGS for -march=native so that's good.

Again, that is rather more verbose than most people will want wink and anyways this is probably best picked up from the environment CFLAGS rather than the project Makefile.

As for inspecting the contents of a binary, we (Arch Linux) want that too at least for packages. This would have the advantage of enhancing Reproducible Builds efforts, as well as allowing us to confirm that packages are actually being properly built with out makepkg.conf *FLAGS

You can use -frecord-gcc-switches for this. You can also enable debugging, as this should turn on -grecord-gcc-switches by default.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB