• Russ Cox's avatar
    runtime/cgo: move common symbol overrides into 6c-compiled code · 5bffa3b8
    Russ Cox authored
    There are some function pointers declared by 6c in
    package runtime without initialization and then also
    declared in package runtime/cgo with initialization,
    so that if runtime/cgo is linked in, the function pointers
    are non-nil, and otherwise they are nil. We depend on
    this property for implementing non-essential cgo hooks
    in package runtime.
    
    The declarations in package runtime are 6c-compiled
    and end up in .6 files. The declarations in package runtime/cgo
    are gcc-compiled and end up in .o files. Since 6l links the .6
    and .o files together, this all works.
    
    However, when we switch to "external linking" mode,
    6l will not see the .o files, and it would be up to the host linker
    to resolve the two into a single initialized symbol.
    Not all host linkers will do this (in particular OS X gcc will not).
    
    To fix this, move the cgo declarations into 6c-compiled code,
    so that they end up in .6 files, so that 6l gets them no matter what.
    
    R=golang-dev
    CC=golang-dev
    https://golang.org/cl/7440045
    5bffa3b8
gcc_darwin_386.c 4.42 KB