https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66870

--- Comment #3 from Ian Lance Taylor <ian at airs dot com> ---
> In gcc.c there is STACK_SPLIT_SPEC which sets --wrap=pthread_create in the 
> LINK_COMMAND_SPEC if -fsplit-stack is set.  Is there a reason there are 2 
> different split stack dependent link options are being set in two different 
> ways?


Sort of.  All uses of -fsplit-stack can and should pass
-Wl,--wrap=pthread_create to the linker.  That option does nothing if the
program is not threaded.  If the program is threaded it will cause the code in
libgcc/generic-morestack-thread.c to be used.

All uses of -fsplit-stack and -static for threaded code should pass
-Wl,-u,pthread_create to the linker.  Otherwise, in some cases, we may not pull
in the threading functions we need.  But, unlike the --wrap option, if the
program is not threaded, and not linked against -lpthread, this option will
cause the link to fail.  Go programs are always threaded, so it's safe to add
this in gospec.c.  It's not safe to add it in a link spec in gcc.c, unless we
have some way of determining from the link spec whether the program is
threaded.  (There is some discussion of why this is needed at
https://groups.google.com/d/msg/golang-nuts/y2RIy0XLJ24/uFIdOE8wPL8J .)

Reply via email to