Problem could be easy reproduced by "gcc412 -O1 -fwhole-program -S
gcc-4.1.2/gcc/testsuite/gcc.gd/tree-ssa/wholeprogram-2.c". The output file
wholeprogram-2.s contains:
        .file   "wholeprogram-2.c"
        .text
        .type   externally_visible_function, @function
externally_visible_function:
        pushl   %ebp
        movl    %esp, %ebp
        popl    %ebp
        ret
        .size   externally_visible_function, .-externally_visible_function
        .ident  "GCC: (GNU) 4.1.2"
        .section        .note.GNU-stack,"",@progbits

Can see the line ".globl externally_visible_function" is absent, so
externally_visible_function() become local, but not public.
It is may be other solution, but my patch is really simple:

diff -Nrcpad gcc-4.1.2-ori/gcc/cgraphunit.c gcc-4.1.2/gcc/cgraphunit.c
*** gcc-4.1.2-ori/gcc/cgraphunit.c      Fri Jan  5 22:44:10 2007
--- gcc-4.1.2/gcc/cgraphunit.c  Fri Mar 16 01:11:24 2007
*************** process_function_and_variable_attributes
*** 937,942 ****
--- 937,943 ----
          if (node->local.finalized)
            cgraph_mark_needed_node (node);
          node->externally_visible = true;
+         node->local.externally_visible = true;
        }
      }
    for (vnode = cgraph_varpool_nodes; vnode != first_var; vnode = vnode->next)


-- 
           Summary: functions with __attribute__((externelly_visible))
                    becomes static when -O -fwhole-program
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: leo at yuriev dot ru


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31192

Reply via email to