Bug 39851

Summary: gcc -Q --help=target does not list extensions selected by -march=
Product: gcc Reporter: Alexander Monakov <amonakov>
Component: otherAssignee: Martin Liška <marxin>
Status: RESOLVED FIXED    
Severity: trivial CC: bratsinot, gcc-bugs, kjslag, rhill
Priority: P3    
Version: 4.5.0   
Target Milestone: ---   
Host: Target:
Build: Known to work: 6.4.0, 7.2.0, 8.0
Known to fail: 5.4.0 Last reconfirmed: 2009-04-22 23:29:02

Description Alexander Monakov 2009-04-22 14:58:33 UTC
Even though -march=nocona enables SSE2 and SSE3 extensions, gcc -Q --help=target does not list them as enabled.  This may be confusing to the user (see http://gcc.gnu.org/ml/gcc-help/2009-04/msg00293.html ):

$ gcc -Q --help=target -march=nocona | grep msse[23]
  -msse2                      		[disabled]
  -msse3                      		[disabled]

-msse[23] would be enabled in gcc/config/i386/i386.c:override_options(), called from toplev.c:process_options(), which is in turn called from do_compile().  OTOH, --help=target is processed in decode_options(), which is executed before do_compile.  It would be nice if --help=target processing could see options overridden by target backend.
Comment 1 Andrew Pinski 2009-04-22 23:29:02 UTC
Confirmed.
Comment 2 Alexander Monakov 2012-06-01 14:05:12 UTC
*** Bug 43718 has been marked as a duplicate of this bug. ***
Comment 3 Alexander Monakov 2012-06-01 14:06:12 UTC
*** Bug 53554 has been marked as a duplicate of this bug. ***
Comment 4 Alexander Monakov 2013-03-04 09:29:32 UTC
*** Bug 56507 has been marked as a duplicate of this bug. ***
Comment 5 Daniel Santos 2017-07-22 19:48:56 UTC
Confirmed.

$ diff -u0 <(gcc -Q -march=sandybridge --help=target) <(gcc -march=native -Q --help=target)
--- /dev/fd/63	2017-07-22 14:49:57.839642336 -0500
+++ /dev/fd/62	2017-07-22 14:49:57.839642336 -0500
@@ -16 +16 @@
-  -maes                       		[disabled]
+  -maes                       		[enabled]
@@ -26 +26 @@
-  -mavx                       		[disabled]
+  -mavx                       		[enabled]
@@ -49 +49 @@
-  -mcx16                      		[disabled]
+  -mcx16                      		[enabled]
@@ -62 +62 @@
-  -mfxsr                      		[disabled]
+  -mfxsr                      		[enabled]
@@ -79 +79 @@
-  -mmmx                       		[disabled]
+  -mmmx                       		[enabled]
@@ -89 +89 @@
-  -mno-sse4                   		[enabled]
+  -mno-sse4                   		[disabled]
@@ -95 +95 @@
-  -mpclmul                    		[disabled]
+  -mpclmul                    		[enabled]
@@ -97 +97 @@
-  -mpopcnt                    		[disabled]
+  -mpopcnt                    		[enabled]
@@ -112 +112 @@
-  -msahf                      		[disabled]
+  -msahf                      		[enabled]
@@ -116,2 +116,2 @@
-  -msse                       		[disabled]
-  -msse2                      		[disabled]
+  -msse                       		[enabled]
+  -msse2                      		[enabled]
@@ -119,4 +119,4 @@
-  -msse3                      		[disabled]
-  -msse4                      		[disabled]
-  -msse4.1                    		[disabled]
-  -msse4.2                    		[disabled]
+  -msse3                      		[enabled]
+  -msse4                      		[enabled]
+  -msse4.1                    		[enabled]
+  -msse4.2                    		[enabled]
@@ -126 +126 @@
-  -mssse3                     		[disabled]
+  -mssse3                     		[enabled]
@@ -135 +135 @@
-  -mtune=                     		
+  -mtune=                     		sandybridge
@@ -142 +142 @@
-  -mxsave                     		[disabled]
+  -mxsave                     		[enabled]
@@ -144 +144 @@
-  -mxsaveopt                  		[disabled]
+  -mxsaveopt                  		[enabled]
Comment 6 Martin Liška 2017-08-08 11:09:02 UTC
I've got a patch candidate, let's see what maintainers say about it.
Comment 7 Martin Liška 2017-08-29 07:46:41 UTC
Author: marxin
Date: Tue Aug 29 07:46:10 2017
New Revision: 251400

URL: https://gcc.gnu.org/viewcvs?rev=251400&root=gcc&view=rev
Log:
Fix --help=target (PR other/39851).

2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* gcc.c (driver_handle_option): Add new argument.
	* opts-common.c (handle_option): Pass
	target_option_override_hook.
	* opts-global.c (lang_handle_option): Add new option.
	(set_default_handlers):  Add new argument.
	(decode_options): Likewise.
	* opts.c (target_handle_option): Likewise.
	(common_handle_option): Call target_option_override_hook.
	* opts.h (struct cl_option_handler_func): Add hook for
	target option override.
	(struct cl_option_handlers): Likewise.
	(set_default_handlers): Add new argument.
	(decode_options): Likewise.
	(common_handle_option): Likewise.
	(target_handle_option): Likewise.
	* toplev.c (toplev::main): Pass targetm.target_option.override
	hook.
2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* c-common.c (parse_optimize_options): Add argument to function
	call.
	* c-pragma.c (handle_pragma_diagnostic): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/c-family/c-pragma.c
    trunk/gcc/gcc.c
    trunk/gcc/opts-common.c
    trunk/gcc/opts-global.c
    trunk/gcc/opts.c
    trunk/gcc/opts.h
    trunk/gcc/toplev.c
Comment 8 Martin Liška 2017-08-29 07:49:10 UTC
Fixed on trunk, queued for backporting.
Comment 9 Martin Liška 2017-08-29 08:36:20 UTC
Author: marxin
Date: Tue Aug 29 08:35:46 2017
New Revision: 251406

URL: https://gcc.gnu.org/viewcvs?rev=251406&root=gcc&view=rev
Log:
Fix --help=target (Ada) (PR other/39851)

2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* gcc-interface/trans.c (Pragma_to_gnu): Set argument to NULL.

Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/gcc-interface/trans.c
Comment 10 Aldy Hernandez 2017-09-13 17:35:21 UTC
Author: aldyh
Date: Wed Sep 13 17:34:49 2017
New Revision: 252599

URL: https://gcc.gnu.org/viewcvs?rev=252599&root=gcc&view=rev
Log:
Fix --help=target (PR other/39851).

2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* gcc.c (driver_handle_option): Add new argument.
	* opts-common.c (handle_option): Pass
	target_option_override_hook.
	* opts-global.c (lang_handle_option): Add new option.
	(set_default_handlers):  Add new argument.
	(decode_options): Likewise.
	* opts.c (target_handle_option): Likewise.
	(common_handle_option): Call target_option_override_hook.
	* opts.h (struct cl_option_handler_func): Add hook for
	target option override.
	(struct cl_option_handlers): Likewise.
	(set_default_handlers): Add new argument.
	(decode_options): Likewise.
	(common_handle_option): Likewise.
	(target_handle_option): Likewise.
	* toplev.c (toplev::main): Pass targetm.target_option.override
	hook.
2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* c-common.c (parse_optimize_options): Add argument to function
	call.
	* c-pragma.c (handle_pragma_diagnostic): Likewise.

Modified:
    branches/range-gen2/gcc/ChangeLog
    branches/range-gen2/gcc/c-family/ChangeLog
    branches/range-gen2/gcc/c-family/c-common.c
    branches/range-gen2/gcc/c-family/c-pragma.c
    branches/range-gen2/gcc/gcc.c
    branches/range-gen2/gcc/opts-common.c
    branches/range-gen2/gcc/opts-global.c
    branches/range-gen2/gcc/opts.c
    branches/range-gen2/gcc/opts.h
    branches/range-gen2/gcc/toplev.c
Comment 11 Aldy Hernandez 2017-09-13 17:35:45 UTC
Author: aldyh
Date: Wed Sep 13 17:35:13 2017
New Revision: 252601

URL: https://gcc.gnu.org/viewcvs?rev=252601&root=gcc&view=rev
Log:
Fix --help=target (Ada) (PR other/39851)

2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* gcc-interface/trans.c (Pragma_to_gnu): Set argument to NULL.

Modified:
    branches/range-gen2/gcc/ada/ChangeLog
    branches/range-gen2/gcc/ada/gcc-interface/trans.c
Comment 12 Martin Liška 2017-09-15 08:14:55 UTC
Author: marxin
Date: Fri Sep 15 08:14:24 2017
New Revision: 252786

URL: https://gcc.gnu.org/viewcvs?rev=252786&root=gcc&view=rev
Log:
Backport r251406

2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* gcc-interface/trans.c (Pragma_to_gnu): Set argument to NULL.

Modified:
    branches/gcc-7-branch/gcc/ada/ChangeLog
    branches/gcc-7-branch/gcc/ada/gcc-interface/trans.c
Comment 13 Martin Liška 2017-09-15 08:19:05 UTC
Author: marxin
Date: Fri Sep 15 08:18:34 2017
New Revision: 252787

URL: https://gcc.gnu.org/viewcvs?rev=252787&root=gcc&view=rev
Log:
Subject: Backport r251400

2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* gcc.c (driver_handle_option): Add new argument.
	* opts-common.c (handle_option): Pass
	target_option_override_hook.
	* opts-global.c (lang_handle_option): Add new option.
	(set_default_handlers):  Add new argument.
	(decode_options): Likewise.
	* opts.c (target_handle_option): Likewise.
	(common_handle_option): Call target_option_override_hook.
	* opts.h (struct cl_option_handler_func): Add hook for
	target option override.
	(struct cl_option_handlers): Likewise.
	(set_default_handlers): Add new argument.
	(decode_options): Likewise.
	(common_handle_option): Likewise.
	(target_handle_option): Likewise.
	* toplev.c (toplev::main): Pass targetm.target_option.override
	hook.
2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* c-common.c (parse_optimize_options): Add argument to function
	call.
	* c-pragma.c (handle_pragma_diagnostic): Likewise.

Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/c-family/ChangeLog
    branches/gcc-7-branch/gcc/c-family/c-common.c
    branches/gcc-7-branch/gcc/c-family/c-pragma.c
    branches/gcc-7-branch/gcc/gcc.c
    branches/gcc-7-branch/gcc/opts-common.c
    branches/gcc-7-branch/gcc/opts-global.c
    branches/gcc-7-branch/gcc/opts.c
    branches/gcc-7-branch/gcc/opts.h
    branches/gcc-7-branch/gcc/toplev.c
Comment 14 Martin Liška 2017-09-15 09:20:08 UTC
Author: marxin
Date: Fri Sep 15 09:19:36 2017
New Revision: 252797

URL: https://gcc.gnu.org/viewcvs?rev=252797&root=gcc&view=rev
Log:
Backport r251400

2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* gcc.c (driver_handle_option): Add new argument.
	* opts-common.c (handle_option): Pass
	target_option_override_hook.
	* opts-global.c (lang_handle_option): Add new option.
	(set_default_handlers):  Add new argument.
	(decode_options): Likewise.
	* opts.c (target_handle_option): Likewise.
	(common_handle_option): Call target_option_override_hook.
	* opts.h (struct cl_option_handler_func): Add hook for
	target option override.
	(struct cl_option_handlers): Likewise.
	(set_default_handlers): Add new argument.
	(decode_options): Likewise.
	(common_handle_option): Likewise.
	(target_handle_option): Likewise.
	* toplev.c (toplev::main): Pass targetm.target_option.override
	hook.
2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* c-common.c (parse_optimize_options): Add argument to function
	call.
	* c-pragma.c (handle_pragma_diagnostic): Likewise.

Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/c-family/ChangeLog
    branches/gcc-6-branch/gcc/c-family/c-common.c
    branches/gcc-6-branch/gcc/c-family/c-pragma.c
    branches/gcc-6-branch/gcc/gcc.c
    branches/gcc-6-branch/gcc/opts-common.c
    branches/gcc-6-branch/gcc/opts-global.c
    branches/gcc-6-branch/gcc/opts.c
    branches/gcc-6-branch/gcc/opts.h
    branches/gcc-6-branch/gcc/toplev.c
Comment 15 Martin Liška 2017-09-15 09:21:09 UTC
Author: marxin
Date: Fri Sep 15 09:20:37 2017
New Revision: 252798

URL: https://gcc.gnu.org/viewcvs?rev=252798&root=gcc&view=rev
Log:
Backport r251406

2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-29  Martin Liska  <mliska@suse.cz>

	PR other/39851
	* gcc-interface/trans.c (Pragma_to_gnu): Set argument to NULL.

Modified:
    branches/gcc-6-branch/gcc/ada/ChangeLog
    branches/gcc-6-branch/gcc/ada/gcc-interface/trans.c
Comment 16 Martin Liška 2017-09-15 09:27:02 UTC
Fixed on GCC 6 and 7 branches, no plans for 5 branch because it's more complicated to backport.
Comment 17 Daniel Santos 2017-09-16 08:15:07 UTC
Thanks for all your work on this Martin.  I've put a script up on my github account (https://github.com/daniel-santos/distccflags), updated the Gentoo Distcc instructions and sent distcc a mail to notify them.

Thanks!
Comment 18 Martin Liška 2017-09-18 08:09:35 UTC
(In reply to Daniel Santos from comment #17)
> Thanks for all your work on this Martin.  I've put a script up on my github
> account (https://github.com/daniel-santos/distccflags), updated the Gentoo
> Distcc instructions and sent distcc a mail to notify them.
> 
> Thanks!

Good to hear it helped ;)