Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dependencies options and -fcopybook-deps #109

Closed

Conversation

lefessan
Copy link
Member

@lefessan lefessan commented Aug 15, 2023

  • Implements dependencies options similar to gcc
  • -fcopybook-deps outputs only copybook names instead of file paths. -fcopybook-deps also forces -E -foneline-deps -MT=copybooks, disables errors on missing copybooks and remove output on stdout.

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2023

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 95.39474% with 7 lines in your changes missing coverage. Please review.

Project coverage is 77.56%. Comparing base (2c000f5) to head (88e292a).

Files with missing lines Patch % Lines
cobc/cobc.c 94.65% 7 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           gcos4gnucobol-3.x     #109    +/-   ##
===================================================
  Coverage              77.56%   77.56%            
===================================================
  Files                     33       33            
  Lines                  60230    60349   +119     
  Branches               15834    15869    +35     
===================================================
+ Hits                   46717    46810    +93     
- Misses                 13513    13539    +26     
Flag Coverage Δ
77.56% <95.39%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GitMensch
Copy link
Collaborator

As testcases are missing I cannot get a grasp what this is about....

We definitely should provide a way to "only" calculate the dependencies and in this case the paths are not available so we can only output the names, which may be the idea behind that.

Not sure why we should have a "only on one line".

Adjustments to -MT and friends are useful and those were added back with an explicit note that there will be changes - but those should mimic what GCC does with them so please provide sample code and output of a C program with #include <something.h> and #include <else/something.h> and #include "other/something.h" along with some different -I and -M... options and add test cases that have the same scenario for cobc - making the later mimic the first is the way to go. Only when we have that we should inspect your scenario to check if that's what you need or what is missing.

And yes: if you could tackle the -M... options, that would be quite good (but those changes should mimic recent GCC, both from their options and from their results).

@lefessan lefessan force-pushed the z-2023-07-15-deps branch 2 times, most recently from b79b1e2 to e3c6cd9 Compare August 16, 2023 16:55
@lefessan
Copy link
Member Author

I added a test in used_binaries.at... and most arguments used by gcc that make sense for GnuCOBOL. I don't know which changes are being done in gcc, but I can import them accordingly.

For -fcopybook-deps, the idea is to output dependencies for other tools than make, in a very simple format and without file path resolution. For example, using this output, it is possible to create a tool that will use it to know the copybooks of a source file, and then search for them by scanning directories, and finally call cobc again with an automatically generated list of -I <dir>.

@lefessan lefessan force-pushed the z-2023-07-15-deps branch 4 times, most recently from 5cfc276 to 9aeb62c Compare August 16, 2023 17:20
@lefessan
Copy link
Member Author

lefessan commented Aug 16, 2023

@GitMensch I have a completely unrelated question ; I have a PR on the manual in OCamlPro/gnucobol-docs#2 . Is there another maintainer for that part, or are you also in charge ?

Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should -MM and -MMD be added, ignoring the copybooks in COB_COPY_DIR (currently extfh and screenio)?

Shouldn't the dependency options be included in gnucobol.texi, possibly copying GCCs docs verbatim? This would also allow to note in NEWS that we adjusted these options (referencing the 3.2 note about the future change) while pointing to the manual for the details on the dependency generation.

In any case this should be split to two commits for SVN - one that adjusts the "standard" dependency options and a second one for the new flags.
I'd like to review them separately, can you please split the PR into two (obviously the new flags would not base on the original target but on the deps branch)?

tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
@GitMensch
Copy link
Collaborator

Should -MM and -MMD be added, ignoring the copybooks in COB_COPY_DIR (currently extfh and screenio)?

Shouldn't the dependency options be included in gnucobol.texi, possibly copying GCCs docs verbatim? This would also allow to note in NEWS that we adjusted these options (referencing the 3.2 note about the future change) while pointing to the manual for the details on the dependency generation.

In any case this should be split to two commits for SVN - one that adjusts the "standard" dependency options and a second one for the new flags. I'd like to review them separately, can you please split the PR into two (obviously the new flags would not base on the original target but on the deps branch)?

Friendly ping @lefessan

@GitMensch
Copy link
Collaborator

