Sync patch for fixing building issues with clang; replace %patchN with %patch -P N

Src: https://gitee.com/openeuler/gcc/pulls/239

Signed-off-by: YunQiang Su <yunqiang@isrc.iscas.ac.cn>
Signed-off-by: jchzhou <zhoujiacheng@iscas.ac.cn>
This commit is contained in:
jchzhou 2024-11-25 17:25:37 +08:00
parent 1a5b9011a6
commit 1ebbd61186
3 changed files with 820 additions and 599 deletions

View File

@ -0,0 +1,105 @@
From 0d157b14f361f8319f4694c54c6e01ac8f59d278 Mon Sep 17 00:00:00 2001
From: YunQiang Su <yunqiang@isrc.iscas.ac.cn>
Date: Tue, 8 Oct 2024 17:56:23 +0800
Subject: [PATCH 1/2] Set fallback value for -print-multi-os-directory
Clang doesn't support -print-multi-os-directory option.
So let's set the fallback value (../lib64) if it is empty.
This is only needed for the projects built by hostcc:
gcc, libcc1, libiberty
The projects for targets only, will always built by gcc itself.
---
gcc/configure | 3 +++
libcc1/configure | 6 ++++++
libcc1/configure.ac | 3 +++
libiberty/Makefile.in | 5 ++++-
libtool.m4 | 3 +++
5 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/gcc/configure b/gcc/configure
index 7e64599b0..ef0449edd 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -18598,6 +18598,9 @@ if test "$GCC" = yes; then
# and add multilib dir if necessary.
lt_tmp_lt_search_path_spec=
lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ if [ -z "$lt_multi_os_dir" ];then
+ lt_multi_os_dir=../lib64
+ fi
for lt_sys_path in $lt_search_path_spec; do
if test -d "$lt_sys_path/$lt_multi_os_dir"; then
lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
diff --git a/libcc1/configure b/libcc1/configure
index 01cfb2806..3c437d690 100755
--- a/libcc1/configure
+++ b/libcc1/configure
@@ -9701,6 +9701,9 @@ if test "$GCC" = yes; then
# and add multilib dir if necessary.
lt_tmp_lt_search_path_spec=
lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ if [ -z "$lt_multi_os_dir" ];then
+ lt_multi_os_dir=../lib64
+ fi
for lt_sys_path in $lt_search_path_spec; do
if test -d "$lt_sys_path/$lt_multi_os_dir"; then
lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
@@ -14865,6 +14868,9 @@ libsuffix=
if test "$GXX" = yes; then
libsuffix=`$CXX -print-multi-os-directory`
fi
+if [ -z "$libsuffix" ];then
+ libsuffix=../lib64
+fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket libraries" >&5
diff --git a/libcc1/configure.ac b/libcc1/configure.ac
index 36f5a7e09..acd7c4c04 100644
--- a/libcc1/configure.ac
+++ b/libcc1/configure.ac
@@ -72,6 +72,9 @@ libsuffix=
if test "$GXX" = yes; then
libsuffix=`$CXX -print-multi-os-directory`
fi
+if [ -z "$libsuffix" ];then
+ libsuffix=../lib64
+fi
AC_SUBST(libsuffix)
dnl Test for -lsocket and -lnsl. Copied from libgo/configure.ac.
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 1b17c2e3a..2bfa00de5 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -385,7 +385,10 @@ install-strip: install
# multilib-specific flags, it's overridden by FLAGS_TO_PASS from the
# default multilib, so we have to take CFLAGS into account as well,
# since it will be passed the multilib flags.
-MULTIOSDIR = `$(CC) $(CFLAGS) -print-multi-os-directory`
+MULTIOSDIR = `$(CC) $(CFLAGS) -print-multi-os-directory 2>/dev/null`
+ifeq ($(MULTIOSDIR),)
+ MULTIOSDIR = ../lib64
+endif
install_to_libdir: all
if test -n "${target_header_dir}"; then \
${mkinstalldirs} $(DESTDIR)$(libdir)/$(MULTIOSDIR); \
diff --git a/libtool.m4 b/libtool.m4
index 17f8e5f30..86fc1e705 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -2059,6 +2059,9 @@ if test "$GCC" = yes; then
# and add multilib dir if necessary.
lt_tmp_lt_search_path_spec=
lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ if [ -z "$lt_multi_os_dir" ];then
+ lt_multi_os_dir=../lib64
+ fi
for lt_sys_path in $lt_search_path_spec; do
if test -d "$lt_sys_path/$lt_multi_os_dir"; then
lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
--
2.47.0

