Repository navigation
[Build] Stop CMake riscv64 defaults from clobbering test cpu-features - #24866
AGindinson merged 2 commits into
Conversation
AGindinson
left a comment
There was a problem hiding this comment.
@TMahlatini sorry for losing track of this one. The PR generally looks good, but there's one clarification point before I understand the purpose and the change fully
| # Append platform defaults whose option is unset. If cpu-features is | ||
| # already set, prepend missing G-extension letters (+m,+a,+f,+d,+c). | ||
| foreach(_FLAG IN LISTS _PLATFORM_DEFAULT_LLVM_FLAGS) | ||
| if(_FLAG MATCHES "^--iree-llvmcpu-target-cpu-features=(.*)$") | ||
| set(_DEFAULT_FEATURES "${CMAKE_MATCH_1}") | ||
| if(IN_FLAGS MATCHES "--iree-llvmcpu-target-cpu-features=([^;]+)") | ||
| set(_VARIANT_FEATURES "${CMAKE_MATCH_1}") | ||
| string(REPLACE "," ";" _DEFAULT_LIST "${_DEFAULT_FEATURES}") | ||
| string(REPLACE "," ";" _VARIANT_LIST "${_VARIANT_FEATURES}") | ||
| set(_MISSING_G "") | ||
| foreach(_F IN LISTS _DEFAULT_LIST) | ||
| if(_F MATCHES "^\\+[mafdc]$") | ||
| list(FIND _VARIANT_LIST "${_F}" _FOUND) | ||
| if(_FOUND EQUAL -1) | ||
| list(APPEND _MISSING_G "${_F}") | ||
| endif() | ||
| endif() | ||
| endforeach() | ||
| if(_MISSING_G) | ||
| list(INSERT _VARIANT_LIST 0 ${_MISSING_G}) | ||
| list(JOIN _VARIANT_LIST "," _MERGED_FEATURES) | ||
| list(APPEND _FLAGS "--iree-llvmcpu-target-cpu-features=${_MERGED_FEATURES}") | ||
| endif() | ||
| continue() | ||
| endif() | ||
| list(APPEND _FLAGS "${_FLAG}") | ||
| continue() | ||
| endif() | ||
| if(_FLAG MATCHES "^--([^=]+)=") | ||
| set(_OPT "${CMAKE_MATCH_1}") | ||
| if(IN_FLAGS MATCHES "${_OPT}") | ||
| continue() | ||
| endif() | ||
| endif() | ||
| list(APPEND _FLAGS "${_FLAG}") | ||
| endforeach() |
There was a problem hiding this comment.
TBH I'm struggling to understand what this chunk is doing. RISCV*_TEST_DEFAULT_LLVM_FLAGS doesn't seem to be used anywhere else, so we can't we just statically modify that?
There was a problem hiding this comment.
RISCV*_TEST_DEFAULT_LLVM_FLAGS is only read here but each call also gets that test's flags IN_FLAGS. The loop checks whether those already contain --iree-llvmcpu-target-features. a variant sets that flag and not --iree-llvmcpu-target-triple sot the risc-v defaults are still appended after it and the later flag replaces the first. If the test omitted cpu-features, the loop appends the full default, including +zvl512b,+v, if the test set it, default copy is dropped and only missing +m,+a,+f,+d,+c are prepended; copying +zvl512b,+v would clobber VLEN and +xsmtvdot again. A fixed edit of the default string cannot do both
RISCV*_TEST_DEFAULT_LLVM_FLAGS might be the only static edit that stops the second flag, but it also drops rvv from every RISC-V test that does not set features. please let me know if this clarifies.
There was a problem hiding this comment.
Thanks, that helps!
Just by nature of CMake, the code is difficult to follow, and I wonder if it would be easier to just split --iree-llvmcpu-target-cpu-features=... out from RISCV*_TEST_DEFAULT_LLVM_FLAGS into a separate variable (so we'd end up with smth like TEST_DEFAULT_ABI_FLAGS and TEST_DEFAULT_FEAT_FLAGS), and then paste that whole default string in when the test doesn't specify --iree-llvmcpu-target-features. What do you think?
There was a problem hiding this comment.
yeah that works actually. Thanks for the suggestion, will update the PR soon
Hi @AGindinson sorry I just realized I left out the related issue description in my pr summary. I have just fixed that, you can find the problem definition here: #24866 |
platform cmake defaults were appending --iree-llvmcpu-target-cpu-features= after test variants, so the default overwrote +xsmtvdot / VLEN. Do not override an existing cpu-features flag; prepend missing +m,+a,+f,+d,+c. Strip those from generator --requirements=. Signed-off-by: Terence <[email protected]> Co-authored-by: Cursor <[email protected]>
triple and ABI flags are now seperate from the default cpu-feature string which is now only appended when the test did not already set --iree-llvmcpu-target-cpu-features. Variants that need +m,+a,+f,+d,+c spell them themselves. Signed-off-by: Terence <[email protected]>
d6be4d4 to
769cf59
Compare
AGindinson
left a comment
There was a problem hiding this comment.
LGTM, thanks for the slight rework!
platform cmake defaults were appending --iree-llvmcpu-target-cpu-features= after test variants, so the default overwrote +xsmtvdot / VLEN. this prevents the override of an existing cpu-features flag; prepend missing +m,+a,+f,+d,+c. and strips those from generator --requirements=.
Towards: #24859