@lefessan I've did a quick browser-only merge, can you please review, adjust as needed and check the review comment above?

cobc/ChangeLog Outdated Show resolved Hide resolved
@GitMensch
Copy link
Collaborator

Thanks for the rebase. As guessed before, noted in the review and now seen in the CI: we have issues at least on Win32 as follows:

#                             -*- compilation -*-
28. used_binaries.at:1119: testing output dependencies ...
../../tests/used_binaries.at:1138: mkdir -p sub
../../tests/used_binaries.at:1144: $COMPILE_ONLY prog.cob
../../tests/used_binaries.at:1146: $COMPILE_ONLY -M prog.cob prog.cob
--- -	2024-03-12 14:25:51.094447400 +0000
+++ /d/a/gnucobol/gnucobol/_build/tests/testsuite.dir/at-groups/28/stdout	2024-03-12 14:25:51.042599800 +0000
@@ -2,12 +2,12 @@
  prog.cob \
  COPY1.CPY \
  COPY2.CPY \
- sub/COPY3.CPY
+ sub\COPY3.CPY
 
 prog.o: \
  prog.cob \
  COPY1.CPY \
  COPY2.CPY \
- sub/COPY3.CPY
+ sub\COPY3.CPY

I think all make implementations support / paths, in this case we may use these here; otherwise the test may get a conditional to change the expected result for Win32 to backslash or we go with adjusting the output of (.)\(.) to $1/$2.

@lefessan lefessan force-pushed the z-2023-07-15-deps branch 2 times, most recently from 136592b to 8dc9eed Compare March 15, 2024 09:22
@lefessan lefessan changed the title add new flags -foneline-deps and -fcopybook-deps to output dependencies add dependencies options and -fcopybook-deps to output dependencies Mar 15, 2024
@lefessan lefessan changed the title add dependencies options and -fcopybook-deps to output dependencies add dependencies options and -fcopybook-deps Mar 15, 2024
@lefessan
Copy link
Member Author

So, in this version, I am using the COB_IS_RUNNING_IN_TESTMODE variable to replace backslashes by slashes in the compiler output, so that tests have the same results on Unix and Windows.

Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly finished! Please see comments.

cobc/flag.def Outdated Show resolved Hide resolved
cobc/help.c Show resolved Hide resolved
cobc/flag.def Show resolved Hide resolved
cobc/error.c Outdated Show resolved Hide resolved
cobc/ChangeLog Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
@lefessan
Copy link
Member Author

Should -MM and -MMD be added, ignoring the copybooks in COB_COPY_DIR (currently extfh and screenio)?

I don't think it is worth it. Though they are easy to implement (by modifying the cb_copy_find_file in pplex.l to set a flag when using the COB_COPY_DIR entry of cb_include_list), I don't see any reason why the external tool that would use the dependencies would need to remove system dependencies, or wouldn't be able to do it by itself. Adding low value features makes the code harder to maintain for little benefit.

@lefessan
Copy link
Member Author

This version has a NEWS section and a new section in gnucobol.texi for dependency options.

@lefessan lefessan force-pushed the z-2023-07-15-deps branch 2 times, most recently from 7cf30b0 to 68c30e6 Compare March 17, 2024 15:54
@ddeclerck
Copy link
Contributor

Took care of most changes ; as far as I can tell the only thing that remains to do is splitting the unrelated testsuite changes and cobc_slashify to another PR, right ?

ddeclerck added a commit to ddeclerck/gnucobol that referenced this pull request Sep 20, 2024
@ddeclerck
Copy link
Contributor

@GitMensch I think I took all remarks into account. Is this ok for you ?

Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: -MMD and -isystem are left for a later PR,. right?

This PR needs testcase adjustments, but otherwise loolks good.

tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
.github/workflows/windows-msvc.yml Outdated Show resolved Hide resolved
NEWS Outdated Show resolved Hide resolved
cobc/typeck.c Outdated
@@ -3588,6 +3588,7 @@ check_argument_conformance (struct cb_program *program, cb_tree argument_tripple
} else {
arg_field = NULL;
}
if (!CB_FIELD_P(param)) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's unrelated but important, I guess there's also test that can (and should be) added for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to trigger this one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly passing a constant/literal? I'd need to check the context.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this and its Changelog entry to a separate PR and we can work out the right test (if @lefessan does not remember).

