Skip to contentSkip to conversation

meson: Use -fno-sanitize=function when available

PATCH Superseded Akihiko Odaki 3 participants 4 messages Jul 28, 2024 – Aug 16, 2024 Arm/Amlogic Meson SoC support

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 meson: Use -fno-sanitize=function when available

Commit 23ef50ae2d0c (".gitlab-ci.d/buildtest.yml: Use -fno-sanitize=function in the clang-system job") adds -fno-sanitize=function for the CI but doesn't add the flag in the other context. Add it to meson.build for such. It is not removed from .gitlab-ci.d/buildtest.yml because -fno-sanitize=function in meson.build does not affect --extra-cflags due to argument ordering.

---
Changes in v2:
- Dropped the change of: .gitlab-ci.d/buildtest.yml
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 meson.build                | 1 +
 .gitlab-ci.d/buildtest.yml | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -0
index 5613b62a4f42..a4169c572ba9 100644
@@ -609,6 +609,7 @@ if host_os != 'openbsd' and \
 endif
 
 qemu_common_flags += cc.get_supported_arguments(hardening_flags)
+qemu_common_flags += cc.get_supported_arguments('-fno-sanitize=function')
 
 add_global_arguments(qemu_common_flags, native: false, language: all_languages)
 add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
.gitlab-ci.d/buildtest.yml +0 -1
index aa327824052d..d83e50abd933 100644
@@ -430,7 +430,6 @@ clang-system:
     IMAGE: fedora
     CONFIGURE_ARGS: --cc=clang --cxx=clang++
       --extra-cflags=-fsanitize=undefined --extra-cflags=-fno-sanitize-recover=undefined
-      --extra-cflags=-fno-sanitize=function
     TARGETS: alpha-softmmu arm-softmmu m68k-softmmu mips64-softmmu s390x-softmmu
     MAKE_CHECK_ARGS: check-qtest check-tcg
 

---
base-commit: 93b799fafd9170da3a79a533ea6f73a18de82e22
change-id: 20240714-function-7d32c723abbc

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>
#1 lore raw
Quoted 46 lines · Akihiko Odaki

