[gcc r12-10303] LoongArch: gcc12: Implement option save/restore.
https://gcc.gnu.org/g:bf0b32d7929f8b4b15b21658d572b89ded03d8f8 commit r12-10303-gbf0b32d7929f8b4b15b21658d572b89ded03d8f8 Author: Lulu Cheng Date: Fri Mar 15 16:41:20 2024 +0800 LoongArch: gcc12: Implement option save/restore. LTO option streaming and target attributes both require per-function target configuration, which is achieved via option save/restore. We implement TARGET_OPTION_{SAVE,RESTORE} to switch the la_target context in addition to other automatically maintained option states (via the "Save" option property in the .opt files). PR target/113233 gcc/ChangeLog: * config/loongarch/genopts/loongarch.opt.in: Mark options with the "Save" property. * config/loongarch/loongarch-opts.cc (loongarch_update_gcc_opt_status): Update the value of the la_target to global_options. * config/loongarch/loongarch-opts.h (loongarch_update_gcc_opt_status): Add a function declaration. * config/loongarch/loongarch.cc (loongarch_option_override_internal): Call the function loongarch_update_gcc_opt_status. (loongarch_option_save): New functions. (loongarch_option_restore): Likewise. (TARGET_OPTION_SAVE): Define macro. (TARGET_OPTION_RESTORE): Likewise. * config/loongarch/loongarch.opt: Regenerate. (cherry picked from commit ea2a9c76a1dcffbbec6e53655bef9236d3a8e691) Diff: --- gcc/config/loongarch/genopts/loongarch.opt.in | 22 - gcc/config/loongarch/loongarch-opts.cc| 22 + gcc/config/loongarch/loongarch-opts.h | 6 + gcc/config/loongarch/loongarch.cc | 34 +-- gcc/config/loongarch/loongarch.opt| 22 - 5 files changed, 82 insertions(+), 24 deletions(-) diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in b/gcc/config/loongarch/genopts/loongarch.opt.in index 420a3941b3b..a3107cb2294 100644 --- a/gcc/config/loongarch/genopts/loongarch.opt.in +++ b/gcc/config/loongarch/genopts/loongarch.opt.in @@ -58,7 +58,7 @@ EnumValue Enum(isa_ext_fpu) String(@@STR_ISA_EXT_FPU64@@) Value(ISA_EXT_FPU64) m@@OPTSTR_ISA_EXT_FPU@@= -Target RejectNegative Joined ToLower Enum(isa_ext_fpu) Var(la_opt_fpu) Init(M_OPTION_NOT_SEEN) +Target RejectNegative Joined ToLower Enum(isa_ext_fpu) Var(la_opt_fpu) Init(M_OPTION_NOT_SEEN) Save -m@@OPTSTR_ISA_EXT_FPU@@=FPU Generate code for the given FPU. m@@OPTSTR_ISA_EXT_FPU@@=@@STR_ISA_EXT_FPU0@@ @@ -92,11 +92,11 @@ EnumValue Enum(cpu_type) String(@@STR_CPU_LA464@@) Value(CPU_LA464) m@@OPTSTR_ARCH@@= -Target RejectNegative Joined Enum(cpu_type) Var(la_opt_cpu_arch) Init(M_OPTION_NOT_SEEN) +Target RejectNegative Joined Enum(cpu_type) Var(la_opt_cpu_arch) Init(M_OPTION_NOT_SEEN) Save -m@@OPTSTR_ARCH@@=PROCESSORGenerate code for the given PROCESSOR ISA. m@@OPTSTR_TUNE@@= -Target RejectNegative Joined Enum(cpu_type) Var(la_opt_cpu_tune) Init(M_OPTION_NOT_SEEN) +Target RejectNegative Joined Enum(cpu_type) Var(la_opt_cpu_tune) Init(M_OPTION_NOT_SEEN) Save -m@@OPTSTR_TUNE@@=PROCESSORGenerate optimized code for PROCESSOR. @@ -127,31 +127,31 @@ int la_opt_abi_ext = M_OPTION_NOT_SEEN mbranch-cost= -Target RejectNegative Joined UInteger Var(loongarch_branch_cost) +Target RejectNegative Joined UInteger Var(loongarch_branch_cost) Save -mbranch-cost=COST Set the cost of branches to roughly COST instructions. mcheck-zero-division -Target Mask(CHECK_ZERO_DIV) +Target Mask(CHECK_ZERO_DIV) Save Trap on integer divide by zero. mcond-move-int -Target Var(TARGET_COND_MOVE_INT) Init(1) +Target Var(TARGET_COND_MOVE_INT) Init(1) Save Conditional moves for integral are enabled. mcond-move-float -Target Var(TARGET_COND_MOVE_FLOAT) Init(1) +Target Var(TARGET_COND_MOVE_FLOAT) Init(1) Save Conditional moves for float are enabled. mmemcpy -Target Mask(MEMCPY) +Target Mask(MEMCPY) Save Prevent optimizing block moves, which is also the default behavior of -Os. mstrict-align -Target Var(TARGET_STRICT_ALIGN) Init(0) +Target Var(TARGET_STRICT_ALIGN) Init(0) Save Do not generate unaligned memory accesses. mmax-inline-memcpy-size= -Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init(1024) +Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init(1024) Save -mmax-inline-memcpy-size=SIZE Set the max size of memcpy to inline, default is 1024. ; The code model option names for -mcmodel. @@ -175,7 +175,7 @@ EnumValue Enum(cmodel) String(@@STR_CMODEL_EXTREME@@) Value(CMODEL_EXTREME) mcmodel= -Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel) Init(CMODEL_NORMAL) +Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel) Init(CMODEL_NORMAL) Save Specify the code model. mrelax diff --git a/gcc/config/loongarch/loongarch-opt
[gcc r13-8545] LoongArch: gcc13: Implement option save/restore.
https://gcc.gnu.org/g:4736b317047ae6b04f7609843f21cb68fef6a0c1 commit r13-8545-g4736b317047ae6b04f7609843f21cb68fef6a0c1 Author: Lulu Cheng Date: Fri Mar 15 16:23:05 2024 +0800 LoongArch: gcc13: Implement option save/restore. LTO option streaming and target attributes both require per-function target configuration, which is achieved via option save/restore. We implement TARGET_OPTION_{SAVE,RESTORE} to switch the la_target context in addition to other automatically maintained option states (via the "Save" option property in the .opt files). PR target/113233 gcc/ChangeLog: * config/loongarch/genopts/loongarch.opt.in: Mark options with the "Save" property. * config/loongarch/loongarch-opts.cc (loongarch_update_gcc_opt_status): Update the value of the la_target to global_options. * config/loongarch/loongarch-opts.h (loongarch_update_gcc_opt_status): Add a function declaration. * config/loongarch/loongarch.cc (loongarch_option_override_internal): Call the function loongarch_update_gcc_opt_status. (loongarch_option_save): New functions. (loongarch_option_restore): Likewise. (TARGET_OPTION_SAVE): Define macro. (TARGET_OPTION_RESTORE): Likewise. * config/loongarch/loongarch.opt: Regenerate. (cherry picked from commit ea2a9c76a1dcffbbec6e53655bef9236d3a8e691) Diff: --- gcc/config/loongarch/genopts/loongarch.opt.in | 24 +-- gcc/config/loongarch/loongarch-opts.cc| 22 + gcc/config/loongarch/loongarch-opts.h | 6 + gcc/config/loongarch/loongarch.cc | 34 +-- gcc/config/loongarch/loongarch.opt| 24 +-- 5 files changed, 84 insertions(+), 26 deletions(-) diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in b/gcc/config/loongarch/genopts/loongarch.opt.in index 76acd35d39c..aea4f2a4f61 100644 --- a/gcc/config/loongarch/genopts/loongarch.opt.in +++ b/gcc/config/loongarch/genopts/loongarch.opt.in @@ -58,7 +58,7 @@ EnumValue Enum(isa_ext_fpu) String(@@STR_ISA_EXT_FPU64@@) Value(ISA_EXT_FPU64) m@@OPTSTR_ISA_EXT_FPU@@= -Target RejectNegative Joined ToLower Enum(isa_ext_fpu) Var(la_opt_fpu) Init(M_OPTION_NOT_SEEN) +Target RejectNegative Joined ToLower Enum(isa_ext_fpu) Var(la_opt_fpu) Init(M_OPTION_NOT_SEEN) Save -m@@OPTSTR_ISA_EXT_FPU@@=FPU Generate code for the given FPU. m@@OPTSTR_ISA_EXT_FPU@@=@@STR_ISA_EXT_FPU0@@ @@ -92,11 +92,11 @@ EnumValue Enum(cpu_type) String(@@STR_CPU_LA464@@) Value(CPU_LA464) m@@OPTSTR_ARCH@@= -Target RejectNegative Joined Enum(cpu_type) Var(la_opt_cpu_arch) Init(M_OPTION_NOT_SEEN) +Target RejectNegative Joined Enum(cpu_type) Var(la_opt_cpu_arch) Init(M_OPTION_NOT_SEEN) Save -m@@OPTSTR_ARCH@@=PROCESSORGenerate code for the given PROCESSOR ISA. m@@OPTSTR_TUNE@@= -Target RejectNegative Joined Enum(cpu_type) Var(la_opt_cpu_tune) Init(M_OPTION_NOT_SEEN) +Target RejectNegative Joined Enum(cpu_type) Var(la_opt_cpu_tune) Init(M_OPTION_NOT_SEEN) Save -m@@OPTSTR_TUNE@@=PROCESSORGenerate optimized code for PROCESSOR. @@ -127,31 +127,31 @@ int la_opt_abi_ext = M_OPTION_NOT_SEEN mbranch-cost= -Target RejectNegative Joined UInteger Var(loongarch_branch_cost) +Target RejectNegative Joined UInteger Var(loongarch_branch_cost) Save -mbranch-cost=COST Set the cost of branches to roughly COST instructions. mcheck-zero-division -Target Mask(CHECK_ZERO_DIV) +Target Mask(CHECK_ZERO_DIV) Save Trap on integer divide by zero. mcond-move-int -Target Var(TARGET_COND_MOVE_INT) Init(1) +Target Var(TARGET_COND_MOVE_INT) Init(1) Save Conditional moves for integral are enabled. mcond-move-float -Target Var(TARGET_COND_MOVE_FLOAT) Init(1) +Target Var(TARGET_COND_MOVE_FLOAT) Init(1) Save Conditional moves for float are enabled. mmemcpy -Target Mask(MEMCPY) +Target Mask(MEMCPY) Save Prevent optimizing block moves, which is also the default behavior of -Os. mstrict-align -Target Var(TARGET_STRICT_ALIGN) Init(0) +Target Var(TARGET_STRICT_ALIGN) Init(0) Save Do not generate unaligned memory accesses. mmax-inline-memcpy-size= -Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init(1024) +Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init(1024) Save -mmax-inline-memcpy-size=SIZE Set the max size of memcpy to inline, default is 1024. mexplicit-relocs @@ -182,11 +182,11 @@ EnumValue Enum(cmodel) String(@@STR_CMODEL_EXTREME@@) Value(CMODEL_EXTREME) mcmodel= -Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel) Init(CMODEL_NORMAL) +Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel) Init(CMODEL_NORMAL) Save Specify the code model. mdirect-extern-access -Target Var(TARGET_DIRECT_EXTERN_ACCESS) Init(0) +Targ
[gcc r14-9737] LoongArch: Split loongarch_option_override_internal into smaller procedures
https://gcc.gnu.org/g:d28ea8e5a70474cf9d28bf0c008092c936ad1358 commit r14-9737-gd28ea8e5a70474cf9d28bf0c008092c936ad1358 Author: Yang Yujie Date: Sat Mar 30 16:43:14 2024 +0800 LoongArch: Split loongarch_option_override_internal into smaller procedures gcc/ChangeLog: * config/loongarch/genopts/loongarch.opt.in: Mark -m[no-]recip as aliases to -mrecip={all,none}, respectively. * config/loongarch/loongarch.opt: Regenerate. * config/loongarch/loongarch-def.h (ABI_FPU_64): Rename to... (ABI_FPU64_P): ...this. (ABI_FPU_32): Rename to... (ABI_FPU32_P): ...this. (ABI_FPU_NONE): Rename to... (ABI_NOFPU_P): ...this. (ABI_LP64_P): Define. * config/loongarch/loongarch.cc (loongarch_init_print_operand_punct): Merged into loongarch_global_init. (loongarch_cpu_option_override): Renamed to loongarch_target_option_override. (loongarch_option_override_internal): Move the work after loongarch_config_target into loongarch_target_option_override. (loongarch_global_init): Define. (INIT_TARGET_FLAG): Move to loongarch-opts.cc. (loongarch_option_override): Call loongarch_global_init separately. * config/loongarch/loongarch-opts.cc (loongarch_parse_mrecip_scheme): Split the parsing of -mrecip= from loongarch_option_override_internal. (loongarch_generate_mrecip_scheme): Define. Split from loongarch_option_override_internal. (loongarch_target_option_override): Define. Renamed from loongarch_cpu_option_override. (loongarch_init_misc_options): Define. Split from loongarch_option_override_internal. (INIT_TARGET_FLAG): Move from loongarch.cc. * config/loongarch/loongarch-opts.h (loongarch_target_option_override): New prototype. (loongarch_parse_mrecip_scheme): New prototype. (loongarch_init_misc_options): New prototype. (TARGET_ABI_LP64): Simplify with ABI_LP64_P. * config/loongarch/loongarch.h (TARGET_RECIP_DIV): Simplify. Do not reference specific CPU architecture (LA664). (TARGET_RECIP_SQRT): Same. (TARGET_RECIP_RSQRT): Same. (TARGET_RECIP_VEC_DIV): Same. (TARGET_RECIP_VEC_SQRT): Same. (TARGET_RECIP_VEC_RSQRT): Same. Diff: --- gcc/config/loongarch/genopts/loongarch.opt.in | 8 +- gcc/config/loongarch/loongarch-def.h | 11 +- gcc/config/loongarch/loongarch-opts.cc| 253 ++ gcc/config/loongarch/loongarch-opts.h | 27 ++- gcc/config/loongarch/loongarch.cc | 253 -- gcc/config/loongarch/loongarch.h | 18 +- gcc/config/loongarch/loongarch.opt| 8 +- 7 files changed, 342 insertions(+), 236 deletions(-) diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in b/gcc/config/loongarch/genopts/loongarch.opt.in index 02f918053f5..a77893d31d9 100644 --- a/gcc/config/loongarch/genopts/loongarch.opt.in +++ b/gcc/config/loongarch/genopts/loongarch.opt.in @@ -197,14 +197,14 @@ mexplicit-relocs Target Alias(mexplicit-relocs=, always, none) Use %reloc() assembly operators (for backward compatibility). -mrecip -Target RejectNegative Var(la_recip) Save -Generate approximate reciprocal divide and square root for better throughput. - mrecip= Target RejectNegative Joined Var(la_recip_name) Save Control generation of reciprocal estimates. +mrecip +Target Alias(mrecip=, all, none) +Generate approximate reciprocal divide and square root for better throughput. + ; The code model option names for -mcmodel. Enum Name(cmodel) Type(int) diff --git a/gcc/config/loongarch/loongarch-def.h b/gcc/config/loongarch/loongarch-def.h index 2dbf006d013..0cbf9476690 100644 --- a/gcc/config/loongarch/loongarch-def.h +++ b/gcc/config/loongarch/loongarch-def.h @@ -90,11 +90,16 @@ extern loongarch_def_array #define TO_LP64_ABI_BASE(C) (C) -#define ABI_FPU_64(abi_base) \ +#define ABI_LP64_P(abi_base) \ + (abi_base == ABI_BASE_LP64D \ + || abi_base == ABI_BASE_LP64F \ + || abi_base == ABI_BASE_LP64S) + +#define ABI_FPU64_P(abi_base) \ (abi_base == ABI_BASE_LP64D) -#define ABI_FPU_32(abi_base) \ +#define ABI_FPU32_P(abi_base) \ (abi_base == ABI_BASE_LP64F) -#define ABI_FPU_NONE(abi_base) \ +#define ABI_NOFPU_P(abi_base) \ (abi_base == ABI_BASE_LP64S) diff --git a/gcc/config/loongarch/loongarch-opts.cc b/gcc/config/loongarch/loongarch-opts.cc index 627f9148adf..e600f08f03b 100644 --- a/gcc/config/loongarch/loongarch-opts.cc +++ b/gcc/config/loongarch/loongarch-opts.cc @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "tm.h" #include "obstack.h" +#include
[gcc r14-9736] LoongArch: Add descriptions of the compilation options.
https://gcc.gnu.org/g:7f424c3167b72db1ecd661ccb71559bf27cbcfc1 commit r14-9736-g7f424c3167b72db1ecd661ccb71559bf27cbcfc1 Author: Lulu Cheng Date: Sat Mar 30 15:14:14 2024 +0800 LoongArch: Add descriptions of the compilation options. Add descriptions for the compilation options '-mfrecipe' '-mdiv32' '-mlam-bh' '-mlamcas' and '-mld-seq-sa'. gcc/ChangeLog: * doc/invoke.texi: Add descriptions for the compilation options. Diff: --- gcc/doc/invoke.texi | 45 +++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index c584664e168..942103c23f5 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1058,8 +1058,9 @@ Objective-C and Objective-C++ Dialects}. -mmax-inline-memcpy-size=@var{n} -mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs -mdirect-extern-access -mno-direct-extern-access --mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as} --mrecip -mrecip=@var{opt} +-mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as +-mrecip -mrecip=@var{opt} -mfrecipe -mno-frecipe -mdiv32 -mno-div32 +-mlam-bh -mno-lam-bh -mlamcas -mno-lamcas -mld-seq-sa -mno-ld-seq-sa} @emph{M32R/D Options} @gccoptlist{-m32r2 -m32rx -m32r @@ -27095,6 +27096,46 @@ Enable the approximation for vectorized reciprocal square root. So, for example, @option{-mrecip=all,!sqrt} enables all of the reciprocal approximations, except for scalar square root. +@opindex mfrecipe +@opindex mno-frecipe +@item -mfrecipe +@itemx -mno-frecipe +Use (do not use) @code{frecipe.@{s/d@}} and @code{frsqrte.@{s/d@}} +instructions. When build with @option{-march=la664}, it is enabled by default. +The default is @option{-mno-frecipe}. + +@opindex mdiv32 +@opindex mno-div32 +@item -mdiv32 +@itemx -mno-div32 +Use (do not use) @code{div.w[u]} and @code{mod.w[u]} instructions with input +not sign-extended. When build with @option{-march=la664}, it is enabled by +default. The default is @option{-mno-div32}. + +@opindex mlam-bh +@opindex mno-lam-bh +@item -mlam-bh +@itemx -mno-lam-bh +Use (do not use) @code{am@{swap/add@}[_db].@{b/h@}} instructions. When build +with @option{-march=la664}, it is enabled by default. The default is +@option{-mno-lam-bh}. + +@opindex mlamcas +@opindex mno-lamcas +@item -mlamcas +@itemx -mno-lamcas +Use (do not use) @code{amcas[_db].@{b/h/w/d@}} instructions. When build with +@option{-march=la664}, it is enabled by default. The default is +@option{-mno-lamcas}. + +@opindex mld-seq-sa +@opindex mno-ld-seq-sa +@item -mld-seq-sa +@itemx -mno-ld-seq-sa +Whether a load-load barrier (@code{dbar 0x700}) is needed. When build with +@option{-march=la664}, it is enabled by default. The default is +@option{-mno-ld-seq-sa}, the load-load barrier is needed. + @item loongarch-vect-unroll-limit The vectorizer will use available tuning information to determine whether it would be beneficial to unroll the main vectorized loop and by how much. This
[gcc r14-9734] modula2: Fix m2.install-info in gcc/m2/Make-lang.in
https://gcc.gnu.org/g:14d0c863aa9415f5d78047910233d67d91f4ecf5 commit r14-9734-g14d0c863aa9415f5d78047910233d67d91f4ecf5 Author: Christophe Lyon Date: Fri Mar 29 17:59:38 2024 + modula2: Fix m2.install-info in gcc/m2/Make-lang.in Fix a few typos: the generated filename is m2.info (not gm2.info, and gm2$(exeext) is a file not a directory (so test -d would always fail). 2024-03-29 Christophe Lyon gcc/m2/ * Make-lang.in (m2.install-info): Fix rule. Diff: --- gcc/m2/Make-lang.in | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index 2d8a47a1b1f..e56240b4c44 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -400,20 +400,20 @@ m2.install-common: installdirs done m2.install-info: installdirs - if [ -d gm2$(exeext) ] ; then \ - if [ -f $(objdir)/doc/gm2.info ]; then \ - rm -f $(DESTDIR)$(infodir)/gm2.info*; \ - for f in $(objdir)/doc/gm2.info*; do \ + if [ -f gm2$(exeext) ] ; then \ + if [ -f $(objdir)/doc/m2.info ]; then \ + rm -f $(DESTDIR)$(infodir)/m2.info*; \ + for f in $(objdir)/doc/m2.info*; do \ realfile=`echo $$f | sed -e 's|.*/\([^/]*\)$$|\1|'`; \ rm -f $(DESTDIR)$(infodir)/`basename $$realfile`; \ $(INSTALL_DATA) $$f $(DESTDIR)$(infodir)/`basename $$realfile`; \ done; \ - chmod a-x $(DESTDIR)$(infodir)/gm2.info*; \ + chmod a-x $(DESTDIR)$(infodir)/m2.info*; \ else true; fi; \ else true; fi - -if [ -f gm2$(exeext) ] && [ -f $(DESTDIR)$(infodir)/gm2.info ]; then \ + -if [ -f gm2$(exeext) ] && [ -f $(DESTDIR)$(infodir)/m2.info ]; then \ if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ - install-info --dir-file=$(infodir)/dir $(DESTDIR)$(infodir)/gm2.info; \ + install-info --dir-file=$(infodir)/dir $(DESTDIR)$(infodir)/m2.info; \ else true; fi; \ else true; fi
[gcc r14-9733] modula2: Add m2.install-html rule to gcc/m2/Make-lang.in
https://gcc.gnu.org/g:ec2c15f14f2278d431756f3d05e6ab7f436bea5e commit r14-9733-gec2c15f14f2278d431756f3d05e6ab7f436bea5e Author: Christophe Lyon Date: Fri Mar 29 17:10:36 2024 + modula2: Add m2.install-html rule to gcc/m2/Make-lang.in This rule was missing, and 'make install-html' was failing. It is copied from the corresponding one in fortran. 2024-03-29 Christophe Lyon gcc/m2/ * Make-lang.in (install-html): New rule. Diff: --- gcc/m2/Make-lang.in | 19 +++ 1 file changed, 19 insertions(+) diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index ef6990ce617..2d8a47a1b1f 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -206,6 +206,25 @@ $(build_htmldir)/m2/index.html: $(TEXISRC) $(objdir)/m2/images/gnu.eps rm -f $(@D)/* $(TEXI2HTML) -I $(objdir)/m2 -I $(srcdir)/m2 -I $(gcc_docdir)/include -o $(@D) $< +M2_HTMLFILES = $(build_htmldir)/m2 + +m2.install-html: $(M2_HTMLFILES) + @$(NORMAL_INSTALL) + test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)" + @list='$(M2_HTMLFILES)'; for p in $$list; do \ + if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; fi; \ + f=$(html__strip_dir) \ + if test -d "$$d$$p"; then \ + echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \ + $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ + echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \ + $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \ + else \ + echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \ + $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \ + fi; \ + done + # gm2-libs.texi m2/gm2-libs.texi: gm2-libs.texi-check; @true
[gcc r14-9732] [committed] RISC-V: Add missing insn types to XiangShan Nanhu scheduler model
https://gcc.gnu.org/g:08eaafadd5beaa56beb2d1fceca9f97eeb0219ba commit r14-9732-g08eaafadd5beaa56beb2d1fceca9f97eeb0219ba Author: Jeff Law Date: Sun Mar 31 10:51:17 2024 -0600 [committed] RISC-V: Add missing insn types to XiangShan Nanhu scheduler model The test for the recently added XiangShan Nanhu microarchitecture is failing because the scheduler description does not have entries for certain insn types. I'm adding branch, jalr, ret and sfb_alu to the scheduler description, that's enough to get the trivial test to pass. However, I strongly suspect running any significant code through the compiler when scheduling for this microarchitecture will trigger faults. Basically we have checking now that will fault if we have an insn in the IL without an associated type or if we have an insn in the IL that does not map to an insn reservation in the scheduler model. We were tripping the latter assertion for one of those branch types. My suspicion is many insn types aren't handled by that DFA. The branch insns were pretty obvious and easy to fix. But someone with more experience with the uarch needs to do an audit to ensure that all insn types map to an insn reservation. gcc/ * config/riscv/xiangshan.md (xiangshan_jump): Add branch, jalr, ret and sfb_alu. Diff: --- gcc/config/riscv/xiangshan.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/riscv/xiangshan.md b/gcc/config/riscv/xiangshan.md index 381c3ce1428..76539d332b8 100644 --- a/gcc/config/riscv/xiangshan.md +++ b/gcc/config/riscv/xiangshan.md @@ -70,7 +70,7 @@ (define_insn_reservation "xiangshan_jump" 1 (and (eq_attr "tune" "xiangshan") - (eq_attr "type" "jump,call,auipc,unknown")) + (eq_attr "type" "jump,call,auipc,unknown,branch,jalr,ret,sfb_alu")) "xs_jmp_rs") (define_insn_reservation "xiangshan_i2f" 3
[gcc r13-8543] fortran: Ignore use statements on error [PR107426]
https://gcc.gnu.org/g:fc5c603da3c9b186308fb3afef7bcf3f3bf695e8 commit r13-8543-gfc5c603da3c9b186308fb3afef7bcf3f3bf695e8 Author: Mikael Morin Date: Thu Mar 21 17:27:54 2024 +0100 fortran: Ignore use statements on error [PR107426] This fixes an access to freed memory on the testcase from the PR. The problem comes from an invalid subroutine statement in an interface, which is ignored and causes the following statements forming the procedure body to be rejected. One of them use-associates the intrinsic ISO_C_BINDING module, which imports new symbols in a namespace that is freed at the time the statement is rejected. However, this creates dangling pointers as ISO_C_BINDING is special and its import creates a reference to the imported C_PTR symbol in the return type of the global intrinsic symbol for C_LOC (see the function create_intrinsic_function). This change saves and restores the list of use statements, so that rejected use statements are removed before they have a chance to be applied to the current namespace and create dangling pointers. PR fortran/107426 gcc/fortran/ChangeLog: * gfortran.h (gfc_save_module_list, gfc_restore_old_module_list): New declarations. * module.cc (old_module_list_tail): New global variable. (gfc_save_module_list, gfc_restore_old_module_list): New functions. (gfc_use_modules): Set module_list and old_module_list_tail. * parse.cc (next_statement): Save module_list before doing any work. (reject_statement): Restore module_list to its saved value. gcc/testsuite/ChangeLog: * gfortran.dg/pr89943_3.f90: Update error pattern. * gfortran.dg/pr89943_4.f90: Likewise. * gfortran.dg/use_31.f90: New test. (cherry picked from commit a44d7e8a52007c2d45217709ca02947c6600de87) Diff: --- gcc/fortran/gfortran.h | 2 ++ gcc/fortran/module.cc | 31 +++ gcc/fortran/parse.cc| 4 gcc/testsuite/gfortran.dg/pr89943_3.f90 | 2 +- gcc/testsuite/gfortran.dg/pr89943_4.f90 | 2 +- gcc/testsuite/gfortran.dg/use_31.f90| 26 ++ 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index e6939056a7c..47414f73254 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -3850,6 +3850,8 @@ void gfc_module_done_2 (void); void gfc_dump_module (const char *, int); bool gfc_check_symbol_access (gfc_symbol *); void gfc_free_use_stmts (gfc_use_list *); +void gfc_save_module_list (); +void gfc_restore_old_module_list (); const char *gfc_dt_lower_string (const char *); const char *gfc_dt_upper_string (const char *); diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index 601497e0998..21141e9422d 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -195,7 +195,12 @@ static const char *module_name; /* The name of the .smod file that the submodule will write to. */ static const char *submodule_name; +/* The list of use statements to apply to the current namespace + before parsing the non-use statements. */ static gfc_use_list *module_list; +/* The end of the MODULE_LIST list above at the time the recognition + of the current statement started. */ +static gfc_use_list **old_module_list_tail; /* If we're reading an intrinsic module, this is its ID. */ static intmod_id current_intmod; @@ -7542,6 +7547,8 @@ gfc_use_modules (void) gfc_use_module (module_list); free (module_list); } + module_list = NULL; + old_module_list_tail = &module_list; gfc_rename_list = NULL; } @@ -7565,6 +7572,30 @@ gfc_free_use_stmts (gfc_use_list *use_stmts) } +/* Remember the end of the MODULE_LIST list, so that the list can be restored + to its previous state if the current statement is erroneous. */ + +void +gfc_save_module_list () +{ + gfc_use_list **tail = &module_list; + while (*tail != NULL) +tail = &(*tail)->next; + old_module_list_tail = tail; +} + + +/* Restore the MODULE_LIST list to its previous value and free the use + statements that are no longer part of the list. */ + +void +gfc_restore_old_module_list () +{ + gfc_free_use_stmts (*old_module_list_tail); + *old_module_list_tail = NULL; +} + + void gfc_module_init_2 (void) { diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index 83bb8a6f58b..0d366894643 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -1609,6 +1609,7 @@ next_statement (void) locus old_locus; gfc_enforce_clean_symbol_state (); + gfc_save_module_list (); gfc_new_block = NULL; @@ -2901,6 +2902,9 @@ reject_statement (void) gfc_reject_data (gfc_current_ns); + /* Don't queue use-association of a module if we reject the use statement. */ + gfc_restore_old_module_l
[gcc r13-8542] testsuite, Objective-C: Fix duplicate libobjc cases.
https://gcc.gnu.org/g:1b81063e29912f7a139c87c711d601d74373ece8 commit r13-8542-g1b81063e29912f7a139c87c711d601d74373ece8 Author: Iain Sandoe Date: Thu Jan 25 20:17:42 2024 + testsuite, Objective-C: Fix duplicate libobjc cases. Two of the encode testcases include '-lobjc' as their dg-options. Since the library is already appended as part of the generic testsuite handling, this means that two instances appear on the link line leading to spurious warnings from Darwin's new linker. gcc/testsuite/ChangeLog: * obj-c++.dg/encode-10.mm: Remove unneeded '-lobjc' option addition. * obj-c++.dg/encode-9.mm: Likewise. Signed-off-by: Iain Sandoe (cherry picked from commit 30d9e81c19d69e15b2e9c53e4377879cbf9b0b84) Diff: --- gcc/testsuite/obj-c++.dg/encode-10.mm | 1 - gcc/testsuite/obj-c++.dg/encode-9.mm | 1 - 2 files changed, 2 deletions(-) diff --git a/gcc/testsuite/obj-c++.dg/encode-10.mm b/gcc/testsuite/obj-c++.dg/encode-10.mm index 2b3af88dcb1..2477400b7f3 100644 --- a/gcc/testsuite/obj-c++.dg/encode-10.mm +++ b/gcc/testsuite/obj-c++.dg/encode-10.mm @@ -1,5 +1,4 @@ /* Test for @encode in templates. */ -/* { dg-options "-lobjc" } */ /* { dg-do run } */ #include #include diff --git a/gcc/testsuite/obj-c++.dg/encode-9.mm b/gcc/testsuite/obj-c++.dg/encode-9.mm index 6b064dfdc09..4fdb5fa50fb 100644 --- a/gcc/testsuite/obj-c++.dg/encode-9.mm +++ b/gcc/testsuite/obj-c++.dg/encode-9.mm @@ -1,5 +1,4 @@ /* Test than @encode is properly instantiated. */ -/* { dg-options "-lobjc" } */ /* { dg-do run } */ #include
[gcc r13-8540] Objective-C, Darwin: Do not overalign CFStrings and Objective-C metadata.
https://gcc.gnu.org/g:4e65626d29c129389b10c1c64fe33af680fc76db commit r13-8540-g4e65626d29c129389b10c1c64fe33af680fc76db Author: Iain Sandoe Date: Thu Jan 25 20:11:09 2024 + Objective-C, Darwin: Do not overalign CFStrings and Objective-C metadata. We have reports of regressions in both Objective-C and Objective-C++ on Darwin23 (macOS 14). In some cases, these are linker warnings about the alignment of CFString constants; in other cases the built executables crash during runtime initialization. The underlying issue is the same in both cases; since the objects (CFStrings, Objective-C meta-data) are TU- local, we are choosing to increase their alignment for efficiency - to values greater than ABI alignment. However, although these objects are TU-local, they are also visible to the linker (since they are placed in specific named sections). In many cases the metadata can be regarded as tables of data, and thus it is expected that these sections can be concatenated from multiple TUs and the data treated as tabular. In order for this to work the data cannot be allowed to exceed ABI alignment - which leads to the crashes. For GCC-15+ it would be nice to find a more elegant solution to this issue (perhaps by adjusting the concept of binds-locally to exclude specific named sections) - but I do not want to do that in stage 4. The solution here is to force the alignment to be preserved as created by setting DECL_USER_ALIGN on the relevant objects. gcc/ChangeLog: * config/darwin.cc (darwin_build_constant_cfstring): Prevent over- alignment of CFString constants by setting DECL_USER_ALIGN. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.cc (build_v2_address_table): Prevent over-alignment of Objective-C metadata by setting DECL_USER_ALIGN on relevant variables. (build_v2_protocol_list_address_table): Likewise. (generate_v2_protocol_list): Likewise. (generate_v2_meth_descriptor_table): Likewise. (generate_v2_meth_type_list): Likewise. (generate_v2_property_table): Likewise. (generate_v2_dispatch_table): Likewise. (generate_v2_ivars_list): Likewise. (generate_v2_class_structs): Likewise. (build_ehtype): Likewise. * objc-runtime-shared-support.cc (generate_strings): Likewise. Signed-off-by: Iain Sandoe (cherry picked from commit f74f840d35117bcaf995cee99fb2ab30c60f64f3) Diff: --- gcc/config/darwin.cc| 1 + gcc/objc/objc-next-runtime-abi-02.cc| 18 +++--- gcc/objc/objc-runtime-shared-support.cc | 4 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 5431b2721c9..3f7fb4d9a6a 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3834,6 +3834,7 @@ darwin_build_constant_cfstring (tree str) /* global namespace. */ DECL_CONTEXT (var) = NULL_TREE; DECL_INITIAL (var) = constructor; + DECL_USER_ALIGN (var) = 1; lang_hooks.decls.pushdecl (var); rest_of_decl_compilation (var, 1, 0); desc->ccf_str = var; diff --git a/gcc/objc/objc-next-runtime-abi-02.cc b/gcc/objc/objc-next-runtime-abi-02.cc index 0f23b73..7a674a0e45e 100644 --- a/gcc/objc/objc-next-runtime-abi-02.cc +++ b/gcc/objc/objc-next-runtime-abi-02.cc @@ -2246,6 +2246,7 @@ build_v2_address_table (vec *src, const char *nam, tree attr) DECL_PRESERVE_P (decl) = 1; expr = objc_build_constructor (type, initlist); OBJCMETA (decl, objc_meta, attr); + DECL_USER_ALIGN (decl) = 1; finish_var_decl (decl, expr); } @@ -2320,8 +2321,9 @@ build_v2_protocol_list_address_table (void) decl = create_global_decl (objc_protocol_type, buf, /*is def=*/true); expr = convert (objc_protocol_type, build_fold_addr_expr (ref->refdecl)); OBJCMETA (decl, objc_meta, meta_label_protocollist); - finish_var_decl (decl, expr); DECL_PRESERVE_P (decl) = 1; + DECL_USER_ALIGN (decl) = 1; + finish_var_decl (decl, expr); } /* TODO: delete the vec. */ @@ -2399,6 +2401,7 @@ generate_v2_protocol_list (tree i_or_p, tree klass_ctxt) /* ObjC2 puts all these in the base section. */ OBJCMETA (refs_decl, objc_meta, meta_base); DECL_PRESERVE_P (refs_decl) = 1; + DECL_USER_ALIGN (refs_decl) = 1; finish_var_decl (refs_decl, objc_build_constructor (TREE_TYPE (refs_decl),initlist)); return refs_decl; @@ -2507,6 +2510,7 @@ generate_v2_meth_descriptor_table (tree chain, tree protocol, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, initlist); /* Get into the right section. */ OBJCMETA (decl, objc_meta, attr); + DECL_USER_ALIGN (decl) = 1; finish_var_decl (decl, objc_build_constructor (method_list_template, v)); return decl; } @
[gcc r13-8541] testsuite, objective-c++: Fix imported NSObjCRuntime.h.
https://gcc.gnu.org/g:46b76b76bdcaa80814249784c9227e5aea82879b commit r13-8541-g46b76b76bdcaa80814249784c9227e5aea82879b Author: Iain Sandoe Date: Fri Jun 23 15:29:14 2023 +0100 testsuite,objective-c++: Fix imported NSObjCRuntime.h. We have imported some headers from the GNUStep project to allow us to maintain the testsuite independent to changing versions of system headers. One of these headers has a macro that (now we have support for __has_feature) expands to a declaration that triggers a warning. These headers are considered part of the implementation so that, in this case, we can suppress the warning with the system_header pragma. Signed-off-by: Iain Sandoe gcc/testsuite/ChangeLog: * objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h: Make this header use pragma system_header. (cherry picked from commit d83e0e3bc375a05844438d28c9a4ab24c5401eb9) Diff: --- gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h index 189af80436a..62556f9ac88 100644 --- a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h @@ -29,6 +29,9 @@ #ifndef __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE #define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE +/* Allow the elaborated enum use in _GS_NAMED_ENUM. */ +#pragma GCC system_header + #ifdef __cplusplus #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1
[gcc r13-8539] Objective-C/C++: Ensure sufficient setup for the preprocessor.
https://gcc.gnu.org/g:56455edc6572f11c68e1a079dba9ba910c334d1e commit r13-8539-g56455edc6572f11c68e1a079dba9ba910c334d1e Author: Iain Sandoe Date: Tue Jan 9 17:31:41 2024 + Objective-C/C++: Ensure sufficient setup for the preprocessor. The tokenizer makes use of functions that determine if identifiers are interface or class names, and those functions need a hash map to be set up. This ensures that these are initialized before pre-process-only jobs are run. gcc/objc/ChangeLog: * objc-act.cc (objc_init): Initialize interface and class name hash maps before the preprocessor uses them. Signed-off-by: Iain Sandoe (cherry picked from commit 60f58d0630805e8dce79f5489658fd83e42fa8f1) Diff: --- gcc/objc/objc-act.cc | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/objc/objc-act.cc b/gcc/objc/objc-act.cc index 08201749207..fe2d2b595b4 100644 --- a/gcc/objc/objc-act.cc +++ b/gcc/objc/objc-act.cc @@ -345,6 +345,11 @@ bool objc_init (void) { bool ok; + + /* Set up stuff used by the preprocessor as well as FE parser. */ + interface_hash_init (); + hash_init (); + #ifdef OBJCPLUS if (cxx_init () == false) #else @@ -374,8 +379,6 @@ objc_init (void) /* Set up stuff used by FE parser and all runtimes. */ errbuf = XNEWVEC (char, 1024 * 10); - interface_hash_init (); - hash_init (); objc_encoding_init (); /* ... and then check flags and set-up for the selected runtime ... */ if (flag_next_runtime && flag_objc_abi >= 2)
[gcc r13-8538] Darwin: Fix a typo in Objective-C meta-data.
https://gcc.gnu.org/g:5ec63c2e0b9bc90247686a60db521426cef428f6 commit r13-8538-g5ec63c2e0b9bc90247686a60db521426cef428f6 Author: Iain Sandoe Date: Mon Jan 8 16:17:04 2024 + Darwin: Fix a typo in Objective-C meta-data. We have a typo in the metadata for assigning NSStrings to a specific section for the V1 (32b) ABI. When that is fixed we should never see the case where the section needs to be deduced from the properties of the DECLs. gcc/ChangeLog: * config/darwin.cc (darwin_objc1_section): Use the correct meta-data version for constant strings. (machopic_select_section): Assert if we fail to handle CFString sections as Obejctive-C meta-data or drectly. Signed-off-by: Iain Sandoe (cherry picked from commit 8d26636f0da31e6c17b57ced52bfc61a45f23cee) Diff: --- gcc/config/darwin.cc | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index d23bfcca18c..5431b2721c9 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -1586,7 +1586,7 @@ darwin_objc1_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base) else if (startswith (p, "V1_CEXT")) return darwin_sections[objc1_class_ext_section]; - else if (startswith (p, "V2_CSTR")) + else if (startswith (p, "V1_CSTR")) return darwin_sections[objc_constant_string_object_section]; return base; @@ -1730,7 +1730,7 @@ machopic_select_section (tree decl, return base_section; /* GNU runtime is happy with it all in one pot. */ } - /* b) Constant string objects. */ + /* b) Constructors for constant NSstring [but not CFString] objects. */ if (TREE_CODE (decl) == CONSTRUCTOR && TREE_TYPE (decl) && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE @@ -1752,6 +1752,12 @@ machopic_select_section (tree decl, else return darwin_sections[objc_string_object_section]; } + else if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_CFString")) + { + /* We should have handled __anon_cfstrings above. */ + gcc_checking_assert (0); + return darwin_sections[cfstring_constant_object_section]; + } else return base_section; }
[gcc r13-8537] Darwin: Fix constant CFString code-gen [PR105522].
https://gcc.gnu.org/g:bd760ac35d792683cd82f6b665516528fe11752a commit r13-8537-gbd760ac35d792683cd82f6b665516528fe11752a Author: Iain Sandoe Date: Sat Jan 6 10:52:38 2024 + Darwin: Fix constant CFString code-gen [PR105522]. Although this only fires for one of the Darwin sub-ports, it is latent elsewhere, it is also a regression c.f. the Darwin system compiler. In the code we imported from an earlier branch, CFString objects (which are constant aggregates) are constructed as CONST_DECLs. Although our current documentation suggests that these are reserved for enumeration values, in fact they are used elsewhere in the compiler for constants. This includes Objective-C where they are used to form NSString constants. In the particular case, we take the address of the constant and that triggers varasm.cc:decode_addr_constant, which does not currently support CONST_DECL. If there is a general intent to allow/encourage wider use of CONST_DECL, then we should fix decode_addr_constant to look through these and evaluate the initializer (a two-line patch, but I'm not suggesting it for stage-4). We also need to update the GCC internals documentation to allow for the additional uses. This patch is Darwin-local and fixes the problem by making the CFString constants into regular variable but TREE_CONSTANT+TREE_READONLY. I plan to back-port this to the open branches once it has baked a while on trunk. Since, for Darwin, the Objective-C default is to construct constant NSString objects as CFStrings; this will also cover the majority of cases there (this patch does not make any changes to Objective-C NSStrings). PR target/105522 gcc/ChangeLog: * config/darwin.cc (machopic_select_section): Handle C and C++ CFStrings. (darwin_rename_builtins): Move this out of the CFString code. (darwin_libc_has_function): Likewise. (darwin_build_constant_cfstring): Create an anonymous var to hold each CFString. * config/darwin.h (ASM_OUTPUT_LABELREF): Handle constant CFstrings. Signed-off-by: Iain Sandoe (cherry picked from commit aecc0d4ba73d0810334b351da1e67232cea450d3) Diff: --- gcc/config/darwin.cc| 100 +++- gcc/config/darwin.h | 2 + gcc/testsuite/gcc.dg/pr105522.c | 17 +++ 3 files changed, 76 insertions(+), 43 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index d719ef29cd6..d23bfcca18c 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -1679,7 +1679,16 @@ machopic_select_section (tree decl, base_section = darwin_sections[zobj_data_section]; } else if (ro) - base_section = darwin_sections[const_data_section]; + { + if (VAR_P (decl) && TREE_TYPE (decl) + && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE + && DECL_NAME (decl) + && strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), + "__anon_cfstring", 15) == 0) + base_section = darwin_sections[cfstring_constant_object_section]; + else + base_section = darwin_sections[const_data_section]; + } else base_section = data_section; break; @@ -1743,8 +1752,6 @@ machopic_select_section (tree decl, else return darwin_sections[objc_string_object_section]; } - else if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_CFString")) - return darwin_sections[cfstring_constant_object_section]; else return base_section; } @@ -3537,6 +3544,29 @@ darwin_patch_builtins (void) } #endif +void +darwin_rename_builtins (void) +{ +} + +/* Implementation for the TARGET_LIBC_HAS_FUNCTION hook. */ + +bool +darwin_libc_has_function (enum function_class fn_class, + tree type ATTRIBUTE_UNUSED) +{ + if (fn_class == function_sincos && darwin_macosx_version_min) +return (strverscmp (darwin_macosx_version_min, "10.9") >= 0); +#if DARWIN_PPC && SUPPORT_DARWIN_LEGACY + if (fn_class == function_c99_math_complex + || fn_class == function_c99_misc) +return (TARGET_64BIT + || (darwin_macosx_version_min && + strverscmp (darwin_macosx_version_min, "10.3") >= 0)); +#endif + return default_libc_has_function (fn_class, type); +} + /* CFStrings implementation. */ static GTY(()) tree cfstring_class_reference = NULL_TREE; static GTY(()) tree cfstring_type_node = NULL_TREE; @@ -3554,7 +3584,7 @@ typedef struct GTY ((for_user)) cfstring_descriptor { /* The string literal. */ tree literal; /* The resulting constant CFString. */ - tree constructor; + tree ccf_str; } cfstring_descriptor; struct cfstring_hasher : ggc_ptr_hash @@ -3629,7 +3659,7 @@ darwin_init_cfstring_bui
[gcc r13-8536] Objective-C, Darwin: Fix a regression in handling bad receivers.
https://gcc.gnu.org/g:db0b08494f3f75704622abf95a7c56d89720627c commit r13-8536-gdb0b08494f3f75704622abf95a7c56d89720627c Author: Iain Sandoe Date: Sat Jan 6 19:21:40 2024 + Objective-C, Darwin: Fix a regression in handling bad receivers. This is seen on 32b hosts with a 64b multilib, and is an ICE when the build has checking enabled. The fix is to exit the routine early if the sender or receiver are already error_mark_node. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.cc (build_v2_objc_method_fixup_call): Early exit for cases where the sender or receiver are known to be in error. Signed-off-by: Iain Sandoe (cherry picked from commit 846794ead2982fc85a3b1a83bbb831fa096b2b7c) Diff: --- gcc/objc/objc-next-runtime-abi-02.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/objc/objc-next-runtime-abi-02.cc b/gcc/objc/objc-next-runtime-abi-02.cc index bcfc0ce8e19..0f23b73 100644 --- a/gcc/objc/objc-next-runtime-abi-02.cc +++ b/gcc/objc/objc-next-runtime-abi-02.cc @@ -1657,6 +1657,8 @@ build_v2_objc_method_fixup_call (int super_flag, tree method_prototype, rcv_p = (super_flag ? objc_super_type : objc_object_type); lookup_object = build_c_cast (input_location, rcv_p, lookup_object); + if (sender == error_mark_node || lookup_object == error_mark_node) +return error_mark_node; /* Use SAVE_EXPR to avoid evaluating the receiver twice. */ lookup_object = save_expr (lookup_object);
[gcc r13-8535] Darwin: Make metadata symbol lables linker-visible for GNU objc.
https://gcc.gnu.org/g:6266bdbe0014659535f9d600ffe2b9e2e9e8c20e commit r13-8535-g6266bdbe0014659535f9d600ffe2b9e2e9e8c20e Author: Iain Sandoe Date: Sat Sep 30 17:15:16 2023 +0100 Darwin: Make metadata symbol lables linker-visible for GNU objc. Now we have shifted to using the same relocation mechanism as clang for objective-c typeinfo the static linker needs to have a linker-visible symbol for metadata names (this is only needed for GNU objective C, for NeXT the names are in separate sections). gcc/ChangeLog: * config/darwin.h (darwin_label_is_anonymous_local_objc_name): Make metadata names linker-visibile for GNU objective C. Signed-off-by: Iain Sandoe (cherry picked from commit 2ae00adb326ed050bd67a67656b20a2cfe789626) Diff: --- gcc/config/darwin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index c50ee94ed28..c2505d70340 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -823,7 +823,7 @@ int darwin_label_is_anonymous_local_objc_name (const char *name); else if (xname[0] == '+' || xname[0] == '-') \ fprintf (FILE, "\"%s\"", xname); \ else if (darwin_label_is_anonymous_local_objc_name (xname)) \ - fprintf (FILE, "L%s", xname); \ + fprintf (FILE, "%c%s", flag_next_runtime ? 'L' : 'l', xname);\ else if (xname[0] != '"' && name_needs_quotes (xname)) \ asm_fprintf (FILE, "\"%U%s\"", xname); \ else \
[gcc r13-8534] Darwin: Check as for .build_version support and use it if available.
https://gcc.gnu.org/g:36240bcad8519b08ebe758cfa49d074adcc68bbc commit r13-8534-g36240bcad8519b08ebe758cfa49d074adcc68bbc Author: Iain Sandoe Date: Tue Oct 17 11:10:27 2023 +0100 Darwin: Check as for .build_version support and use it if available. This adds support for the minimum OS version data in assembler files. At present, we have no mechanism to detect the SDK version in use, and so that is omitted from build_versions. We follow the implementation in clang, '.build_version' is only emitted (where supported) for target macOS versions >= 10.14. For earlier macOS we fall back to using a '.macosx_version_min' directive. This latter is also emitted when the assembler supports it, but not build_version. gcc/ChangeLog: * config.in: Regenerate. * config/darwin.cc (darwin_file_start): Add assembler directives for the target OS version, where these are supported by the assembler. (darwin_override_options): Check for building >= macOS 10.14. * configure: Regenerate. * configure.ac: Check for assembler support of .build_version directives. Signed-off-by: Iain Sandoe (cherry picked from commit a4184c8a65a00eaf8a8d7f92fb8ad2f8621b39e2) Diff: --- gcc/config.in| 9 +++-- gcc/config/darwin.cc | 34 -- gcc/configure| 33 + gcc/configure.ac | 10 +- 4 files changed, 81 insertions(+), 5 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index 83c98ae1457..5281a12a707 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -610,6 +610,12 @@ #endif +/* Define if your macOS assembler supports .build_version directives */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_MACOS_BUILD_VERSION +#endif + + /* Define if the assembler understands -march=rv*_zifencei. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_MARCH_ZIFENCEI @@ -635,8 +641,7 @@ #endif -/* Define if your Mac OS X assembler supports the -mmacos-version-min option. - */ +/* Define if your macOS assembler supports the -mmacos-version-min option. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_MMACOSX_VERSION_MIN_OPTION #endif diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 5e1b8ccd4eb..d719ef29cd6 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3021,7 +3021,35 @@ darwin_asm_output_dwarf_offset (FILE *file, int size, const char * lab, void darwin_file_start (void) { - /* Nothing to do. */ +#ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION + /* This should not happen with a well-formed command line, but the user could + invoke cc1* directly without it. */ + if (!darwin_macosx_version_min) +return; + /* This assumes that the version passed has been validated in the driver. */ + unsigned maj, min, tiny; + int count = sscanf (darwin_macosx_version_min, "%u.%u.%u", &maj, &min, &tiny); + if (count < 0) +return; + if (count < 3) +tiny = 0; + if (count < 2) +min = 0; + const char *directive; +#ifdef HAVE_AS_MACOS_BUILD_VERSION + /* We only handle macos, so far. */ + if (generating_for_darwin_version >= 18) +directive = "build_version macos, "; + else +#endif +directive = "macosx_version_min "; + if (count > 2 && tiny != 0) +fprintf (asm_out_file, "\t.%s %u, %u, %u\n", directive, maj, min, tiny); + else if (count > 1) +fprintf (asm_out_file, "\t.%s %u, %u\n", directive, maj, min); + else + fprintf (asm_out_file, "\t.%s %u, 0\n", directive, maj); +#endif } /* Called for the TARGET_ASM_FILE_END hook. @@ -3243,7 +3271,9 @@ darwin_override_options (void) /* Keep track of which (major) version we're generating code for. */ if (darwin_macosx_version_min) { - if (strverscmp (darwin_macosx_version_min, "10.7") >= 0) + if (strverscmp (darwin_macosx_version_min, "10.14") >= 0) + generating_for_darwin_version = 18; + else if (strverscmp (darwin_macosx_version_min, "10.7") >= 0) generating_for_darwin_version = 11; else if (strverscmp (darwin_macosx_version_min, "10.6") >= 0) generating_for_darwin_version = 10; diff --git a/gcc/configure b/gcc/configure index bb675fdd461..ade0af23e8c 100755 --- a/gcc/configure +++ b/gcc/configure @@ -26266,6 +26266,39 @@ $as_echo "#define HAVE_AS_MMACOSX_VERSION_MIN_OPTION 1" >>confdefs.h fi +if test x$gcc_cv_as_mmacosx_version_min = "xyes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .build_version" >&5 +$as_echo_n "checking assembler for .build_version... " >&6; } +if ${gcc_cv_as_darwin_build_version+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_darwin_build_version=no + if test x$gcc_cv_as != x; then +$as_echo ' .build_version macos, 10, 14 sdk_version 10, 14' > conftest.s +if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mmacosx-version-min=10.14 -o conftest.o conftest.s >&
[gcc r14-9731] RISC-V: Fix misspelled term builtin in error message
https://gcc.gnu.org/g:b313baba57f7e09f66b603e1e30dd4b48800693f commit r14-9731-gb313baba57f7e09f66b603e1e30dd4b48800693f Author: Pan Li Date: Sat Mar 30 20:03:18 2024 +0800 RISC-V: Fix misspelled term builtin in error message This patch would like to fix below misspelled term in error message. ../../gcc/config/riscv/riscv-vector-builtins.cc:4592:16: error: misspelled term 'builtin function' in format; use 'built-in function' instead [-Werror=format-diag] 4592 | "builtin function %qE requires the V ISA extension", exp); The below tests are passed for this patch. * The riscv regression test on rvv.exp and riscv.exp. gcc/ChangeLog: * config/riscv/riscv-vector-builtins.cc (expand_builtin): Take the term built-in over builtin. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-7.c: Adjust test dg-error. * gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-8.c: Ditto. Signed-off-by: Pan Li Diff: --- gcc/config/riscv/riscv-vector-builtins.cc | 2 +- .../gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-7.c | 2 +- .../gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-8.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc index e07373d8b57..db9246eed2d 100644 --- a/gcc/config/riscv/riscv-vector-builtins.cc +++ b/gcc/config/riscv/riscv-vector-builtins.cc @@ -4589,7 +4589,7 @@ expand_builtin (unsigned int code, tree exp, rtx target) if (!TARGET_VECTOR) error_at (EXPR_LOCATION (exp), - "builtin function %qE requires the V ISA extension", exp); + "built-in function %qE requires the V ISA extension", exp); return function_expander (rfn.instance, rfn.decl, exp, target).expand (); } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-7.c b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-7.c index 520b2e59fae..a4cd67f4f95 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-7.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-7.c @@ -5,5 +5,5 @@ size_t test_1 (size_t vl) { - return __riscv_vsetvl_e8m4 (vl); /* { dg-error {builtin function '__riscv_vsetvl_e8m4\(vl\)' requires the V ISA extension} } */ + return __riscv_vsetvl_e8m4 (vl); /* { dg-error {built-in function '__riscv_vsetvl_e8m4\(vl\)' requires the V ISA extension} } */ } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-8.c b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-8.c index 9032d9d0b43..06ed9a9eddc 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-8.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-8.c @@ -19,5 +19,5 @@ test_2 () size_t test_3 (size_t vl) { - return __riscv_vsetvl_e8m4 (vl); /* { dg-error {builtin function '__riscv_vsetvl_e8m4\(vl\)' requires the V ISA extension} } */ + return __riscv_vsetvl_e8m4 (vl); /* { dg-error {built-in function '__riscv_vsetvl_e8m4\(vl\)' requires the V ISA extension} } */ }
[gcc r14-9730] RISC-V: Fix one unused varable in riscv_subset_list::parse
https://gcc.gnu.org/g:46eb34a75a9d004ce776bba382fe8af0978cace7 commit r14-9730-g46eb34a75a9d004ce776bba382fe8af0978cace7 Author: Pan Li Date: Sat Mar 30 21:32:06 2024 +0800 RISC-V: Fix one unused varable in riscv_subset_list::parse This patch would like to fix one unused variable as below: ../../gcc/common/config/riscv/riscv-common.cc: In static member function 'static riscv_subset_list* riscv_subset_list::parse(const char*, location_t)': ../../gcc/common/config/riscv/riscv-common.cc:1501:19: error: unused variable 'itr' [-Werror=unused-variable] 1501 | riscv_subset_t *itr; The variable consume code was removed but missed the var itself in previous. Thus, we have unused variable here. gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_subset_list::parse): Remove unused var decl. Signed-off-by: Pan Li Diff: --- gcc/common/config/riscv/riscv-common.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 7095f303cbb..43b7549e3ec 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -1498,7 +1498,6 @@ riscv_subset_list::parse (const char *arch, location_t loc) return NULL; riscv_subset_list *subset_list = new riscv_subset_list (arch, loc); - riscv_subset_t *itr; const char *p = arch; p = subset_list->parse_base_ext (p); if (p == NULL)
[gcc r13-8533] Darwin, configure: Allow for an unrecognisable dsymutil [PR111610].
https://gcc.gnu.org/g:17e5d36db43f22a696a97c24afb5fb36b00dfb0b commit r13-8533-g17e5d36db43f22a696a97c24afb5fb36b00dfb0b Author: Iain Sandoe Date: Wed Sep 27 11:05:31 2023 +0100 Darwin, configure: Allow for an unrecognisable dsymutil [PR111610]. We had a catch-all configuration case for missing or unrecognised dsymutil but it was setting the dsymutil source to "UNKNOWN" which is not usable in this context (since it clashes with an existing enum). We rename this to DET_UNKNOWN (for Darwin External Toolchain). PR target/111610 gcc/ChangeLog: * configure: Regenerate. * configure.ac: Rename the missing dsymutil case to "DET_UNKNOWN". Signed-off-by: Iain Sandoe (cherry picked from commit 2ecab2f32b9e9a75bf563f80752d5b44dcd26b98) Diff: --- gcc/configure| 2 +- gcc/configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/configure b/gcc/configure index f46c8c15147..bb675fdd461 100755 --- a/gcc/configure +++ b/gcc/configure @@ -30710,7 +30710,7 @@ $as_echo_n "checking dsymutil version \"$dsymutil_temp\"... " >&6; } dsymutil_kind=LLVM dsymutil_vers=`echo $dsymutil_temp | sed 's/.*LLVM\ version\ \([0-9\.]*\).*/\1/'` else - dsymutil_kind=UNKNOWN + dsymutil_kind=DET_UNKNOWN dsymutil_vers="0.0" fi dsymutil_major=`expr "$dsymutil_vers" : '\([0-9]*\)'` diff --git a/gcc/configure.ac b/gcc/configure.ac index 947d7cd596e..70a51919e24 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -6351,7 +6351,7 @@ if test x"$dsymutil_flag" = x"yes"; then dsymutil_kind=LLVM dsymutil_vers=`echo $dsymutil_temp | sed 's/.*LLVM\ version\ \([[0-9\.]]*\).*/\1/'` else - dsymutil_kind=UNKNOWN + dsymutil_kind=DET_UNKNOWN dsymutil_vers="0.0" fi dsymutil_major=`expr "$dsymutil_vers" : '\([[0-9]]*\)'`
[gcc r13-8532] Darwin: Place global inits in the correct section.
https://gcc.gnu.org/g:be95ee81bc934d6b22e5639eb7b5f9603fa1443d commit r13-8532-gbe95ee81bc934d6b22e5639eb7b5f9603fa1443d Author: Iain Sandoe Date: Fri Sep 1 09:04:13 2023 +0100 Darwin: Place global inits in the correct section. This handles placement of global initializers into __TEXT,__StaticInit as used by other platform toolchains. Since we do see global initialization code getting hot/cold splits, this patch places the cold parts into text_cold, and keeps the hot part in the correct Init section per ABI. This includes the update from 5b33b364652866165431aef1810af1e890229c5e. Signed-off-by: Iain Sandoe gcc/ChangeLog: * config/darwin-sections.def (static_init_section): Add the __TEXT,__StaticInit section. * config/darwin.cc (darwin_function_section): Use the static init section for global initializers, to match other platform toolchains. Place unlikely executed global init code into the standard cold section. (cherry picked from commit 68dc3e94fd6bd395a8b343533485616dff3fc796) Diff: --- gcc/config/darwin-sections.def | 2 ++ gcc/config/darwin.cc | 13 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/config/darwin-sections.def b/gcc/config/darwin-sections.def index de2334f4a7a..7e1b4710bd6 100644 --- a/gcc/config/darwin-sections.def +++ b/gcc/config/darwin-sections.def @@ -98,6 +98,8 @@ DEF_SECTION (mod_init_section, 0, ".mod_init_func", 0) DEF_SECTION (mod_term_section, 0, ".mod_term_func", 0) DEF_SECTION (constructor_section, 0, ".constructor", 0) DEF_SECTION (destructor_section, 0, ".destructor", 0) +DEF_SECTION (static_init_section, SECTION_CODE, +".section\t__TEXT,__StaticInit,regular,pure_instructions", 0) /* Objective-C ABI=0 (Original version) sections. */ DEF_SECTION (objc_class_section, 0, ".objc_class", 1) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index c5c0fb034af..5e1b8ccd4eb 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3854,11 +3854,22 @@ darwin_function_section (tree decl, enum node_frequency freq, if (decl && DECL_SECTION_NAME (decl) != NULL) return get_named_section (decl, NULL, 0); - /* We always put unlikely executed stuff in the cold section. */ + /* We always put unlikely executed stuff in the cold section; we have to put + this ahead of the global init section, since partitioning within a section + breaks some assumptions made in the DWARF handling. */ if (freq == NODE_FREQUENCY_UNLIKELY_EXECUTED) return (use_coal) ? darwin_sections[text_cold_coal_section] : darwin_sections[text_cold_section]; + /* Intercept functions in global init; these are placed in separate sections. + FIXME: there should be some neater way to do this, FIXME we should be able + to partition within a section. */ + if (DECL_NAME (decl) + && (startswith (IDENTIFIER_POINTER (DECL_NAME (decl)), "_GLOBAL__sub_I") + || startswith (IDENTIFIER_POINTER (DECL_NAME (decl)), +"__static_initialization_and_destruction"))) +return darwin_sections[static_init_section]; + /* If we have LTO *and* feedback information, then let LTO handle the function ordering, it makes a better job (for normal, hot, startup and exit - hence the bailout for cold above). */
[gcc r13-8531] Darwin: Match system sections and relocs for exception tables.
https://gcc.gnu.org/g:3449ce05f7cf5b84a866c2a1969285fdece6e5e9 commit r13-8531-g3449ce05f7cf5b84a866c2a1969285fdece6e5e9 Author: Iain Sandoe Date: Thu Aug 31 19:20:43 2023 +0100 Darwin: Match system sections and relocs for exception tables. System tools from Darwin10 onwards have moved the exceptions tables from the __DATA segment to the __TEXT one. They also revised the relocations used for typeinfo. While Darwin9 was not changed at the time, in fact the tools there are equally happy with the revised scheme - and therefore at present there seems no reason to special-case it. Signed-off-by: Iain Sandoe gcc/ChangeLog: * config/darwin-sections.def (darwin_exception_section): Move to the __TEXT segment. * config/darwin.cc (darwin_emit_except_table_label): Align before the exception table label. * config/darwin.h (ASM_PREFERRED_EH_DATA_FORMAT): Use indirect PC- relative 4byte relocs. (cherry picked from commit 0fe7962afc7c01488432b98b6f442b24946a490d) Diff: --- gcc/config/darwin-sections.def | 2 +- gcc/config/darwin.cc | 1 + gcc/config/darwin.h| 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/darwin-sections.def b/gcc/config/darwin-sections.def index 62a51b9761c..de2334f4a7a 100644 --- a/gcc/config/darwin-sections.def +++ b/gcc/config/darwin-sections.def @@ -157,7 +157,7 @@ DEF_SECTION (machopic_picsymbol_stub3_section, SECTION_NO_ANCHOR, /* Exception-related. */ DEF_SECTION (darwin_exception_section, SECTION_NO_ANCHOR, -".section __DATA,__gcc_except_tab", 0) +".section __TEXT,__gcc_except_tab", 0) DEF_SECTION (darwin_eh_frame_section, SECTION_NO_ANCHOR, ".section " EH_FRAME_SECTION_NAME ",__eh_frame" EH_FRAME_SECTION_ATTR, 0) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index ced2f7e40a6..c5c0fb034af 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -2232,6 +2232,7 @@ darwin_emit_except_table_label (FILE *file) { char section_start_label[30]; + fputs ("\t.p2align\t2\n", file); ASM_GENERATE_INTERNAL_LABEL (section_start_label, "GCC_except_table", except_table_label_num++); ASM_OUTPUT_LABEL (file, section_start_label); diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 1b538c73593..c50ee94ed28 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -1082,7 +1082,7 @@ enum machopic_addr_class { #undef ASM_PREFERRED_EH_DATA_FORMAT #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ - (((CODE) == 2 && (GLOBAL) == 1) \ + (((CODE) == 2 && (GLOBAL) == 1) || ((CODE) == 0 && (GLOBAL) == 1) \ ? (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4) : \ ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
[gcc r13-8530] build: Allow for Xcode 15 ld -v output
https://gcc.gnu.org/g:5213c9050636fa5c8210be4b5f93a1df4b6fa05b commit r13-8530-g5213c9050636fa5c8210be4b5f93a1df4b6fa05b Author: Rainer Orth Date: Thu Aug 17 10:14:49 2023 +0200 build: Allow for Xcode 15 ld -v output Since Xcode 15 beta 6, ld -v output differs from previous versions: * macOS 13/Xcode 14: @(#)PROGRAM:ld PROJECT:ld64-857.1 * macOS 14/Xcode 15: @(#)PROGRAM:ld PROJECT:dyld-1015.1 configure cannot handle the new form, so LD64_VERSION isn't set. This patch fixes this. The autoconf manual states that sed doesn't portably support alternation, so I'm using two separate expressions to extract the version number. Tested on x86_64-apple-darwin23.0.0. 2023-08-16 Rainer Orth gcc: * configure.ac (gcc_cv_ld64_version): Allow for dyld in ld -v output. * configure: Regenerate. (cherry picked from commit 0beac9209f0ae230b34ad31e76e7b0b633a5fb21) Diff: --- gcc/configure| 3 ++- gcc/configure.ac | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/configure b/gcc/configure index a6f39ba4659..f46c8c15147 100755 --- a/gcc/configure +++ b/gcc/configure @@ -30639,7 +30639,8 @@ $as_echo "$gcc_cv_ld64_major" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker version" >&5 $as_echo_n "checking linker version... " >&6; } if test x"${gcc_cv_ld64_version}" = x; then - gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | grep ld64 | sed s/.*ld64-// | awk '{print $1}'` + gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | $EGREP 'ld64|dyld' \ + | sed -e 's/.*ld64-//' -e 's/.*dyld-//'| awk '{print $1}'` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_version" >&5 $as_echo "$gcc_cv_ld64_version" >&6; } diff --git a/gcc/configure.ac b/gcc/configure.ac index 4ed70c5..947d7cd596e 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -6296,7 +6296,8 @@ if test x"$ld64_flag" = x"yes"; then # If the version was not specified, try to find it. AC_MSG_CHECKING(linker version) if test x"${gcc_cv_ld64_version}" = x; then - gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | grep ld64 | sed s/.*ld64-// | awk '{print $1}'` + gcc_cv_ld64_version=`$gcc_cv_ld -v 2>&1 | $EGREP 'ld64|dyld' \ + | sed -e 's/.*ld64-//' -e 's/.*dyld-//'| awk '{print $1}'` fi AC_MSG_RESULT($gcc_cv_ld64_version)
[gcc r13-8529] configure, Darwin: Adjust handing of stdlib option.
https://gcc.gnu.org/g:b491a8bed37a46bca69a811718d212c8b43355ab commit r13-8529-gb491a8bed37a46bca69a811718d212c8b43355ab Author: Iain Sandoe Date: Sat Sep 16 08:40:49 2023 +0100 configure, Darwin: Adjust handing of stdlib option. The intent of the configuration choices for -stdlib is that default setting should choose reasonable options for the target. This should enable -stdlib= for Darwin targets where libc++ is the default on the system (so that it is only necessary to provide the headers). However, it seems that there are some cases where (external) config scripts are using -stdlib (incorrectly) to determine if the compiler in use is GCC or clang. In order to allow for these cases, this patch refines the setting like so: --with-gxx-libcxx-include-dir= is used to configure the path containing libc++ headers; it also controls the enabling of the -stdlib option. We are adding a special value for path: if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option. Otherwise if the --with-gxx-libcxx-include-dir is set we use the path provided, and enable the stdlib option. if --with-gxx-libcxx-include-dir is unset We decide on the stdlib option based on the OS type and revision being targeted. The path is set to a fixed position relative to the compiler install (similar logic to that used for libstdc++ headers). Signed-off-by: Iain Sandoe gcc/ChangeLog: * configure: Regenerate. * configure.ac: Handle explict disable of stdlib option, set defaults for Darwin. (cherry picked from commit ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc) Diff: --- gcc/configure| 45 ++--- gcc/configure.ac | 38 ++ 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/gcc/configure b/gcc/configure index 8a92601ef40..a6f39ba4659 100755 --- a/gcc/configure +++ b/gcc/configure @@ -3761,31 +3761,54 @@ gcc_gxx_libcxx_include_dir= if test "${with_gxx_libcxx_include_dir+set}" = set; then : withval=$with_gxx_libcxx_include_dir; case "${withval}" in yes) as_fn_error $? "bad value ${withval} given for libc++ include directory" "$LINENO" 5 ;; -no);; *) gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir ;; esac fi +# --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option. +# if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option. +# if --with-gxx-libcxx-include-dir is unset we enable the stdlib option +# based on the platform (to be available on platform versions where it is the +# default for the system tools). We also use a default path within the compiler +# install tree. +# Otherwise, we use the path provided and enable the stdlib option. # If both --with-sysroot and --with-gxx-libcxx-include-dir are passed, we # check to see if the latter starts with the former and, upon success, compute # gcc_gxx_libcxx_include_dir as relative to the sysroot. gcc_gxx_libcxx_include_dir_add_sysroot=0 - +gcc_enable_stdlib_opt=0 if test x${gcc_gxx_libcxx_include_dir} != x; then + if test x${gcc_gxx_libcxx_include_dir} = xno; then +# set defaults for the dir, but the option is disabled anyway. +gcc_gxx_libcxx_include_dir= + else +gcc_enable_stdlib_opt=1 + fi +else + case $target in +*-darwin1[1-9]* | *-darwin2*) + # Default this on for Darwin versions which default to libcxx, + # and embed the path in the compiler install so that we get a + # self-contained toolchain. + gcc_enable_stdlib_opt=1 + ;; +*) ;; + esac +fi -$as_echo "#define ENABLE_STDLIB_OPTION 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define ENABLE_STDLIB_OPTION $gcc_enable_stdlib_opt +_ACEOF -else - $as_echo "#define ENABLE_STDLIB_OPTION 0" >>confdefs.h -fi -# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO. +# Sysroot behaviour as for gxx-include-dir if test x${gcc_gxx_libcxx_include_dir} = x; then + # default path,embedded in the compiler tree. + libcxx_incdir='include/c++/v1' if test x${enable_version_specific_runtime_libs} = xyes; then -gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1' +gcc_gxx_libcxx_include_dir='${libsubdir}/$libcxx_incdir' else -libcxx_incdir='libc++_include/c++/$(version)/v1' if test x$host != x$target; then libcxx_incdir="$target_alias/$libcxx_incdir" fi @@ -19848,7 +19871,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19851 "configure" +#line 19874 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19954,7 +19977,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19957 "configure" +#line 19980 "
[gcc r11-11302] Objective-C, NeXT: Fix messenging non-aggregate return-in-memory.
https://gcc.gnu.org/g:106cfc476a55c7423dca23be1eb0a5fb5da736b5 commit r11-11302-g106cfc476a55c7423dca23be1eb0a5fb5da736b5 Author: Iain Sandoe Date: Mon Aug 16 21:22:13 2021 +0100 Objective-C, NeXT: Fix messenging non-aggregate return-in-memory. When a method returns a type that the platform ABI says should be returned in memory, and that is done by a hidden 'sret' parameter, the message send calls must be adjusted to inform the runtime that the sret parameter is present. As reported in the PR, this is not working for non-aggregate types that use this mechanism. The fix here is to adjust the logic such that all return values that flag 'in memory' are considered to use the mechanism *unless* they provide a struct_value_rtx *and* the return object is an aggregate. Signed-off-by: Iain Sandoe PR objc/101718 - Objective-C frontend emits wrong code to call methods returning scalar types returned in memory PR objc/101718 gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (build_v2_build_objc_method_call): Revise for cases where scalar objects use an sret parameter. (next_runtime_abi_02_build_objc_method_call): Likwise. (cherry picked from commit 1cef3039b880a21fbdf4153e6fc42026619fd4ad) Diff: --- gcc/objc/objc-next-runtime-abi-02.c | 29 - 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index af68c1c84a3..19f137c632e 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -1740,15 +1740,16 @@ build_v2_build_objc_method_call (int super, tree method_prototype, /* Param list + 2 slots for object and selector. */ vec_alloc (parms, nparm + 2); - /* If we are returning a struct in memory, and the address - of that memory location is passed as a hidden first - argument, then change which messenger entry point this - expr will call. NB: Note that sender_cast remains - unchanged (it already has a struct return type). */ - if (!targetm.calls.struct_value_rtx (0, 0) - && (TREE_CODE (ret_type) == RECORD_TYPE - || TREE_CODE (ret_type) == UNION_TYPE) - && targetm.calls.return_in_memory (ret_type, 0)) + /* If we are returning an item that must be returned in memory, and the + target ABI does this by an invisible pointer provided as the first arg, + we need to adjust the message signature to include this. The second + part of this excludes targets that provide some alternate scheme for + structure returns. */ + if (ret_type && !VOID_TYPE_P (ret_type) + && targetm.calls.return_in_memory (ret_type, 0) + && !(targetm.calls.struct_value_rtx (0, 0) + && (TREE_CODE (ret_type) == RECORD_TYPE + || TREE_CODE (ret_type) == UNION_TYPE))) { if (super) sender = umsg_id_super2_stret_fixup_decl; @@ -1853,10 +1854,12 @@ next_runtime_abi_02_build_objc_method_call (location_t loc, ? TREE_VALUE (TREE_TYPE (method_prototype)) : objc_object_type; - if (!targetm.calls.struct_value_rtx (0, 0) - && (TREE_CODE (ret_type) == RECORD_TYPE - || TREE_CODE (ret_type) == UNION_TYPE) - && targetm.calls.return_in_memory (ret_type, 0)) + /* See comment for the fixup version above. */ + if (ret_type && !VOID_TYPE_P (ret_type) + && targetm.calls.return_in_memory (ret_type, 0) + && !(targetm.calls.struct_value_rtx (0, 0) + && (TREE_CODE (ret_type) == RECORD_TYPE + || TREE_CODE (ret_type) == UNION_TYPE))) { if (super) message_func_decl = umsg_id_super2_stret_fixup_decl;