Bug 59884

Summary: Unexpected warning pragma GCC target
Product: gcc Reporter: Joey Ye <joey.ye>
Component: targetAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: chrbr, ramana
Priority: P3    
Version: 4.9.0   
Target Milestone: ---   
Host: Target: arm
Build: Known to work:
Known to fail: Last reconfirmed: 2015-04-30 00:00:00
Bug Depends on: 52144    
Bug Blocks:    

Description Joey Ye 2014-01-20 03:07:45 UTC
Affected target: arm. (x86/x86_64 passes)
Affected version: trunk 20140109, 4.8, 4.7

~/cases/pragma $ cat p.c
#pragma GCC push_options
#pragma GCC optimize("O2")
int foo(int a){
return a+1;
}
#pragma GCC pop_options

~/cases/pragma $ arm-none-eabi-gcc p.c -c
p.c:6:9: warning: #pragma GCC target is not supported for this machine [-Wpragmas]
 #pragma GCC pop_options
Comment 1 Andrew Pinski 2014-01-20 03:46:30 UTC
Comes from:
  if (p->target_binary != target_option_current_node)
    {
      (void) targetm.target_option.pragma_parse (NULL_TREE, p->target_binary);
      target_option_current_node = p->target_binary;
    }


The front-end expects the target always to implement these target hooks it seems rather than the default.

Really I think the arm back-end should implement them so that thumb2 code can be in the same source file as arm32 code and would help out LTO when people mix and match them.
Comment 2 Joey Ye 2014-01-20 03:56:03 UTC
(In reply to Andrew Pinski from comment #1)
> Comes from:
>   if (p->target_binary != target_option_current_node)
>     {
>       (void) targetm.target_option.pragma_parse (NULL_TREE,
> p->target_binary);
>       target_option_current_node = p->target_binary;
>     }
> 
> 
> The front-end expects the target always to implement these target hooks it
> seems rather than the default.
> 
> Really I think the arm back-end should implement them so that thumb2 code
> can be in the same source file as arm32 code and would help out LTO when
> people mix and match them.
It is a useful feature on ARM. I don't know why it isn't support now.

But this warning still need to be fixed as there are always some targets not supportting this pragma.
Comment 3 Ramana Radhakrishnan 2015-04-30 09:59:07 UTC
https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01977.html are the seeds of fixing this. A lot more will be needed than this basic set of patches to support more of this. Christian Bruel is looking into this.
Comment 4 chrbr 2015-05-20 12:59:35 UTC
#pragma GCC target relies on the target_attribute work

*** This bug has been marked as a duplicate of bug 52144 ***