From ee26c18476ffe11c6faebb2a24c8ae4a5dcf6b6e Mon Sep 17 00:00:00 2001 From: Graffioh Date: Thu, 24 Sep 2026 07:19:40 +0000 Subject: [PATCH] fix(cmake): adopt DFLASH27B_* options left from before the rename The luce rename moved every CMake option from DFLASH27B_* (and DFLASH_GPU_SAMPLER) to LUCE_* with no migration. A build directory configured under the old names keeps them in its cache, and its next configure silently falls back to the defaults: an R9700 build dir reconfigured with LUCE_HIP_ARCHITECTURES empty compiled ggml for gfx1151 and the server segfaulted in the first HIP kernel launch; a DFLASH27B_GPU_BACKEND=hip dir would switch to CUDA. Fresh CI build dirs never see it. Each renamed user option now adopts its old cached value once, with a warning, and the old entry is dropped. The value is adopted when the new option is unset, empty, or still at its declared default: a single configure caches GPU_BACKEND=cuda and the ON switches, so an old -D on an existing dir, or a stale old entry in a dir reconfigured once after the rename, must still win over them. A LUCE_* value set away from its default wins, and the old flag is reported as ignored. The adopted entry keeps the new option's cache type, or BOOL for an untyped ON/OFF option not declared on this backend. Checked with real HIP configures: a fresh dir with the old names, and a dir already configured with the defaults, both give --offload-arch=gfx1201 for ggml-hip and luce_common; the second also gives LUCE_TESTS:BOOL=OFF from -DDFLASH27B_TESTS=OFF, and -DDFLASH_GPU_SAMPLER=OFF gives LUCE_GPU_SAMPLER:BOOL=OFF. Co-Authored-By: Claude Opus 5.5 (1M context) --- server/CMakeLists.txt | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 8d32b7fb7..daddc555c 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -1,4 +1,59 @@ cmake_minimum_required(VERSION 3.21) # 3.21 adds first-class HIP language support (project(LANGUAGES ... HIP)) +# The options were called DFLASH27B_* (DFLASH_GPU_SAMPLER) before the luce +# rename. A build directory configured under the old names (or an old -D +# command line) would otherwise fall back to the defaults without a word: CUDA +# instead of HIP, gfx1151 instead of the configured GPU. Adopt each old value +# once, when the new option is unset, empty, or still at its declared default +# below, then drop the old entry. Keep these defaults in sync with the +# declarations. +foreach(_luce_entry + "DFLASH27B_GPU_BACKEND=cuda" "DFLASH27B_ENABLE_MIXED_CUDA_HIP=OFF" + "DFLASH27B_CUDA_ARCHITECTURES=86" "DFLASH27B_HIP_ARCHITECTURES=" + "DFLASH27B_COVERAGE=OFF" "DFLASH27B_FA_ALL_QUANTS=ON" + "DFLASH27B_ROCMFP2_AFFINE=OFF" "DFLASH27B_HIP_SM80_EQUIV=OFF" + "DFLASH27B_USE_BLACKWELL_CONSUMER_FIX=OFF" "DFLASH_GPU_SAMPLER=ON" + "DFLASH27B_TESTS=ON" "DFLASH27B_SERVER=ON") + string(REGEX MATCH "^(DFLASH27B_|DFLASH_)([^=]+)=(.*)$" _luce_match + "${_luce_entry}") + set(_luce_old "${CMAKE_MATCH_1}${CMAKE_MATCH_2}") + set(_luce_new "LUCE_${CMAKE_MATCH_2}") + set(_luce_default "${CMAKE_MATCH_3}") + if(DEFINED CACHE{${_luce_old}}) + if(NOT DEFINED CACHE{${_luce_new}} + OR "$CACHE{${_luce_new}}" STREQUAL "" + OR "$CACHE{${_luce_new}}" STREQUAL "${_luce_default}") + if(NOT "$CACHE{${_luce_old}}" STREQUAL "$CACHE{${_luce_new}}") + if(DEFINED CACHE{${_luce_new}}) + get_property(_luce_type CACHE ${_luce_new} PROPERTY TYPE) + else() + get_property(_luce_type CACHE ${_luce_old} PROPERTY TYPE) + endif() + if(_luce_type STREQUAL "UNINITIALIZED") + if(_luce_default MATCHES "^(ON|OFF)$") + set(_luce_type BOOL) + else() + set(_luce_type STRING) + endif() + endif() + set(${_luce_new} "$CACHE{${_luce_old}}" CACHE ${_luce_type} "" FORCE) + message(WARNING + "${_luce_old} is renamed ${_luce_new}; using " + "${_luce_new}=$CACHE{${_luce_old}}") + endif() + elseif(NOT "$CACHE{${_luce_old}}" STREQUAL "$CACHE{${_luce_new}}") + message(WARNING + "${_luce_old}=$CACHE{${_luce_old}} is ignored: " + "${_luce_new}=$CACHE{${_luce_new}} is already set") + endif() + unset(${_luce_old} CACHE) + endif() +endforeach() +unset(_luce_entry) +unset(_luce_match) +unset(_luce_old) +unset(_luce_new) +unset(_luce_default) +unset(_luce_type) set(LUCE_GPU_BACKEND "cuda" CACHE STRING "GPU backend to build: cuda or hip") set_property(CACHE LUCE_GPU_BACKEND PROPERTY STRINGS cuda hip) option(LUCE_ENABLE_MIXED_CUDA_HIP