[v2] RISC-V: Add --with-cmodel configure option
Checks
Context |
Check |
Description |
rivoscibot/toolchain-ci-rivos-lint |
warning
|
Lint failed
|
rivoscibot/toolchain-ci-rivos-apply-patch |
success
|
Patch applied
|
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gc-lp64d-non-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc-lp64d-non-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gcv-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc_zba_zbb_zbc_zbs-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv64gcv-lp64d-multilib |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
fail
|
Build failed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
fail
|
Build failed
|
rivoscibot/toolchain-ci-rivos-test |
success
|
Testing passed
|
Commit Message
Sometimes we want to use default cmodel other than medlow. Add a GCC
configure option for that.
gcc/ChangeLog:
* config.gcc (riscv*-*-*): Add support for --with-cmodel configure option.
* config/riscv/riscv.h (TARGET_RISCV_DEFAULT_CMODEL): Define default cmodel.
* configure: Regenerate.
* configure.ac: Add --with-cmodel configure option.
* doc/install.texi: Document --with-cmodel configure option.
* doc/invoke.texi (-mcmodel): Mention --with-cmodel configure option.
---
gcc/config.gcc | 19 +++++++++++++++++--
gcc/config/riscv/riscv.h | 2 ++
gcc/configure | 15 +++++++++++++--
gcc/configure.ac | 5 +++++
gcc/doc/install.texi | 4 ++++
gcc/doc/invoke.texi | 6 ++++--
6 files changed, 45 insertions(+), 6 deletions(-)
Comments
On 8/1/24 11:11 PM, Hau Hsu wrote:
> Sometimes we want to use default cmodel other than medlow. Add a GCC
> configure option for that.
>
> gcc/ChangeLog:
>
> * config.gcc (riscv*-*-*): Add support for --with-cmodel configure option.
> * config/riscv/riscv.h (TARGET_RISCV_DEFAULT_CMODEL): Define default cmodel.
> * configure: Regenerate.
> * configure.ac: Add --with-cmodel configure option.
> * doc/install.texi: Document --with-cmodel configure option.
> * doc/invoke.texi (-mcmodel): Mention --with-cmodel configure option.
I thought Palmer had submitted an equivalent patch a while back, but I
can't seem to find it.
It looks like pre-commit testing has flagged this as failing to build on
arm/aarch64. I'm not as familiar with that system, so I don't know
exactly what it's complaining about other than the configuration step
for GCC failed.
https://patchwork.sourceware.org/project/gcc/patch/20240802051151.3658614-1-hau.hsu@sifive.com/
# reset_artifacts:
-10
# true:
0
# build_abe gcc:
# FAILED
# First few build errors in logs:
# 00:01:36 make[1]: *** [Makefile:4646: configure-gcc] Error 1
# 00:01:36 make: *** [Makefile:1065: all] Error 2
Oh the Palmer's patch is here
https://gcc.gnu.org/pipermail/gcc-patches/2023-December/641172.html
It doesn't mater who's patch get merged for me :)
> On Aug 2, 2024, at 10:43 PM, Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
> On 8/1/24 11:11 PM, Hau Hsu wrote:
>> Sometimes we want to use default cmodel other than medlow. Add a GCC
>> configure option for that.
>> gcc/ChangeLog:
>> * config.gcc (riscv*-*-*): Add support for --with-cmodel configure option.
>> * config/riscv/riscv.h (TARGET_RISCV_DEFAULT_CMODEL): Define default cmodel.
>> * configure: Regenerate.
>> * configure.ac: Add --with-cmodel configure option.
>> * doc/install.texi: Document --with-cmodel configure option.
>> * doc/invoke.texi (-mcmodel): Mention --with-cmodel configure option.
> I thought Palmer had submitted an equivalent patch a while back, but I can't seem to find it.
>
>
> It looks like pre-commit testing has flagged this as failing to build on arm/aarch64. I'm not as familiar with that system, so I don't know exactly what it's complaining about other than the configuration step for GCC failed.
>
>
> https://patchwork.sourceware.org/project/gcc/patch/20240802051151.3658614-1-hau.hsu@sifive.com/
>
> # reset_artifacts:
> -10
> # true:
> 0
> # build_abe gcc:
> # FAILED
> # First few build errors in logs:
> # 00:01:36 make[1]: *** [Makefile:4646: configure-gcc] Error 1
> # 00:01:36 make: *** [Makefile:1065: all] Error 2
>
>
>
>
On 8/4/24 8:24 PM, Hau Hsu wrote:
> Oh the Palmer's patch is here
> [PATCH] RISC-V: Add --with-cmodel configure-time argument <https://
> gcc.gnu.org/pipermail/gcc-patches/2023-December/641172.html>
> gcc.gnu.org <https://gcc.gnu.org/pipermail/gcc-patches/2023-December/
> 641172.html>
> favicon.ico <https://gcc.gnu.org/pipermail/gcc-patches/2023-December/
> 641172.html>
>
> <https://gcc.gnu.org/pipermail/gcc-patches/2023-December/641172.html>
>
>
> It doesn't mater who's patch get merged for me :)
Me neither. We do need to understand if this is causing other problems
though. As I noted earlier, pre-commit testing showed a failure on aarch64:
> https://patchwork.sourceware.org/project/gcc/patch/20240802051151.3658614-1-hau.hsu@sifive.com/
I'm not familiar enough with that tester to identify what went wrong,
but it needs to be understood/fixed before we can move forward.
jeff
@@ -4723,7 +4723,7 @@ case "${target}" in
;;
riscv*-*-*)
- supported_defaults="abi arch tune riscv_attribute isa_spec tls"
+ supported_defaults="abi arch tune riscv_attribute isa_spec tls cmodel"
case "${target}" in
riscv-* | riscv32*) xlen=32 ;;
@@ -4879,6 +4879,21 @@ case "${target}" in
exit 1
esac
fi
+
+ # Handle --with-cmodel.
+ if test "x${with_cmodel}" != xdefault; then
+ # Make sure --with-cmodel is valid. If it was not specified,
+ # use medlow as the default value.
+ case "${with_cmodel}" in
+ medlow | medany | large)
+ ;;
+ *)
+ echo "invalid option for --with-cmodel: '${with_cmodel}', available values are 'medlow' 'medany' 'large'" 1>&2
+ exit 1
+ ;;
+ esac
+ tm_defines="${tm_defines} TARGET_RISCV_DEFAULT_CMODEL=${with_cmodel}"
+ fi
;;
mips*-*-*)
@@ -6071,7 +6086,7 @@ case ${target} in
esac
t=
-all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 schedule float mode fpu nan fp_32 odd_spreg_32 divide llsc mips-plt synci tls lxc1-sxc1 madd4 isa_spec compact-branches msa"
+all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 schedule float mode fpu nan fp_32 odd_spreg_32 divide llsc mips-plt synci tls lxc1-sxc1 madd4 isa_spec compact-branches msa cmodel"
for option in $all_defaults
do
eval "val=\$with_"`echo $option | sed s/-/_/g`
@@ -65,6 +65,7 @@ extern const char *riscv_arch_help (int argc, const char **argv);
--with-tune is ignored if -mtune or -mcpu is specified.
--with-isa-spec is ignored if -misa-spec is specified.
--with-tls is ignored if -mtls-dialect is specified.
+ --with-cmodel is ignored if -mcmodel is specified.
But using default -march/-mtune value if -mcpu don't have valid option. */
#define OPTION_DEFAULT_SPECS \
@@ -77,6 +78,7 @@ extern const char *riscv_arch_help (int argc, const char **argv);
{"abi", "%{!mabi=*:-mabi=%(VALUE)}" }, \
{"isa_spec", "%{!misa-spec=*:-misa-spec=%(VALUE)}" }, \
{"tls", "%{!mtls-dialect=*:-mtls-dialect=%(VALUE)}"}, \
+ {"cmodel", "%{!mcmodel=*:-mcmodel=%(VALUE)}" }, \
#ifdef IN_LIBGCC2
#undef TARGET_64BIT
@@ -1000,6 +1000,7 @@ with_changes_root_url
enable_languages
with_multilib_list
with_multilib_generator
+with_cmodel
with_zstd
with_zstd_include
with_zstd_lib
@@ -1880,6 +1881,7 @@ Optional Packages:
SH and x86-64 only)
--with-multilib-generator
Multi-libs configuration string (RISC-V only)
+ --with-cmodel Code model configuration string (RISC-V only)
--with-zstd=PATH specify prefix directory for installed zstd library.
Equivalent to --with-zstd-include=PATH/include plus
--with-zstd-lib=PATH/lib
@@ -8381,6 +8383,15 @@ else
fi
+
+# Check whether --with-cmodel was given.
+if test "${with_cmodel+set}" = set; then :
+ withval=$with_cmodel; :
+else
+ with_cmodel=medlow
+fi
+
+
# -------------------------
# Checks for other programs
# -------------------------
@@ -21406,7 +21417,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 21409 "configure"
+#line 21420 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -21512,7 +21523,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 21515 "configure"
+#line 21526 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -1212,6 +1212,11 @@ AC_ARG_WITH(multilib-generator,
:,
with_multilib_generator=default)
+AC_ARG_WITH(cmodel,
+[AS_HELP_STRING([--with-cmodel], [Code model configuration string (RISC-V only)])],
+:,
+with_cmodel=medlow)
+
# -------------------------
# Checks for other programs
# -------------------------
@@ -1519,6 +1519,10 @@ Use big endian by default. Provide a multilib for little endian.
Use little endian by default. Provide a multilib for big endian.
@end table
+@item --with-cmodel=@var{cmodel}
+Specify what code model to use by default.
+Currently only implemented for riscv*-*-*.
+
@item --enable-threads
Specify that the target
supports threads. This affects the Objective-C compiler and runtime
@@ -31285,8 +31285,10 @@ element-misaligned vector memory access.
@item -mcmodel=medlow
Generate code for the medium-low code model. The program and its statically
defined symbols must lie within a single 2 GiB address range and must lie
-between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
-statically or dynamically linked. This is the default code model.
+between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be statically
+or dynamically linked. This is the default code model unless GCC has been
+configured with @option{--with-cmodel=} specifying a different default code
+model.
@opindex mcmodel=medany
@item -mcmodel=medany