From c483c3b75fd242f9452c3c577074bbcce422f604 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 27 Oct 2025 14:08:21 +0100 Subject: [PATCH] Update naming to cpu-flags --- releasenotes.md | 2 +- resources/testproject/project.json | 2 +- src/build/build.h | 4 ++-- src/build/build_options.c | 10 +++++----- src/build/builder.c | 10 +++++----- src/build/project.c | 10 +++++----- src/compiler/target.c | 10 +++++----- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/releasenotes.md b/releasenotes.md index f6523f62f..48dd0fe12 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -17,7 +17,7 @@ - Rename `@extern` to `@cname`, deprecating the old name #2493. - Allow `(Foo)0` bitstruct casts even if type sizes do not match. - The option `--riscvfloat` renamed `--riscv-abi`. -- Add initial `--cpu-features` allowing fine grained control over CPU features. +- Add initial `--cpu-flags` allowing fine grained control over CPU features. ### Fixes - Bug in `io::write_using_write_byte`. diff --git a/resources/testproject/project.json b/resources/testproject/project.json index 485b8f80b..147322786 100644 --- a/resources/testproject/project.json +++ b/resources/testproject/project.json @@ -13,7 +13,7 @@ ], "dependency-search-paths": [ "./lib" ], "dependencies": ["clib", "clib2"], - + "cpu-flags": ",,", "features": ["ABCD"], "exec": ["scriptme.c3 myarg"], // c sources diff --git a/src/build/build.h b/src/build/build.h index b98829583..62a4c26c8 100644 --- a/src/build/build.h +++ b/src/build/build.h @@ -586,7 +586,7 @@ typedef struct BuildOptions_ SanitizeMode sanitize_mode; uint32_t max_vector_size; uint32_t max_stack_object_size; - const char *cpu_features; + const char *cpu_flags; uint32_t max_macro_iterations; bool print_keywords; bool print_attributes; @@ -727,7 +727,7 @@ typedef struct ArchOsTarget arch_os_target; CompilerBackend backend; LinkerType linker_type; - const char *cpu_features; + const char *cpu_flags; uint32_t symtab_size; uint32_t max_vector_size; uint32_t max_stack_object_size; diff --git a/src/build/build_options.c b/src/build/build_options.c index 2497c343d..6d23e788e 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -974,17 +974,17 @@ static void parse_option(BuildOptions *options) options->riscv_abi = parse_opt_select(RiscvAbi, argopt, riscv_abi); return; } - if (match_longopt("cpu-features")) + if (match_longopt("cpu-flags")) { - if (at_end() || next_is_opt()) error_exit("error: --cpu-features expected a comma-separated list, like '+a,-b,+x'."); + if (at_end() || next_is_opt()) error_exit("error: --cpu-flags expected a comma-separated list, like '+a,-b,+x'."); scratch_buffer_clear(); - if (options->cpu_features) + if (options->cpu_flags) { - scratch_buffer_append(options->cpu_features); + scratch_buffer_append(options->cpu_flags); scratch_buffer_append_char(','); } scratch_buffer_append(next_arg()); - options->cpu_features = scratch_buffer_copy(); + options->cpu_flags = scratch_buffer_copy(); return; } if (match_longopt("max-stack-object-size")) diff --git a/src/build/builder.c b/src/build/builder.c index bd3bb91ac..8826129e1 100644 --- a/src/build/builder.c +++ b/src/build/builder.c @@ -447,17 +447,17 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions * OVERRIDE_IF_SET(android.ndk_path); OVERRIDE_IF_SET(android.api_version); - if (options->cpu_features) + if (options->cpu_flags) { - if (target->cpu_features) + if (target->cpu_flags) { scratch_buffer_clear(); - scratch_buffer_printf("%s,%s", target->cpu_features, options->cpu_features); - target->cpu_features = scratch_buffer_copy(); + scratch_buffer_printf("%s,%s", target->cpu_flags, options->cpu_flags); + target->cpu_flags = scratch_buffer_copy(); } else { - target->cpu_features = options->cpu_features; + target->cpu_flags = options->cpu_flags; } } if (!target->max_vector_size) target->max_vector_size = DEFAULT_VECTOR_WIDTH; diff --git a/src/build/project.c b/src/build/project.c index 94ff9b5a6..a9d366a16 100644 --- a/src/build/project.c +++ b/src/build/project.c @@ -195,15 +195,15 @@ static void load_into_build_target(BuildParseContext context, JSONObject *json, const char *cpu_flags = get_optional_string(context, json, "cpu-flags"); if (cpu_flags) { - if (target->cpu_features) + if (target->cpu_flags) { scratch_buffer_clear(); - scratch_buffer_printf("%s,%s", target->cpu_features, cpu_flags); - target->cpu_features = scratch_buffer_copy(); + scratch_buffer_printf("%s,%s", target->cpu_flags, cpu_flags); + target->cpu_flags = scratch_buffer_copy(); } else { - target->cpu_features = cpu_flags; + target->cpu_flags = cpu_flags; } } if (context.target) @@ -215,7 +215,7 @@ static void load_into_build_target(BuildParseContext context, JSONObject *json, { error_exit("Error reading %s: 'cpu-flags' and 'cpu-flags-override' cannot be combined.", context.file); } - target->cpu_features = cpu_flags_override; + target->cpu_flags = cpu_flags_override; } } diff --git a/src/compiler/target.c b/src/compiler/target.c index 7a4d8ed1b..8a8f3a291 100644 --- a/src/compiler/target.c +++ b/src/compiler/target.c @@ -368,7 +368,7 @@ static inline void target_setup_aarch64_abi(void) cpu_features_add_feature_single(&features, AARCH64_FEAT_RDM); cpu_features_add_feature_single(&features, AARCH64_FEAT_FP_ARMV8); cpu_features_add_feature_single(&features, AARCH64_FEAT_NEON); - update_cpu_features(compiler.build.cpu_features, &features, aarch64_feature_name, AARCH64_FEATURE_LAST); + update_cpu_features(compiler.build.cpu_flags, &features, aarch64_feature_name, AARCH64_FEATURE_LAST); cpu_features_set_to_features(features, cpu_feature_zero, NULL, aarch64_feature_name, AARCH64_FEATURE_LAST); } @@ -393,7 +393,7 @@ static inline void target_setup_arm_abi(void) cpu_features_add_feature_single(&features, ARM_FEAT_VFP2); cpu_features_add_feature_single(&features, ARM_FEAT_VFP2SP); - update_cpu_features(compiler.build.cpu_features, &features, arm_feature_name, ARM_FEAT_LAST); + update_cpu_features(compiler.build.cpu_flags, &features, arm_feature_name, ARM_FEAT_LAST); cpu_features_set_to_features(features, cpu_feature_zero, NULL, arm_feature_name, ARM_FEAT_LAST); if (compiler.platform.object_format == OBJ_FORMAT_MACHO) { @@ -1093,7 +1093,7 @@ static inline void target_setup_x64_abi(BuildTarget *target) if (target->feature.pass_win64_simd_as_arrays == WIN64_SIMD_ARRAY) compiler.platform.x64.win64_simd_as_array = true; if (compiler.platform.x64.soft_float) cpu_features_add_feature_single(&cpu_features, X86_FEAT_SOFT_FLOAT); - update_cpu_features(compiler.build.cpu_features, &cpu_features, x86_feature_name, X86_FEATURE_LAST); + update_cpu_features(compiler.build.cpu_flags, &cpu_features, x86_feature_name, X86_FEATURE_LAST); x86features_as_diff_to_scratch(cpu_features, cpu_set); @@ -1998,7 +1998,7 @@ static void target_setup_wasm_abi(BuildTarget *target) cpu_features_add_feature_single(&features, WASM_FEAT_NONTRAPPING_FPTORINT); cpu_features_add_feature_single(&features, WASM_FEAT_REFERENCE_TYPES); cpu_features_add_feature_single(&features, WASM_FEAT_SIGN_EXT); - update_cpu_features(target->cpu_features, &features, wasm_feature_name, WASM_FEATURE_LAST); + update_cpu_features(target->cpu_flags, &features, wasm_feature_name, WASM_FEATURE_LAST); cpu_features_set_to_features(features, cpu_feature_zero, NULL, wasm_feature_name, WASM_FEATURE_LAST); } @@ -2026,7 +2026,7 @@ static void target_setup_riscv_abi(BuildTarget *target) { cpu_features_add_feature_single(&features, RISCV_FEAT_32BIT); } - update_cpu_features(target->cpu_features, &features, riscv_feature_name, RISCV_FEATURE_LAST); + update_cpu_features(target->cpu_flags, &features, riscv_feature_name, RISCV_FEATURE_LAST); cpu_features_set_to_features(features, cpu_feature_zero, NULL, riscv_feature_name, RISCV_FEATURE_LAST); }