This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Build+Fortran] PR54725 - correctly set TARGET_SYSTEM_ROOT for CPP


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.
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);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]