When the host compiler is not GCC (GCC_VERSION < 3004), hwint.h declares
floor_log2, exact_log2 and related functions out of line instead of
defining them inline.  Generators that use vec.o and objects in
libcommon then fail to link because hwint.o is only part of OBJS.

gcc/ChangeLog:

        * hwint.cc: Include bconfig.h for generator files.
        * Makefile.in (BUILD_RTL): Add build/hwint.o.
        (OBJS): Move hwint.o from here...
        (OBJS-libcommon): ...to here.
        (build/hwint.o): New rule.
        (build/gencfn-macros, build/genmatch): Depend on build/hwint.o.

Signed-off-by: Shiva <[email protected]>
---

Bootstrapped and regression-tested on x86_64-pc-linux-gnu and
aarch64-unknown-linux-gnu.  I do not have write access; please commit
if approved.

 gcc/Makefile.in | 10 +++++-----
 gcc/hwint.cc    |  7 +++++++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 19e35f6149b..5b1ef7aceec 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1194,7 +1194,7 @@ BUILD_LIBS = $(BUILD_LIBIBERTY)
 
 BUILD_RTL = build/rtl.o build/read-rtl.o build/ggc-none.o \
            build/vec.o build/min-insn-modes.o build/gensupport.o \
-           build/print-rtl.o build/hash-table.o build/sort.o
+           build/print-rtl.o build/hash-table.o build/sort.o build/hwint.o
 BUILD_MD = build/read-md.o
 BUILD_ERRORS = build/errors.o
 
@@ -1582,7 +1582,6 @@ OBJS = \
        hash-map-tests.o \
        hash-set-tests.o \
        hw-doloop.o \
-       hwint.o \
        ifcvt.o \
        ree.o \
        inchash.o \
@@ -1925,7 +1924,7 @@ OBJS-libcommon = \
        pub-sub.o \
        xml.o \
        sbitmap.o \
-       vec.o input.o hash-table.o ggc-none.o memory-block.o \
+       vec.o input.o hash-table.o ggc-none.o memory-block.o hwint.o \
        selftest.o sort.o \
        selftest-json.o \
        text-art/box-drawing.o \
@@ -3281,6 +3280,7 @@ build/vec.o : vec.cc $(BCONFIG_H) $(SYSTEM_H) 
$(CORETYPES_H) $(VEC_H)     \
 build/hash-table.o : hash-table.cc $(BCONFIG_H) $(SYSTEM_H)            \
   $(CORETYPES_H) $(HASH_TABLE_H) $(GGC_H) toplev.h $(DIAGNOSTIC_CORE_H)
 build/sort.o : sort.cc $(BCONFIG_H) $(SYSTEM_H)
+build/hwint.o : hwint.cc $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H)
 build/inchash.o : inchash.cc $(BCONFIG_H) $(SYSTEM_H) $(CORETYPES_H)   \
   $(HASHTAB_H) inchash.h
 build/gencondmd.o : build/gencondmd.cc $(BCONFIG_H) $(SYSTEM_H)                
\
@@ -3422,7 +3422,7 @@ build/genautomata$(build_exeext) : BUILD_LIBS += -lm
 
 build/genrecog$(build_exeext) : build/hash-table.o build/inchash.o
 build/gencfn-macros$(build_exeext) : build/hash-table.o build/vec.o \
-  build/ggc-none.o build/sort.o
+  build/ggc-none.o build/sort.o build/hwint.o
 
 # For stage1 and when cross-compiling use the build libcpp which is
 # built with NLS disabled.  For stage2+ use the host library and
@@ -3437,7 +3437,7 @@ build/genmatch.o: BUILD_CPPFLAGS += -DGENMATCH_SELFTESTS
 endif
 
 build/genmatch$(build_exeext) : $(BUILD_CPPLIB) \
-  $(BUILD_ERRORS) build/vec.o build/hash-table.o build/sort.o
+  $(BUILD_ERRORS) build/vec.o build/hash-table.o build/sort.o build/hwint.o
 
 # These programs are not linked with the MD reader.
 build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o \
diff --git a/gcc/hwint.cc b/gcc/hwint.cc
index d89be33f636..0222b4139f7 100644
--- a/gcc/hwint.cc
+++ b/gcc/hwint.cc
@@ -17,7 +17,14 @@ You should have received a copy of the GNU General Public 
License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+/* This file is compiled twice: once for the generator programs
+   once for the compiler.  */
+#ifdef GENERATOR_FILE
+#include "bconfig.h"
+#else
 #include "config.h"
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 

Reply via email to