From ff3a562acf3805c8f41dd9761725f7913698a94b Mon Sep 17 00:00:00 2001 From: Alexander Markov Date: Thu, 8 Jan 2026 08:43:09 -0800 Subject: [PATCH] [vm] Fix gcc build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change fixes the following gcc build errors: ``` ../../runtime/vm/simulator_arm.cc:1403:44: error: ‘function’ attribute directive ignored [-Werror=attributes] 1403 | int32_t r4) { | ^ ../../runtime/vm/simulator_arm.cc:1417:47: error: ‘function’ attribute directive ignored [-Werror=attributes] 1417 | double d1) { | ^ cc1plus: note: unrecognized command-line option ‘-Wno-unused-private-field’ may have been intended to silence earlier diagnostics cc1plus: all warnings being treated as errors ``` It looks like gcc doesn't support [[no_sanitize("function")]] attribute, so limit its usage to clang. TEST=ci Change-Id: Id054970b9970dd1bf9fec78e97b4dbed5fd12c82 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471521 Reviewed-by: Alexander Aprelev Commit-Queue: Alexander Markov --- runtime/platform/undefined_behavior_sanitizer.h | 2 ++ runtime/vm/simulator_arm.cc | 4 ++-- runtime/vm/simulator_arm64.cc | 4 ++-- runtime/vm/simulator_riscv.cc | 4 ++-- runtime/vm/virtual_memory_test.cc | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/runtime/platform/undefined_behavior_sanitizer.h b/runtime/platform/undefined_behavior_sanitizer.h index 1985d0542f8..15de70ac91a 100644 --- a/runtime/platform/undefined_behavior_sanitizer.h +++ b/runtime/platform/undefined_behavior_sanitizer.h @@ -7,8 +7,10 @@ #ifdef __clang__ #define NO_SANITIZE_UNDEFINED(check) [[clang::no_sanitize(check)]] +#define NO_SANITIZE_UNDEFINED_FUNCTION NO_SANITIZE_UNDEFINED("function") #else #define NO_SANITIZE_UNDEFINED(check) [[gnu::no_sanitize(check)]] +#define NO_SANITIZE_UNDEFINED_FUNCTION #endif #endif // RUNTIME_PLATFORM_UNDEFINED_BEHAVIOR_SANITIZER_H_ diff --git a/runtime/vm/simulator_arm.cc b/runtime/vm/simulator_arm.cc index 85b6aefd444..905daed00b8 100644 --- a/runtime/vm/simulator_arm.cc +++ b/runtime/vm/simulator_arm.cc @@ -1394,7 +1394,7 @@ typedef int32_t (*SimulatorLeafRuntimeCall)(int32_t r0, // SimulatorLeafRuntimeCall. We can call them all from here only because in // IA32's calling convention a function can be called with extra arguments // and the callee will see the first arguments and won't unbalance the stack. -NO_SANITIZE_UNDEFINED("function") +NO_SANITIZE_UNDEFINED_FUNCTION static int32_t InvokeLeafRuntime(SimulatorLeafRuntimeCall target, int32_t r0, int32_t r1, @@ -1411,7 +1411,7 @@ typedef double (*SimulatorLeafFloatRuntimeCall)(double d0, double d1); // SimulatorFloatLeafRuntimeCall. We can call them all from here only because // IA32's calling convention a function can be called with extra arguments // and the callee will see the first arguments and won't unbalance the stack. -NO_SANITIZE_UNDEFINED("function") +NO_SANITIZE_UNDEFINED_FUNCTION static double InvokeFloatLeafRuntime(SimulatorLeafFloatRuntimeCall target, double d0, double d1) { diff --git a/runtime/vm/simulator_arm64.cc b/runtime/vm/simulator_arm64.cc index c1514288c3a..ba84fedcaa4 100644 --- a/runtime/vm/simulator_arm64.cc +++ b/runtime/vm/simulator_arm64.cc @@ -1630,7 +1630,7 @@ typedef int64_t (*SimulatorLeafRuntimeCall)(int64_t r0, // SimulatorLeafRuntimeCall. We can call them all from here only because in // X64's calling conventions a function can be called with extra arguments // and the callee will see the first arguments and won't unbalance the stack. -NO_SANITIZE_UNDEFINED("function") +NO_SANITIZE_UNDEFINED_FUNCTION static int64_t InvokeLeafRuntime(SimulatorLeafRuntimeCall target, int64_t r0, int64_t r1, @@ -1657,7 +1657,7 @@ typedef double (*SimulatorLeafFloatRuntimeCall)(double d0, // SimulatorFloatLeafRuntimeCall. We can call them all from here only because in // X64's calling conventions a function can be called with extra arguments // and the callee will see the first arguments and won't unbalance the stack. -NO_SANITIZE_UNDEFINED("function") +NO_SANITIZE_UNDEFINED_FUNCTION static double InvokeFloatLeafRuntime(SimulatorLeafFloatRuntimeCall target, double d0, double d1, diff --git a/runtime/vm/simulator_riscv.cc b/runtime/vm/simulator_riscv.cc index 0a42bd481b2..64167b83644 100644 --- a/runtime/vm/simulator_riscv.cc +++ b/runtime/vm/simulator_riscv.cc @@ -2194,7 +2194,7 @@ typedef intx_t (*SimulatorLeafRuntimeCall)(intx_t r0, // SimulatorLeafRuntimeCall. We can call them all from here only because in // X64's calling conventions a function can be called with extra arguments // and the callee will see the first arguments and won't unbalance the stack. -NO_SANITIZE_UNDEFINED("function") +NO_SANITIZE_UNDEFINED_FUNCTION static intx_t InvokeLeafRuntime(SimulatorLeafRuntimeCall target, intx_t r0, intx_t r1, @@ -2221,7 +2221,7 @@ typedef double (*SimulatorLeafFloatRuntimeCall)(double d0, // SimulatorFloatLeafRuntimeCall. We can call them all from here only because in // X64's calling conventions a function can be called with extra arguments // and the callee will see the first arguments and won't unbalance the stack. -NO_SANITIZE_UNDEFINED("function") +NO_SANITIZE_UNDEFINED_FUNCTION static double InvokeFloatLeafRuntime(SimulatorLeafFloatRuntimeCall target, double d0, double d1, diff --git a/runtime/vm/virtual_memory_test.cc b/runtime/vm/virtual_memory_test.cc index 25cbb043fd4..ab9b2e1acc9 100644 --- a/runtime/vm/virtual_memory_test.cc +++ b/runtime/vm/virtual_memory_test.cc @@ -96,7 +96,7 @@ static int testFunction(int x) { return x * 2; } -NO_SANITIZE_UNDEFINED("function") // See https://dartbug.com/52440 +NO_SANITIZE_UNDEFINED_FUNCTION // See https://dartbug.com/52440 VM_UNIT_TEST_CASE(DuplicateRXVirtualMemory) { const uword page_size = VirtualMemory::PageSize(); const uword pointer = reinterpret_cast(&testFunction);