[vm] Fix gcc build

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 <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov
2026-01-08 08:43:09 -08:00
committed by Commit Queue
parent 1cde280830
commit ff3a562acf
5 changed files with 9 additions and 7 deletions
@@ -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_
+2 -2
View File
@@ -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) {
+2 -2
View File
@@ -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,
+2 -2
View File
@@ -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,
+1 -1
View File
@@ -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<uword>(&testFunction);