bazelbuild / rules_cc

C++ Rules for Bazel
https://bazel.build
Apache License 2.0
189 stars 94 forks source link

Bazel builds using rules_cc on recent (Ventura, Sonoma) MacOS fail due to -undefined dynamic_lookup #229

Open AIWintermuteAI opened 4 months ago

AIWintermuteAI commented 4 months ago

Description of the problem / feature request:

Bazel builds using rules_cc on recent (Ventura, Sonoma) MacOS fail with

compiling lib/findprog-in.c...
./lib/findprog-in.c:137:25: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                    if (eaccess (progpathname, X_OK) == 0)
                        ^
./lib/findprog-in.c:137:25: note: did you mean 'access'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:431:6: note: 'access' declared here
int      access(const char *, int);
         ^
./lib/findprog-in.c:211:21: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                if (eaccess (progpathname, X_OK) == 0)
                    ^
2 errors generated.

The root cause of this issue was that https://github.com/bazelbuild/bazel/pull/16414 was not merged to rules_cc, but only to rules_llvm and apple_support. Which removed the culprit -undefined dynamic_lookup.

This issue gives more insight in the problem: https://github.com/bazelbuild/rules_foreign_cc/issues/859#issuecomment-2216704874

What operating system are you running Bazel on?

image

What's the output of bazel info release?

release 6.0.0- (@non-git)

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

Conda forge

What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?

    maybe(
        http_archive,
        name = "rules_cc",
        sha256 = "3d9e271e2876ba42e114c9b9bc51454e379cbf0ec9ef9d40e2ae4cec61a31b40",
        strip_prefix = "rules_cc-0.0.6",
        urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz"],
    )

What Bazel options do you use to trigger the issue? What C++ toolchain do you use?

Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: x86_64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin