Hi.
Following patch is a follow up of the discussion we had on IRC about
locations where a Fortran pre-include should be searched.
With the patch applied I see now:
$ strace -f -s512 ./xgcc -B. ~/Programming/testcases/usage.F90 -c 2>&1 | grep
math-vector
access("./x86_64-pc-linux-gnu/9.0.0/math-vector-fortran.h", R_OK) = -1 ENOENT
(No such file or directory)
access("./math-vector-fortran.h", R_OK) = -1 ENOENT (No such file or directory)
access("/home/marxin/bin/gcc2/bin/../include/finclude/x86_64-pc-linux-gnu/9.0.0/math-vector-fortran.h",
R_OK) = -1 ENOENT (No such file or directory)
access("/home/marxin/bin/gcc2/bin/../include/finclude/math-vector-fortran.h",
R_OK) = -1 ENOENT (No such file or directory)
access("/usr/include/finclude/x86_64-pc-linux-gnu/9.0.0/math-vector-fortran.h",
R_OK) = -1 ENOENT (No such file or directory)
access("/usr/include/finclude/math-vector-fortran.h", R_OK) = -1 ENOENT (No
such file or directory)
Martin
>From c89d25005ae649d652d316cefe2aab8c676cd6ca Mon Sep 17 00:00:00 2001
From: marxin <[email protected]>
Date: Tue, 20 Nov 2018 15:09:16 +0100
Subject: [PATCH] Extend locations where to seach for Fortran pre-include.
---
gcc/gcc.c | 49 +++++++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 4d01e1e2f3b..bd6b83a3e6d 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -9891,20 +9891,49 @@ debug_level_greater_than_spec_func (int argc, const char **argv)
return NULL;
}
+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 2 arguments: OPTION name and file name.
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)
{
+ char *result = NULL;
if (argc != 2)
return NULL;
+ struct path_prefix prefixes = { 0, 0, "preinclude" };
+ add_prefix (&prefixes, STANDARD_BINDIR_PREFIX "../include/finclude/", NULL,
+ 0, 0, 0);
+ add_prefix (&prefixes, "/usr/include/finclude/", NULL, 0, 0, 0);
+
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;
}
@@ -9956,22 +9985,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.19.1