git: kern.mk: Simplify and improve FPU/SIMD compiler flags

Aaron LI aly at crater.dragonflybsd.org
Fri Apr 17 19:04:14 PDT 2026


commit 8363c80b8868a73cb4fc80ced607897384d26e75
Author: Aaron LI <aly at aaronly.me>
Date:   Fri Apr 17 21:33:33 2026 +0800

    kern.mk: Simplify and improve FPU/SIMD compiler flags
    
    * Simplify and modernize the global kernel compiler flags for disabling
      FPU/SIMD to be:
    
          -mno-mmx -mno-sse -msoft-float -mno-fp-ret-in-387
    
      while the various -mno-* flags are removed as they are already implied
      by the above flags.  This reduces maintenance burden and is similarly
      adopted by FreeBSD and Linux kernel.
    
    * Drop '-mfpmath=387' to allow the compiler to choose the 'sse' backend
      when SSE/SSE2 is explicitly enabled. (further explained below for
      amdgpu sources)
    
    * Also remove the redundant '-mpreferred-stack-boundary=4' option, which
      is the default on x86_64.
    
    To validate correctness, all kernel objects were rebuilt and compared
    the '.text' section.  The result is identical code generation for the
    entire kernel, except for five amdgpu DML sources:
    
    - sys/dev/drm/amd/display/dc/calcs/dcn_calcs.c
    - sys/dev/drm/amd/display/dc/calcs/dcn_calc_auto.c
    - sys/dev/drm/amd/display/dc/calcs/dcn_calc_math.c
    - sys/dev/drm/amd/display/dc/dml/dml_common_defs.c
    - sys/dev/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c
    
    These sources explicitly enable double floating-point via local flags
    in sys/dev/drm/amd/amdgpu/Makefile:
    
        -mhard-float -msse -msse2
    
    The different code generation was caused by they previously inheriting
    the '-mfpmath=387' option.  With the cleanup, they now use the default
    SSE-based floating-point instead of legacy x87.  This results in
    different (but correct) code generation due to the change from x87
    (80-bit internal precision) to SSE (IEEE 64-bit).  The new behavior
    matches upstream practice (e.g., Linux amdgpu) and is more consistent
    with modern compiler expectations.
    
    Credit: ChatGPT (https://chatgpt.com/)

Summary of changes:
 sys/platform/pc64/conf/kern.mk      | 40 ++++++++++++++-----------------------
 sys/platform/vkernel64/conf/kern.mk | 24 +++++++++++-----------
 2 files changed, 27 insertions(+), 37 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/8363c80b8868a73cb4fc80ced607897384d26e75


-- 
DragonFly BSD source repository


More information about the Commits mailing list