Commit 23ef50ae2d0c (".gitlab-ci.d/buildtest.yml: Use

(quoted diff) +0 -2
-fno-sanitize=function in the clang-system job") adds
-fno-sanitize=function for the CI but doesn't add the flag in the

other context. Add it to meson.build for such. It is not removed from .gitlab-ci.d/buildtest.yml because -fno-sanitize=function in meson.build does not affect --extra-cflags due to argument ordering.

---
Changes in v2:
- Dropped the change of: .gitlab-ci.d/buildtest.yml
- Link to v1: https://lore.kernel.org/r/[email protected]

---
  meson.build                | 1 +
  .gitlab-ci.d/buildtest.yml | 1 -
  2 files changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -0
index 5613b62a4f42..a4169c572ba9 100644
@@ -609,6 +609,7 @@ if host_os != 'openbsd' and \
  endif
 
  qemu_common_flags += cc.get_supported_arguments(hardening_flags)
+qemu_common_flags += cc.get_supported_arguments('-fno-sanitize=function')
 
  add_global_arguments(qemu_common_flags, native: false, language: all_languages)
  add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
.gitlab-ci.d/buildtest.yml +0 -2
index aa327824052d..d83e50abd933 100644
@@ -430,7 +430,6 @@ clang-system:
      IMAGE: fedora
      CONFIGURE_ARGS: --cc=clang --cxx=clang++
        --extra-cflags=-fsanitize=undefined --extra-cflags=-fno-sanitize-recover=undefined
-      --extra-cflags=-fno-sanitize=function
      TARGETS: alpha-softmmu arm-softmmu m68k-softmmu mips64-softmmu s390x-softmmu
      MAKE_CHECK_ARGS: check-qtest check-tcg
 
 
---

base-commit: 93b799fafd9170da3a79a533ea6f73a18de82e22
change-id: 20240714-function-7d32c723abbc

Quoted 1 line

Best regards,

Doesn't work, because --extra-cflags comes last and overrides it.

I think we need to drop -fsanitize=undefined from --extra-cflags as well, and use --enable-sanitizers. I think it should be ok to leave -fno-sanitize-recover=undefined in extra.

r~

#2 lore raw
Quoted 46 lines · Richard Henderson
Quoted 45 lines · Akihiko Odaki

Commit 23ef50ae2d0c (".gitlab-ci.d/buildtest.yml: Use

(quoted diff) +0 -2
-fno-sanitize=function in the clang-system job") adds
-fno-sanitize=function for the CI but doesn't add the flag in the

other context. Add it to meson.build for such. It is not removed from .gitlab-ci.d/buildtest.yml because -fno-sanitize=function in meson.build does not affect --extra-cflags due to argument ordering.

---
Changes in v2:
- Dropped the change of: .gitlab-ci.d/buildtest.yml
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
  meson.build                | 1 + .gitlab-ci.d/buildtest.yml | 1 -

  2 files changed, 1 insertion(+), 1 deletion(-)
meson.build +0 -0
index 5613b62a4f42..a4169c572ba9 100644
@@ -609,6 +609,7 @@ if host_os != 'openbsd' and \

  endif
  qemu_common_flags += cc.get_supported_arguments(hardening_flags) +qemu_common_flags += cc.get_supported_arguments('-fno-sanitize=function') add_global_arguments(qemu_common_flags, native: false, language: all_languages) add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)

.gitlab-ci.d/buildtest.yml +0 -0
index aa327824052d..d83e50abd933 100644
@@ -430,7 +430,6 @@ clang-system:

      IMAGE: fedora
      CONFIGURE_ARGS: --cc=clang --cxx=clang++ --extra-cflags=-fsanitize=undefined --extra-cflags=-fno-sanitize-recover=undefined
-      --extra-cflags=-fno-sanitize=function
      TARGETS: alpha-softmmu arm-softmmu m68k-softmmu mips64-softmmu s390x-softmmu
      MAKE_CHECK_ARGS: check-qtest check-tcg

---
base-commit: 93b799fafd9170da3a79a533ea6f73a18de82e22
change-id: 20240714-function-7d32c723abbc

Quoted 6 lines
Quoted 1 line

Best regards,

Doesn't work, because --extra-cflags comes last and overrides it.

I think we need to drop -fsanitize=undefined from --extra-cflags as well, and use --enable-sanitizers.  I think it should be ok to leave -fno-sanitize-recover=undefined in extra.

That could be a solution, too, but I think the change in meson.build should then also be moved to the spot where -fsanitize=undefined is added.

Thomas

#3 lore raw
In reply to Akihiko Odaki
Quoted 34 lines · Akihiko Odaki

Commit 23ef50ae2d0c (".gitlab-ci.d/buildtest.yml: Use

(quoted diff) +0 -2
-fno-sanitize=function in the clang-system job") adds
-fno-sanitize=function for the CI but doesn't add the flag in the

other context. Add it to meson.build for such. It is not removed from .gitlab-ci.d/buildtest.yml because -fno-sanitize=function in meson.build does not affect --extra-cflags due to argument ordering.

---
Changes in v2:
- Dropped the change of: .gitlab-ci.d/buildtest.yml
- Link to v1: https://lore.kernel.org/r/[email protected]

---
  meson.build                | 1 +
  .gitlab-ci.d/buildtest.yml | 1 -
  2 files changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -0
index 5613b62a4f42..a4169c572ba9 100644
@@ -609,6 +609,7 @@ if host_os != 'openbsd' and \
  endif
 
  qemu_common_flags += cc.get_supported_arguments(hardening_flags)
+qemu_common_flags += cc.get_supported_arguments('-fno-sanitize=function')
 
  add_global_arguments(qemu_common_flags, native: false, language: all_languages)
  add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
.gitlab-ci.d/buildtest.yml +0 -0
index aa327824052d..d83e50abd933 100644

.gitlab-ci.d/buildtest.yml clang-system: · line 433

Quoted 4 lines
.gitlab-ci.d/buildtest.yml +0 -1
@@ -430,7 +430,6 @@ clang-system:
      IMAGE: fedora
      CONFIGURE_ARGS: --cc=clang --cxx=clang++
        --extra-cflags=-fsanitize=undefined --extra-cflags=-fno-sanitize-recover=undefined
-      --extra-cflags=-fno-sanitize=function

I'm confused, in the patch description you say that buildtest.yml does not get changed anymore, but this hunk here does it anyway? Did you maybe send out v1 by accident again?

Thomas