Skip to content

ld: unknown option: -no-as-needed when compiling GoStdLib with bazel 0.15.0 #1579

@kerinin

Description

@kerinin
# WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "io_bazel_rules_go",
    urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.12.1/rules_go-0.12.1.tar.gz"],
    sha256 = "8b68d0630d63d95dacc0016c3bb4b76154fe34fca93efd65d1c366de3fcb4294",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
# BUILD
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
    name = "go_default_library",
    srcs = ["main.go"],
    importpath = "github.com/example/test",
    visibility = ["//visibility:public"],
)
// main.go
package main

import "fmt"

func main() {
	fmt.Println("vim-go")
}
$ bazel build ...
INFO: Build options have changed, discarding analysis cache.
INFO: Analysed target //:go_default_library (13 packages loaded).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_rmichael/06e60338365ef2dc6ee66ff039467a66/external/io_bazel_rules_go/BUILD.bazel:8:1: GoStdlib external/io_bazel_rules_go/darwin_amd64_stripped/stdlib~/pkg failed (Exit 1)
# runtime/cgo
ld: unknown option: -no-as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)
GoStdlib: error running subcommand: exit status 2
Target //:go_default_library failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 27.030s, Critical Path: 12.65s
INFO: 4 processes: 4 darwin-sandbox.
FAILED: Build did NOT complete successfully

$ bazel version
Build label: 0.15.0-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 26 12:42:27 2018 (1530016947)
Build timestamp: 1530016947
Build timestamp as int: 1530016947

The error doesn't happen with bazel 0.14.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions