perf python: Fix splitting CC into compiler and options

Noticed this build failure on archlinux:base when building with clang:

  clang-14: error: optimization flag '-ffat-lto-objects' is not supported [-Werror,-Wignored-optimization-argument]

In tools/perf/util/ we check if clang supports that option, but
since commit 3cad53a6f9cdbafa ("perf python: Account for multiple words
in CC") this got broken as in the common case where CC="clang":

  >>> cc="clang"
  >>> print(cc.split()[0])
  >>> option="-ffat-lto-objects"
  >>> print(str(cc.split()[1:]) + option)

And then the Popen will call clang with that bogus option name that in
turn will not produce the b"unknown argument" or b"is not supported"
that this function uses to detect if the option is not available and
thus later on clang will be called with an unknown/unsupported option.

Fix it by looking if really there are options in the provided CC
variable, and if so override 'cc' with the first token and append the
options to the 'option' variable.

Fixes: 3cad53a6f9cdbafa ("perf python: Account for multiple words in CC")
Cc: Adrian Hunter <>
Cc: Fangrui Song <>
Cc: Florian Fainelli <>
Cc: Ian Rogers <>
Cc: Jiri Olsa <>
Cc: John Keeping <>
Cc: Khem Raj <>
Cc: Leo Yan <>
Cc: Michael Petlan <>
Cc: Namhyung Kim <>
Cc: Nathan Chancellor <>
Cc: Nick Desaulniers <>
Cc: Sedat Dilek <>
Signed-off-by: Arnaldo Carvalho de Melo <>
1 file changed