From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7694 invoked by alias); 19 Oct 2012 08:22:44 -0000 Received: (qmail 7674 invoked by uid 22791); 19 Oct 2012 08:22:41 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Oct 2012 08:22:35 +0000 Received: from [192.168.178.22] (port-92-195-26-156.dynamic.qsc.de [92.195.26.156]) by mx01.qsc.de (Postfix) with ESMTP id C03AE3CD75; Fri, 19 Oct 2012 10:22:33 +0200 (CEST) Message-ID: <50810DC8.7010905@net-b.de> Date: Fri, 19 Oct 2012 09:23:00 -0000 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Build+Fortran] PR54725 - correctly set TARGET_SYSTEM_ROOT for CPP Content-Type: multipart/mixed; boundary="------------040906020706040706070904" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-10/txt/msg01782.txt.bz2 This is a multi-part message in MIME format. --------------040906020706040706070904 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1075 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. --------------040906020706040706070904 Content-Type: text/x-patch; name="target_root.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="target_root.diff" Content-length: 2140 gcc/ 2012-10-19 Tobias Burnus PR fortran/54725 * Makefile.in (TARGET_SYSTEM_ROOT_DEFINE): New. gcc/fortran 2012-10-19 Tobias Burnus 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); --------------040906020706040706070904--