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

Fail to build/run gtest cc_test on macOS due to unknown options for ld. #38

Open
pauldruce opened this issue Feb 8, 2024 · 0 comments

Comments

@pauldruce
Copy link

pauldruce commented Feb 8, 2024

Hello, I've been trying to get a minimal C++ project working with please.

I want to be able to run googletest tests and hit the following build error when using cc_test

❯ plz build
Build stopped after 10.26s. 1 target failed:
    //src:my_test
Error building target //src:my_test: exit status 1
ld: unknown options: -noall_load 
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I made a fork of this repository, changed the flag -all_load to -force_load and removed the -noall_load flags from build_defs/cc.build_defs. I can build and run the test with that change.

However, the GitHub actions for this repository are failing.
I'm not convinced they are failing due to this change, though, as other pull requests have them failing in the same way.

I'm opening this issue as a means of communication.
I'd be happy to help address this however I can.


Here is a minimal set of files to reproduce this issue:

contents of .plzconfig

[please]
version = 17.7.0

[parse]
preloadsubincludes = ///cc//build_defs:cc

[Plugin "cc"]
Target = //plugins:cc

contents of plugins/cc/BUILD

plugin_repo(
  name = "cc",
  revision = "v0.4.0",
  plugin = "cc-rules",
  owner = "please-build",
)

contents of third_party/cc/BUILD

github_repo(
    name = "gtest",
    bazel_compat = True,
    repo = "google/googletest",
    revision = "release-1.8.1",
)

cc_library(
    name = "main",
    deps = [
        "///third_party/cc/gtest//:gtest_main",
    ],
    visibility = ["PUBLIC"],
)

contents of src/BUILD

subinclude("///cc//build_defs:c")
package(cc = {
    "test_main": "//third_party/cc:main",
})

cc_test(
    name = "my_test",
    srcs = ["test.cc"],
)

contents of src/test.cc

#include "gtest/gtest.h"

TEST(GTest, Number1) {
  int a = 5;
  int b = 7;
  EXPECT_EQ(12, a + b);
}
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

1 participant