cobc/pplex.l Outdated Show resolved Hide resolved
cobc/cobc.c Outdated Show resolved Hide resolved
cobc/cobc.c Outdated Show resolved Hide resolved
cobc/cobc.c Outdated Show resolved Hide resolved
cobc/cobc.c Outdated Show resolved Hide resolved
tests/testsuite.src/used_binaries.at Outdated Show resolved Hide resolved
@ddeclerck
Copy link
Contributor

Just a question: -MMD and -isystem are left for a later PR,. right?

Not sure ; quoting Fabrice's reply (#109 (comment)):

Should -MM and -MMD be added, ignoring the copybooks in COB_COPY_DIR (currently extfh and screenio)?

I don't think it is worth it. Though they are easy to implement (by modifying the cb_copy_find_file in pplex.l to set a flag when using the COB_COPY_DIR entry of cb_include_list), I don't see any reason why the external tool that would use the dependencies would need to remove system dependencies, or wouldn't be able to do it by itself. Adding low value features makes the code harder to maintain for little benefit.

@GitMensch
Copy link
Collaborator

GitMensch commented Sep 21, 2024 via email

@GitMensch

This comment was marked as resolved.

@GitMensch

This comment was marked as resolved.

cobc/pplex.l Outdated Show resolved Hide resolved
@GitMensch
Copy link
Collaborator

From the GCC docs the following may be not "correct" yet:

Passing -M to the driver implies -E, and suppresses warnings with an implicit -w.

Note that we can, of course, should be able to copy most of the GCC docs about those options to gnucobol.texi.

Would there be any reason to support DEPENDENCIES_OUTPUT env var?

Copy link
Collaborator

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After moving that unrelated thing without a testcase out, this is nearly good to go now, it just needs ChangeLog entries for the changes done after Fabrice's work, then can be merged upstream.

@GitMensch
Copy link
Collaborator

I'm quite sure that there were also recent adjustments from you :-)
But you can tackle this changelog change directly when committing upstream.

@ddeclerck
Copy link
Contributor

I'm quite sure that there were also recent adjustments from you

Not really, just minor changes: allow duplicates in pplex.l (I added to the ChangeLog), moving the flag from flag.def to cobc.c (I adjusted the filenames in the ChangeLog entry), some whitespaces fixes (adding a space when I found ){ glued together), and a two or three const added (to the new code, not to existing code).

Unless I'm missing something (I'm working on 10 things at the same time, I'm kinda lost)

@GitMensch
Copy link
Collaborator

then let's only out the duplicate stuff in pplex.l to recent changelog entry from you before commit (and possibly leave flags.def in upstream as-is)

@ddeclerck
Copy link
Contributor

then let's only out the duplicate stuff in pplex.l to recent changelog entry from you before commit (and possibly leave flags.def in upstream as-is)

Ah, I had added that to Fabrice's entry from 03/2024. It's only a 3-line patch, I'm okay with not taking the credit for that 😂

@GitMensch
Copy link
Collaborator

I'd like to keep the Changelog including time entries relative clean, that's not (only) about attribution (also a the date is quite interesting) eeeeeeeeeI see from https://github.com/OCamlPro/gnucobol/compare/1a2949b4df2a55b7bca16f13a91c53a2e3807a9d..236c8b2c21dbaf470250d48bd2a014be4b10aaf1 that the adjustment is mostly testcases.

lefessan and others added 4 commits September 26, 2024 12:32
Flags following gcc options: -M to output deps only, -MD to output
  deps while compiling (in .d files), -MP to output phony targets, -MG
  to keep missing copybooks, -MQ <target> to Makefile-quote target

Additional flags specific to GnuCOBOL: -fcopybook-deps outputs only
copybook names instead of file paths. -fcopybook-deps also forces -E.
@ddeclerck
Copy link
Contributor

Didn't notice this was granted the "Ready for SVN" tag 😅. Rebasing before upstreaming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants