From a672c68f03223efcab8f487d1bef05edaf5cf266 Mon Sep 17 00:00:00 2001 From: Yhya Ibrahim Date: Sat, 11 Oct 2025 15:26:01 +0300 Subject: [PATCH] Make `-target-features` flag support disabling of a feature --- src/llvm_backend.cpp | 5 ++++- src/main.cpp | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index c2decf091..9256acbb2 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -3055,7 +3055,10 @@ gb_internal bool lb_generate_code(lbGenerator *gen) { } first = false; - llvm_features = gb_string_appendc(llvm_features, "+"); + if (*str.text != '+' && *str.text != '-') { + llvm_features = gb_string_appendc(llvm_features, "+"); + } + llvm_features = gb_string_append_length(llvm_features, str.text, str.len); } diff --git a/src/main.cpp b/src/main.cpp index 6ad20cf26..2d58cf218 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3719,6 +3719,11 @@ int main(int arg_count, char const **arg_ptr) { String item = string_split_iterator(&target_it, ','); if (item == "") break; + if (*item.text == '+' || *item.text == '-') { + item.text++; + item.len--; + } + String invalid; if (!check_target_feature_is_valid_for_target_arch(item, &invalid) && item != str_lit("help")) { if (item != str_lit("?")) {