Skip to content
Snippets Groups Projects
  1. Dec 13, 2024
    • Robin Dapp's avatar
      genrecog: Split into separate partitions [PR111600]. · 6dcfe874
      Robin Dapp authored
      Hi,
      
      this patch makes genrecog split its output into separate files (10 by
      default) in the same vein genemit does.  The changes are mostly
      mechanical again, changing printfs and puts to fprintf.
      As insn-recog.cc relies on being able to call other recog functions a
      header insn-recog.h is introduced that pre declares all of those.
      
      For simplicity the number of files is determined by (re-using)
      --with-insnemit-partitions.  Naming suggestions welcome :)
      
      Bootstrapped and regtested on x86 and power10, regtested on riscv.
      aarch64 bootstrap is currently blocked because of the
      "maybe uninitialized" issue discussed on IRC.
      
      Regards
       Robin
      
      	PR target/111600
      
      gcc/ChangeLog:
      
      	* Makefile.in:  Add insn-recog split.
      	* configure: Regenerate.
      	* configure.ac: Document that the number of insnemit partitions is
      	used for insn-recog as well.
      	* genconditions.cc (write_one_condition): Use fprintf.
      	* genpreds.cc (write_predicate_expr): Ditto.
      	(write_init_reg_class_start_regs): Ditto.
      	* genrecog.cc (write_header): Add header file to includes.
      	(printf_indent): Use fprintf.
      	(change_state): Ditto.
      	(print_code): Ditto.
      	(print_host_wide_int): Ditto.
      	(print_parameter_value): Ditto.
      	(print_test_rtx): Ditto.
      	(print_nonbool_test): Ditto.
      	(print_label_value): Ditto.
      	(print_test): Ditto.
      	(print_decision): Ditto.
      	(print_state): Ditto.
      	(print_subroutine_call): Ditto.
      	(print_acceptance): Ditto.
      	(print_subroutine_start): Ditto.
      	(print_pattern): Ditto.
      	(print_subroutine): Ditto.
      	(print_subroutine_group): Ditto.
      	(handle_arg): Add -O and -H for output and header file handling.
      	(main): Use callback.
      	* gentarget-def.cc (def_target_insn): Use fprintf.
      	* read-md.cc (md_reader::print_c_condition): Ditto.
      	* read-md.h (class md_reader): Ditto.
      6dcfe874
  2. Dec 06, 2024
    • Thomas Schwinge's avatar
      nvptx: Support '--with-multilib-list' · 86b3a753
      Thomas Schwinge authored
      No change in behavior unless specifying it.
      
      	gcc/
      	* config.gcc: nvptx: Support '--with-multilib-list'.
      	* config/nvptx/gen-multilib-matches.sh: Adjust.
      	* configure.ac: Likewise.
      	* configure: Regenerate.
      	* doc/install.texi: Update.
      	* doc/invoke.texi: Align.
      	* config/nvptx/gen-multilib-matches-tests: Extend.
      86b3a753
  3. Dec 04, 2024
  4. Dec 01, 2024
    • Slava Barinov's avatar
      [PATCH] gcc: configure: Fix the optimization flags cleanup · 721a38ad
      Slava Barinov authored
      Currently sed command in flag cleanup removes all the -O[0-9] flags, ignoring
      the context. This leads to issues when the optimization flags is passed to
      linker:
      
      CFLAGS="-Os -Wl,-O1 -Wl,--hash-style=gnu"
      is converted into
      CFLAGS="-Os -Wl,-Wl,--hash-style=gnu"
      
      Which leads to configure failure with ld: unrecognized option '-Wl,-Wl'.
      
      gcc/
      	* configure.ac: Only remove -O[0-9] if not preceded with comma
      	* configure: Regenerated
      721a38ad
    • Matevos Mehrabyan's avatar
      [PATCH v6 09/12] Add symbolic execution support. · 148e2046
      Matevos Mehrabyan authored
      
      Gives an opportunity to execute the code on bit level, assigning
      symbolic values to the variables which don't have initial values.
      Supports only CRC specific operations.
      
      Example:
      
      uint8_t crc;
      uint8_t pol = 1;
      crc = crc ^ pol;
      
      during symbolic execution crc's value will be:
      crc(8), crc(7), ... crc(1), crc(0) ^ 1
      
      gcc/
      	* Makefile.in (OBJS): Add sym-exec/sym-exec-expression.o,
      	sym-exec/sym-exec-state.o, sym-exec/sym-exec-condition.o.
      	* configure (sym-exec): New subdir.
      	* sym-exec/sym-exec-condition.cc: New file.
      	* sym-exec/sym-exec-condition.h: New file.
      	* sym-exec/sym-exec-expr-is-a-helper.h: New file.
      	* sym-exec/sym-exec-expression.cc: New file.
      	* sym-exec/sym-exec-expression.h: New file.
      	* sym-exec/sym-exec-state.cc: New file.
      	* sym-exec/sym-exec-state.h: New file.
      
      Co-authored-by: default avatarMariam Arutunian <mariamarutunian@gmail.com>
      148e2046
    • Mark Harmstone's avatar
      Write binary annotations for CodeView S_INLINESITE symbols · 75fe4e29
      Mark Harmstone authored
      Add "binary annotations" at the end of CodeView S_INLINESITE symbols,
      which are a series of compressed integers that represent how line
      numbers map to addresses.
      
      This requires assembler support; you will need commit b3aa594d ("gas:
      add .cv_ucomp and .cv_scomp pseudo-directives") in binutils.
      
      gcc/
      	* configure.ac (HAVE_GAS_CV_UCOMP): New check.
      	* configure: Regenerate.
      	* config.in: Regenerate.
      	* dwarf2codeview.cc (enum binary_annotation_opcode): Define.
      	(struct codeview_function): Add htab_next and inline_loc;
      	(struct cv_func_hasher): Define.
      	(cv_func_htab): New global variable.
      	(new_codeview_function): Add new codeview_function to hash table.
      	(codeview_begin_block): Record location of inline block.
      	(codeview_end_block): Add dummy source line at end of inline block.
      	(find_line_function): New function.
      	(write_binary_annotations): New function.
      	(write_s_inlinesite): Call write_binary_annotations.
      	(codeview_debug_finish): Delete cv_func_htab.
      75fe4e29
  5. Nov 29, 2024
    • David Malcolm's avatar
      Rename "libdiagnostics" to "libgdiagnostics" · bc359763
      David Malcolm authored
      "libdiagnostics" clashes with an existing soname in Debian, as
      per:
        https://gcc.gnu.org/pipermail/gcc/2024-November/245175.html
      
      
      
      Rename it to "libgdiagnostics" for uniqueness.
      
      I am being deliberately vague about what the "g" stands for:
      it could be "gnu", "gcc", or "gpl-licensed" as the reader desires.
      
      ChangeLog:
      	* configure.ac: Rename "libdiagnostics" to "libgdiagnostics".
      	* configure: Regenerate.
      
      gcc/ChangeLog:
      	* Makefile.in: Rename "libdiagnostics" to "libgdiagnostics".
      	* configure.ac: Likewise.
      	* configure: Regenerate.
      	* doc/install.texi: Rename "libdiagnostics" to
      	"libgdiagnostics".
      	* doc/libdiagnostics/*: Rename to doc/libgdiagnostics, renaming
      	"libdiagnostics" to "libgdiagnostics" throughout.
      	* libdiagnostics++.h: Rename to...
      	* libgdiagnostics++.h: ...this, renaming "libdiagnostics" to
      	"libgdiagnostics" throughout.
      	* libdiagnostics.cc: Rename to...
      	* libgdiagnostics.cc: ...this, renaming "libdiagnostics" to
      	"libgdiagnostics" throughout.
      	* libdiagnostics.h: Rename to...
      	* libgdiagnostics.h: ...this, renaming "libdiagnostics" to
      	"libgdiagnostics" throughout.
      	* libdiagnostics.map: Rename to...
      	* libgdiagnostics.map: ...this, renaming "libdiagnostics" to
      	"libgdiagnostics" throughout.
      	* libsarifreplay.cc: Update for renaming of "libdiagnostics"
      	to "libgdiagnostics".
      	* libsarifreplay.h: Likewise.
      	* sarif-replay.cc: Likewise.
      
      gcc/testsuite/ChangeLog:
      	* libdiagnostics.dg/*: Rename to libgdiagnostics.dg, renaming
      	"libdiagnostics" to "libgdiagnostics" throughout.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      bc359763
  6. Nov 25, 2024
    • Sandra Loosemore's avatar
      nios2: Remove all support for Nios II target. · e876acab
      Sandra Loosemore authored
      nios2 target support in GCC was deprecated in GCC 14 as the
      architecture has been EOL'ed by the vendor.  This patch removes the
      entire port for GCC 15
      
      There are still references to "nios2" in libffi and libgo.  Since those
      libraries are imported into the gcc sources from master copies maintained
      by other projects, those will need to be addressed elsewhere.
      
      ChangeLog:
      	* MAINTAINERS: Remove references to nios2.
      	* configure.ac: Likewise.
      	* configure: Regenerated.
      
      config/ChangeLog:
      	* mt-nios2-elf: Deleted.
      
      contrib/ChangeLog:
      	* config-list.mk: Remove references to Nios II.
      
      gcc/ChangeLog:
      	* common/config/nios2/*: Delete entire directory.
      	* config/nios2/*: Delete entire directory.
      	* config.gcc: Remove references to nios2.
      	* configure.ac: Likewise.
      	* doc/extend.texi: Likewise.
      	* doc/install.texi: Likewise.
      	* doc/invoke.texi: Likewise.
      	* doc/md.texi: Likewise.
      	* regenerate-opt-urls.py: Likewise.
      	* config.in: Regenerated.
      	* configure: Regenerated.
      
      gcc/testsuite/ChangeLog:
      	* g++.target/nios2/*: Delete entire directory.
      	* gcc.target/nios2/*: Delete entire directory.
      	* g++.dg/cpp0x/constexpr-rom.C: Remove refences to nios2.
      	* g++.old-deja/g++.jason/thunk3.C: Likewise.
      	* gcc.c-torture/execute/20101011-1.c: Likewise.
      	* gcc.c-torture/execute/pr47237.c: Likewise.
      	* gcc.dg/20020312-2.c: Likewise.
      	* gcc.dg/20021029-1.c: Likewise.
      	* gcc.dg/debug/btf/btf-datasec-1.c: Likewise.
      	* gcc.dg/ifcvt-4.c: Likewise.
      	* gcc.dg/stack-usage-1.c: Likewise.
      	* gcc.dg/struct-by-value-1.c: Likewise.
      	* gcc.dg/tree-ssa/reassoc-33.c: Likewise.
      	* gcc.dg/tree-ssa/reassoc-34.c: Likewise.
      	* gcc.dg/tree-ssa/reassoc-35.c: Likewise.
      	* gcc.dg/tree-ssa/reassoc-36.c: Likewise.
      	* lib/target-supports.exp: Likewise.
      
      libgcc/ChangeLog:
      	* config/nios2/*: Delete entire directory.
      	* config.host: Remove refences to nios2.
      	* unwind-dw2-fde-dip.c: Likewise.
      e876acab
  7. Aug 26, 2024
    • Bernd Edlinger's avatar
      Fix bootstap-errors due to enabling -gvariable-location-views · eb63f958
      Bernd Edlinger authored
      This recent change triggered various bootstap-errors, mostly on
      x86 targets because line info advance address entries were output
      in the wrong section table.
      The switch to the wrong line table happened in dwarfout_set_ignored_loc.
      It must use the same section as the earlier called
      dwarf2out_switch_text_section.
      
      But also ft32-elf was affected, because the assembler choked on
      something simple as ".2byte .LM2-.LM1", but fortunately it is
      able to use native location views, the configure test was just
      not executed because the ft32 "nop" instruction was missing.
      
      gcc/ChangeLog:
      
      	PR debug/116470
      	* configure.ac: Add the "nop" instruction for cpu type ft32.
      	* configure: Regenerate.
      	* dwarf2out.cc (dwarf2out_set_ignored_loc): Use the correct
      	line info section.
      eb63f958
  8. Jul 30, 2024
    • Edwin Lu's avatar
      RISC-V: Add configure check for B extention support · 7ef8a9d4
      Edwin Lu authored
      
      Binutils 2.42 and before don't recognize the b extension in the march
      strings even though it supports zba_zbb_zbs. Add a configure check to
      ignore the b in the march string if found.
      
      gcc/ChangeLog:
      
      	* common/config/riscv/riscv-common.cc (riscv_subset_list::to_string):
      	Skip b in march string
      	* config.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Add B assembler check
      
      Signed-off-by: default avatarEdwin Lu <ewlu@rivosinc.com>
      7ef8a9d4
    • Patrick O'Neill's avatar
      RISC-V: Remove configure check for zabha · c0af64af
      Patrick O'Neill authored
      
      This patch removes the zabha configure check since it's not a breaking change
      and updates the existing zaamo/zalrsc comment.
      
      gcc/ChangeLog:
      
      	* common/config/riscv/riscv-common.cc
      	(riscv_subset_list::to_string): Remove zabha configure check
      	handling and clarify zaamo/zalrsc comment.
      	* config.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Remove zabha configure check.
      
      Signed-off-by: default avatarPatrick O'Neill <patrick@rivosinc.com>
      c0af64af
  9. Jul 21, 2024
    • Sam James's avatar
      gcc: stop adding -fno-common for checking builds · 80c37335
      Sam James authored
      Originally added in r0-44646-g204250d2fcd084 and r0-44627-gfd350d241fecf6 whic
      moved -fno-common from all builds to just checking builds.
      
      Since r10-4867-g6271dd984d7f92, GCC defaults to -fno-common. There's no need
      to pass it specially for checking builds.
      
      We could keep it for older bootstrap compilers with checking but I don't see
      much value in that, it was already just a bonus before.
      
      gcc/ChangeLog:
      	* Makefile.in (NOCOMMON_FLAG): Delete.
      	(GCC_WARN_CFLAGS): Drop NOCOMMON_FLAG.
      	(GCC_WARN_CXXFLAGS): Drop NOCOMMON_FLAG.
      	* configure.ac: Ditto.
      	* configure: Regenerate.
      
      gcc/d/ChangeLog:
      	* Make-lang.in (WARN_DFLAGS): Drop NOCOMMON_FLAG.
      80c37335
  10. Jul 15, 2024
    • Jakub Jelinek's avatar
      varasm: Add support for emitting binary data with the new gas .base64 directive · 9964edfb
      Jakub Jelinek authored
      Nick has implemented a new .base64 directive in gas (to be shipped in
      the upcoming binutils 2.43; big thanks for that).
      See https://sourceware.org/bugzilla/show_bug.cgi?id=31964
      
      The following patch adjusts default_elf_asm_output_ascii (i.e.
      ASM_OUTPUT_ASCII elfos.h implementation) to use it if it detects binary
      data and gas supports it.
      
      Without this patch, we emit stuff like:
              .string "\177ELF\002\001\001\003"
              .string ""
              .string ""
              .string ""
              .string ""
              .string ""
              .string ""
              .string ""
              .string "\002"
              .string ">"
      ...
              .string "\324\001\236 0FS\202\002E\n0@\203\004\005&\202\021\337)\021\203C\020A\300\220I\004\t\b\206(\234\0132l\004b\300\bK\006\220$0\303\020P$\233\211\002D\f"
      etc., with this patch more compact
              .base64 "f0VMRgIBAQMAAAAAAAAAAAIAPgABAAAAABf3AAAAAABAAAAAAAAAAACneB0AAAAAAAAAAEAAOAAOAEAALAArAAYAAAAEAAAAQAAAAAAAAABAAEAAAAAAAEAAQAAAAAAAEAMAAAAAAAAQAwAAAAAAAAgAAAAAAAAAAwAAAAQAAABQAwAAAAAAAFADQAAAAAAAUANAAAAAAAAcAAAAAAAAABwAAAAAAAAAAQAAAAAAAAABAAAABAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAADBwOQAAAAAAMHA5AAAAAAAAEAAAAAAAAAEAAAAFAAAAAIA5AAAAAAAAgHkAAAAA"
              .base64 "AACAeQAAAAAAxSSgAgAAAADFJKACAAAAAAAQAAAAAAAAAQAAAAQAAAAAsNkCAAAAAACwGQMAAAAAALAZAwAAAADMtc0AAAAAAMy1zQAAAAAAABAAAAAAAAABAAAABgAAAGhmpwMAAAAAaHbnAwAAAABoducDAAAAAOAMAQAAAAAA4MEeAAAAAAAAEAAAAAAAAAIAAAAGAAAAkH2nAwAAAACQjecDAAAAAJCN5wMAAAAAQAIAAAAAAABAAgAAAAAAAAgAAAAAAAAABAAAAAQAAABwAwAAAAAAAHADQAAAAAAAcANAAAAAAABAAAAAAAAAAEAAAAAAAAAACAAAAAAA"
              .base64 "AAAEAAAABAAAALADAAAAAAAAsANAAAAAAACwA0AAAAAAACAAAAAAAAAAIAAAAAAAAAAEAAAAAAAAAAcAAAAEAAAAaGanAwAAAABoducDAAAAAGh25wMAAAAAAAAAAAAAAAAQAAAAAAAAAAgAAAAAAAAAU+V0ZAQAAABwAwAAAAAAAHADQAAAAAAAcANAAAAAAABAAAAAAAAAAEAAAAAAAAAACAAAAAAAAABQ5XRkBAAAAAw/WAMAAAAADD+YAwAAAAAMP5gDAAAAAPy7CgAAAAAA/LsKAAAAAAAEAAAAAAAAAFHldGQGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
              .base64 "AAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAUuV0ZAQAAABoZqcDAAAAAGh25wMAAAAAaHbnAwAAAACYGQAAAAAAAJgZAAAAAAAAAQAAAAAAAAAvbGliNjQvbGQtbGludXgteDg2LTY0LnNvLjIAAAAAAAQAAAAwAAAABQAAAEdOVQACgADABAAAAAEAAAAAAAAAAQABwAQAAAAJAAAAAAAAAAIAAcAEAAAAAwAAAAAAAAAEAAAAEAAAAAEAAABHTlUAAAAAAAMAAAACAAAAAAAAAAOAAACsqAAAgS0AAOJWAAAjNwAAXjAAAAAAAAAAAAAAF1gAAHsxAABBBwAA"
              .base64 "G0kAALGmAACwoAAAAAAAAAAAAACQhAAAAAAAAOw1AACNYgAAAAAAAFQoAAAAAAAAx3UAALZAAAAAAAAAiIUAALGeAABBlAAAWEsAAPmRAACmOgAAAAAAADh3AAAAAAAAlCAAAAAAAABymgAAaosAAMIjAAAKMQAAMkIAADU0AAAAAAAA5ZwAAAAAAAAAAAAAAAAAAFIdAAAIGQAAAAAAAMFbAAAoTQAAGDcAAIRgAAA6HgAAlxwAAAAAAADOlgAAAAAAAEhPAAARiwAAMGgAAOVtAADMFgAAAAAAAAAAAACrjgAAYl4AACZVAAA/HgAAAAAAAAAAAABqPwAAAAAA"
      The patch attempts to juggle between readability and compactness, so
      if it detects some hunk of the initializer that would be shorter to be
      emitted as .string/.ascii directive, it does so, but if it previously
      used .base64 directive it switches mode only if there is a 16+ char
      ASCII-ish string.
      
      On my #embed testcase from yesterday
      unsigned char a[] = {
       #embed "cc1plus"
      };
      without this patch it emits 2.4GB of assembly, while with this
      patch 649M.
      Compile times (trunk, so yes,rtl,extra checking) are:
      time ./xgcc -B ./ -S -std=c23 -O2 embed-11.c
      
      real    0m13.647s
      user    0m7.157s
      sys     0m2.597s
      time ./xgcc -B ./ -c -std=c23 -O2 embed-11.c
      
      real    0m28.649s
      user    0m26.653s
      sys     0m1.958s
      without the patch and
      time ./xgcc -B ./ -S -std=c23 -O2 embed-11.c
      
      real    0m4.283s
      user    0m2.288s
      sys     0m0.859s
      time ./xgcc -B ./ -c -std=c23 -O2 embed-11.c
      
      real    0m6.888s
      user    0m5.876s
      sys     0m1.002s
      with the patch, so that feels like significant improvement.
      The resulting embed-11.o is identical between the two ways of expressing
      the mostly binary data in the assembly.  But note that there are portions
      like:
              .base64 "nAAAAAAAAAAvZRcAIgAOAFAzMwEAAAAABgAAAAAAAACEQBgAEgAOAFBHcAIAAAAA7AAAAAAAAAAAX19nbXB6X2dldF9zaQBtcGZyX3NldF9zaV8yZXhwAG1wZnJfY29zaABtcGZyX3RhbmgAbXBmcl9zZXRfbmFuAG1wZnJfc3ViAG1wZnJfdGFuAG1wZnJfc3RydG9mcgBfX2dtcHpfc3ViX3VpAF9fZ21wX2dldF9tZW1vcnlfZnVuY3Rpb25zAF9fZ21wel9zZXRfdWkAbXBmcl9wb3cAX19nbXB6X3N1YgBfX2dtcHpfZml0c19zbG9uZ19wAG1wZnJfYXRh"
              .base64 "bjIAX19nbXB6X2RpdmV4YWN0AG1wZnJfc2V0X2VtaW4AX19nbXB6X3NldABfX2dtcHpfbXVsAG1wZnJfY2xlYXIAbXBmcl9sb2cAbXBmcl9hdGFuaABfX2dtcHpfc3dhcABtcGZyX2FzaW5oAG1wZnJfYXNpbgBtcGZyX2NsZWFycwBfX2dtcHpfbXVsXzJleHAAX19nbXB6X2FkZG11bABtcGZyX3NpbmgAX19nbXB6X2FkZF91aQBfX2dtcHFfY2xlYXIAX19nbW9uX3N0YXJ0X18AbXBmcl9hY29zAG1wZnJfc2V0X2VtYXgAbXBmcl9jb3MAbXBmcl9zaW4A"
              .string "__gmpz_ui_pow_ui"
              .string "mpfr_get_str"
              .string "mpfr_acosh"
              .string "mpfr_sub_ui"
              .string "__gmpq_set_ui"
              .string "mpfr_set_inf"
      ...
              .string "GLIBC_2.14"
              .string "GLIBC_2.11"
              .base64 "AAABAAIAAQADAAMAAwADAAMAAwAEAAUABgADAAEAAQADAAMABwABAAEAAwADAAMAAwAIAAEAAwADAAEAAwABAAMAAwABAAMAAQADAAMAAwADAAMAAwADAAYAAwADAAEAAQAIAAMAAwADAAMAAwABAAMAAQADAAMAAQABAAEAAwAIAAEAAwADAAEAAwABAAMAAQADAAEABgADAAMAAQAHAAMAAwADAAMAAwABAAMAAQABAAMAAwADAAkAAQABAAEAAwAKAAEAAwADAAMAAQABAAMAAwALAAEAAwADAAEAAQADAAMAAwABAAMAAwABAAEAAwADAAMABwABAAMAAwAB"
              .base64 "AAEAAwADAAEAAwABAAMAAQADAAMAAwADAAEAAQABAAEAAwADAAMAAQABAAEAAQABAAEAAQADAAMAAwADAAMAAQABAAwAAwADAA0AAwADAAMAAwADAAEAAQADAAMAAQABAAMAAwADAAEAAwADAAEAAwAIAAMAAwADAAMABgABAA4ACwAGAAEAAQADAAEAAQADAAEAAwABAAMAAwABAAEAAwABAAMAAwABAAEAAwADAAMAAwABAAMAAQABAAEAAQABAAMADwABAAMAAQADAAMAAwABAAEAAQAIAAEADAADAAMAAQABAAMAAwADAAEAAQABAAEAAQADAAEAAwADAAEA"
              .base64 "AwABAAMAAQADAAMAAQABAAEAAwADAAMAAwADAAMAAQADAAMACAAQAA8AAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQA="
      so it isn't all just totally unreadable stuff.
      
      2024-07-15  Jakub Jelinek  <jakub@redhat.com>
      
      	* configure.ac (HAVE_GAS_BASE64): New check.
      	* config/elfos.h (BASE64_ASM_OP): Define if HAVE_GAS_BASE64 is
      	defined.
      	* varasm.cc (assemble_string): Bump maximum from 2000 to 16384 if
      	BASE64_ASM_OP is defined.
      	(default_elf_asm_output_limited_string): Emit opening '"' together
      	with STRING_ASM_OP.
      	(default_elf_asm_output_ascii): Use BASE64_ASM_OP if defined and
      	beneficial.  Remove UB when last_null is NULL.
      	* configure: Regenerate.
      	* config.in: Regenerate.
      9964edfb
  11. Jul 03, 2024
    • Gianluca Guida's avatar
      RISC-V: Add support for Zabha extension · 7b2b2e3d
      Gianluca Guida authored
      The Zabha extension adds support for subword Zaamo ops.
      
      Extension: https://github.com/riscv/riscv-zabha.git
      Ratification: https://jira.riscv.org/browse/RVS-1685
      
      
      
      gcc/ChangeLog:
      
      	* common/config/riscv/riscv-common.cc
      	(riscv_subset_list::to_string): Skip zabha when not supported by
      	the assembler.
      	* config.in: Regenerate.
      	* config/riscv/arch-canonicalize: Make zabha imply zaamo.
      	* config/riscv/iterators.md (amobh): Add iterator for amo
      	byte/halfword.
      	* config/riscv/riscv.opt: Add zabha.
      	* config/riscv/sync.md (atomic_<atomic_optab><mode>): Add
      	subword atomic op pattern.
      	(zabha_atomic_fetch_<atomic_optab><mode>): Add subword
      	atomic_fetch op pattern.
      	(lrsc_atomic_fetch_<atomic_optab><mode>): Prefer zabha over lrsc
      	for subword atomic ops.
      	(zabha_atomic_exchange<mode>): Add subword atomic exchange
      	pattern.
      	(lrsc_atomic_exchange<mode>): Prefer zabha over lrsc for subword
      	atomic exchange ops.
      	* configure: Regenerate.
      	* configure.ac: Add zabha assembler check.
      	* doc/sourcebuild.texi: Add zabha documentation.
      
      gcc/testsuite/ChangeLog:
      
      	* lib/target-supports.exp: Add zabha testsuite infra support.
      	* gcc.target/riscv/amo/inline-atomics-1.c: Remove zabha to continue to
      	test the lr/sc subword patterns.
      	* gcc.target/riscv/amo/inline-atomics-2.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-acq-rel.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-acquire.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-relaxed.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-release.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-seq-cst.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-acq-rel.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-acquire.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-relaxed.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-release.c: Ditto.
      	* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-seq-cst.c: Ditto.
      	* gcc.target/riscv/amo/zabha-all-amo-ops-char-run.c: New test.
      	* gcc.target/riscv/amo/zabha-all-amo-ops-short-run.c: New test.
      	* gcc.target/riscv/amo/zabha-rvwmo-all-amo-ops-char.c: New test.
      	* gcc.target/riscv/amo/zabha-rvwmo-all-amo-ops-short.c: New test.
      	* gcc.target/riscv/amo/zabha-rvwmo-amo-add-char.c: New test.
      	* gcc.target/riscv/amo/zabha-rvwmo-amo-add-short.c: New test.
      	* gcc.target/riscv/amo/zabha-ztso-amo-add-char.c: New test.
      	* gcc.target/riscv/amo/zabha-ztso-amo-add-short.c: New test.
      
      Co-Authored-By: default avatarPatrick O'Neill <patrick@rivosinc.com>
      Signed-Off-By: default avatarGianluca Guida <gianluca@rivosinc.com>
      Tested-by: default avatarAndrea Parri <andrea@rivosinc.com>
      7b2b2e3d
  12. Jun 21, 2024
    • YunQiang Su's avatar
      Build: Set gcc_cv_as_mips_explicit_relocs if gcc_cv_as_mips_explicit_relocs_pcrel · 573f11ec
      YunQiang Su authored
      We check gcc_cv_as_mips_explicit_relocs if gcc_cv_as_mips_explicit_relocs_pcrel
      only, while gcc_cv_as_mips_explicit_relocs is used by later code.
      
      Maybe, it is time for use to set gcc_cv_as_mips_explicit_relocs always now,
      as it has been in Binutils for more than 20 years.
      
      gcc
      	* configure.ac: Set gcc_cv_as_mips_explicit_relocs if
      	gcc_cv_as_mips_explicit_relocs_pcrel.
      	* configure: Regenerate.
      573f11ec
  13. Jun 19, 2024
    • YunQiang Su's avatar
      Revert "build: Fix missing variable quotes" · 6d6587bc
      YunQiang Su authored
      This reverts commit c6a9ab8c.
      6d6587bc
    • Collin Funk's avatar
      build: Fix missing variable quotes · c6a9ab8c
      Collin Funk authored
      
      When dlopen and pthread_create are in libc the variable is
      set to "none required", therefore running configure will show
      the following errors:
      
      ./configure: line 8997: test: too many arguments
      ./configure: line 8999: test: too many arguments
      ./configure: line 9003: test: too many arguments
      ./configure: line 9005: test: =: unary operator expected
      
      gcc/configure also has a similar problem on
      gcc_cv_as_mips_explicit_relocs:
      
      ./gcc/configure: line 30242: test: =: unary operator expected
      
      ChangeLog:
      
      	* configure.ac: Quote variable result of AC_SEARCH_LIBS.
      	* configure: Regenerate.
      
      gcc/ChangeLog:
      
      	* configure.ac: Add missing quotation of variable
      	gcc_cv_as_mips_explicit_relocs.
      	* configure: Regenerate.
      
      Signed-off-by: default avatarCollin Funk <collin.funk1@gmail.com>
      c6a9ab8c
  14. Jun 17, 2024
    • Patrick O'Neill's avatar
      RISC-V: Add configure check for Zaamo/Zalrsc assembler support · 4f18f75c
      Patrick O'Neill authored
      
      Binutils 2.42 and before don't support Zaamo/Zalrsc. Add a configure
      check to prevent emitting Zaamo/Zalrsc in the arch string when the
      assember does not support it.
      
      gcc/ChangeLog:
      
      	* common/config/riscv/riscv-common.cc
      	(riscv_subset_list::to_string): Skip zaamo/zalrsc when not
      	supported by the assembler.
      	* config.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Add zaamo/zalrsc assmeber check.
      
      Signed-off-by: default avatarPatrick O'Neill <patrick@rivosinc.com>
      Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
      Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
      4f18f75c
  15. Jun 14, 2024
    • Jan Beulich's avatar
      configure: adjustments for building with in-tree binutils · 4b1f486f
      Jan Beulich authored
      For one setting ld_ver in a conditional (no in-tree ld) when it's used,
      for x86 at least, in unconditional ways can't be quite right. And then
      prefixing relative paths to binaries with ${objdir}/, when ${objdir}
      nowadays resolves to just .libs, can at best be a leftover that wasn't
      properly cleaned up at some earlier point.
      
      gcc/
      
      	* configure.ac: Drop ${objdir}/ from NM and AR. Move setting of
      	ld_ver out of conditional.
      	* configure: Re-generate.
      4b1f486f
  16. May 07, 2024
    • Rainer Orth's avatar
      Remove obsolete Solaris 11.3 support · f68e90a0
      Rainer Orth authored
      Support for Solaris 11.3 had already been obsoleted in GCC 13.  However,
      since the only Solaris system in the cfarm was running 11.3, I've kept
      it in tree until now when both Solaris 11.4/SPARC and x86 systems have
      been added.
      
      This patch actually removes the Solaris 11.3 support.  Apart from
      several minor simplifications, there are two more widespread changes:
      
      * In Solaris 11.4, libsocket and libnsl were folded into libc, so
        there's no longer a need to link them explictly.
      
      * Since Solaris 11.4, Solaris includes all crts needed by gcc (like
        crt1.o and gcrt1.o) with the base system.  All workarounds to provide
        fallbacks can thus go.
      
      Bootstrapped without regressions on i386-pc-solaris2.11 and
      sparc-sun-solaris2.11 (as/ld, gas/ld, and gas/gld) as well as Solaris
      11.3/x86 to ascertain that version is actually rejected.
      
      2024-04-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	c++tools:
      	* configure.ac (ax_lib_socket_nsl.m4): Don't sinclude.
      	(AX_LIB_SOCKET_NSL): Don't call.
      	(NETLIBS): Remove.
      	* configure: Regenerate.
      	* Makefile.in (NETLIBS): Remove.
      	(g++-mapper-server$(exeext)): Remove $(NETLIBS).
      
      	gcc:
      	* config.gcc: Move *-*-solaris2.11.[0-3]* to unsupported list.
      	<*-*-solaris2*> (default_use_cxa_atexit): Set unconditionally.
      	* configure.ac (AX_LIB_SOCKET_NSL): Don't call.
      	(NETLIBS): Remove.
      	(gcc_cv_ld_aligned_shf_merge): Remove.
      	(hidden_linkonce) <i?86-*-solaris2* | x86_64-*-solaris2*>: Remove.
      	(gcc_cv_target_dl_iterate_phdr) <*-*-solaris2*>: Always set to yes.
      	* Makefile.in (NETLIBS): Remove.
      	* configure, config.in, aclocal.m4: Regenerate.
      	* config/sol2.h: Don't check HAVE_SOLARIS_CRTS.
      	(STARTFILE_SPEC): Remove !HAVE_SOLARIS_CRTS case.
      	[USE_GLD] (LINK_EH_SPEC): Remove TARGET_DL_ITERATE_PHDR guard.
      	* config/i386/i386.cc (USE_HIDDEN_LINKONCE): Remove guard.
      	* varasm.cc (mergeable_string_section): Remove
      	HAVE_LD_ALIGNED_SHF_MERGE handling.
      	(mergeable_constant_section): Likewise.
      
      	* doc/install.texi (Specific,i?86-*-solaris2*): Reference Solaris
      	11.4 only.
      	(Specific, *-*-solaris2*): Document Solaris 11.3 removal.  Remove
      	11.3 references and caveats.  Update for 11.4.
      
      	gcc/cp:
      	* Make-lang.in (cc1plus$(exeext)): Remove $(NETLIBS).
      
      	gcc/objcp:
      	* Make-lang.in (cc1objplus$(exeext)): Remove $(NETLIBS).
      
      	gcc/testsuite:
      	* lib/target-supports.exp (check_effective_target_pie): Always
      	enable on *-*-solaris2*.
      
      	libgcc:
      	* configure.ac <*-*-solaris2*> (libgcc_cv_solaris_crts): Remove.
      	* config.host <*-*-solaris2*>: Remove !libgcc_cv_solaris_crts
      	support.
      	* configure, config.in: Regenerate.
      	* config/sol2/gmon.c (internal_mcount) [!HAVE_SOLARIS_CRTS]: Remove.
      	* config/i386/sol2-c1.S, config/sparc/sol2-c1.S: Remove.
      	* config/sol2/t-sol2 (crt1.o, gcrt1.o): Remove.
      
      	libstdc++-v3:
      	* testsuite/lib/dg-options.exp (add_options_for_net_ts)
      	<*-*-solaris2*>: Don't link with -lsocket -lnsl.
      f68e90a0
  17. Apr 24, 2024
    • Jakub Jelinek's avatar
      v2: DOCUMENTATION_ROOT_URL vs. release branches [PR114738] · 97a54c05
      Jakub Jelinek authored
      This patch moves the documentation root URL infix for release branches
      from get_option_url/make_doc_url to configure, such that only the default
      changes and when users specify a custom documentation root URL, they don't
      have to add gcc-MAJOR.MINOR.0 subdirectories for release branches.
      
      Tested by checking
      ../configure --disable-bootstrap --enable-languages=c --disable-multilib
      built trunk on
      void
      foo (int x)
      {
        __builtin_printf ("%ld\n", x);
      }
      testcase and looking for the URL in there, then repeating that after
      changing gcc/BASE-VER to 14.1.0 and again after changing it to 14.1.1,
      plus normal bootstrap/regtest.
      
      2024-04-24  Jakub Jelinek  <jakub@redhat.com>
      
      	PR other/114738
      	* opts.cc (get_option_url): Revert 2024-04-17 changes.
      	* gcc-urlifier.cc: Don't include diagnostic-core.h.
      	(gcc_urlifier::make_doc_url): Revert 2024-04-17 changes.
      	* configure.ac (documentation-root-url): On release branches
      	append gcc-MAJOR.MINOR.0/ to the default DOCUMENTATION_ROOT_URL.
      	* doc/install.texi (--with-documentation-root-url=): Document
      	the change of the default.
      	* configure: Regenerate.
      97a54c05
  18. Feb 23, 2024
    • H.J. Lu's avatar
      x86-64: Check R_X86_64_CODE_6_GOTTPOFF support · 7f2cf0c4
      H.J. Lu authored
      If assembler and linker supports
      
      add %reg1, name@gottpoff(%rip), %reg2
      
      with R_X86_64_CODE_6_GOTTPOFF, we can generate it instead of
      
      mov name@gottpoff(%rip), %reg2
      add %reg1, %reg2
      
      gcc/
      
      	* configure.ac (HAVE_AS_R_X86_64_CODE_6_GOTTPOFF): Defined as 1
      	if R_X86_64_CODE_6_GOTTPOFF is supported.
      	* config.in: Regenerated.
      	* configure: Likewise.
      	* config/i386/predicates.md (apx_ndd_add_memory_operand): Allow
      	UNSPEC_GOTNTPOFF if R_X86_64_CODE_6_GOTTPOFF is supported.
      
      gcc/testsuite/
      
      	* gcc.target/i386/apx-ndd-tls-1b.c: New test.
      	* lib/target-supports.exp
      	(check_effective_target_code_6_gottpoff_reloc): New.
      7f2cf0c4
    • Lulu Cheng's avatar
      LoongArch: When checking whether the assembler supports conditional branch... · 33abf741
      Lulu Cheng authored
      LoongArch: When checking whether the assembler supports conditional branch relaxation, add compilation parameter "--fatal-warnings" to the assembler.
      
      In binutils 2.40 and earlier versions, only a warning will be reported
      when a relocation immediate value is out of bounds. As a result,
      the value of the macro HAVE_AS_COND_BRANCH_RELAXATION will also be
      defined as 1 when the assembler does not support conditional branch
      relaxation. Therefore, add the compilation option "--fatal-warnings"
      to avoid this problem.
      
      gcc/ChangeLog:
      
      	* configure: Regenerate.
      	* configure.ac: Add parameter "--fatal-warnings" to assemble
      	when checking whether the assemble support conditional branch
      	relaxation.
      33abf741
  19. Feb 12, 2024
    • Christophe Lyon's avatar
      gcc/Makefile.in: Always check info dependencies · 1fcaa3a8
      Christophe Lyon authored
      BUILD_INFO is currently a byproduct of checking makeinfo
      presence/version.  INSTALL_INFO used to be defined similarly, but was
      removed in 2000 (!) by commit 17db6582
      (svn r38141).
      
      In order to save build time, our CI overrides MAKEINFO=echo, which
      works when invoking 'make all' but not for 'make install' in case some
      info files need an update.
      
      I noticed this while testing a patch posted on the gcc-patches list,
      leading to an error at 'make install' time after updating tm.texi (the
      build reported 'new text' in tm.texi and stopped).  This is because
      'install' depends on 'install-info', which depends on
      $(DESTDIR)$(infodir)/gccint.info (among others).
      
      As discussed, it is better to detect this problem during 'make all'
      rather than 'make install', and we still want to detect it even if
      makeinfo is not available.
      
      This patch makes configure set BUILD_INFO=no-info in case makeinfo is
      missing/too old, which effectively makes the build rules no-ops
      (x$(BUILD_INFO) != xinfo), and updates Makefile.in so that 'info'
      dependencies are still checked.
      
      2024-02-10  Christophe Lyon  <christophe.lyon@linaro.org>
      
      	gcc/
      	* Makefile.in: Add no-info dependency.
      	* configure.ac: Set BUILD_INFO=no-info if makeinfo is not
      	available.
      	* configure: Regenerate.
      1fcaa3a8
  20. Jan 29, 2024
  21. Jan 24, 2024
    • YunQiang Su's avatar
      MIPS: Accept arguments for -mexplicit-relocs · 58af788d
      YunQiang Su authored
      GAS introduced explicit relocs since 2001, and %pcrel_hi/low were
      introduced in 2014.  In future, we may introduce more.
      
      Let's convert -mexplicit-relocs option, and accpet options:
          none, base, pcrel.
      
      We also update gcc/configure.ac to set the value to option
      the gas support when GCC itself is built.
      
      gcc
      	* configure.ac: Detect the explicit relocs support for
      	mips, and define C macro MIPS_EXPLICIT_RELOCS.
      	* config.in: Regenerated.
      	* configure: Regenerated.
      	* doc/invoke.texi(MIPS Options): Add -mexplicit-relocs.
      	* config/mips/mips-opts.h: Define enum mips_explicit_relocs.
      	* config/mips/mips.cc(mips_set_compression_mode): Sorry if
      	!TARGET_EXPLICIT_RELOCS instead of just set it.
      	* config/mips/mips.h: Define TARGET_EXPLICIT_RELOCS and
      	TARGET_EXPLICIT_RELOCS_PCREL with mips_opt_explicit_relocs.
      	* config/mips/mips.opt: Introduce -mexplicit-relocs= option
      	and define -m(no-)explicit-relocs as aliases.
      58af788d
  22. Nov 18, 2024
    • David Malcolm's avatar
      libdiagnostics: add a "sarif-replay" command-line tool [PR96032] · ea1506ad
      David Malcolm authored
      
      This patch adds a new "sarif-replay" command-line tool for
      viewing .sarif files.  It uses libdiagnostics to "replay"
      any diagnostics found in the .sarif files in text form as if
      they were GCC diagnostics.
      
      contrib/ChangeLog:
      	PR other/96032
      	* regenerate-sarif-spec-index.py: New file.
      
      gcc/ChangeLog:
      	PR other/96032
      	* Makefile.in (lang_checks): If libdiagnostics is enabled, add
      	check-sarif-replay.
      	(SARIF_REPLAY_OBJS): New.
      	(ALL_HOST_OBJS): If libdiagnostics is enabled, add
      	$(SARIF_REPLAY_OBJS).
      	(sarif-replay): New.
      	(install-libdiagnostics): Add sarif-replay to deps, and install
      	it.
      	* configure: Regenerate.
      	* configure.ac (check_languages): If libdiagnostics is enabled,
      	add check-sarif-replay.
      	(LIBDIAGNOSTICS): If libdiagnostics is enabled, add sarif-replay.
      	* doc/install.texi (--enable-libdiagnostics): Note that it also
      	enables sarif-replay.
      	* libsarifreplay.cc: New file.
      	* libsarifreplay.h: New file.
      	* sarif-replay.cc: New file.
      	* sarif-spec-urls.def: New file.
      
      gcc/testsuite/ChangeLog:
      	PR other/96032
      	* lib/gcc-dg.exp (gcc-dg-test-1): Add "replay-sarif".
      	* lib/sarif-replay-dg.exp: New file.
      	* lib/sarif-replay.exp: New file.
      	* sarif-replay.dg/2.1.0-invalid/3.1-not-an-object.sarif: New test.
      	* sarif-replay.dg/2.1.0-invalid/3.11.11-malformed-placeholder.sarif:
      	New test.
      	* sarif-replay.dg/2.1.0-invalid/3.11.11-missing-arguments-for-placeholders.sarif:
      	New test.
      	* sarif-replay.dg/2.1.0-invalid/3.11.11-not-enough-arguments-for-placeholders.sarif:
      	New test.
      	* sarif-replay.dg/2.1.0-invalid/3.13.2-no-version.sarif: New test.
      	* sarif-replay.dg/2.1.0-invalid/3.13.2-version-not-a-string.sarif:
      	New test.
      	* sarif-replay.dg/2.1.0-invalid/3.13.4-bad-runs.sarif: New test.
      	* sarif-replay.dg/2.1.0-invalid/3.13.4-no-runs.sarif: New test.
      	* sarif-replay.dg/2.1.0-invalid/3.13.4-non-object-in-runs.sarif:
      	New test.
      	* sarif-replay.dg/2.1.0-invalid/3.27.10-bad-level.sarif: New test.
      	* sarif-replay.dg/2.1.0-unhandled/3.27.10-none-level.sarif: New test.
      	* sarif-replay.dg/2.1.0-valid/error-with-note.sarif: New test.
      	* sarif-replay.dg/2.1.0-valid/escaped-braces.sarif: New test.
      	* sarif-replay.dg/2.1.0-valid/null-runs.sarif: New test.
      	* sarif-replay.dg/2.1.0-valid/signal-1.c.sarif: New test.
      	* sarif-replay.dg/2.1.0-valid/spec-example-1.sarif: New test.
      	* sarif-replay.dg/2.1.0-valid/spec-example-2.sarif: New test.
      	* sarif-replay.dg/2.1.0-valid/spec-example-3.sarif: New test.
      	* sarif-replay.dg/2.1.0-valid/spec-example-4.sarif: New test.
      	* sarif-replay.dg/2.1.0-valid/tutorial-example.sarif: New test.
      	* sarif-replay.dg/dg.exp: New script.
      	* sarif-replay.dg/malformed-json/array-missing-comma.sarif: New test.
      	* sarif-replay.dg/malformed-json/array-with-trailing-comma.sarif:
      	New test.
      	* sarif-replay.dg/malformed-json/bad-token.sarif: New test.
      	* sarif-replay.dg/malformed-json/object-missing-comma.sarif: New test.
      	* sarif-replay.dg/malformed-json/object-with-trailing-comma.sarif:
      	New test.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      ea1506ad
    • David Malcolm's avatar
      Add libdiagnostics (v4) · 99a909ab
      David Malcolm authored
      This patch adds a new libdiagnostics shared library available as
      part of the GCC build via --enable-libdiagnostics when
      configuring GCC.
      
      It combines the following patches from:
        https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668632.html
      
      
          [PATCH 1/8] libdiagnostics v4: header
          [PATCH 2/8] libdiagnostics v4: implementation
          [PATCH 3/8] libdiagnostics: add API docs
          [PATCH 4/8] libdiagnostics v4: add C++ wrapper API
          [PATCH 6/8] libdiagnostics v4: test suite
      
      ChangeLog:
      	* configure.ac (--enable-libdiagnostics): New.
      	* configure: Regenerate.
      
      gcc/ChangeLog:
      	* configure.ac (check_languages): Add check-libdiagnostics.
      	(--enable-libdiagnostics): New.
      	* configure: Regenerate.
      	* Makefile.in (enable_libdiagnostics): New.
      	(lang_checks): If libdiagnostics is enabled, add
      	check-libdiagnostics.
      	(ALL_HOST_OBJS): If libdiagnostics is enabled, add
      	$(libdiagnostics_OBJS).
      	(start.encap): Add LIBDIAGNOSTICS.
      	(libdiagnostics_OBJS): New.
      	(LIBDIAGNOSTICS_VERSION_NUM): New, adapted from code in
      	jit/Make-lang.in.
      	(LIBDIAGNOSTICS_MINOR_NUM): Likewise.
      	(LIBDIAGNOSTICS_RELEASE_NUM): Likewise.
      	(LIBDIAGNOSTICS_FILENAME): Likewise.
      	(LIBDIAGNOSTICS_IMPORT_LIB): Likewise.
      	(libdiagnostics): Likewise.
      	(LIBDIAGNOSTICS_AGE): Likewise.
      	(LIBDIAGNOSTICS_BASENAME): Likewise.
      	(LIBDIAGNOSTICS_SONAME): Likewise.
      	(LIBDIAGNOSTICS_LINKER_NAME): Likewise.
      	(LIBDIAGNOSTICS_COMMA): Likewise.
      	(LIBDIAGNOSTICS_VERSION_SCRIPT_OPTION): Likewise.
      	(LIBDIAGNOSTICS_SONAME_OPTION): Likewise.
      	(LIBDIAGNOSTICS_SONAME_SYMLINK): Likewise.
      	(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK): Likewise.
      	(LIBDIAGNOSTICS_FILENAME): Likewise.
      	(libdiagnostics.serial): Likewise.
      	(LIBDIAGNOSTICS_EXTRA_OPTS): Likewise.
      	(install): If libdiagnostics is enabled, add
      	install-libdiagnostics.
      	(libdiagnostics.install-headers): New.
      	(libdiagnostics.install-common): New, adapted from code in
      	jit/Make-lang.in.
      	(install-libdiagnostics): New.
      	* diagnostic-format-text.h
      	(diagnostic_text_output_format::get_location_text): Make public.
      	* doc/install.texi (--enable-libdiagnostics): New.
      	* doc/libdiagnostics/Makefile: New file.
      	* doc/libdiagnostics/conf.py: New file.
      	* doc/libdiagnostics/index.rst: New file.
      	* doc/libdiagnostics/make.bat: New file.
      	* doc/libdiagnostics/topics/diagnostic-manager.rst: New file.
      	* doc/libdiagnostics/topics/diagnostics.rst: New file.
      	* doc/libdiagnostics/topics/execution-paths.rst: New file.
      	* doc/libdiagnostics/topics/fix-it-hints.rst: New file.
      	* doc/libdiagnostics/topics/index.rst: New file.
      	* doc/libdiagnostics/topics/logical-locations.rst: New file.
      	* doc/libdiagnostics/topics/message-formatting.rst: New file.
      	* doc/libdiagnostics/topics/metadata.rst: New file.
      	* doc/libdiagnostics/topics/physical-locations.rst: New file.
      	* doc/libdiagnostics/topics/retrofitting.rst: New file.
      	* doc/libdiagnostics/topics/sarif.rst: New file.
      	* doc/libdiagnostics/topics/text-output.rst: New file.
      	* doc/libdiagnostics/topics/ux.rst: New file.
      	* doc/libdiagnostics/tutorial/01-hello-world.rst: New file.
      	* doc/libdiagnostics/tutorial/02-physical-locations.rst: New file.
      	* doc/libdiagnostics/tutorial/03-logical-locations.rst: New file.
      	* doc/libdiagnostics/tutorial/04-notes.rst: New file.
      	* doc/libdiagnostics/tutorial/05-warnings.rst: New file.
      	* doc/libdiagnostics/tutorial/06-fix-it-hints.rst: New file.
      	* doc/libdiagnostics/tutorial/07-execution-paths.rst: New file.
      	* doc/libdiagnostics/tutorial/index.rst: New file.
      	* libdiagnostics++.h: New file.
      	* libdiagnostics.cc: New file.
      	* libdiagnostics.h: New file.
      	* libdiagnostics.map: New file.
      
      gcc/testsuite/ChangeLog:
      	* libdiagnostics.dg/libdiagnostics.exp: New, adapted from jit.exp.
      	* libdiagnostics.dg/sarif.py: New.
      	* libdiagnostics.dg/test-dump.c: New test.
      	* libdiagnostics.dg/test-error-c.py: New test.
      	* libdiagnostics.dg/test-error-with-note-c.py: New test.
      	* libdiagnostics.dg/test-error-with-note.c: New test.
      	* libdiagnostics.dg/test-error-with-note.cc: New test.
      	* libdiagnostics.dg/test-error.c: New test.
      	* libdiagnostics.dg/test-error.cc: New test.
      	* libdiagnostics.dg/test-example-1.c: New test.
      	* libdiagnostics.dg/test-fix-it-hint-c.py: New test.
      	* libdiagnostics.dg/test-fix-it-hint.c: New test.
      	* libdiagnostics.dg/test-fix-it-hint.cc: New test.
      	* libdiagnostics.dg/test-helpers++.h: New test.
      	* libdiagnostics.dg/test-helpers.h: New test.
      	* libdiagnostics.dg/test-labelled-ranges.c: New test.
      	* libdiagnostics.dg/test-labelled-ranges.cc: New test.
      	* libdiagnostics.dg/test-labelled-ranges.py: New test.
      	* libdiagnostics.dg/test-logical-location-c.py: New test.
      	* libdiagnostics.dg/test-logical-location.c: New test.
      	* libdiagnostics.dg/test-metadata-c.py: New test.
      	* libdiagnostics.dg/test-metadata.c: New test.
      	* libdiagnostics.dg/test-multiple-lines-c.py: New test.
      	* libdiagnostics.dg/test-multiple-lines.c: New test.
      	* libdiagnostics.dg/test-no-column-c.py: New test.
      	* libdiagnostics.dg/test-no-column.c: New test.
      	* libdiagnostics.dg/test-no-diagnostics-c.py: New test.
      	* libdiagnostics.dg/test-no-diagnostics.c: New test.
      	* libdiagnostics.dg/test-note-with-fix-it-hint-c.py: New test.
      	* libdiagnostics.dg/test-note-with-fix-it-hint.c: New test.
      	* libdiagnostics.dg/test-text-sink-options.c: New test.
      	* libdiagnostics.dg/test-warning-c.py: New test.
      	* libdiagnostics.dg/test-warning-with-path-c.py: New test.
      	* libdiagnostics.dg/test-warning-with-path.c: New test.
      	* libdiagnostics.dg/test-warning.c: New test.
      	* libdiagnostics.dg/test-write-sarif-to-file-c.py: New test.
      	* libdiagnostics.dg/test-write-sarif-to-file.c: New test.
      	* libdiagnostics.dg/test-write-text-to-file.c: New test.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      99a909ab
  23. Nov 14, 2024
    • Sam James's avatar
      gcc: regenerate configure · 7744da67
      Sam James authored
      r15-5257-g56ded80b96b0f6 didn't regenerate configure correctly.
      
      See https://inbox.sourceware.org/gcc-patches/ZzZf69gORVPRo6Ct@zen.kayari.org/.
      
      gcc/ChangeLog:
      
      	* configure: Regenerate.
      7744da67
    • Szabolcs Nagy's avatar
      aarch64: Add -mbranch-protection=gcs option · 56ded80b
      Szabolcs Nagy authored
      This enables Guarded Control Stack (GCS) compatible code generation.
      
      The "standard" branch-protection type enables it, and the default
      depends on the compiler default.
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64-protos.h (aarch_gcs_enabled): Declare.
      	* config/aarch64/aarch64.cc (aarch_gcs_enabled): Define.
      	(aarch_handle_no_branch_protection): Handle gcs.
      	(aarch_handle_standard_branch_protection): Handle gcs.
      	(aarch_handle_gcs_protection): New.
      	* config/aarch64/aarch64.opt: Add aarch_enable_gcs.
      	* configure: Regenerate.
      	* configure.ac: Handle gcs in --enable-standard-branch-protection.
      	* doc/invoke.texi: Document -mbranch-protection=gcs.
      56ded80b
  24. Oct 31, 2024
    • Andi Kleen's avatar
      Add autoconf check for clock_gettime · b23de8ec
      Andi Kleen authored
      Reported by Andrew Stubbs
      
      gcc/ChangeLog:
      
      	* config.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Check for HAVE_CLOCK_GETTIME.
      	* timevar.cc (get_time): Use HAVE_CLOCK_GETTIME.
      b23de8ec
  25. Oct 27, 2024
    • Jakub Jelinek's avatar
      genmatch: Add selftests to genmatch for diag_vfprintf · c246c4bc
      Jakub Jelinek authored
      The following patch adds selftests to genmatch to verify the new printing
      routine there.
      So that I can rely on HAVE_DECL_FMEMOPEN (host test), the tests are done
      solely in stage2+ where we link the host libcpp etc. to genmatch.
      The tests have been adjusted from pretty-print.cc (test_pp_format),
      and I've added to that function two new tests because I've noticed nothing
      was testing the %M$.*N$s etc. format specifiers.
      
      2024-10-27  Jakub Jelinek  <jakub@redhat.com>
      
      	* configure.ac (gcc_AC_CHECK_DECLS): Add fmemopen.
      	* configure: Regenerate.
      	* config.in: Regenerate.
      	* Makefile.in (build/genmatch.o): Add -DGENMATCH_SELFTESTS to
      	BUILD_CPPFLAGS for stage2+ genmatch.
      	* genmatch.cc (test_diag_vfprintf, genmatch_diag_selftests): New
      	functions.
      	(main): Call genmatch_diag_selftests.
      	* pretty-print.cc (test_pp_format): Add two tests, one for %M$.*N$s
      	and one for %M$.Ns.
      c246c4bc
  26. Sep 24, 2024
    • Jason Merrill's avatar
      build: enable C++11 narrowing warnings · 2249c3b4
      Jason Merrill authored
      We've been using -Wno-narrowing since gcc 4.7, but at this point narrowing
      diagnostics seem like a stable part of C++ and we should adjust.
      
      This patch changes -Wno-narrowing to -Wno-error=narrowing so that narrowing
      issues will still not break bootstrap, but we can see them.
      
      The rest of the patch fixes the narrowing warnings I see in an
      x86_64-pc-linux-gnu bootstrap.  In most of the cases, by adjusting the types
      of various declarations so that we store the values in the same types we
      compute them in, which seems worthwhile anyway.  This also allowed us to
      remove a few -Wsign-compare casts.
      
      gcc/ChangeLog:
      
      	* configure.ac (CXX_WARNING_OPTS): Change -Wno-narrowing
      	to -Wno-error=narrowing.
      	* configure: Regenerate.
      	* config/i386/i386.h (debugger_register_map)
      	(debugger64_register_map)
      	(svr4_debugger_register_map): Make unsigned.
      	* config/i386/i386.cc: Likewise.
      	* diagnostic-event-id.h (diagnostic_thread_id_t): Make int.
      	* vec.h (vec::size): Make unsigned int.
      	* ipa-modref.cc (escape_point::arg): Make unsigned.
      	(modref_lattice::add_escape_point): Use eaf_flags_t.
      	(update_escape_summary_1): Use eaf_flags_t, && for bool.
      	* pair-fusion.cc (pair_fusion_bb_info::track_access):
      	Make mem_size unsigned int.
      	* pretty-print.cc (format_phase_2): Cast va_arg to char.
      	* tree-ssa-loop-ch.cc (ch_base::copy_headers): Make nheaders
      	unsigned, remove cast.
      	* tree-ssa-structalias.cc (bitpos_of_field): Return unsigned.
      	(push_fields_onto_fieldstack):Make offset unsigned, remove cast.
      	* tree-vect-slp.cc (vect_prologue_cost_for_slp): Use nelt_limit.
      	* tree-vect-stmts.cc (vect_truncate_gather_scatter_offset):
      	Make scale unsigned.
      	(vectorizable_operation): Make ncopies unsigned.
      	* rtl-ssa/member-fns.inl: Make num_accesses unsigned int.
      2249c3b4
  27. Jan 14, 2024
    • Georg-Johann Lay's avatar
      AVR: Support .rodata in Flash for AVR64* and AVR128* Devices. · 48448055
      Georg-Johann Lay authored
      These devices see a 32 KiB block of their program memory (flash) in
      the RAM address space.  This can be used to support .rodata in flash
      provided Binutils support PR31124 (Add new emulations which locate
      .rodata in flash).  This patch does the following:
      
      * configure checks availability of Binutils PR31124.
      
      * Add new command line options -mrodata-in-ram and -mflmap.
      While -flmap is for internal usage (communicate hardware properties
      from device-specs to the compiler proper), -mrodata-in-ram is a user
      space option that allows to return to the current rodata-in-ram layout.
      
      * Adjust gen-avr-mmcu-specs.cc so that device-specs are generated
      that sanity check options, and that translate -m[no-]rodata-in-ram
      to its emulation.
      
      * Objects in .rodata don't drag __do_copy_data.
      
      * Document new options and built-in macros.
      
      	PR target/112944
      
      gcc/
      	* configure.ac [target=avr]: Check availability of emulations
      	avrxmega2_flmap and avrxmega4_flmap, resulting in new config vars
      	HAVE_LD_AVR_AVRXMEGA2_FLMAP and HAVE_LD_AVR_AVRXMEGA4_FLMAP.
      	* configure: Regenerate.
      	* config.in: Regenerate.
      	* doc/invoke.texi (AVR Options): Document -mflmap, -mrodata-in-ram,
      	__AVR_HAVE_FLMAP__, __AVR_RODATA_IN_RAM__.
      
      	* config/avr/avr.opt (-mflmap, -mrodata-in-ram): New options.
      	* config/avr/avr-arch.h (enum avr_device_specific_features):
      	Add AVR_ISA_FLMAP.
      	* config/avr/avr-mcus.def (AVR_MCU) [avr64*, avr128*]: Set isa flag
      	AVR_ISA_FLMAP.
      	* config/avr/avr.cc (avr_arch_index, avr_has_rodata_p): New vars.
      	(avr_set_core_architecture): Set avr_arch_index.
      	(have_avrxmega2_flmap, have_avrxmega4_flmap)
      	(have_avrxmega3_rodata_in_flash): Set new static const bool according
      	to configure results.
      	(avr_rodata_in_flash_p): New function using them.
      	(avr_asm_init_sections): Let readonly_data_section->unnamed.callback
      	track avr_need_copy_data_p only if not avr_rodata_in_flash_p().
      	(avr_asm_named_section): Track avr_has_rodata_p.
      	(avr_file_end): Emit __do_copy_data also when avr_has_rodata_p
      	and not avr_rodata_in_flash_p ().
      	* config/avr/specs.h (CC1_SPEC): Add %(cc1_rodata_in_ram).
      	(LINK_SPEC): Add %(link_rodata_in_ram).
      	(LINK_ARCH_SPEC): Remove.
      	* config/avr/gen-avr-mmcu-specs.cc (have_avrxmega3_rodata_in_flash)
      	(have_avrxmega2_flmap, have_avrxmega4_flmap): Set new static
      	const bool according to configure results.
      	(diagnose_mrodata_in_ram): New function.
      	(print_mcu): Generate specs with the following changes:
      	<*cc1_misc, *asm_misc, *link_misc>: New specs so that we don't
      	need to extend avr/specs.h each time we add a new bell or whistle.
      	<*cc1_rodata_in_ram, *link_rodata_in_ram>: New specs to diagnose
      	-m[no-]rodata-in-ram.
      	<*cpp_rodata_in_ram>: New. Does -D__AVR_RODATA_IN_RAM__=0/1.
      	<*cpp_mcu>: Add -D__AVR_AVR_FLMAP__ if it applies.
      	<*cpp>: Add %(cpp_rodata_in_ram).
      	<*link_arch>: Use emulation avrxmega2_flmap, avrxmega4_flmap as
      	requested.
      	<*self_spec>: Add -mflmap or %<mflmap as needed.
      
      gcc/testsuite/
      	* gcc.target/avr/torture/pr112944-flmap-0.c: New test.
      	* gcc.target/avr/torture/pr112944-flmap-1.c: New test.
      48448055
  28. Jan 02, 2024
    • Lulu Cheng's avatar
      LoongArch: Added TLS Le Relax support. · 3c20e626
      Lulu Cheng authored
      Check whether the assembler supports tls le relax. If it supports it, the assembly
      instruction sequence of tls le relax will be generated by default.
      
      The original way to obtain the tls le symbol address:
          lu12i.w $rd, %le_hi20(sym)
          ori $rd, $rd, %le_lo12(sym)
          add.{w/d} $rd, $rd, $tp
      
      If the assembler supports tls le relax, the following sequence is generated:
      
          lu12i.w $rd, %le_hi20_r(sym)
          add.{w/d} $rd,$rd,$tp,%le_add_r(sym)
          addi.{w/d} $rd,$rd,%le_lo12_r(sym)
      
      gcc/ChangeLog:
      
      	* config.in: Regenerate.
      	* config/loongarch/loongarch-opts.h (HAVE_AS_TLS_LE_RELAXATION): Define.
      	* config/loongarch/loongarch.cc (loongarch_legitimize_tls_address):
      	Added TLS Le Relax support.
      	(loongarch_print_operand_reloc): Add the output string of TLS Le Relax.
      	* config/loongarch/loongarch.md (@add_tls_le_relax<mode>): New template.
      	* configure: Regenerate.
      	* configure.ac: Check if binutils supports TLS le relax.
      
      gcc/testsuite/ChangeLog:
      
      	* lib/target-supports.exp: Add a function to check whether binutil supports
      	TLS Le Relax.
      	* gcc.target/loongarch/tls-le-relax.c: New test.
      3c20e626
  29. Nov 24, 2023
    • Alexander Monakov's avatar
      gcc: configure: drop Valgrind 3.1 compatibility · f9a10e91
      Alexander Monakov authored
      Our system.h and configure.ac try to accommodate valgrind-3.1, but it is
      more than 15 years old at this point. As Valgrind-based checking is a
      developer-oriented feature, drop the compatibility stuff and streamline
      the detection.
      
      gcc/ChangeLog:
      
      	* config.in: Regenerate.
      	* configure: Regenerate.
      	* configure.ac: Delete manual checks for old Valgrind headers.
      	* system.h (VALGRIND_MAKE_MEM_NOACCESS): Delete.
      	(VALGRIND_MAKE_MEM_DEFINED): Delete.
      	(VALGRIND_MAKE_MEM_UNDEFINED): Delete.
      	(VALGRIND_MALLOCLIKE_BLOCK): Delete.
      	(VALGRIND_FREELIKE_BLOCK): Delete.
      f9a10e91
  30. Nov 23, 2023
    • Marek Polacek's avatar
      gcc: Introduce -fhardened · 24592abd
      Marek Polacek authored
      In <https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628748.html>
      I proposed -fhardened, a new umbrella option that enables a reasonable set
      of hardening flags.  The read of the room seems to be that the option
      would be useful.  So here's a patch implementing that option.
      
      Currently, -fhardened enables:
      
        -D_FORTIFY_SOURCE=3 (or =2 for older glibcs)
        -D_GLIBCXX_ASSERTIONS
        -ftrivial-auto-var-init=zero
        -fPIE  -pie  -Wl,-z,relro,-z,now
        -fstack-protector-strong
        -fstack-clash-protection
        -fcf-protection=full (x86 GNU/Linux only)
      
      -fhardened will not override options that were specified on the command line
      (before or after -fhardened).  For example,
      
           -D_FORTIFY_SOURCE=1 -fhardened
      
      means that _FORTIFY_SOURCE=1 will be used.  Similarly,
      
            -fhardened -fstack-protector
      
      will not enable -fstack-protector-strong.
      
      Currently, -fhardened is only supported on GNU/Linux.
      
      In DW_AT_producer it is reflected only as -fhardened; it doesn't expand
      to anything.  This patch provides -Whardened, enabled by default, which
      warns when -fhardened couldn't enable a particular option.  I think most
      often it will say that _FORTIFY_SOURCE wasn't enabled because optimization
      were not enabled.
      
      gcc/c-family/ChangeLog:
      
      	* c-opts.cc: Include "target.h".
      	(c_finish_options): Maybe cpp_define _FORTIFY_SOURCE
      	and _GLIBCXX_ASSERTIONS.
      
      gcc/ChangeLog:
      
      	* common.opt (Whardened, fhardened): New options.
      	* config.in: Regenerate.
      	* config/bpf/bpf.cc: Include "opts.h".
      	(bpf_option_override): If flag_stack_protector_set_by_fhardened_p, do
      	not inform that -fstack-protector does not work.
      	* config/i386/i386-options.cc (ix86_option_override_internal): When
      	-fhardened, maybe enable -fcf-protection=full.
      	* config/linux-protos.h (linux_fortify_source_default_level): Declare.
      	* config/linux.cc (linux_fortify_source_default_level): New.
      	* config/linux.h (TARGET_FORTIFY_SOURCE_DEFAULT_LEVEL): Redefine.
      	* configure: Regenerate.
      	* configure.ac: Check if the linker supports '-z now' and '-z relro'.
      	Check if -fhardened is supported on $target_os.
      	* doc/invoke.texi: Document -fhardened and -Whardened.
      	* doc/tm.texi: Regenerate.
      	* doc/tm.texi.in (TARGET_FORTIFY_SOURCE_DEFAULT_LEVEL): Add.
      	* gcc.cc (driver_handle_option): Remember if any link options or -static
      	were specified on the command line.
      	(process_command): When -fhardened, maybe enable -pie and
      	-Wl,-z,relro,-z,now.
      	* opts.cc (flag_stack_protector_set_by_fhardened_p): New global.
      	(finish_options): When -fhardened, enable
      	-ftrivial-auto-var-init=zero and -fstack-protector-strong.
      	(print_help_hardened): New.
      	(print_help): Call it.
      	* opts.h (flag_stack_protector_set_by_fhardened_p): Declare.
      	* target.def (fortify_source_default_level): New target hook.
      	* targhooks.cc (default_fortify_source_default_level): New.
      	* targhooks.h (default_fortify_source_default_level): Declare.
      	* toplev.cc (process_options): When -fhardened, enable
      	-fstack-clash-protection.  If flag_stack_protector_set_by_fhardened_p,
      	do not warn that -fstack-protector not supported for this target.
      	Don't enable -fhardened when !HAVE_FHARDENED_SUPPORT.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.misc-tests/help.exp: Test -fhardened.
      	* c-c++-common/fhardened-1.S: New test.
      	* c-c++-common/fhardened-1.c: New test.
      	* c-c++-common/fhardened-10.c: New test.
      	* c-c++-common/fhardened-11.c: New test.
      	* c-c++-common/fhardened-12.c: New test.
      	* c-c++-common/fhardened-13.c: New test.
      	* c-c++-common/fhardened-14.c: New test.
      	* c-c++-common/fhardened-15.c: New test.
      	* c-c++-common/fhardened-2.c: New test.
      	* c-c++-common/fhardened-3.c: New test.
      	* c-c++-common/fhardened-4.c: New test.
      	* c-c++-common/fhardened-5.c: New test.
      	* c-c++-common/fhardened-6.c: New test.
      	* c-c++-common/fhardened-7.c: New test.
      	* c-c++-common/fhardened-8.c: New test.
      	* c-c++-common/fhardened-9.c: New test.
      	* gcc.target/i386/cf_check-6.c: New test.
      24592abd
    • Costas Argyris's avatar
      mingw: Exclude utf8 manifest [PR111170, PR108865] · 4f1ebd54
      Costas Argyris authored
      
      Make the utf8 manifest optional (on by default and
      explicitly off with --disable-win32-utf8-manifest)
      in the mingw hosts.
      
      Also eliminate duplication between the 32-bit and
      64-bit mingw hosts by putting them both in the
      same branch and special-case only the 64-bit long
      long setting.
      
      PR mingw/111170
      PR mingw/108865
      
      Signed-off-by: default avatarCostas Argyris <costas.argyris@gmail.com>
      Signed-off-by: default avatarJonathan Yong <10walls@gmail.com>
      
      gcc/Changelog:
      
      	* configure.ac: Handle new --enable-win32-utf8-manifest
      	option.
      	* config.host: allow win32 utf8 manifest to be disabled
      	by user.
      	* configure: Regenerate.
      4f1ebd54
  31. Nov 18, 2023
    • Lulu Cheng's avatar
      LoongArch: Add code generation support for call36 function calls. · 094cca42
      Lulu Cheng authored
      
      When compiling with '-mcmodel=medium', the function call is made through
      'pcaddu18i+jirl' if binutils supports call36, otherwise the
      native implementation 'pcalau12i+jirl' is used.
      
      gcc/ChangeLog:
      
      	* config.in: Regenerate.
      	* config/loongarch/loongarch-opts.h (HAVE_AS_SUPPORT_CALL36): Define macro.
      	* config/loongarch/loongarch.cc (loongarch_legitimize_call_address):
      	If binutils supports call36, the function call is not split over expand.
      	* config/loongarch/loongarch.md: Add call36 generation code.
      	* config/loongarch/predicates.md: Likewise.
      	* configure: Regenerate.
      	* configure.ac: Check whether binutils supports call36.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/loongarch/func-call-medium-5.c: If the assembler supports call36,
      	the test is abandoned.
      	* gcc.target/loongarch/func-call-medium-6.c: Likewise.
      	* gcc.target/loongarch/func-call-medium-7.c: Likewise.
      	* gcc.target/loongarch/func-call-medium-8.c: Likewise.
      	* lib/target-supports.exp: Added a function to see if the assembler supports
      	the call36 relocation.
      	* gcc.target/loongarch/func-call-medium-call36-1.c: New test.
      	* gcc.target/loongarch/func-call-medium-call36.c: New test.
      
      Co-authored-by: default avatarXi Ruoyao <xry111@xry111.site>
      094cca42
  32. Nov 14, 2023
    • Xi Ruoyao's avatar
      LoongArch: Disable relaxation if the assembler don't support conditional... · fe23a2ff
      Xi Ruoyao authored
      LoongArch: Disable relaxation if the assembler don't support conditional branch relaxation [PR112330]
      
      As the commit message of r14-4674 has indicated, if the assembler does
      not support conditional branch relaxation, a relocation overflow may
      happen on conditional branches when relaxation is enabled because the
      number of NOP instructions inserted by the assembler will be more than
      the number estimated by GCC.
      
      To work around this issue, disable relaxation by default if the
      assembler is detected incapable to perform conditional branch relaxation
      at GCC build time.  We also need to pass -mno-relax to the assembler to
      really disable relaxation.  But, if the assembler does not support
      -mrelax option at all, we should not pass -mno-relax to the assembler or
      it will immediately error out.  Also handle this with the build time
      assembler capability probing, and add a pair of options
      -m[no-]pass-mrelax-to-as to allow using a different assembler from the
      build-time one.
      
      With this change, if GCC is built with GAS 2.41, relaxation will be
      disabled by default.  So the default value of -mexplicit-relocs= is also
      changed to 'always' if -mno-relax is specified or implied by the
      build-time default, because using assembler macros for symbol addresses
      produces no benefit when relaxation is disabled.
      
      gcc/ChangeLog:
      
      	PR target/112330
      	* config/loongarch/genopts/loongarch.opt.in: Add
      	-m[no]-pass-relax-to-as.  Change the default of -m[no]-relax to
      	account conditional branch relaxation support status.
      	* config/loongarch/loongarch.opt: Regenerate.
      	* configure.ac (gcc_cv_as_loongarch_cond_branch_relax): Check if
      	the assembler supports conditional branch relaxation.
      	* configure: Regenerate.
      	* config.in: Regenerate.  Note that there are some unrelated
      	changes introduced by r14-5424 (which does not contain a
      	config.in regeneration).
      	* config/loongarch/loongarch-opts.h
      	(HAVE_AS_COND_BRANCH_RELAXATION): Define to 0 if not defined.
      	* config/loongarch/loongarch-driver.h (ASM_MRELAX_DEFAULT):
      	Define.
      	(ASM_MRELAX_SPEC): Define.
      	(ASM_SPEC): Use ASM_MRELAX_SPEC instead of "%{mno-relax}".
      	* config/loongarch/loongarch.cc: Take the setting of
      	-m[no-]relax into account when determining the default of
      	-mexplicit-relocs=.
      	* doc/invoke.texi: Document -m[no-]relax and
      	-m[no-]pass-mrelax-to-as for LoongArch.  Update the default
      	value of -mexplicit-relocs=.
      fe23a2ff
Loading