]> git.ipfire.org Git - thirdparty/gcc.git/commit
c-family: add -fsearch-include-path
authorJason Merrill <jason@redhat.com>
Fri, 17 May 2024 01:43:20 +0000 (21:43 -0400)
committerJason Merrill <jason@redhat.com>
Sun, 17 Nov 2024 15:23:21 +0000 (16:23 +0100)
commitdbfbd3aa2c1fb6293defcb1ad16099bb8aa4a0cb
tree358098e57f13ab437e047c32ac98a41490ca94fd
parent7db55c0ba1baaf0e323ef7f9ef8c9cda077d40e9
c-family: add -fsearch-include-path

The C++ modules code has a -fmodule-header (or -x c++-{user,system}-header)
option to specify looking up headers to compile to header units on the usual
include paths.  I'd like to have the same functionality for full C++20
modules such as module std, which I proposed to live on the include path at
bits/std.cc.  But this behavior doesn't seem necessarily connected to
modules, so I'm proposing a general C/C++ option to specify the behavior of
looking in the include path for the input files specified on the command
line.

Other ideas for the name of the option are very welcome.

The libcpp change is to allow -fsearch-include-path{,=user} to find files in
the current working directory, like -include.  This can be handy for a quick
compile of both std.cc and a file that imports it, e.g.

g++ -std=c++20 -fmodules -fsearch-include-path bits/std.cc importer.cc

gcc/ChangeLog:

* doc/cppopts.texi: Document -fsearch-include-path.
* doc/invoke.texi: Mention it for modules.

gcc/c-family/ChangeLog:

* c.opt: Add -fsearch-include-path.
* c-opts.cc (c_common_post_options): Handle it.

gcc/cp/ChangeLog:

* module.cc (module_preprocess_options): Don't override it.

libcpp/ChangeLog:

* internal.h (search_path_head): Declare.
* files.cc (search_path_head): No longer static.
* init.cc (cpp_read_main_file): Use it.
gcc/c-family/c-opts.cc
gcc/c-family/c.opt
gcc/cp/module.cc
gcc/doc/cppopts.texi
gcc/doc/invoke.texi
libcpp/files.cc
libcpp/init.cc
libcpp/internal.h