build extract_interface using build compiler
authorSven Verdoolaege <sven.verdoolaege@gmail.com>
Thu, 21 May 2020 12:55:46 +0000 (21 14:55 +0200)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Sat, 13 Jun 2020 17:04:56 +0000 (13 19:04 +0200)
Since extract_interface is only used on the build system,
it should be built using the build compiler.
Inside the interface subdirectory, check for the build compiler and
use it throughout.  Do this instead of overriding the host system
to allow the caller of isl's configure to override
the host and build compilers separately.

The top level also needs to detect the build compiler
since EXEEXT may be different on the host and the build system.

It is not entirely clear if this is the right approach.
In particular, it is not clear how libtool is supposed
to be used in conjunction with a build compiler.
An alternative would be to have the top level
pass in the top level build compiler as
the (host) compiler for the interface subdirectory.
However, this needs special care to ensure that
the top level is not affected and would still affect
all subdir configures.  Even if there is currently only one,
this might cause problems in the future.

Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
Makefile.am
configure.ac
interface/configure.ac

index 445ef5a..22e3cb8 100644 (file)
@@ -2,8 +2,8 @@ if HAVE_CLANG
 if HAVE_CXX11
 MAYBE_INTERFACE = interface
 FORCE:
-interface/extract_interface$(EXEEXT): FORCE
-       $(MAKE) $(AM_MAKEFLAGS) -C interface extract_interface$(EXEEXT)
+interface/extract_interface$(BUILD_EXEEXT): FORCE
+       $(MAKE) $(AM_MAKEFLAGS) -C interface extract_interface$(BUILD_EXEEXT)
 endif
 endif
 SUBDIRS = . $(MAYBE_INTERFACE) doc
@@ -323,40 +323,41 @@ if HAVE_CLANG
 if HAVE_CXX11
 interface/isldlname.py: libisl.la
        $(AM_V_GEN) $(GREP) dlname $< | $(SED) -e 's/dlname/isl_dlname/' > $@
-interface/isl.py: interface/extract_interface$(EXEEXT) libdep.a \
+interface/isl.py: interface/extract_interface$(BUILD_EXEEXT) libdep.a \
                python/isl.py.top interface/isldlname.py
        (cat interface/isldlname.py $(srcdir)/python/isl.py.top && \
-               interface/extract_interface$(EXEEXT) --language=python \
+               interface/extract_interface$(BUILD_EXEEXT) --language=python \
                        $(includes) $(srcdir)/all.h) \
                        > $@ || (rm $@ && false)
 
-include/isl/cpp.h: interface/extract_interface$(EXEEXT) libdep.a \
+include/isl/cpp.h: interface/extract_interface$(BUILD_EXEEXT) libdep.a \
                cpp/cpp.h.top cpp/cpp.h.pre cpp/cpp.h.bot
        $(MKDIR_P) "include/isl/cpp" && \
        (cat $(srcdir)/cpp/cpp.h.top $(srcdir)/all.h \
            $(srcdir)/cpp/cpp.h.pre && \
-               interface/extract_interface$(EXEEXT) --language=cpp \
+               interface/extract_interface$(BUILD_EXEEXT) --language=cpp \
                        $(includes) $(srcdir)/all.h && \
                cat $(srcdir)/cpp/cpp.h.bot) \
                        > $@ || (rm $@ && false)
 
-include/isl/cpp-checked.h: interface/extract_interface$(EXEEXT) libdep.a \
+include/isl/cpp-checked.h: interface/extract_interface$(BUILD_EXEEXT) libdep.a \
                cpp/cpp-checked.h.top \
                cpp/cpp-checked.h.pre cpp/cpp-checked.h.bot
        (cat $(srcdir)/cpp/cpp-checked.h.top $(srcdir)/all.h \
            $(srcdir)/cpp/cpp-checked.h.pre && \
-               interface/extract_interface$(EXEEXT) \
+               interface/extract_interface$(BUILD_EXEEXT) \
                        --language=cpp-checked \
                        $(includes) $(srcdir)/all.h && \
                cat $(srcdir)/cpp/cpp-checked.h.bot) \
                        > $@ || (rm $@ && false)
 
-include/isl/cpp-checked-conversion.h: interface/extract_interface$(EXEEXT) \
+include/isl/cpp-checked-conversion.h: \
+               interface/extract_interface$(BUILD_EXEEXT) \
                libdep.a \
                cpp/cpp-checked-conversion.h.top \
                cpp/cpp-checked-conversion.h.bot
        (cat $(srcdir)/cpp/cpp-checked-conversion.h.top && \
-               interface/extract_interface$(EXEEXT) \
+               interface/extract_interface$(BUILD_EXEEXT) \
                        --language=cpp-checked-conversion \
                        $(includes) $(srcdir)/all.h && \
                cat $(srcdir)/cpp/cpp-checked-conversion.h.bot) \
index e153716..bd878e9 100644 (file)
@@ -20,6 +20,7 @@ fi
 
 AC_PROG_CC
 AC_PROG_CXX
+AX_PROG_CC_FOR_BUILD
 
 AX_CC_MAXOPT
 AX_GCC_WARN_UNUSED_RESULT
index 5aa99aa..9399b0a 100644 (file)
@@ -5,6 +5,17 @@ AM_INIT_AUTOMAKE([foreign])
 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 
 AC_PROG_CXX
+AX_PROG_CXX_FOR_BUILD
+
+# extract_interface needs to be run on the build system.
+# Since this is the only target that is being built,
+# simply use the build compiler throughout.
+# This ensures that the clang configure checks are
+# performed using the right compiler.
+CXX="$CXX_FOR_BUILD"
+CXXCPP="$CXXCPP_FOR_BUILD"
+EXEEXT="$BUILD_EXEEXT"
+OBJEXT="$BUILD_OBJEXT"
 
 AC_DISABLE_SHARED
 AC_PROG_LIBTOOL