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

ccc-analyzer does not accept CCC_CC/CCC_CXX with quotes #26594

Closed
llvmbot opened this issue Jan 20, 2016 · 1 comment · Fixed by #131932
Closed

ccc-analyzer does not accept CCC_CC/CCC_CXX with quotes #26594

llvmbot opened this issue Jan 20, 2016 · 1 comment · Fixed by #131932
Assignees
Labels
bugzilla Issues migrated from bugzilla clang-tools-extra

Comments

@llvmbot
Copy link
Member

llvmbot commented Jan 20, 2016

Bugzilla Link 26220
Version 3.7
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

We're using ccache to speed up compilation, so in our system, CC is set to "ccache gcc-4.9" (basically). We want and need to run scan-build with the same underlying compiler, so we run it with the CCC_CC="$(CC)" environment variable.

However, ccc-analyzer doesn't accept this, but falls back to the default compiler instead. An easy way to reproduce this is to do

$ touch /tmp/a.c # Empty C source
$ CCC_CC=ls ccc-analyzer /tmp/a.c
/tmp/a.c
$ CCC_CC="true ; ls" ccc-analyzer /tmp/a.c
/usr/bin/ld: [...]: relocation 0 has invalid symbol index 11

so in the second case, ccc-analyzer ignores CCC_CC and falls back to gcc. My Perl-knowledge is extremely limited, but I believe this is caused by ccc-analyzer verifying that the compiler exists in the path:

Search in the PATH if the compiler exists

sub SearchInPath {
my $file = shift;
foreach my $dir (split (':', $ENV{PATH})) {
if (-x "$dir/$file") {
return 1;
}
}
return 0;
}
[...]

$Compiler = $ENV{'CCC_CC'};
if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { $Compiler = $DefaultCCompiler; }

I tested this with clang-3.7, but the latest ccc-analyzer seems to have the same construct. Obviously, the same is true for the handling of CCC_CXX.

@llvmbot
Copy link
Member Author

llvmbot commented Jan 20, 2016

assigned to @tkremenek

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
rafl added a commit to rafl/llvm-project that referenced this issue Mar 18, 2025
So that things like --use-cc="ccache gcc" work.

Fixes llvm#26594.

Also use the slightly simpler shellwords instead of quotewords.
rafl added a commit to rafl/llvm-project that referenced this issue Mar 21, 2025
So that things like --use-cc="ccache gcc" work.

Fixes llvm#26594.

Also use the slightly simpler shellwords instead of quotewords.
balazs-benics-sonarsource pushed a commit that referenced this issue Mar 24, 2025
…131932)

So that things like --use-cc="ccache gcc" work.

Fixes #26594.

Also use the slightly simpler shellwords instead of quotewords.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang-tools-extra
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants