From patchwork Wed Feb 28 01:19:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 878884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-473977-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=golang.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Xrvu72uW"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zrd5G4pkyz9s2b for ; Wed, 28 Feb 2018 12:19:28 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=Q3MR/AfLJgTatvq9e9u5UE3UUWkY3IUtKDEcqbAcFqcpyU K8eTziLyDpjMQnSSNlzi/kVGAe31lWcUsLNN3WU7aZ5ngdf19hH1U5JUkfSVL5+G 7CWCM7qT2q3BrQ/5Gn6M21N6z7oZkDa8X30Dgm/SSSd86yYN2SjPJ2PEy4t0Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=k6oIcyYIUh3R+WGWJuciDhKQmy4=; b=Xrvu72uWoZ3pqtomlIe3 ag0NW6QcaxuMRrnsC679KdhP6rzPLFHQbZbtfPjEXcGKAmjHQDFkovioYcmq9H+h oEg6R/BBhQSl1dqGGCIYmj0xzd7i42sGg6cRncZYsUvvzFeN3wkop5CL51HaXKBq ZzCN2fFVgBS3GoLiBDyt9J8= Received: (qmail 77170 invoked by alias); 28 Feb 2018 01:19:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 76499 invoked by uid 89); 28 Feb 2018 01:19:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=UD:Dir, Home X-HELO: mail-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Feb 2018 01:19:17 +0000 Received: by mail-wm0-f53.google.com with SMTP id x7so2011958wmc.0 for ; Tue, 27 Feb 2018 17:19:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=E4fBrP4QM5MPHahqTZQdKdVyqEfxZvhE8GBXGkShmzQ=; b=JM5kUJcNxKNxKHDA76370Aq7dqVhrT9W0Mw0QoAsMyQmxX1Qro6WC4VwZ5MZkNncu+ 3R9zgrjt5yenyYsTyTLBxGLjGjyasTjH+AmIboxXAOk9t/sC+vtVQqJA7uD9zarRJ+ED 76cjSsWn3WFDcnaDpCkBlTqo3Wxqh+51MACOfMEe2gvjX6BRFdu73b7KDv7/6gZTyuou r0Ow7kk1hvVoCO2upOHFAYrkJKKO/VocggtDZt5uN2Ff0BFZIg/GJxjCFdsUlelvTS1v LuZQlW+n15WRsOwOhFRlYPoERjbeRqPGOBMzUYzRf3I8HLxFNahU9//gJ4aVSVaB0/1z rd2A== X-Gm-Message-State: APf1xPC4LsoXfzjeKVYkqELCq1zwt6dJPQ89Wiywx+eVQeFstzEBX19k B0tkAgusYjMDspaHX66Y6cnuvOtngD7hrHJgTN358Q== X-Google-Smtp-Source: AH8x225HE5mqm3dD6Ng5hGzJrmHQugAPUDCssobGxtQNpaXmk94zwdwZo85XPI9M+kFeL9tZcOKjkD7tCtpnjtz4oX0= X-Received: by 10.80.182.52 with SMTP id b49mr21397338ede.279.1519780755366; Tue, 27 Feb 2018 17:19:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.144.132 with HTTP; Tue, 27 Feb 2018 17:19:14 -0800 (PST) From: Ian Lance Taylor Date: Tue, 27 Feb 2018 17:19:14 -0800 Message-ID: Subject: libgo patch committed: Update to final Go 1.10 release To: gcc-patches , gofrontend-dev@googlegroups.com This patch to libgo updates it to the final Go 1.10 release. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 257954) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -8b3d6091801d485c74a9c92740c69673e39160b0 +bd7fc3c85d874344b18bbb0a738ec94dfb43794b The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/MERGE =================================================================== --- libgo/MERGE (revision 257914) +++ libgo/MERGE (working copy) @@ -1,4 +1,4 @@ -20e228f2fdb44350c858de941dff4aea9f3127b8 +bf86aec25972f3a100c3aa58a6abcbcc35bdea49 The first line of this file holds the git revision number of the last merge done from the master library sources. Index: libgo/VERSION =================================================================== --- libgo/VERSION (revision 257914) +++ libgo/VERSION (working copy) @@ -1 +1 @@ -go1.10rc2 +go1.10 Index: libgo/go/cmd/go/internal/load/pkg.go =================================================================== --- libgo/go/cmd/go/internal/load/pkg.go (revision 257914) +++ libgo/go/cmd/go/internal/load/pkg.go (working copy) @@ -1224,6 +1224,7 @@ func (p *Package) load(stk *ImportStack, // GNU binutils flagfile specifiers, sometimes called "response files"). // To be conservative, we reject almost any arg beginning with non-alphanumeric ASCII. // We accept leading . _ and / as likely in file system paths. +// There is a copy of this function in cmd/compile/internal/gc/noder.go. func SafeArg(name string) bool { if name == "" { return false Index: libgo/go/cmd/go/internal/work/exec.go =================================================================== --- libgo/go/cmd/go/internal/work/exec.go (revision 257914) +++ libgo/go/cmd/go/internal/work/exec.go (working copy) @@ -945,15 +945,20 @@ func splitPkgConfigOutput(out []byte) [] // Calls pkg-config if needed and returns the cflags/ldflags needed to build the package. func (b *Builder) getPkgConfigFlags(p *load.Package) (cflags, ldflags []string, err error) { if pkgs := p.CgoPkgConfig; len(pkgs) > 0 { + var pcflags []string + for len(pkgs) > 0 && strings.HasPrefix(pkgs[0], "--") { + pcflags = append(pcflags, pkgs[0]) + pkgs = pkgs[1:] + } for _, pkg := range pkgs { if !load.SafeArg(pkg) { return nil, nil, fmt.Errorf("invalid pkg-config package name: %s", pkg) } } var out []byte - out, err = b.runOut(p.Dir, p.ImportPath, nil, b.PkgconfigCmd(), "--cflags", "--", pkgs) + out, err = b.runOut(p.Dir, p.ImportPath, nil, b.PkgconfigCmd(), "--cflags", pcflags, "--", pkgs) if err != nil { - b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --cflags "+strings.Join(pkgs, " "), string(out)) + b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --cflags "+strings.Join(pcflags, " ")+strings.Join(pkgs, " "), string(out)) b.Print(err.Error() + "\n") return nil, nil, errPrintedOutput } @@ -963,15 +968,15 @@ func (b *Builder) getPkgConfigFlags(p *l return nil, nil, err } } - out, err = b.runOut(p.Dir, p.ImportPath, nil, b.PkgconfigCmd(), "--libs", "--", pkgs) + out, err = b.runOut(p.Dir, p.ImportPath, nil, b.PkgconfigCmd(), "--libs", pcflags, "--", pkgs) if err != nil { - b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --libs "+strings.Join(pkgs, " "), string(out)) + b.showOutput(nil, p.Dir, b.PkgconfigCmd()+" --libs "+strings.Join(pcflags, " ")+strings.Join(pkgs, " "), string(out)) b.Print(err.Error() + "\n") return nil, nil, errPrintedOutput } if len(out) > 0 { ldflags = strings.Fields(string(out)) - if err := checkLinkerFlags("CFLAGS", "pkg-config --cflags", ldflags); err != nil { + if err := checkLinkerFlags("LDFLAGS", "pkg-config --libs", ldflags); err != nil { return nil, nil, err } } Index: libgo/go/cmd/go/internal/work/security.go =================================================================== --- libgo/go/cmd/go/internal/work/security.go (revision 257914) +++ libgo/go/cmd/go/internal/work/security.go (working copy) @@ -34,6 +34,7 @@ import ( "fmt" "os" "regexp" + "strings" ) var re = regexp.MustCompile @@ -45,26 +46,42 @@ var validCompilerFlags = []*regexp.Regex re(`-O([^@\-].*)`), re(`-W`), re(`-W([^@,]+)`), // -Wall but not -Wa,-foo. + re(`-f(no-)?blocks`), + re(`-f(no-)?common`), + re(`-f(no-)?constant-cfstrings`), + re(`-f(no-)?exceptions`), + re(`-finput-charset=([^@\-].*)`), + re(`-f(no-)?lto`), + re(`-f(no-)?modules`), re(`-f(no-)?objc-arc`), re(`-f(no-)?omit-frame-pointer`), + re(`-f(no-)?openmp(-simd)?`), + re(`-f(no-)?permissive`), re(`-f(no-)?(pic|PIC|pie|PIE)`), + re(`-f(no-)?rtti`), re(`-f(no-)?split-stack`), re(`-f(no-)?stack-(.+)`), re(`-f(no-)?strict-aliasing`), re(`-fsanitize=(.+)`), re(`-g([^@\-].*)?`), re(`-m(arch|cpu|fpu|tune)=([^@\-].*)`), + re(`-m(no-)?avx[0-9a-z.]*`), + re(`-m(no-)?ms-bitfields`), re(`-m(no-)?stack-(.+)`), re(`-mmacosx-(.+)`), re(`-mnop-fun-dllimport`), + re(`-m(no-)?sse[0-9.]*`), + re(`-pedantic(-errors)?`), + re(`-pipe`), re(`-pthread`), - re(`-std=([^@\-].*)`), + re(`-?-std=([^@\-].*)`), re(`-x([^@\-].*)`), } var validCompilerFlagsWithNextArg = []string{ "-D", "-I", + "-isystem", "-framework", "-x", } @@ -79,16 +96,29 @@ var validLinkerFlags = []*regexp.Regexp{ re(`-m(arch|cpu|fpu|tune)=([^@\-].*)`), re(`-(pic|PIC|pie|PIE)`), re(`-pthread`), + re(`-?-static([-a-z0-9+]*)`), // Note that any wildcards in -Wl need to exclude comma, // since -Wl splits its argument at commas and passes // them all to the linker uninterpreted. Allowing comma // in a wildcard would allow tunnelling arbitrary additional // linker arguments through one of these. + re(`-Wl,--(no-)?as-needed`), + re(`-Wl,-Bdynamic`), + re(`-Wl,-Bstatic`), + re(`-Wl,--disable-new-dtags`), + re(`-Wl,--enable-new-dtags`), + re(`-Wl,--end-group`), + re(`-Wl,-framework,[^,@\-][^,]+`), + re(`-Wl,-headerpad_max_install_names`), + re(`-Wl,--no-undefined`), re(`-Wl,-rpath,([^,@\-][^,]+)`), + re(`-Wl,-search_paths_first`), + re(`-Wl,--start-group`), + re(`-Wl,-?-unresolved-symbols=[^,]+`), re(`-Wl,--(no-)?warn-([^,]+)`), - re(`[a-zA-Z0-9_].*\.(o|obj|dll|dylib|so)`), // direct linker inputs: x.o or libfoo.so (but not -foo.o or @foo.o) + re(`[a-zA-Z0-9_/].*\.(a|o|obj|dll|dylib|so)`), // direct linker inputs: x.o or libfoo.so (but not -foo.o or @foo.o) } var validLinkerFlagsWithNextArg = []string{ @@ -96,6 +126,7 @@ var validLinkerFlagsWithNextArg = []stri "-l", "-L", "-framework", + "-Wl,-framework", } func checkCompilerFlags(name, source string, list []string) error { @@ -147,10 +178,21 @@ Args: i++ continue Args } + + // Permit -Wl,-framework -Wl,name. + if i+1 < len(list) && + strings.HasPrefix(arg, "-Wl,") && + strings.HasPrefix(list[i+1], "-Wl,") && + load.SafeArg(list[i+1][4:]) && + !strings.Contains(list[i+1][4:], ",") { + i++ + continue Args + } + if i+1 < len(list) { - return fmt.Errorf("invalid flag in %s: %s %s", source, arg, list[i+1]) + return fmt.Errorf("invalid flag in %s: %s %s (see https://golang.org/s/invalidflag)", source, arg, list[i+1]) } - return fmt.Errorf("invalid flag in %s: %s without argument", source, arg) + return fmt.Errorf("invalid flag in %s: %s without argument (see https://golang.org/s/invalidflag)", source, arg) } } Bad: Index: libgo/go/cmd/go/internal/work/security_test.go =================================================================== --- libgo/go/cmd/go/internal/work/security_test.go (revision 257914) +++ libgo/go/cmd/go/internal/work/security_test.go (working copy) @@ -132,6 +132,9 @@ var goodLinkerFlags = [][]string{ {"-l", "世界"}, {"-L", "framework"}, {"-framework", "Chocolate"}, + {"-Wl,-framework", "-Wl,Chocolate"}, + {"-Wl,-framework,Chocolate"}, + {"-Wl,-unresolved-symbols=ignore-all"}, } var badLinkerFlags = [][]string{ @@ -185,6 +188,10 @@ var badLinkerFlags = [][]string{ {"-l", "-foo"}, {"-framework", "-Caffeine"}, {"-framework", "@Home"}, + {"-Wl,-framework,-Caffeine"}, + {"-Wl,-framework", "-Wl,@Home"}, + {"-Wl,-framework", "@Home"}, + {"-Wl,-framework,Chocolate,@Home"}, {"-x", "--c"}, {"-x", "@obj"}, {"-Wl,-rpath,@foo"},