From: Srinath Parvathaneni Date: Fri, 18 Jun 2021 12:21:51 +0000 (+0100) Subject: arm: Fix multilib mapping for CDE extensions [PR100856]. X-Git-Tag: basepoints/gcc-13~6669 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f58d03b5df25f9eab06b7eacea8da780fc2e0219;p=thirdparty%2Fgcc.git arm: Fix multilib mapping for CDE extensions [PR100856]. On passing +cdecp[0-7] extension to the -march string in command line options, multilib linking is failing as mentioned in PR100856. This patch fixes this issue by generating a separate canonical string by removing compiler options which are not required for multilib linking from march string and assign the new string to mlibarch option. This mlibarch string is used for multilib comparison. gcc/ChangeLog: 2021-06-10 Srinath Parvathaneni PR target/100856 * common/config/arm/arm-common.c (arm_canon_arch_option_1): New function derived from arm_canon_arch. (arm_canon_arch_option): Call it. (arm_canon_arch_multilib_option): New function. * config/arm/arm-cpus.in (IGNORE_FOR_MULTILIB): New fgroup. * config/arm/arm.h (arm_canon_arch_multilib_option): New prototype. (CANON_ARCH_MULTILIB_SPEC_FUNCTION): New macro. (MULTILIB_ARCH_CANONICAL_SPECS): New macro. (DRIVER_SELF_SPECS): Add MULTILIB_ARCH_CANONICAL_SPECS. * config/arm/arm.opt (mlibarch): New option. * config/arm/t-rmprofile (MULTILIB_MATCHES): For armv8*-m, replace use of march on RHS with mlibarch. gcc/testsuite/ChangeLog: 2021-06-10 Srinath Parvathaneni PR target/100856 * gcc.target/arm/acle/pr100856.c: New test. * gcc.target/arm/multilib.exp: Add tests for cde options. --- diff --git a/gcc/common/config/arm/arm-common.c b/gcc/common/config/arm/arm-common.c index 9980af6885c3..481aa9e43d9c 100644 --- a/gcc/common/config/arm/arm-common.c +++ b/gcc/common/config/arm/arm-common.c @@ -627,9 +627,15 @@ public: The options array consists of couplets of information where the first item in each couplet is the string describing which option name was selected (arch, cpu, fpu) and the second is the value - passed for that option. */ -const char * -arm_canon_arch_option (int argc, const char **argv) + passed for that option. + + arch_for_multilib is boolean variable taking value true or false. + arch_for_multilib is false when the canonical representation is for -march + option and it is true when canonical representation is for -mlibarch option. + On passing arch_for_multilib true the canonical string generated will be + without the compiler options which are not required for multilib linking. */ +static const char * +arm_canon_arch_option_1 (int argc, const char **argv, bool arch_for_multilib) { const char *arch = NULL; const char *cpu = NULL; @@ -694,8 +700,8 @@ arm_canon_arch_option (int argc, const char **argv) /* First build up a bitmap describing the target architecture. */ if (arch) { - selected_arch = arm_parse_arch_option_name (all_architectures, - "-march", arch); + selected_arch = arm_parse_arch_option_name (all_architectures, "-march", + arch, !arch_for_multilib); if (selected_arch == NULL) return ""; @@ -703,6 +709,15 @@ arm_canon_arch_option (int argc, const char **argv) arm_initialize_isa (target_isa, selected_arch->common.isa_bits); arm_parse_option_features (target_isa, &selected_arch->common, strchr (arch, '+')); + if (arch_for_multilib) + { + const enum isa_feature removable_bits[] = {ISA_IGNORE_FOR_MULTILIB, + isa_nobit}; + sbitmap isa_bits = sbitmap_alloc (isa_num_bits); + arm_initialize_isa (isa_bits, removable_bits); + bitmap_and_compl (target_isa, target_isa, isa_bits); + } + if (fpu && strcmp (fpu, "auto") != 0) { /* We assume that architectures do not have any FPU bits @@ -719,7 +734,8 @@ arm_canon_arch_option (int argc, const char **argv) else if (cpu) { const cpu_option *selected_cpu - = arm_parse_cpu_option_name (all_cores, "-mcpu", cpu); + = arm_parse_cpu_option_name (all_cores, "-mcpu", cpu, + !arch_for_multilib); if (selected_cpu == NULL) return ""; @@ -1069,3 +1085,22 @@ arm_asm_auto_mfpu (int argc, const char **argv) #define TARGET_EXCEPT_UNWIND_INFO arm_except_unwind_info struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; + +/* Returns a canonical representation of the -march option from the current + -march string (if given) and other options on the command line that might + affect the architecture. */ +const char * +arm_canon_arch_option (int argc, const char **argv) +{ + return arm_canon_arch_option_1 (argc, argv, false); +} + +/* Returns a canonical representation of the -mlibarch option from the current + -march string (if given) and other options on the command line that might + affect the architecture after removing the compiler extension options which + are not required for multilib linking. */ +const char * +arm_canon_arch_multilib_option (int argc, const char **argv) +{ + return arm_canon_arch_option_1 (argc, argv, true); +} diff --git a/gcc/config/arm/arm-cpus.in b/gcc/config/arm/arm-cpus.in index 0becb4385b67..ab4b6acf5ea4 100644 --- a/gcc/config/arm/arm-cpus.in +++ b/gcc/config/arm/arm-cpus.in @@ -324,6 +324,8 @@ define implied vfp_base MVE MVE_FP ALL_FP # need to ignore it for matching purposes. define fgroup ALL_QUIRKS quirk_no_volatile_ce quirk_armv6kz quirk_cm3_ldrd xscale quirk_no_asmcpu +define fgroup IGNORE_FOR_MULTILIB cdecp0 cdecp1 cdecp2 cdecp3 cdecp4 cdecp5 cdecp6 cdecp7 + # Architecture entries # format: # begin arch diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 8e5bd5793237..015299c15346 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -2444,10 +2444,14 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #endif const char *arm_canon_arch_option (int argc, const char **argv); +const char *arm_canon_arch_multilib_option (int argc, const char **argv); #define CANON_ARCH_SPEC_FUNCTION \ { "canon_arch", arm_canon_arch_option }, +#define CANON_ARCH_MULTILIB_SPEC_FUNCTION \ + { "canon_arch_multilib", arm_canon_arch_multilib_option }, + const char *arm_be8_option (int argc, const char **argv); #define BE8_SPEC_FUNCTION \ { "be8_linkopt", arm_be8_option }, @@ -2456,6 +2460,7 @@ const char *arm_be8_option (int argc, const char **argv); MCPU_MTUNE_NATIVE_FUNCTIONS \ ASM_CPU_SPEC_FUNCTIONS \ CANON_ARCH_SPEC_FUNCTION \ + CANON_ARCH_MULTILIB_SPEC_FUNCTION \ TARGET_MODE_SPEC_FUNCTIONS \ BE8_SPEC_FUNCTION @@ -2476,12 +2481,22 @@ const char *arm_be8_option (int argc, const char **argv); " %{mfloat-abi=*: abi %*}" \ " %