From 87239c7c9fe384557f541c77c17eb0cf5bc18f59 Mon Sep 17 00:00:00 2001 From: Jake Stevens Date: Thu, 28 May 2026 09:12:26 -0700 Subject: [PATCH 1/2] Opportunistically use __FILE_NAME__ to get filename (#19834) Summary: The current approach use __FILE__ and opportunistically trims it if the utility is available. However, the long name is still stored in .rodata This can contribute some memory on embedded platforms. Instead, first try __FILE_NAME__ Differential Revision: D106587633 --- runtime/platform/compiler.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/platform/compiler.h b/runtime/platform/compiler.h index edd340d1fb0..fc335f6e316 100644 --- a/runtime/platform/compiler.h +++ b/runtime/platform/compiler.h @@ -138,8 +138,14 @@ #define __has_builtin(x) (0) #endif -#if __has_builtin(__builtin_strrchr) +#if defined(__FILE_NAME__) +/// __FILE_NAME__ provides just the filename at +/// compile time, avoiding embedding full paths in the binary +#define ET_SHORT_FILENAME __FILE_NAME__ +#elif __has_builtin(__builtin_strrchr) /// Name of the source file without a directory string. +/// Note: This approach embeds the full path in .rodata even though only the +/// basename is used at runtime. __FILE_NAME__ is preferred when available. #define ET_SHORT_FILENAME (__builtin_strrchr("/" __FILE__, '/') + 1) #else #define ET_SHORT_FILENAME __FILE__ From 76e27dc17c2874fe81c0106c81400039bf9ac1be Mon Sep 17 00:00:00 2001 From: Jake Stevens Date: Thu, 28 May 2026 09:12:26 -0700 Subject: [PATCH 2/2] add program verif constraint (#19843) Summary: Mirroring other constraints like number of kernels in table, this diff adds support for disabling program verification via buck constraint Differential Revision: D106660443 --- runtime/executor/targets.bzl | 10 ++++++++-- tools/buck/constraints/BUCK | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/runtime/executor/targets.bzl b/runtime/executor/targets.bzl index 90f8d0221e9..81d0a58667f 100644 --- a/runtime/executor/targets.bzl +++ b/runtime/executor/targets.bzl @@ -16,8 +16,14 @@ def _program_preprocessor_flags(): if enable_verification == "false": return ["-DET_ENABLE_PROGRAM_VERIFICATION=0"] elif enable_verification == "true": - # Enabled by default. - return [] + # Enabled by default; allow opt-out via constraint + if not runtime.is_oss: + return select({ + "DEFAULT": [], + "fbsource//xplat/executorch/tools/buck/constraints:executorch-program-verification-disabled": ["-DET_ENABLE_PROGRAM_VERIFICATION=0"], + }) + else: + return [] else: fail("executorch.enable_program_verification must be one of 'true' or 'false'; saw '" + enable_verification + "'") diff --git a/tools/buck/constraints/BUCK b/tools/buck/constraints/BUCK index b558bb9e4a4..1d37e0ef623 100644 --- a/tools/buck/constraints/BUCK +++ b/tools/buck/constraints/BUCK @@ -61,3 +61,22 @@ fb_native.constraint_value( constraint_setting = ":executorch-event-tracer", visibility = ["PUBLIC"], ) + +fb_native.config_setting( + name = "executorch-program-verification-disabled", + constraint_values = [ + ":program-verification-disabled", + ], + visibility = ["PUBLIC"], +) + +fb_native.constraint_setting( + name = "executorch-program-verification", + visibility = ["PUBLIC"], +) + +fb_native.constraint_value( + name = "program-verification-disabled", + constraint_setting = ":executorch-program-verification", + visibility = ["PUBLIC"], +)