Re: [PATCH v2 10/10] detect-compiler: detect clang even if it found CUDA
- From
Jeff King <peff@peff.net>
- Date
- Mar 26, 2025, 17:41 UTC
- Message-ID
- <20250326174127.GA2508080@coredump.intra.peff.net>
- In-Reply-To
- <2f6f31240fe6ce5f8efab662af477540a0f966ca.1742945534.git.gitgitgadget@gmail.com>
On Tue, Mar 25, 2025 at 11:32:14PM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 14 quoted lines
> In my setup, clang finds `/usr/local/cuda` and hence the output of > `clang -v` ends with this line: > > Found CUDA installation: /usr/local/cuda, version > > This confuses the `detect-compiler` script because it matches _all_ > lines that contain the needle "version" surrounded by spaces. As a > consequence, the `get_family` function returns two lines: "Ubuntu clang" > and above-mentioned line, which the `case` statement does not handle > well and hence reports "unknown compiler family" instead of the expected > set of "clang14", "clang13", ..., "clang1" output. > > Let's unconfuse the script by letting it parse the first matching line > and ignore the rest.
Makes sense. I wondered if this:
> get_version_line() {
> - LANG=C LC_ALL=C $CC -v 2>&1 | grep ' version '
> + LANG=C LC_ALL=C $CC -v 2>&1 | sed -n '/ version /{p;q}'might be more readable with "grep -m1", but it looks like "-m" is not in POSIX. So what you wrote is probably safer.
-Peff