From 9e4dc6f37f75840d1193accae697a0e9283f5384 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 13 Oct 2021 12:46:33 -0700 Subject: [PATCH] cmd/link/internal/ld: don't use linkname before 1.12 Before the 1.12 release the use of linkname did not prevent a compiler error for an empty function body (see #23311). Add some build tags so that cmd/link will build with earlier releases. It's true that we currently require Go 1.16 as the bootstrap compiler (#44505). But for this simple case keep things working with older compilers for now. Change-Id: I67fe021406096c64c01d6e2c9adbcc4388988a6e Reviewed-on: https://go-review.googlesource.com/c/go/+/355690 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Russ Cox --- src/cmd/link/internal/ld/outbuf_darwin.go | 3 +++ src/cmd/link/internal/ld/outbuf_nofallocate.go | 4 ++-- src/cmd/link/internal/ld/outbuf_notdarwin.go | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cmd/link/internal/ld/outbuf_darwin.go b/src/cmd/link/internal/ld/outbuf_darwin.go index 6920a0a843..b1ee3c5628 100644 --- a/src/cmd/link/internal/ld/outbuf_darwin.go +++ b/src/cmd/link/internal/ld/outbuf_darwin.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin && go1.12 +// +build darwin,go1.12 + package ld import ( diff --git a/src/cmd/link/internal/ld/outbuf_nofallocate.go b/src/cmd/link/internal/ld/outbuf_nofallocate.go index 6564bd54a3..3bffe4543d 100644 --- a/src/cmd/link/internal/ld/outbuf_nofallocate.go +++ b/src/cmd/link/internal/ld/outbuf_nofallocate.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !darwin && !linux -// +build !darwin,!linux +//go:build (!darwin && !linux) || (darwin && !go1.12) +// +build !darwin,!linux darwin,!go1.12 package ld diff --git a/src/cmd/link/internal/ld/outbuf_notdarwin.go b/src/cmd/link/internal/ld/outbuf_notdarwin.go index f9caa413e3..85e64421a3 100644 --- a/src/cmd/link/internal/ld/outbuf_notdarwin.go +++ b/src/cmd/link/internal/ld/outbuf_notdarwin.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !darwin -// +build !darwin +//go:build !darwin || (darwin && !go1.12) +// +build !darwin darwin,!go1.12 package ld -- 2.48.1