PR #23363 opened by Kacper Michajłow (kasper93) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23363 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23363.patch
--cpu=host resolved =native to the concrete CPU name and passed that to the compiler. The name is a strict superset of the actual machine: it discards the per-feature adjustments the compiler makes for =native (e.g. AVX-512 left disabled by the OS or a VM), so the build could emit instructions that fault at runtime. Keep the resolved name for per-arch feature gating, but feed -march/-mcpu=native for the codegen so that information is preserved. From bc58cc75e6ab8435552361e48f7927809c1edb42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Fri, 5 Jun 2026 11:35:19 +0200 Subject: [PATCH] configure: keep -march=native for --cpu=host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --cpu=host resolved =native to the concrete CPU name and passed that to the compiler. The name is a strict superset of the actual machine: it discards the per-feature adjustments the compiler makes for =native (e.g. AVX-512 left disabled by the OS or a VM), so the build could emit instructions that fault at runtime. Keep the resolved name for per-arch feature gating, but feed -march/-mcpu=native for the codegen so that information is preserved. Signed-off-by: Kacper Michajłow <[email protected]> --- configure | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/configure b/configure index f136365d8c..970b880916 100755 --- a/configure +++ b/configure @@ -5622,7 +5622,11 @@ if test "$cpu" = host; then q }" $TMPE } - cpu=$(check_native -march || check_native -mcpu) + if cpu=$(check_native -march); then + native_cpuflags="-march=native" + elif cpu=$(check_native -mcpu); then + native_cpuflags="-mcpu=native" + fi ;; clang) check_native(){ @@ -5634,7 +5638,7 @@ if test "$cpu" = host; then q }" $TMPE } - cpu=$(check_native -march) + cpu=$(check_native -march) && native_cpuflags="-march=native" ;; esac @@ -6006,6 +6010,9 @@ else fi if [ "$cpu" != generic ]; then + # For --cpu=host, use the compiler's =native for codegen. $cpu is + # only the resolved name used for feature gating above. + test -n "$native_cpuflags" && cpuflags=$native_cpuflags add_allcflags $cpuflags add_asflags $cpuflags test "$cc_type" = "$ld_type" && add_ldflags $cpuflags -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