View File

@ -0,0 +1,108 @@
From 1624bdceb341e0034c22ce46bc2e422726f76cce Mon Sep 17 00:00:00 2001
From: YunQiang Su <yunqiang@isrc.iscas.ac.cn>
Date: Tue, 8 Oct 2024 17:59:56 +0800
Subject: [PATCH 2/2] Fix enum { INPUT, MIDDLE, FINAL } aes_stage
The FINAL is defined in ansidecl.h.
Let's rename the elements to
aesINPUT, aseMIDDLE, aseFINAL
to avoid conflits.
I find this problem when trying to build gcc with clang.
In fact FINAL is defined to empty for clang, and `final` for gcc.
So it coincidentally worked for gcc.
---
gcc/crypto-accel.cc | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/gcc/crypto-accel.cc b/gcc/crypto-accel.cc
index e7766a585..716c4a38b 100644
--- a/gcc/crypto-accel.cc
+++ b/gcc/crypto-accel.cc
@@ -1251,7 +1251,7 @@ public:
/* AES stage description. Required for some specializations
for curtain rounds. */
-typedef enum { INPUT, MIDDLE, FINAL } aes_stage;
+typedef enum { aesINPUT, aesMIDDLE, aesFINAL } aes_stage;
/* AES entity description. It can be both round or state inside round.
It provides interface for unified analysis between blocks of 4 parts:
@@ -1356,7 +1356,7 @@ struct state_input
/* Input round state uses special input. */
template<>
-struct state_input<INPUT>
+struct state_input<aesINPUT>
{
typedef std::pair<rtx, unsigned HOST_WIDE_INT> type;
@@ -1389,7 +1389,7 @@ struct state_output
/* Final round state generates special output. */
template<>
-struct state_output<FINAL>
+struct state_output<aesFINAL>
{
typedef std::pair<rtx, unsigned HOST_WIDE_INT> type;
@@ -1409,7 +1409,7 @@ struct round_input
/* Input round uses special input just as its state. */
template<>
-struct round_input<INPUT>
+struct round_input<aesINPUT>
{
typedef std::pair<rtx, unsigned HOST_WIDE_INT> type;
};
@@ -1437,7 +1437,7 @@ struct round_output
AES encryption. */
template<>
template<>
-void round_output<INPUT>::reorder<aes_decrypt_table> (type &out)
+void round_output<aesINPUT>::reorder<aes_decrypt_table> (type &out)
{
gcc_assert (out.size () == 4);
std::swap (out[1], out[3]);
@@ -1445,14 +1445,14 @@ void round_output<INPUT>::reorder<aes_decrypt_table> (type &out)
template<>
template<>
-void round_output<MIDDLE>::reorder<aes_decrypt_table> (type &out)
+void round_output<aesMIDDLE>::reorder<aes_decrypt_table> (type &out)
{
- round_output<INPUT>::reorder<aes_decrypt_table> (out);
+ round_output<aesINPUT>::reorder<aes_decrypt_table> (out);
}
/* Final round generates special output. */
template<>
-struct round_output<FINAL> : state_output<FINAL>
+struct round_output<aesFINAL> : state_output<aesFINAL>
{
template<typename T>
static void finalize (type &out, const T &v)
@@ -1644,14 +1644,14 @@ public:
typedef std::map<rtx_insn *, aes_table_ref<T> > table_ref_map;
/* AES states typedefs. */
- typedef aes_state<input_info, INPUT, T> aes_input_state;
- typedef aes_state<round_input_info<T>, MIDDLE, T> aes_body_state;
- typedef aes_state<round_input_info<T>, FINAL, T> aes_final_state;
+ typedef aes_state<input_info, aesINPUT, T> aes_input_state;
+ typedef aes_state<round_input_info<T>, aesMIDDLE, T> aes_body_state;
+ typedef aes_state<round_input_info<T>, aesFINAL, T> aes_final_state;
/* AES rounds typedefs. */
- typedef aes_round<input_info, INPUT, T> aes_input_round;
- typedef aes_round<round_input_info<T>, MIDDLE, T> aes_body_round;
- typedef aes_round<round_input_info<T>, FINAL, T> aes_final_round;
+ typedef aes_round<input_info, aesINPUT, T> aes_input_round;
+ typedef aes_round<round_input_info<T>, aesMIDDLE, T> aes_body_round;
+ typedef aes_round<round_input_info<T>, aesFINAL, T> aes_final_round;
bool run ();
--
2.47.0

1206
gcc.spec

File diff suppressed because it is too large Load Diff