Bug 35055 - missing path to finclude directory when compiling .F90 files
Summary: missing path to finclude directory when compiling .F90 files
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-02 10:23 UTC by Li-Juan.Hai
Modified: 2008-07-12 17:10 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Li-Juan.Hai 2008-02-02 10:23:03 UTC
testcase: (a.F90)
#include "omp_lib.h"

call omp_set_dynamic (.false.)
call omp_set_num_threads(4)

!$omp parallel
 print *, "t#:", omp_get_thread_num()
!$omp end parallel
end

#gfortran a.F90 -fopenmp
a.F90:1: error: omp_lib.h: No such file or directory

the file omp_lib.h is found in /import/dr3/s10/gcc-4.3/bin/../lib/gcc/sparc-sun-solaris2.10/4.3.0/finclude.

"cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN" is invoked to preprocess a.F90. the array cpp_include_defaults defined in cppdefault.c has to add in ***/finclude/ and its data structure has to be refined to mark the include is for fortran.
Comment 1 Daniel Franke 2008-04-05 23:50:48 UTC
> #include "omp_lib.h"

Question is, whether this should be supported or not.

OMP specs 2.5, section 3.1 "Runtime Library Definitions" state:
"Interface declarations for the OpenMP Fortran runtime library routines described in this chapter shall be provided in the form of a Fortran include file named omp_lib.h or a Fortran 90 module named omp_lib. It is implementation defined whether the include file or the module file (or both) is provided."

Example A.2.1f then shows:
  INCLUDE "omp_lib.h" ! or USE OMP_LIB

gfortran provides both versions. Further, it is possible to define additional include paths at the command-line via -I<path>, these are also passed to the preprocessor. 

IMO, either use the INCLUDE-statement, USE the module, or pass the path manually. If one insists on adding this path to the default search path, one could do it like this:

Index: gcc/fortran/lang-specs.h
===================================================================
--- gcc/fortran/lang-specs.h    (revision 133799)
+++ gcc/fortran/lang-specs.h    (working copy)
@@ -27,7 +27,7 @@
 {".FPP", "@f77-cpp-input", 0, 0, 0},
 {"@f77-cpp-input",
   "cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN %(cpp_options) \
-      %{E|M|MM:%(cpp_debug_options)}\
+      %{E|M|MM:%(cpp_debug_options)} -I finclude%s\
       %{!M:%{!MM:%{!E: -o %|.f |\n\
     f951 %|.f %{!ffree-form:-ffixed-form} %(cc1_options) %{J*} %{I*}\
       -fpreprocessed %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
@@ -37,7 +37,7 @@
 {".F08", "@f95-cpp-input", 0, 0, 0},
 {"@f95-cpp-input",
   "cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN %(cpp_options) \
-      %{E|M|MM:%(cpp_debug_options)}\
+      %{E|M|MM:%(cpp_debug_options)} -I finclude%s\
       %{!M:%{!MM:%{!E: -o %|.f95 |\n\
     f951 %|.f95 %{!ffixed-form:-ffree-form} %(cc1_options) %{J*} %{I*}\
       -fpreprocessed %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},


Take your pick :)
Comment 2 Tobias Burnus 2008-05-26 21:27:25 UTC
I think this works now (cf. PR18428).
Comment 3 Tom Tromey 2008-07-12 17:10:38 UTC
I tried this and it is fixed on trunk.
Closing.