From: "Martin Liška" <mliska@suse.cz>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Jakub Jelinek <jakub@redhat.com>,
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>,
Richard Biener <richard.guenther@gmail.com>,
"fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
Thomas Koenig <tkoenig@netcologne.de>,
Toon Moene <toon@moene.org>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH][RFC] Extend locations where to seach for Fortran pre-include.
Date: Mon, 14 Jan 2019 14:09:00 -0000 [thread overview]
Message-ID: <7f25a578-6ca5-276d-d2a1-566a9cbc5dce@suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.21.1901111804191.25471@digraph.polyomino.org.uk>
[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]
On 1/11/19 7:06 PM, Joseph Myers wrote:
> On Fri, 11 Jan 2019, Martin Liška wrote:
>
>> +/* Same as add_prefix, but prepending target_sysroot_hdrs_suffix to prefix. */
>
> Actually, it should be prepending target_system_root, but followed by
> target_sysroot_hdrs_suffix rather than target_sysroot_suffix. That is,
> this function should be following add_sysrooted_prefix more closely.
>
>> + if (target_sysroot_hdrs_suffix)
>
> So this should be "if (target_system_root)" - it needs to be sysrooted
> even if there is no sysroot headers suffix.
>
>> + {
>> + char *sysroot_no_trailing_dir_separator
>> + = xstrdup (target_sysroot_hdrs_suffix);
>> + size_t sysroot_len = strlen (target_sysroot_hdrs_suffix);
>
> And again this would use target_system_root.
>
>> + if (sysroot_len > 0
>> + && target_sysroot_hdrs_suffix[sysroot_len - 1] == DIR_SEPARATOR)
>> + sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0';
>
> Likewise.
>
>> + if (target_sysroot_suffix)
>> + prefix = concat (sysroot_no_trailing_dir_separator,
>> + target_sysroot_suffix, prefix, NULL);
>
> While this would use target_sysroot_hdrs_suffix.
>
Thanks for review, fixed that in updated version of the patch.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
[-- Attachment #2: 0001-Extend-locations-where-to-seach-for-Fortran-pre-incl.patch --]
[-- Type: text/x-patch, Size: 6007 bytes --]
From 8f60e280c40d60b1590d0eb41ce130582c7733a9 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 20 Nov 2018 15:09:16 +0100
Subject: [PATCH] Extend locations where to seach for Fortran pre-include.
gcc/ChangeLog:
2019-01-14 Martin Liska <mliska@suse.cz>
* Makefile.in: Set TOOL_INCLUDE_DIR and NATIVE_SYSTEM_HEADER_DIR
for GCC driver.
* config/gnu-user.h (TARGET_F951_OPTIONS): Add 'finclude%s/' as
a new argument.
* gcc.c (add_sysrooted_hdrs_prefix): New function.
(path_prefix_reset): Move up in the source file.
(find_fortran_preinclude_file): Make complex search for the
fortran header files.
---
gcc/Makefile.in | 4 +-
gcc/config/gnu-user.h | 2 +-
gcc/gcc.c | 103 ++++++++++++++++++++++++++++++++++--------
3 files changed, 87 insertions(+), 22 deletions(-)
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 2fa9083d1b3..095156bd537 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2172,7 +2172,9 @@ DRIVER_DEFINES = \
@TARGET_SYSTEM_ROOT_DEFINE@ \
$(VALGRIND_DRIVER_DEFINES) \
$(if $(SHLIB),$(if $(filter yes,@enable_shared@),-DENABLE_SHARED_LIBGCC)) \
- -DCONFIGURE_SPECS="\"@CONFIGURE_SPECS@\""
+ -DCONFIGURE_SPECS="\"@CONFIGURE_SPECS@\"" \
+ -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+ -DNATIVE_SYSTEM_HEADER_DIR=\"$(NATIVE_SYSTEM_HEADER_DIR)\"
CFLAGS-gcc.o += $(DRIVER_DEFINES) -DBASEVER=$(BASEVER_s)
gcc.o: $(BASEVER)
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index ba146921655..055a4f0afec 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -151,4 +151,4 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#undef TARGET_F951_OPTIONS
#define TARGET_F951_OPTIONS "%{!nostdinc:\
- %:fortran-preinclude-file(-fpre-include= math-vector-fortran.h)}"
+ %:fortran-preinclude-file(-fpre-include= math-vector-fortran.h finclude%s/)}"
diff --git a/gcc/gcc.c b/gcc/gcc.c
index bcd04df1691..797ed36616f 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -2976,6 +2976,44 @@ add_sysrooted_prefix (struct path_prefix *pprefix, const char *prefix,
add_prefix (pprefix, prefix, component, priority,
require_machine_suffix, os_multilib);
}
+
+/* Same as add_prefix, but prepending target_sysroot_hdrs_suffix to prefix. */
+
+static void
+add_sysrooted_hdrs_prefix (struct path_prefix *pprefix, const char *prefix,
+ const char *component,
+ /* enum prefix_priority */ int priority,
+ int require_machine_suffix, int os_multilib)
+{
+ if (!IS_ABSOLUTE_PATH (prefix))
+ fatal_error (input_location, "system path %qs is not absolute", prefix);
+
+ if (target_system_root)
+ {
+ char *sysroot_no_trailing_dir_separator = xstrdup (target_system_root);
+ size_t sysroot_len = strlen (target_system_root);
+
+ if (sysroot_len > 0
+ && target_system_root[sysroot_len - 1] == DIR_SEPARATOR)
+ sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0';
+
+ if (target_sysroot_hdrs_suffix)
+ prefix = concat (sysroot_no_trailing_dir_separator,
+ target_sysroot_hdrs_suffix, prefix, NULL);
+ else
+ prefix = concat (sysroot_no_trailing_dir_separator, prefix, NULL);
+
+ free (sysroot_no_trailing_dir_separator);
+
+ /* We have to override this because GCC's notion of sysroot
+ moves along with GCC. */
+ component = "GCC";
+ }
+
+ add_prefix (pprefix, prefix, component, priority,
+ require_machine_suffix, os_multilib);
+}
+
\f
/* Execute the command specified by the arguments on the current line of spec.
When using pipes, this includes several piped-together commands
@@ -9896,20 +9934,61 @@ debug_level_greater_than_spec_func (int argc, const char **argv)
return NULL;
}
-/* The function takes 2 arguments: OPTION name and file name.
+static void
+path_prefix_reset (path_prefix *prefix)
+{
+ struct prefix_list *iter, *next;
+ iter = prefix->plist;
+ while (iter)
+ {
+ next = iter->next;
+ free (const_cast <char *> (iter->prefix));
+ XDELETE (iter);
+ iter = next;
+ }
+ prefix->plist = 0;
+ prefix->max_len = 0;
+}
+
+/* The function takes 3 arguments: OPTION name, file name and location
+ where we search for Fortran modules.
When the FILE is found by find_file, return OPTION=path_to_file. */
static const char *
find_fortran_preinclude_file (int argc, const char **argv)
{
- if (argc != 2)
+ char *result = NULL;
+ if (argc != 3)
return NULL;
+ struct path_prefix prefixes = { 0, 0, "preinclude" };
+
+ /* Search first for 'finclude' folder location for a header file
+ installed by the compiler (similar to omp_lib.h). */
+ add_prefix (&prefixes, argv[2], NULL, 0, 0, false);
+#ifdef TOOL_INCLUDE_DIR
+ /* Then search: <prefix>/<target>/<include>/finclude */
+ add_prefix (&prefixes, TOOL_INCLUDE_DIR "/finclude/",
+ NULL, 0, 0, false);
+#endif
+#ifdef NATIVE_SYSTEM_HEADER_DIR
+ /* Then search: <sysroot>/usr/include/finclude/<multilib> */
+ add_sysrooted_hdrs_prefix (&prefixes, NATIVE_SYSTEM_HEADER_DIR "/finclude/",
+ NULL, 0, 0, false);
+#endif
+
const char *path = find_a_file (&include_prefixes, argv[1], R_OK, true);
if (path != NULL)
- return concat (argv[0], path, NULL);
+ result = concat (argv[0], path, NULL);
+ else
+ {
+ path = find_a_file (&prefixes, argv[1], R_OK, true);
+ if (path != NULL)
+ result = concat (argv[0], path, NULL);
+ }
- return NULL;
+ path_prefix_reset (&prefixes);
+ return result;
}
@@ -9961,22 +10040,6 @@ convert_white_space (char *orig)
return orig;
}
-static void
-path_prefix_reset (path_prefix *prefix)
-{
- struct prefix_list *iter, *next;
- iter = prefix->plist;
- while (iter)
- {
- next = iter->next;
- free (const_cast <char *> (iter->prefix));
- XDELETE (iter);
- iter = next;
- }
- prefix->plist = 0;
- prefix->max_len = 0;
-}
-
/* Restore all state within gcc.c to the initial state, so that the driver
code can be safely re-run in-process.
--
2.20.1
next prev parent reply other threads:[~2019-01-14 14:09 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <d749cd46-e231-1405-5713-ae7d966ff8c1@suse.cz>
[not found] ` <CAFiYyc0QyhpvQxam9E3BHn2hPkr1izQM13oo+_QvkhQvwroJqw@mail.gmail.com>
[not found] ` <ee42ab7d-12b8-d7d2-1769-1c96252bbd7b@netcologne.de>
[not found] ` <CAFiYyc1cHpw-7CEE8-1ipqHKCqpL+sX6dWOCK88iVk0cn2Mm8A@mail.gmail.com>
[not found] ` <48dcb864-bad1-5e09-d209-def296ed1cd3@suse.cz>
[not found] ` <676acdda-1253-b3bd-4e03-60298c4c995c@netcologne.de>
[not found] ` <4f37f79f-647a-4851-2ff2-e0e5592b3e7f@suse.cz>
[not found] ` <2082f59c-7c61-6b81-79f7-addf70da39fa@netcologne.de>
[not found] ` <CAFiYyc2AFExBnak5YX8-L_STQYxORuwWHnD9ETRMWN3u0gB1gg@mail.gmail.com>
[not found] ` <6b852ddd-001c-40d6-383b-0b36f3d13ee7@suse.cz>
[not found] ` <CAFiYyc2Q4eXBXBSisaWDE2JH_tS82AnZBPJv1D9fkZnAQpz0CA@mail.gmail.com>
[not found] ` <60df9de6-9607-c88a-de0d-1f2c83bf3970@suse.cz>
[not found] ` <D6325C52-AE0D-49DB-86A2-F5CBDE6BAC0B@gmail.com>
[not found] ` <916e3e10-e020-f4f3-6f8e-c57909c81d55@suse.cz>
[not found] ` <CAFiYyc14yjzAojw0o+mJoLvBwobLGhN1ppLKHOt56wan_-ApZw@mail.gmail.com>
[not found] ` <20181112163347.4cc3537e@nbbrfq.loc>
[not found] ` <CAFiYyc1cczXvCf1v4PPhHVmuvT_W8RuU+8R05vjuJ=_c_nP-6w@mail.gmail.com>
2018-11-14 10:06 ` [PATCH] Support simd function declarations via a pre-include. (was: [PATCH][RFC]Overloading intrinsics) Martin Liška
2018-11-14 11:35 ` Jakub Jelinek
2018-11-14 11:56 ` Jakub Jelinek
2018-11-14 11:57 ` Jakub Jelinek
2018-11-14 14:09 ` [PATCH] Support simd function declarations via a pre-include Martin Liška
2018-11-14 14:14 ` Jakub Jelinek
2018-11-15 19:40 ` [PATCH] Support simd function declarations via a pre-include. (was: [PATCH][RFC]Overloading intrinsics) Bernhard Reutner-Fischer
2018-11-15 20:54 ` Jakub Jelinek
2018-11-16 13:25 ` [PATCH] Support simd function declarations via a pre-include Martin Liška
2018-11-16 13:50 ` Jakub Jelinek
2018-11-16 15:12 ` Martin Liška
2018-11-17 13:30 ` Paul Richard Thomas
2018-11-17 17:57 ` Paul Richard Thomas
2018-11-17 18:16 ` Bernhard Reutner-Fischer
2018-11-19 12:14 ` Martin Liška
2018-11-19 12:16 ` Martin Liška
2018-11-19 12:33 ` Jakub Jelinek
2018-11-20 14:14 ` [PATCH][RFC] Extend locations where to seach for Fortran pre-include Martin Liška
2018-11-20 14:27 ` Jakub Jelinek
2018-11-20 18:11 ` Joseph Myers
2018-11-22 8:58 ` Martin Liška
2018-11-22 14:35 ` Joseph Myers
2018-11-23 13:59 ` Martin Liška
2018-11-23 18:08 ` Joseph Myers
2018-11-26 12:20 ` Martin Liška
2018-11-26 16:19 ` Matthias Klose
2018-11-26 16:35 ` Martin Liška
2018-11-26 18:33 ` Joseph Myers
2018-11-27 13:34 ` Martin Liška
2018-11-27 7:57 ` Thomas Koenig
2018-11-27 13:32 ` Martin Liška
2018-11-27 16:22 ` Steve Ellcey
2018-11-27 21:12 ` Thomas Koenig
2019-02-18 13:23 ` Martin Liška
2019-02-19 18:18 ` Steve Kargl
2019-02-20 7:09 ` Bernhard Reutner-Fischer
2019-02-20 9:23 ` Martin Liška
2019-02-20 9:37 ` Thomas König
2019-02-20 14:17 ` Martin Liška
2019-02-20 20:11 ` Thomas König
2019-02-20 9:52 ` Bernhard Reutner-Fischer
2019-02-20 9:57 ` Martin Liška
2019-02-20 10:46 ` Bernhard Reutner-Fischer
2019-02-20 11:12 ` Martin Liška
2018-11-26 16:54 ` Martin Liška
2018-11-26 18:45 ` Joseph Myers
2018-11-27 13:40 ` Martin Liška
2018-11-30 13:51 ` Martin Liška
2019-01-09 16:01 ` Martin Liška
2019-01-09 17:16 ` Joseph Myers
2019-01-09 17:21 ` Joseph Myers
2019-01-11 15:17 ` Martin Liška
2019-01-11 18:06 ` Joseph Myers
2019-01-14 14:09 ` Martin Liška [this message]
2019-01-15 17:45 ` Joseph Myers
2019-01-16 9:42 ` Fortran vector math header Martin Liška
2019-01-16 12:39 ` Jakub Jelinek
2019-01-16 14:05 ` Joseph Myers
2019-01-16 17:42 ` Joseph Myers
2019-01-16 18:04 ` Jakub Jelinek
2019-01-16 20:35 ` Joseph Myers
2019-01-18 8:18 ` Martin Liška
2019-01-18 8:40 ` Jakub Jelinek
2019-01-21 7:47 ` Martin Liška
2019-01-21 7:58 ` Jakub Jelinek
2019-01-21 9:09 ` Martin Liška
2019-01-21 9:19 ` Jakub Jelinek
2019-01-21 9:36 ` Martin Liška
2019-01-21 9:40 ` Jakub Jelinek
2019-01-21 14:25 ` Joseph Myers
2019-01-22 11:01 ` Martin Liška
2019-01-22 11:15 ` Jakub Jelinek
2019-01-22 12:18 ` Richard Biener
2019-01-23 1:18 ` Joseph Myers
2019-01-24 14:59 ` Martin Liška
2019-01-24 15:11 ` Jakub Jelinek
2019-01-24 15:36 ` Martin Liška
2019-01-24 22:10 ` Steve Ellcey
2019-01-25 13:17 ` Martin Liška
2019-02-04 9:59 ` Martin Liška
2019-02-04 10:10 ` Jakub Jelinek
2019-02-05 1:31 ` Joseph Myers
2019-02-05 12:48 ` Martin Liška
2019-02-13 11:34 ` Martin Liška
2019-02-14 21:14 ` Steve Ellcey
2019-02-15 11:16 ` Martin Liška
2019-02-05 12:48 ` Martin Liška
2019-02-14 18:27 ` Joseph Myers
2019-02-16 0:05 ` Steve Kargl
2019-01-23 22:53 ` Steve Ellcey
2019-01-23 22:57 ` Jakub Jelinek
2019-01-23 23:14 ` [EXT] " Steve Ellcey
2019-01-16 13:59 ` Joseph Myers
2018-11-17 21:13 ` [PATCH] Support simd function declarations via a pre-include. (was: [PATCH][RFC]Overloading intrinsics) Bernhard Reutner-Fischer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7f25a578-6ca5-276d-d2a1-566a9cbc5dce@suse.cz \
--to=mliska@suse.cz \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=joseph@codesourcery.com \
--cc=rep.dot.nop@gmail.com \
--cc=richard.guenther@gmail.com \
--cc=tkoenig@netcologne.de \
--cc=toon@moene.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).