On Fri, Jun 9, 2017 at 7:14 AM, Ian Lance Taylor <i...@golang.org> wrote: > This recent patch > https://gcc.gnu.org/ml/gcc-patches/2017-06/msg00518.html turned on > block partitioning even when profiling is not enabled. This can break > code compiled with -fsplit-stack, if the cold partition calls a > function that is not compiled with -fsplit-stack (such as a C library > function). The problem is that when the linker sees a split-stack > function call a non-split-stack function, it adjusts the function > header to request more stack space. This doesn't work if the call is > in the cold partition, as the linker doesn't know how to find the > header to adjust. You can see this by trying to build the Go library > using the gold linker with this patch. > > This patch fixes the problem by disabling an implicit > -freorder-blocks-and-partition when -fsplit-stack is turned on. If > the user explicitly requested -freorder-blocks-and-partition we leave > it alone, assuming that they know what they are doing. But if it was > only turned it on implicitly because of the optimization level we turn > it off. > > This is done in both the main option handling code and in the Go > frontend option handling, because the Go frontend implicitly turns on > -fsplit-stack itself. > The test case in the patch fails to build when using the gold linker > without the patch. > > Bootstrapped and ran split-stack test cases on x86_64-pc-linux-gnu. > > I plan to commit this tomorrow unless I hear objections.
Ok. > Ian > > > 2017-06-08 Ian Lance Taylor <i...@golang.org> > > * opts.c (finish_options): If -fsplit-stack, disable implicit > -forder-blocks-and-partition. > > 2017-06-08 Ian Lance Taylor <i...@golang.org> > > * go-lang.c (go_langhook_post_options): If -fsplit-stack is turned > on, disable implicit -forder-blocks-and-partition. > > 2017-06-08 Ian Lance Taylor <i...@golang.org> > > * gcc.dg/tree-prof/split-1.c: New test.