Re: [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv

2024-05-08 Thread Andrew Pinski
On Sat, Jul 22, 2023 at 8:36 PM Kito Cheng via Gcc-patches
 wrote:
>
> OK for trunk, thanks:)

I have now backported it to 13 branch.

Thanks,
Andrew


>
> Andrew Pinski via Gcc-patches  於 2023年7月23日 週日
> 09:07 寫道:
>
> > The problem -fasynchronous-unwind-tables is on by default for riscv linux
> > We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__
> > point
> > to .eh_frame data from crtbeginT.o instead of the user-defined object
> > during static linking.
> >
> > This turns it off.
> >
> > OK?
> >
> > libgcc/ChangeLog:
> >
> > * config.host (riscv*-*-linux*): Add t-crtstuff to tmake_file.
> > (riscv*-*-freebsd*): Likewise.
> > * config/riscv/t-crtstuff: New file.
> > ---
> >  libgcc/config.host | 4 ++--
> >  libgcc/config/riscv/t-crtstuff | 5 +
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> >  create mode 100644 libgcc/config/riscv/t-crtstuff
> >
> > diff --git a/libgcc/config.host b/libgcc/config.host
> > index 9d7212028d0..c94d69d84b7 100644
> > --- a/libgcc/config.host
> > +++ b/libgcc/config.host
> > @@ -1304,12 +1304,12 @@ pru-*-*)
> > tm_file="$tm_file pru/pru-abi.h"
> > ;;
> >  riscv*-*-linux*)
> > -   tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp
> > riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
> > +   tmake_file="${tmake_file} riscv/t-crtstuff
> > riscv/t-softfp${host_address} t-softfp riscv/t-elf
> > riscv/t-elf${host_address} t-slibgcc-libgcc"
> > extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o
> > crtendS.o crtbeginT.o"
> > md_unwind_header=riscv/linux-unwind.h
> > ;;
> >  riscv*-*-freebsd*)
> > -   tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp
> > riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
> > +   tmake_file="${tmake_file} riscv/t-crtstuff
> > riscv/t-softfp${host_address} t-softfp riscv/t-elf
> > riscv/t-elf${host_address} t-slibgcc-libgcc"
> > extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o
> > crtendS.o crtbeginT.o"
> > ;;
> >  riscv*-*-*)
> > diff --git a/libgcc/config/riscv/t-crtstuff
> > b/libgcc/config/riscv/t-crtstuff
> > new file mode 100644
> > index 000..685d11b3e66
> > --- /dev/null
> > +++ b/libgcc/config/riscv/t-crtstuff
> > @@ -0,0 +1,5 @@
> > +# -fasynchronous-unwind-tables -funwind-tables is on by default for riscv
> > linux
> > +# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> > +# to .eh_frame data from crtbeginT.o instead of the user-defined object
> > +# during static linking.
> > +CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
> > --
> > 2.39.1
> >
> >


Re: [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv

2023-07-23 Thread Andreas Schwab
On Jul 22 2023, Andrew Pinski via Gcc-patches wrote:

> The problem -fasynchronous-unwind-tables is on by default for riscv linux
> We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> to .eh_frame data from crtbeginT.o instead of the user-defined object
> during static linking.
>
> This turns it off.

Since this is a recurring problem, and difficult to notice (see how long
the aarch64 case went unnoticed), it should be fixed generically,
instead of having to patch every case separately.

> diff --git a/libgcc/config/riscv/t-crtstuff b/libgcc/config/riscv/t-crtstuff
> new file mode 100644
> index 000..685d11b3e66
> --- /dev/null
> +++ b/libgcc/config/riscv/t-crtstuff
> @@ -0,0 +1,5 @@
> +# -fasynchronous-unwind-tables -funwind-tables is on by default for riscv 
> linux
> +# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> +# to .eh_frame data from crtbeginT.o instead of the user-defined object
> +# during static linking.
> +CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables

What about CRTSTUFF_T_CFLAGS_S?

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv

2023-07-22 Thread Kito Cheng via Gcc-patches
OK for trunk, thanks:)

Andrew Pinski via Gcc-patches  於 2023年7月23日 週日
09:07 寫道:

