Hi!

It seems building of the host compiler requires the offloading compiler
to be installed directly in the prefix, which is something really
undesirable e.g. for distro builds where things are installed with
non-empty $(DESTDIR).
Right now it seems that for building all that is needed is
main_target_image.h.

Either we can do something like the following patch, i.e. look
at -I$(DESTDIR)/$(target_dir)/include first and fall back to
-I$(target_dir)/include, which fixed the build for me, but unfortunately
it violates GNU conventions:
https://www.gnu.org/prep/standards/html_node/DESTDIR.html
"DESTDIR should be supported only in the install* and uninstall* targets, as
those are the only targets where it is useful."
while this patch uses it during build.

Another option would be to have two different modes of building
--enable-offload-targets= compilers, one where you really have
all the offloading target compilers installed (with empty DESTDIR, or
initially with non-empty DESTDIR, then somehow (package manager, etc.)
copied to the right prefix), and another one where for each offloading
target you'd additionally specify the build directory containing
non-installed tree (dunno, could be e.g.
--enable-offload-targets=x86_64-intelmic-linux-gnu=/some/path,ptx-none=/some/other/path
format?) and let the host compiler's build look into the other build trees
for what it needs during building and/or testing (for building 
main_target_image.h should be supposedly all that is needed, for testing
perhaps more).

Thoughts on this?

2014-09-17  Jakub Jelinek  <ja...@redhat.com>

        * plugin/Makefile.am (libgomp_plugin_mic_la_CPPFLAGS): Use
        $(DESTDIR)$(target_dir)/include path before
        trying $(target_dir)/include.
        * plugin/Makefile.in: Regenerated.

--- liboffloadmic/plugin/Makefile.am    2014-09-16 18:16:17.961415565 +0200
+++ liboffloadmic/plugin/Makefile.am    2014-09-17 14:40:26.990566860 +0200
@@ -47,7 +47,7 @@ target_dir = $(libdir)/gcc/$(accel_targe
 if PLUGIN_HOST
   toolexeclib_LTLIBRARIES = libgomp-plugin-mic.la
   libgomp_plugin_mic_la_SOURCES = libgomp-plugin-mic.cpp
-  libgomp_plugin_mic_la_CPPFLAGS = $(CPPFLAGS) -DLINUX -DCOI_LIBRARY_VERSION=2 
-DMYO_SUPPORT -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT -DTIMING_SUPPORT -DHOST_LIBRARY=1 
-DMIC_LIB_PATH=\"$(target_dir)\" -I$(coi_inc_dir) -I$(myo_inc_dir) 
-I$(liboffload_src_dir) -I$(libgomp_dir) -I$(target_dir)/include
+  libgomp_plugin_mic_la_CPPFLAGS = $(CPPFLAGS) -DLINUX -DCOI_LIBRARY_VERSION=2 
-DMYO_SUPPORT -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT -DTIMING_SUPPORT -DHOST_LIBRARY=1 
-DMIC_LIB_PATH=\"$(target_dir)\" -I$(coi_inc_dir) -I$(myo_inc_dir) 
-I$(liboffload_src_dir) -I$(libgomp_dir) -I$(DESTDIR)$(target_dir)/include 
-I$(target_dir)/include
   libgomp_plugin_mic_la_LDFLAGS = -L$(liboffload_dir)/.libs -loffloadmic 
-version-info 1:0:0
 else # PLUGIN_TARGET
   plugin_includedir = $(libsubincludedir)
--- liboffloadmic/plugin/Makefile.in    2014-09-16 18:16:17.961415565 +0200
+++ liboffloadmic/plugin/Makefile.in    2014-09-17 14:54:50.555096069 +0200
@@ -277,7 +277,7 @@ libsubincludedir = $(libdir)/gcc/$(targe
 target_dir = $(libdir)/gcc/$(accel_target)/$(gcc_version)
 @PLUGIN_HOST_TRUE@toolexeclib_LTLIBRARIES = libgomp-plugin-mic.la
 @PLUGIN_HOST_TRUE@libgomp_plugin_mic_la_SOURCES = libgomp-plugin-mic.cpp
-@PLUGIN_HOST_TRUE@libgomp_plugin_mic_la_CPPFLAGS = $(CPPFLAGS) -DLINUX 
-DCOI_LIBRARY_VERSION=2 -DMYO_SUPPORT -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT 
-DTIMING_SUPPORT -DHOST_LIBRARY=1 -DMIC_LIB_PATH=\"$(target_dir)\" 
-I$(coi_inc_dir) -I$(myo_inc_dir) -I$(liboffload_src_dir) -I$(libgomp_dir) 
-I$(target_dir)/include
+@PLUGIN_HOST_TRUE@libgomp_plugin_mic_la_CPPFLAGS = $(CPPFLAGS) -DLINUX 
-DCOI_LIBRARY_VERSION=2 -DMYO_SUPPORT -DOFFLOAD_DEBUG=1 -DSEP_SUPPORT 
-DTIMING_SUPPORT -DHOST_LIBRARY=1 -DMIC_LIB_PATH=\"$(target_dir)\" 
-I$(coi_inc_dir) -I$(myo_inc_dir) -I$(liboffload_src_dir) -I$(libgomp_dir) 
-I$(DESTDIR)$(target_dir)/include -I$(target_dir)/include
 @PLUGIN_HOST_TRUE@libgomp_plugin_mic_la_LDFLAGS = -L$(liboffload_dir)/.libs 
-loffloadmic -version-info 1:0:0
 @PLUGIN_HOST_FALSE@plugin_includedir = $(libsubincludedir)
 @PLUGIN_HOST_FALSE@plugin_include_HEADERS = main_target_image.h

        Jakub

Reply via email to