Dear all,
I have a question to the GCC build-system experts to make
TARGET_SYSTEM_ROOT available to gfortran (see PR54725); it's required to
have the proper "<system_root>/usr/include" directory when using CPP.
That's partially cured by the patch below, however, it is not sufficient
as "TARGET_SYSTEM_ROOT" is not available. The bug reporter suggests the
following (see PR). What's the recommend GCC way?
(The first option, seems to be the cleanest, but it adds gcc/fortran
dependency to gcc/Makefile.in; I have the feeling that the second option
is wrong and that the last one won't work as it mixes driver and compiler.)
Mike Frysinger wrote (in PR54725 comment 6):
in gcc/Makefile.in, they do:
CFLAGS-c-family/c-opts.o += @TARGET_SYSTEM_ROOT_DEFINE@
but you can't do that in gcc/fortran/Make-lang.in. you can't use
$(TARGET_SYSTEM_ROOT_DEFINE) either because the variable is only AC_SUBST().
so you could add this line to gcc/Makefile.in:
CFLAGS-fortran/cpp.o += @TARGET_SYSTEM_ROOT_DEFINE@
and it'd work. this seems to be how they propagate the define into the
CFLAGS-c-family/c-opts.o variable, so maybe this is OK.
alternatively, gcc/Makefile.in does setup $(COMPILER_DEFINES), so adding this
to gcc/fortran/Make-lang.in works:
CFLAGS-fortran/cpp.o += $(DRIVER_DEFINES)
but i'm sure that's the wrong answer.
the other alternative is to declare a "static const char *sysroot" inside of
gcc/fortran/gfortranspec.c and then initialize gfc_cpp_option.sysroot via that.
this works because gfortranspec.c is compiled already with
$(COMPILER_DEFINES).
Tobias
PS: The following patch does the same as c-family/c-opts.c does:
--- a/gcc/fortran/cpp.c
+++ b/gcc/fortran/cpp.c
@@ -40,0 +41,4 @@ along with GCC; see the file COPYING3. If not see
+#ifndef TARGET_SYSTEM_ROOT
+# define TARGET_SYSTEM_ROOT NULL
+#endif
+
@@ -270 +274 @@ gfc_cpp_init_options (unsigned int decoded_options_count,
- gfc_cpp_option.sysroot = NULL;
+ gfc_cpp_option.sysroot = TARGET_SYSTEM_ROOT;