]> Cypherpunks repositories - gostls13.git/commit
runtime/race: do not use cgo on macOS
authorRuss Cox <rsc@golang.org>
Wed, 16 Nov 2022 01:36:10 +0000 (20:36 -0500)
committerGopher Robot <gobot@golang.org>
Wed, 16 Nov 2022 21:38:55 +0000 (21:38 +0000)
commit5bf9aeba1cfec8804425f3838b661fd6c2eb26ff
treec16d485540bda9541aad85c678011f46b6c253f5
parent4d1052b0d4e8916fefb542ba8a6f9d325db214f6
runtime/race: do not use cgo on macOS

The use of an empty import "C" to trigger cgo in runtime/race
serves two purposes:

1. Cause the runtime to use the C library to create system threads,
   because the race syso implementation expects things like
   thread-local storage to work correctly.

2. Derive the right set of //go:cgo_import_dynamic comments
   to pass to the Go linker, so that it doesn't diagnose them as
   undefined references.

On macOS, (1) is unnecessary because using the C library
(via DLL calls) is the only way the runtime ever creates threads.

We can accomplish (2) by writing those comments ourselves.

Having done that in this CL, cgo is no longer needed to run
the race detector on macOS, which means that having a
pre-compiled set of .a files is no longer necessary,
nor is having Xcode for use with cgo when rebuilding those .a files.

Change-Id: Iee24cc67900eb542141b32beaadafb2c94f5fe26
Reviewed-on: https://go-review.googlesource.com/c/go/+/451055
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/go/internal/work/init.go
src/cmd/go/testdata/script/install_msan_and_race_and_asan_require_cgo.txt
src/runtime/race.go
src/runtime/race/doc.go
src/runtime/race/mkcgo.sh [new file with mode: 0755]
src/runtime/race/race.go
src/runtime/race/race_darwin_amd64.go [new file with mode: 0644]
src/runtime/race/race_darwin_arm64.go [new file with mode: 0644]