> The problem -fasynchronous-unwind-tables is on by default for riscv linux
> We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__
> point
> to .eh_frame data from crtbeginT.o instead of the user-defined object
> during static linking.
>
> This turns it off.
>
> OK?
>
> libgcc/ChangeLog:
>
> * config.host (riscv*-*-linux*): Add t-crtstuff to tmake_file.
> (riscv*-*-freebsd*): Likewise.
> * config/riscv/t-crtstuff: New file.
> ---
>  libgcc/config.host | 4 ++--
>  libgcc/config/riscv/t-crtstuff | 5 +
>  2 files changed, 7 insertions(+), 2 deletions(-)
>  create mode 100644 libgcc/config/riscv/t-crtstuff
>
> diff --git a/libgcc/config.host b/libgcc/config.host
> index 9d7212028d0..c94d69d84b7 100644
> --- a/libgcc/config.host
> +++ b/libgcc/config.host
> @@ -1304,12 +1304,12 @@ pru-*-*)
> tm_file="$tm_file pru/pru-abi.h"
> ;;
>  riscv*-*-linux*)
> -   tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp
> riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
> +   tmake_file="${tmake_file} riscv/t-crtstuff
> riscv/t-softfp${host_address} t-softfp riscv/t-elf
> riscv/t-elf${host_address} t-slibgcc-libgcc"
> extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o
> crtendS.o crtbeginT.o"
> md_unwind_header=riscv/linux-unwind.h
> ;;
>  riscv*-*-freebsd*)
> -   tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp
> riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
> +   tmake_file="${tmake_file} riscv/t-crtstuff
> riscv/t-softfp${host_address} t-softfp riscv/t-elf
> riscv/t-elf${host_address} t-slibgcc-libgcc"
> extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o
> crtendS.o crtbeginT.o"
> ;;
>  riscv*-*-*)
> diff --git a/libgcc/config/riscv/t-crtstuff
> b/libgcc/config/riscv/t-crtstuff
> new file mode 100644
> index 000..685d11b3e66
> --- /dev/null
> +++ b/libgcc/config/riscv/t-crtstuff
> @@ -0,0 +1,5 @@
> +# -fasynchronous-unwind-tables -funwind-tables is on by default for riscv
> linux
> +# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> +# to .eh_frame data from crtbeginT.o instead of the user-defined object
> +# during static linking.
> +CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
> --
> 2.39.1
>
>


[PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv

2023-07-22 Thread Andrew Pinski via Gcc-patches
The problem -fasynchronous-unwind-tables is on by default for riscv linux
We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
to .eh_frame data from crtbeginT.o instead of the user-defined object
during static linking.

This turns it off.

OK?

libgcc/ChangeLog:

* config.host (riscv*-*-linux*): Add t-crtstuff to tmake_file.
(riscv*-*-freebsd*): Likewise.
* config/riscv/t-crtstuff: New file.
---
 libgcc/config.host | 4 ++--
 libgcc/config/riscv/t-crtstuff | 5 +
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 libgcc/config/riscv/t-crtstuff

diff --git a/libgcc/config.host b/libgcc/config.host
index 9d7212028d0..c94d69d84b7 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1304,12 +1304,12 @@ pru-*-*)
tm_file="$tm_file pru/pru-abi.h"
;;
 riscv*-*-linux*)
-   tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp 
riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
+   tmake_file="${tmake_file} riscv/t-crtstuff 
riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} 
t-slibgcc-libgcc"
extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o 
crtbeginT.o"
md_unwind_header=riscv/linux-unwind.h
;;
 riscv*-*-freebsd*)
-   tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp 
riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
+   tmake_file="${tmake_file} riscv/t-crtstuff 
riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} 
t-slibgcc-libgcc"
extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o 
crtbeginT.o"
;;
 riscv*-*-*)
diff --git a/libgcc/config/riscv/t-crtstuff b/libgcc/config/riscv/t-crtstuff
new file mode 100644
index 000..685d11b3e66
--- /dev/null
+++ b/libgcc/config/riscv/t-crtstuff
@@ -0,0 +1,5 @@
+# -fasynchronous-unwind-tables -funwind-tables is on by default for riscv linux
+# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
+# to .eh_frame data from crtbeginT.o instead of the user-defined object
+# during static linking.
+CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
-- 
2.39.1