Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kerinin opened this issue Jun 29, 2018 · 4 comments
Closed

Comments

@kerinin
Copy link
Contributor

kerinin commented Jun 29, 2018

# 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

@jayconrod
Copy link
Contributor

Could you try running bazel clean --expunge and then building again? Bazel may cache some auto-configuration data which can become out of date. In the past, it's been an issue when upgrading Xcode, but I think it can also happen in different versions of Bazel.

-no-as-needed is not a flag that's added or removed by rules_go. The Go SDK doesn't do anything with that either. So I'm guessing this is coming from the C/C++ toolchain, and we just pass those flags through.

Are you able to build cc_binary targets?

@RookieX
Copy link

RookieX commented Jul 10, 2018

I have encountered the same problem as you. Have you solved it?

@girving
Copy link

girving commented Jul 11, 2018

I'm trying to build TensorFlow, and just upgraded to bazel 0.15.0 via homebrew. Even after bazel clean --expunge, I get

(master) poisson:kernels% cns test gather_nd_op_test.cc scatter_nd_op_test.cc 
bazel test gather_nd_op_test scatter_nd_op_test
Starting local Bazel server and connecting to it...
...........
INFO: Analysed 2 targets (53 packages loaded).
INFO: Found 2 test targets...
...
ERROR: /private/var/tmp/_bazel_irving/d4bad52af7e8ccc6c91f211db4181990/external/protobuf_archive/BUILD:260:1: Linking of rule '@protobuf_archive//:js_embed' failed (Exit 1)
ld: unknown option: -no-as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)
INFO: Elapsed time: 109.611s, Critical Path: 31.43s
INFO: 920 processes: 920 local.
FAILED: Build did NOT complete successfully
//tensorflow/core/kernels:scatter_nd_op_test                          NO STATUS

FAILED: Build did NOT complete successfully

This is with Mac OS 10.13.5, TensorFlow commit ae1056ea22c8462668e168741fae1b456c9155d9.

@girving
Copy link

girving commented Jul 11, 2018

bazelbuild/bazel#5468 notes that this is fixed at HEAD. This issue should presumably be closed as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants