lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+icZUVtHn8X1Tb_Y__c-WswsO0K8U9uy3r2MzKXwTA5THtL7w@mail.gmail.com>
Date: Thu, 22 Aug 2024 19:02:52 +0200
From: Sedat Dilek <sedat.dilek@...il.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
	Namhyung Kim <namhyung@...nel.org>, Ian Rogers <irogers@...gle.com>, 
	linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Nathan Chancellor <nathan@...nel.org>
Subject: Re: [Linux-6.11-rc4] perf BROKEN with LLVM/Clang 19.1.0-rc3

On Thu, Aug 22, 2024 at 5:10 PM Arnaldo Carvalho de Melo
<acme@...nel.org> wrote:
>
> On Thu, Aug 22, 2024 at 11:26:16AM -0300, Arnaldo Carvalho de Melo wrote:
> > So the cast is ok, I think we should disable that
> > -Wcast-function-type-mismatch for util/python.o when building with
> > clang.
>
> > Lemme try to cook a patch for you to test...
>
> Can you try the patch below? Notice that there was already a patch
> disabling that for !clang (gcc) for a similar reason:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b7a313d84e853049062011d78cb04b6decd12f5c
>
> ------------------------------------------------------------------------------------------
> perf tools: Fix python extension build for gcc 8
> The gcc 8 compiler won't compile the python extension code with the
> following errors (one example):
>
>   python.c:830:15: error: cast between incompatible  function types from              \
>   ‘PyObject * (*)(struct pyrf_evsel *, PyObject *, PyObject *)’                       \
>   uct _object * (*)(struct pyrf_evsel *, struct _object *, struct _object *)’} to     \
>   ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _objeuct \
>   _object *)’} [-Werror=cast-function-type]
>      .ml_meth  = (PyCFunction)pyrf_evsel__open,
>
> The problem with the PyMethodDef::ml_meth callback is that its type is
> determined based on the PyMethodDef::ml_flags value, which we set as
> METH_VARARGS | METH_KEYWORDS.
> <SNIP>
> ------------------------------------------------------------------------------------------
>
> Can you please check with both clang versions? I just checked with clang
> 18 as available in in Fedora 40 and it failed in the first, naïve patch,
> that simply adds that -Wno- variant:
>
>   GEN     /tmp/build/perf-tools-next/python/perf.cpython-312-x86_64-linux-gnu.so
> error: unknown warning option '-Wno-cast-function-type-mismatch'; did you mean '-Wno-cast-function-type-strict'? [-Werror,-Wunknown-warning-option]
> error: command '/usr/bin/clang' failed with exit code 1
> cp: cannot stat '/tmp/build/perf-tools-next/python_ext_build/lib/perf*.so': No such file or directory
>
> we need to check if clang has that option, we have infra for that, the
> patch below works, please try it.
>
> If it works with clang 19 I'll add two patches, one enhancing
> clang_has_option and the other using it for this warning only present in
> clang 19.
>
> - Arnaldo
>
> diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
> index 142e9d447ce721e3..649550e9b7aa8c8f 100644
> --- a/tools/perf/util/setup.py
> +++ b/tools/perf/util/setup.py
> @@ -17,7 +17,7 @@ src_feature_tests  = getenv('srctree') + '/tools/build/feature'
>
>  def clang_has_option(option):
>      cc_output = Popen([cc, cc_options + option, path.join(src_feature_tests, "test-hello.c") ], stderr=PIPE).stderr.readlines()
> -    return [o for o in cc_output if ((b"unknown argument" in o) or (b"is not supported" in o))] == [ ]
> +    return [o for o in cc_output if ((b"unknown argument" in o) or (b"is not supported" in o) or (b"unknown warning option" in o))] == [ ]
>
>  if cc_is_clang:
>      from sysconfig import get_config_vars
> @@ -63,6 +63,8 @@ cflags = getenv('CFLAGS', '').split()
>  cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter', '-Wno-redundant-decls' ]
>  if cc_is_clang:
>      cflags += ["-Wno-unused-command-line-argument" ]
> +    if clang_has_option("-Wno-cast-function-type-mismatch"):
> +        cflags += ["-Wno-cast-function-type-mismatch" ]
>  else:
>      cflags += ['-Wno-cast-function-type' ]
>

I tried with your diff with SLIM LLVM toolchains 18 and 19.

Both work - see attached build-logs.

Yes, are right that LLVM/Clang v19 was first introducing:

-Wcast-function-type-mismatch / -Wno-cast-function-type-mismatch

[4] says for LLVM 18.1.8:

-Wcast-function-type
-Wcast-function-type-strict

Feel free to add my Reported-by/Tested-by credentials if you sent a full patch.

Thanks.

BR,
-Sedat-

[1] https://mirrors.edge.kernel.org/pub/tools/llvm/
[2] https://mirrors.edge.kernel.org/pub/tools/llvm/files/llvm-18.1.8-x86_64.tar.xz
[3] https://mirrors.edge.kernel.org/pub/tools/llvm/files/llvm-19.1.0-rc3-x86_64.tar.xz
[4] https://releases.llvm.org/18.1.8/tools/clang/docs/DiagnosticsReference.html
[5] https://clang.llvm.org/docs/DiagnosticsReference.html

Download attachment "make-log_perf-install_bin_python3.12_llvm18_acme-diff.txt.zst" of type "application/zstd" (17316 bytes)

Download attachment "make-log_perf-install_bin_python3.12_llvm19_acme-diff.txt.zst" of type "application/zstd" (17286 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