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

Broken Auto Genreated CC Toolchain when Using ccache/clang #130

Open
chenhao94 opened this issue May 19, 2022 · 0 comments
Open

Broken Auto Genreated CC Toolchain when Using ccache/clang #130

chenhao94 opened this issue May 19, 2022 · 0 comments
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.

Comments

@chenhao94
Copy link

Description of the problem / feature request:

cc toolchain is not correctly generated when using ccache with clang, while ccache with gcc works.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

chenhao@chenhao:~/bazel-ccache$ cat WORKSPACE
chenhao@chenhao:~/bazel-ccache$ cat BUILD 
cc_binary(
    name = "hello",
    srcs = ["hello.cc"],
)
chenhao@chenhao:~/bazel-ccache$ cat hello.cc 
int main() { return 0; }
chenhao@chenhao:~/bazel-ccache$ ls -alh tools
total 8.0K
drwxrwxr-x 2 chenhao chenhao 4.0K May 19 20:08 .
drwxrwxr-x 3 chenhao chenhao 4.0K May 19 20:10 ..
lrwxrwxrwx 1 chenhao chenhao   15 May 19 20:08 clang-12 -> /usr/bin/ccache
lrwxrwxrwx 1 chenhao chenhao   15 May 19 20:08 gcc-10 -> /usr/bin/ccache
chenhao@chenhao:~/bazel-ccache$ which ccache
/usr/bin/ccache
chenhao@chenhao:~/bazel-ccache$ which clang-12
/usr/bin/clang-12
chenhao@chenhao:~/bazel-ccache$ which gcc-10 
/usr/bin/gcc-10

chenhao@chenhao:~/bazel-ccache$ CC=$(pwd)/tools/gcc-10 bazel build --sandbox_writable_path=$HOME/.ccache :all
INFO: Analyzed target //:hello (1 packages loaded, 12 targets configured).
INFO: Found 1 target...
Target //:hello up-to-date:
  bazel-bin/hello
INFO: Elapsed time: 1.512s, Critical Path: 0.04s
INFO: 3 processes: 2 internal, 1 linux-sandbox.
INFO: Build completed successfully, 3 total actions

chenhao@chenhao:~/bazel-ccache$ CC=$(pwd)/tools/clang-12 bazel build --sandbox_writable_path=$HOME/.ccache :all
INFO: Analyzed target //:hello (1 packages loaded, 12 targets configured).
INFO: Found 1 target...
ERROR: /home/chenhao/bazel-ccache/BUILD:1:10: Compiling hello.cc failed: (Exit 1): ccache failed: error executing command /usr/bin/ccache -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++0x' -MD ... (remaining 21 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox
/usr/bin/ccache: invalid option -- 'U'
Usage:
    ccache [options]
...

What operating system are you running Bazel on?

Ubuntu 20.04

What's the output of bazel info release?

release 5.1.0. I also tried other 5.x and the latest 6.0-pre, all broken. 4.x does not have this issue.

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?

I don't specify the rules_cc version by myself. My WORKSPACE is empty.

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

See the "bugs" section

chenhao94 added a commit to cyfitech/cris-core that referenced this issue Jun 7, 2022
Tested with Bazel 5.2. It is a workaround for issue
bazelbuild/rules_cc#130
chenhao94 added a commit to cyfitech/cris-core that referenced this issue Jun 8, 2022
Tested with Bazel 5.2. It is a workaround for issue
bazelbuild/rules_cc#130
chenhao94 added a commit to cyfitech/cris-core that referenced this issue Jun 10, 2022
Tested with Bazel 5.2. It is a workaround for issue
bazelbuild/rules_cc#130
chenhao94 added a commit to cyfitech/cris-core that referenced this issue Jun 11, 2022
Tested with Bazel 5.2. It is a workaround for issue
bazelbuild/rules_cc#130
@comius comius added the P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made. label Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.
Projects
None yet
Development

No branches or pull requests

2 participants