From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85867 invoked by alias); 18 Feb 2020 20:03:47 -0000 Mailing-List: contact gcc-cvs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-cvs-owner@gcc.gnu.org Received: (qmail 85791 invoked by uid 17); 18 Feb 2020 20:03:46 -0000 Date: Tue, 18 Feb 2020 20:03:00 -0000 Message-ID: <20200218200346.85783.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ian Lance Taylor To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-6712] cmd/go: update -DGOPKGPATH to use current pkgpath encoding X-Act-Checkin: gcc X-Git-Author: Ian Lance Taylor X-Git-Refname: refs/heads/master X-Git-Oldrev: ce7b39d0fc694e5ec80520b7cc76f91a5476d7db X-Git-Newrev: 855b4aaeabdcddce04ff9295c4b0e6c7aa6db96b X-SW-Source: 2020-02/txt/msg03657.txt.bz2 https://gcc.gnu.org/g:855b4aaeabdcddce04ff9295c4b0e6c7aa6db96b commit r10-6712-g855b4aaeabdcddce04ff9295c4b0e6c7aa6db96b Author: Ian Lance Taylor Date: Mon Feb 17 18:16:41 2020 -0800 cmd/go: update -DGOPKGPATH to use current pkgpath encoding This will need to be done in the gc version too, probably more cleverly. This version will ensure that the next GCC release works correctly when using the GCC version of the go tool. Updates golang/go#37272 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/219817 Diff: --- gcc/go/gofrontend/MERGE | 2 +- libgo/go/cmd/go/internal/work/gccgo.go | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 47dd5fb..ce10ee1 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -8505defaa91ecc5b42afd02eb335981e8b02b288 +d5d00d310ec33aeb18f33f807956ec0c4eeea6bb The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/cmd/go/internal/work/gccgo.go b/libgo/go/cmd/go/internal/work/gccgo.go index f6fa17d..63d5c62 100644 --- a/libgo/go/cmd/go/internal/work/gccgo.go +++ b/libgo/go/cmd/go/internal/work/gccgo.go @@ -596,14 +596,28 @@ func gccgoPkgpath(p *load.Package) string { return p.ImportPath } +// gccgoCleanPkgpath returns the form of p's pkgpath that gccgo uses +// for symbol names. This is like gccgoPkgpathToSymbolNew in cmd/cgo/out.go. func gccgoCleanPkgpath(p *load.Package) string { - clean := func(r rune) rune { + ppath := gccgoPkgpath(p) + bsl := []byte{} + changed := false + for _, c := range []byte(ppath) { switch { - case 'A' <= r && r <= 'Z', 'a' <= r && r <= 'z', - '0' <= r && r <= '9': - return r + case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z', + '0' <= c && c <= '9', c == '_': + bsl = append(bsl, c) + case c == '.': + bsl = append(bsl, ".x2e"...) + changed = true + default: + encbytes := []byte(fmt.Sprintf("..z%02x", c)) + bsl = append(bsl, encbytes...) + changed = true } - return '_' } - return strings.Map(clean, gccgoPkgpath(p)) + if !changed { + return ppath + } + return string(bsl) }