Hello Robert, > On 17 Mar 2025, at 17:45, Robert Dubner <rdub...@symas.com> wrote: > > If this is deemed OK, then we can close out PR119213 > > It compiles and runs my both check-cobol and my more comprehensive > tests on x86_64
This looks a reasonable approach to me; it has the advantage of making the shared headers explicit in the sources (which adding a search path does not). ==== I believe in my testing that some of the includes in the two shared sources could be removed (which would reduce the sed-ing a little) see: [https://forge.sourceware.org/iains/gcc-TEST/commit/7f6f9c447f4b528c2fb1d8a8fd84e5acbe04d408] (If you agree with that assesment, you might want to apply that patch first). Plus a couple of small points mentioned in-line in the patch. I guess in the end it’s your call as to which mechanism you prefer. cheers Iain > From 8d6c8efdd9495259cc5ed1d6537c694791bd4661 Mon Sep 17 00:00:00 2001 > From: Bob Dubner mailto:rdub...@symas.com > Date: Mon, 17 Mar 2025 13:13:50 -0400 > Subject: [PATCH] cobol: Eliminate CPPFLAGS assignment from Make-lang.in > [PR119213]. > > A number of gcc/cobol files had to be modified to > '#include "../../libgcobol/xxx.h" instead of "xxx.h" > > gcc/cobol > > PR cobol/119213 > * Make-lang.in: Eliminate CPPFLAGS= assignment. > * cdf.y: Modify #includes that reference libgcobol. > * cobol1.cc: Modify #includes that reference libgcobol. > * except.cc: Modify #includes that reference libgcobol. > * gcobolspec.cc: Modify #includes that reference libgcobol. > * genapi.cc: Modify #includes that reference libgcobol. > * gengen.cc: Modify #includes that reference libgcobol. > * genmath.cc: Modify #includes that reference libgcobol. > * genutil.cc: Modify #includes that reference libgcobol. > * parse.y: Modify #includes that reference libgcobol. > * scan.l: Modify #includes that reference libgcobol. > * structs.cc: Modify #includes that reference libgcobol. > * symbols.cc: Modify #includes that reference libgcobol. > * symfind.cc: Modify #includes that reference libgcobol. > * util.cc: Modify #includes that reference libgcobol. > --- > gcc/cobol/Make-lang.in | 45 ++++++++++++++++++++++------------------- > gcc/cobol/cdf.y | 6 +++--- > gcc/cobol/cobol1.cc | 8 ++++---- > gcc/cobol/except.cc | 10 ++++----- > gcc/cobol/gcobolspec.cc | 7 +++---- > gcc/cobol/genapi.cc | 14 ++++++------- > gcc/cobol/gengen.cc | 4 ++-- > gcc/cobol/genmath.cc | 10 ++++----- > gcc/cobol/genutil.cc | 14 ++++++------- > gcc/cobol/parse.y | 16 +++++++-------- > gcc/cobol/scan.l | 6 +++--- > gcc/cobol/structs.cc | 4 ++-- > gcc/cobol/symbols.cc | 6 +++--- > gcc/cobol/symfind.cc | 6 +++--- > gcc/cobol/util.cc | 6 +++--- > 15 files changed, 82 insertions(+), 80 deletions(-) > > diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in > index 650b695e7ef5..5707768f1be7 100644 > --- a/gcc/cobol/Make-lang.in > +++ b/gcc/cobol/Make-lang.in > @@ -43,26 +43,8 @@ cobol: cobol1$(exeext) > cobol.serial = cobol1$(exeext) > .PHONY: cobol > > -BINCLUDE ?= ./gcc > -LIB_INCLUDE ?= $(srcdir)/../libgcobol > LIB_SOURCE ?= $(srcdir)/../libgcobol > > -# > -# At this point, as of 2022-10-21, CPPFLAGS is an empty string and can be > -# altered. CFLAGS and CXXFLAGS are being established upstream, and thus > -# cannot, at this point, be changed. > -# > -# Note further that we are producing only a 64-bit version of > libgcobol.so, so > -# it is safe to hard-code the lib64 location. This obviously has to > match the > -# installation code in libgcobol/Makefile.in > -# > -CPPFLAGS = \ > - -std=c++14 \ > - -I$(BINCLUDE) \ > - -I$(LIB_INCLUDE) \ > - -DEXEC_LIB=\"$(prefix)/lib64\" \ > - $(END) > - > YFLAGS = -Werror -Wmidrule-values -Wno-yacc \ > --debug --verbose > > @@ -96,16 +78,37 @@ cobol1_OBJS = \ > # There is source code in libgcobol/charmaps.cc and > # libgcobol/valconv.cc that needs to be compiled into both libgcobol > # and cobol1. We copy those two source code files from libgcobol to > -# here to avoid the nightmare of one file appearing in more than one > -# place. For simplicity, we make those compilations dependent on all > -# of the libgcobol/*.h files, which might lead to the occasional > +# build/gcc/cobol to avoid the nightmare of one file appearing in more > +# than one place. For simplicity, we make those compilations dependent > +# on all of the libgcobol/*.h files, which might lead to the occasional > # unnecessary compilation. The impact of that is negligible. > # > +# Various #includes in the files copied from gcc/libgfortran need to be s/libgfortran/libgcobol/, I think. > modified > +# so that the .h files can be found. > + > cobol/charmaps.cc: $(LIB_SOURCE)/charmaps.cc > cp $^ $@ > + sed -i "s|\"ec[.]h\"|\"$(LIB_SOURCE)/ec.h\"|g" $@ > + sed -i "s|\"common-defs[.]h\"|\"$(LIB_SOURCE)/common-defs.h\"|g" > $@ > + sed -i "s|\"io[.]h\"|\"$(LIB_SOURCE)/io.h\"|g" $@ > + sed -i "s|\"gcobolio[.]h\"|\"$(LIB_SOURCE)/gcobolio.h\"|g" $@ > + sed -i "s|\"libgcobol[.]h\"|\"$(LIB_SOURCE)/libgcobol.h\"|g" $@ > + sed -i "s|\"gfileio[.]h\"|\"$(LIB_SOURCE)/gfileio.h\"|g" $@ > + sed -i "s|\"charmaps[.]h\"|\"$(LIB_SOURCE)/charmaps.h\"|g" $@ > + sed -i "s|\"valconv[.]h\"|\"$(LIB_SOURCE)/valconv.h\"|g" $@ > + sed -i "s|\"exceptl[.]h\"|\"$(LIB_SOURCE)/exceptl.h\"|g" $@ > > cobol/valconv.cc: $(LIB_SOURCE)/valconv.cc > cp $^ $@ > + sed -i "s|\"ec[.]h\"|\"$(LIB_SOURCE)/ec.h\"|g" $@ > + sed -i "s|\"common-defs[.]h\"|\"$(LIB_SOURCE)/common-defs.h\"|g" > $@ > + sed -i "s|\"io[.]h\"|\"$(LIB_SOURCE)/io.h\"|g" $@ > + sed -i "s|\"gcobolio[.]h\"|\"$(LIB_SOURCE)/gcobolio.h\"|g" $@ > + sed -i "s|\"libgcobol[.]h\"|\"$(LIB_SOURCE)/libgcobol.h\"|g" $@ > + sed -i "s|\"gfileio[.]h\"|\"$(LIB_SOURCE)/gfileio.h\"|g" $@ > + sed -i "s|\"charmaps[.]h\"|\"$(LIB_SOURCE)/charmaps.h\"|g" $@ > + sed -i "s|\"valconv[.]h\"|\"$(LIB_SOURCE)/valconv.h\"|g" $@ > + sed -i "s|\"exceptl[.]h\"|\"$(LIB_SOURCE)/exceptl.h\"|g" $@ > > LIB_SOURCE_H=$(wildcard $(LIB_SOURCE)/*.h) > > diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y > index 08b53412b26f..beb4697b8419 100644 > --- a/gcc/cobol/cdf.y > +++ b/gcc/cobol/cdf.y > @@ -30,13 +30,13 @@ > %{ > > #include "cobol-system.h" > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > #include "copybook.h" > -#include "exceptl.h" > +#include "../../libgcobol/exceptl.h" > #include "exceptg.h" > > #define COUNT_OF(X) (sizeof(X) / sizeof(X[0])) > diff --git a/gcc/cobol/cobol1.cc b/gcc/cobol/cobol1.cc > index c2e68edea253..08af367e2264 100644 > --- a/gcc/cobol/cobol1.cc > +++ b/gcc/cobol/cobol1.cc > @@ -30,15 +30,15 @@ along with GCC; see the file COPYING3. If not see > #include "target.h" > #include "stringpool.h" > #define HOWEVER_GCC_DEFINES_TREE 1 > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > #include "inspect.h" > -#include "io.h" > +#include "../../libgcobol/io.h" > #include "genapi.h" > -#include "exceptl.h" > +#include "../../libgcobol/exceptl.h" > #include "exceptg.h" > #include "util.h" > #include "gengen.h" // This has some GTY(()) markers > diff --git a/gcc/cobol/except.cc b/gcc/cobol/except.cc > index 859a76d6efbb..3510ca3ac218 100644 > --- a/gcc/cobol/except.cc > +++ b/gcc/cobol/except.cc > @@ -33,16 +33,16 @@ > #include "coretypes.h" > #include "tree.h" > #define HOWEVER_GCC_DEFINES_TREE 1 > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > #include "inspect.h" > -#include "io.h" > +#include "../../libgcobol/io.h" > #include "genapi.h" > #include "gengen.h" > -#include "exceptl.h" > +#include "../../libgcobol/exceptl.h" > #include "util.h" > > #pragma GCC diagnostic ignored "-Wmissing-field-initializers" > @@ -310,7 +310,7 @@ symbol_declaratives_add( size_t program, > * section is PERFORMed, and control branches to the end of this > * section, and thence back to the statement it came from. > */ > -#include "io.h" > +#include "../../libgcobol/io.h" > size_t current_file_index(); > file_status_t current_file_handled_status(); > > diff --git a/gcc/cobol/gcobolspec.cc b/gcc/cobol/gcobolspec.cc > index f3f9c327cd0a..5bd68531bc4b 100644 > --- a/gcc/cobol/gcobolspec.cc > +++ b/gcc/cobol/gcobolspec.cc > @@ -616,10 +616,9 @@ lang_specific_driver (struct cl_decoded_option > **in_decoded_options, > > if( need_libgcobol ) > { > - if( 0 != strcmp(EXEC_LIB, "/usr/lib") ) > - { > - append_option(OPT_L, EXEC_LIB, 1); > - } > +#ifdef EXEC_LIB > + append_option(OPT_L, EXEC_LIB, 1); > +#endif I am still not sure what this ^ is for - but we can (and should) address that separately. > add_arg_lib(COBOL_LIBRARY, static_libgcobol); > } > if( need_libmath ) > diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc > index eac1e264279a..73aa680bb008 100644 > --- a/gcc/cobol/genapi.cc > +++ b/gcc/cobol/genapi.cc > @@ -37,22 +37,22 @@ > > #define HOWEVER_GCC_DEFINES_TREE 1 > > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > #include "gengen.h" > #include "inspect.h" > -#include "io.h" > +#include "../../libgcobol/io.h" > #include "genapi.h" > #include "genutil.h" > #include "genmath.h" > #include "structs.h" > -#include "gcobolio.h" > -#include "libgcobol.h" > -#include "charmaps.h" > -#include "valconv.h" > +#include "../../libgcobol/gcobolio.h" > +#include "../../libgcobol/libgcobol.h" > +#include "../../libgcobol/charmaps.h" > +#include "../../libgcobol/valconv.h" > #include "show_parse.h" > > extern int yylineno; > diff --git a/gcc/cobol/gengen.cc b/gcc/cobol/gengen.cc > index e4331204d0ad..d0601e0c6c45 100644 > --- a/gcc/cobol/gengen.cc > +++ b/gcc/cobol/gengen.cc > @@ -96,8 +96,8 @@ > #include "function.h" > #include "fold-const.h" > #define HOWEVER_GCC_DEFINES_TREE 1 > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > diff --git a/gcc/cobol/genmath.cc b/gcc/cobol/genmath.cc > index 138551b1f6c6..42f01cda6eec 100644 > --- a/gcc/cobol/genmath.cc > +++ b/gcc/cobol/genmath.cc > @@ -31,19 +31,19 @@ > #include "coretypes.h" > #include "tree.h" > #define HOWEVER_GCC_DEFINES_TREE 1 > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > #include "inspect.h" > -#include "io.h" > +#include "../../libgcobol/io.h" > #include "genapi.h" > #include "genutil.h" > #include "gengen.h" > #include "structs.h" > -#include "gcobolio.h" > -#include "libgcobol.h" > +#include "../../libgcobol/gcobolio.h" > +#include "../../libgcobol/libgcobol.h" > #include "show_parse.h" > > void > diff --git a/gcc/cobol/genutil.cc b/gcc/cobol/genutil.cc > index f7708e8a3aec..b58181c823b1 100644 > --- a/gcc/cobol/genutil.cc > +++ b/gcc/cobol/genutil.cc > @@ -31,22 +31,22 @@ > #include "coretypes.h" > #include "tree.h" > #define HOWEVER_GCC_DEFINES_TREE 1 > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > #include "gengen.h" > #include "inspect.h" > -#include "io.h" > +#include "../../libgcobol/io.h" > #include "genapi.h" > #include "genutil.h" > #include "structs.h" > -#include "gcobolio.h" > -#include "libgcobol.h" > -#include "charmaps.h" > +#include "../../libgcobol/gcobolio.h" > +#include "../../libgcobol/libgcobol.h" > +#include "../../libgcobol/charmaps.h" > #include "show_parse.h" > -#include "exceptl.h" > +#include "../../libgcobol/exceptl.h" > #include "exceptg.h" > > bool internal_codeset_is_ebcdic() { return > gcobol_feature_internal_ebcdic(); } > diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y > index 15dbd1cff32c..c901bd66629b 100644 > --- a/gcc/cobol/parse.y > +++ b/gcc/cobol/parse.y > @@ -33,8 +33,8 @@ > #include <cmath> > #include <algorithm> > #include <map> > - #include "io.h" > - #include "ec.h" > + #include "../../libgcobol/io.h" > + #include "../../libgcobol/ec.h" > > #pragma GCC diagnostic ignored "-Wmissing-field-initializers" > > @@ -277,8 +277,8 @@ > > bool set_debug(bool); > > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "inspect.h" > } > > @@ -286,15 +286,15 @@ > #include <fstream> // Before cobol-system because it uses poisoned > functions > #include "cobol-system.h" > #include "cdfval.h" > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > #include "inspect.h" > -#include "io.h" > +#include "../../libgcobol/io.h" > #include "genapi.h" > -#include "exceptl.h" > +#include "../../libgcobol/exceptl.h" > #include "exceptg.h" > #include "parse_ante.h" > %} > diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l > index e4df4e82d649..18d0d82cf43d 100644 > --- a/gcc/cobol/scan.l > +++ b/gcc/cobol/scan.l > @@ -31,8 +31,8 @@ > #include <fstream> // Before cobol-system because it uses poisoned > functions > #include "cobol-system.h" > > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > @@ -41,7 +41,7 @@ > #include "copybook.h" > #include "scan_ante.h" > #include "lexio.h" > -#include "exceptl.h" > +#include "../../libgcobol/exceptl.h" > > #pragma GCC diagnostic push > #pragma GCC diagnostic ignored "-Wsign-compare" > diff --git a/gcc/cobol/structs.cc b/gcc/cobol/structs.cc > index bf98d1f15f20..39c8a425fa51 100644 > --- a/gcc/cobol/structs.cc > +++ b/gcc/cobol/structs.cc > @@ -56,8 +56,8 @@ > #include "coretypes.h" > #include "tree.h" > #define HOWEVER_GCC_DEFINES_TREE 1 > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc > index a4e87c8cef42..7cc3b9f203af 100644 > --- a/gcc/cobol/symbols.cc > +++ b/gcc/cobol/symbols.cc > @@ -32,13 +32,13 @@ > #include "cobol-system.h" > #include <search.h> > #include <iconv.h> > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > #include "inspect.h" > -#include "io.h" > +#include "../../libgcobol/io.h" > #include "genapi.h" > > #pragma GCC diagnostic ignored "-Wunused-result" > diff --git a/gcc/cobol/symfind.cc b/gcc/cobol/symfind.cc > index 3c3b5d00b810..38a890006c8d 100644 > --- a/gcc/cobol/symfind.cc > +++ b/gcc/cobol/symfind.cc > @@ -31,13 +31,13 @@ > > #include "cobol-system.h" > > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "util.h" > #include "cbldiag.h" > #include "symbols.h" > #include "inspect.h" > -#include "io.h" > +#include "../../libgcobol/io.h" > #include "genapi.h" > > extern int yydebug; > diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc > index 6ade146b5dda..9f746a388081 100644 > --- a/gcc/cobol/util.cc > +++ b/gcc/cobol/util.cc > @@ -56,11 +56,11 @@ > #include "lexio.h" > > #define HOWEVER_GCC_DEFINES_TREE > -#include "ec.h" > -#include "common-defs.h" > +#include "../../libgcobol/ec.h" > +#include "../../libgcobol/common-defs.h" > #include "symbols.h" > #include "inspect.h" > -#include "io.h" > +#include "../../libgcobol/io.h" > #include "genapi.h" > > #pragma GCC diagnostic ignored "-Wunused-result" > -- > 2.34.1 >