public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Build+Fortran] PR54725 - correctly set TARGET_SYSTEM_ROOT for CPP
@ 2012-10-19  9:23 Tobias Burnus
  2012-10-21 11:04 ` Paul Richard Thomas
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2012-10-19  9:23 UTC (permalink / raw)
  To: gcc patches, gfortran

[-- Attachment #1: Type: text/plain, Size: 1075 bytes --]

gfortran was ignoring the TARGET_SYSTEM_ROOT and thus searched in 
/usr/include for files specified with "#include"/"include" files and for 
.mod files.

The solution is to do in gcc/fortran/cpp.c the same as it is done in 
gcc/c-family/c-opts.c.


However, the TARGET_SYSTEM_ROOT also has to be available. For C/C++ 
that's done via gcc/Makefile.in:
   CFLAGS-c-family/c-opts.o += @TARGET_SYSTEM_ROOT_DEFINE@

For Fortran, we have to to it likewise, but slightly different:

The gcc/Makefile.in gets updated by configure and written to 
$BUILD/gcc/Makefile. At that point the @TARGET...@ has been replaced by 
the actual value.

For Fortran, the gcc/fortran/Make-lang.in is included in 
$BUILD/gcc/Makefile:
   include $(LANG_MAKEFRAGS)

Thus, we cannot use @TARGET_...@ as it won't get replaced. Hence, I 
create a Makefile variable in gcc/Makefile.in and set it there, which 
then in turn gets used in gcc/fortran/Make-lang.in.

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias

PS: I haven't yet cross compiled and thus checked whether it indeed works.

[-- Attachment #2: target_root.diff --]
[-- Type: text/x-patch, Size: 2140 bytes --]

gcc/
2012-10-19  Tobias Burnus  <burnus@net-b.de>

	PR fortran/54725
	* Makefile.in (TARGET_SYSTEM_ROOT_DEFINE): New.

gcc/fortran
2012-10-19  Tobias Burnus  <burnus@net-b.de>

	PR fortran/54725
	* Make-lang.in (CFLAGS-cpp.o): Use TARGET_SYSTEM_ROOT_DEFINE.
	* cpp.o (gfc_cpp_init_options): Use it for
	setting gfc_cpp_option.sysroot.

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 7ae3bb9..e18dc8f 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -468,6 +468,7 @@ LIMITS_H_TEST = [ -f $(SYSTEM_HEADER_DIR)/limits.h ]
 # Directory for prefix to system directories, for
 # each of $(system_prefix)/usr/include, $(system_prefix)/usr/lib, etc.
 TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
+TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
 
 xmake_file=@xmake_file@
 tmake_file=@tmake_file@
diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in
index a74eb7f..4041d2d 100644
--- a/gcc/fortran/Make-lang.in
+++ b/gcc/fortran/Make-lang.in
@@ -341,6 +341,7 @@ GFORTRAN_TRANS_DEPS = fortran/gfortran.h fortran/libgfortran.h \
     $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TM_H) coretypes.h $(GGC_H) \
     fortran/iso-c-binding.def fortran/iso-fortran-env.def
 
+CFLAGS-cpp.o += $(TARGET_SYSTEM_ROOT_DEFINE)
 fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
   gt-fortran-f95-lang.h gtype-fortran.h $(CGRAPH_H) $(TARGET_H) fortran/cpp.h \
   $(BUILTINS_DEF) fortran/types.def \
diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c
index c45af39..f54ba96 100644
--- a/gcc/fortran/cpp.c
+++ b/gcc/fortran/cpp.c
@@ -38,6 +38,10 @@ along with GCC; see the file COPYING3.  If not see
 #include "cppbuiltin.h"
 #include "mkdeps.h"
 
+#ifndef TARGET_SYSTEM_ROOT
+# define TARGET_SYSTEM_ROOT NULL
+#endif
+
 #ifndef TARGET_CPU_CPP_BUILTINS
 # define TARGET_CPU_CPP_BUILTINS()
 #endif
@@ -267,7 +271,7 @@ gfc_cpp_init_options (unsigned int decoded_options_count,
 
   gfc_cpp_option.multilib = NULL;
   gfc_cpp_option.prefix = NULL;
-  gfc_cpp_option.sysroot = NULL;
+  gfc_cpp_option.sysroot = TARGET_SYSTEM_ROOT;
 
   gfc_cpp_option.deferred_opt = XNEWVEC (gfc_cpp_deferred_opt_t,
 					 decoded_options_count);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, Build+Fortran] PR54725 - correctly set TARGET_SYSTEM_ROOT for CPP
  2012-10-19  9:23 [Patch, Build+Fortran] PR54725 - correctly set TARGET_SYSTEM_ROOT for CPP Tobias Burnus
@ 2012-10-21 11:04 ` Paul Richard Thomas
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Richard Thomas @ 2012-10-21 11:04 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

Dear Tobias,

I had already reviewed this patch in its previous accidental manifestation :-)

OK for trunk

Thanks for the patch

Paul

On 19 October 2012 10:22, Tobias Burnus <burnus@net-b.de> wrote:
> gfortran was ignoring the TARGET_SYSTEM_ROOT and thus searched in
> /usr/include for files specified with "#include"/"include" files and for
> .mod files.
>
> The solution is to do in gcc/fortran/cpp.c the same as it is done in
> gcc/c-family/c-opts.c.
>
>
> However, the TARGET_SYSTEM_ROOT also has to be available. For C/C++ that's
> done via gcc/Makefile.in:
>   CFLAGS-c-family/c-opts.o += @TARGET_SYSTEM_ROOT_DEFINE@
>
> For Fortran, we have to to it likewise, but slightly different:
>
> The gcc/Makefile.in gets updated by configure and written to
> $BUILD/gcc/Makefile. At that point the @TARGET...@ has been replaced by the
> actual value.
>
> For Fortran, the gcc/fortran/Make-lang.in is included in
> $BUILD/gcc/Makefile:
>   include $(LANG_MAKEFRAGS)
>
> Thus, we cannot use @TARGET_...@ as it won't get replaced. Hence, I create a
> Makefile variable in gcc/Makefile.in and set it there, which then in turn
> gets used in gcc/fortran/Make-lang.in.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias
>
> PS: I haven't yet cross compiled and thus checked whether it indeed works.



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-21  9:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-19  9:23 [Patch, Build+Fortran] PR54725 - correctly set TARGET_SYSTEM_ROOT for CPP Tobias Burnus
2012-10-21 11:04 ` Paul Richard Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).