Hi, This is a backport to gcc-10 and the patch applied cleanly on the branch. 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. Ok for gcc-10 branch? Regards, Srinath. 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. (cherry picked from commit f58d03b5df25f9eab06b7eacea8da780fc2e0219) ############### Attachment also inlined for ease of reply ############### diff --git a/gcc/common/config/arm/arm-common.c b/gcc/common/config/arm/arm-common.c index 78a779c935071c534a780821d399cb7d2e170808..a4b3e86ad5251be18f7131cd05fdab40f11d3742 100644 --- a/gcc/common/config/arm/arm-common.c +++ b/gcc/common/config/arm/arm-common.c @@ -590,9 +590,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; @@ -657,8 +663,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 ""; @@ -666,6 +672,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 @@ -682,7 +697,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 ""; @@ -1032,3 +1048,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 db0b93f6bb74f6ddf42636caa0d9a3db38692982..5abcad4c35d07576c1e2c83092e0aac215280339 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 30e1d6dc994e18012fd2e5a1bbd7c69134ee100c..2922dfe677c88cb2b3c445ddfe012f2f40016f3e 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -2357,10 +2357,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 }, @@ -2369,6 +2373,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 @@ -2389,12 +2394,22 @@ const char *arm_be8_option (int argc, const char **argv); " %{mfloat-abi=*: abi %*}" \ " %