Skip to content
Snippets Groups Projects
Commit a98de38d authored by Ryan Gonzalez's avatar Ryan Gonzalez
Browse files

build: Disable -fsanitize=function when building with UBSan

LLVM 17 enabled -fsanitize=function by default for C, instead of only
C++:

https://github.com/llvm/llvm-project/commit/279a4d0d67c874e80c171666822f2fabdd6fa926



But GLib uses function pointer casts extensively, resulting in a myriad
of test failures. Just disable it as a workaround.

steamrt/tasks#677

Signed-off-by: default avatarRyan Gonzalez <ryan.gonzalez@collabora.com>
parent 5a2da7d7
No related branches found
No related tags found
1 merge request!796build: Disable -fsanitize=function when building with UBSan
Pipeline #118967 passed
...@@ -219,6 +219,15 @@ else ...@@ -219,6 +219,15 @@ else
no_leak_sanitizer = ['b_sanitize=none'] no_leak_sanitizer = ['b_sanitize=none']
endif endif
# GLib explicitly requires being able to call functions through a different
# function pointer type, which trips UBSan's -fsanitize=function:
# https://gitlab.gnome.org/GNOME/glib/-/blob/53b0ba327ba52ebcd38ee4e7f479bf029ffcdc1f/docs/toolchain-requirements.md#calling-functions-through-differently-typed-function-pointers
if enabled_sanitizers.contains('undefined')
add_project_arguments(
c_compiler.get_supported_arguments('-fno-sanitize=function'),
language : 'c')
endif
add_project_link_arguments( add_project_link_arguments(
c_compiler.get_supported_link_arguments( c_compiler.get_supported_link_arguments(
'-Wl,-z,origin', '-Wl,-z,origin',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment