-
Notifications
You must be signed in to change notification settings - Fork 20
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
base: gcos4gnucobol-3.x
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
❗ 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 65.87% 65.90% +0.03%
=====================================================
Files 32 32
Lines 59483 59622 +139
Branches 15709 15747 +38
=====================================================
+ Hits 39182 39292 +110
- Misses 14282 14310 +28
- Partials 6019 6020 +1 ☔ View full report in Codecov by Sentry. |
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 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). |
b79b1e2
to
e3c6cd9
Compare
I added a test in For |
5cfc276
to
9aeb62c
Compare
@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 ? |
9aeb62c
to
e2ed1a0
Compare
There was a problem hiding this 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
AT_CHECK([$COMPILE -MD prog.cob]) | ||
|
||
AT_CHECK([cat prog.d], [0], | ||
[prog.o: \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that test would fail when COB_OBJECT_EXT != o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That still fails with a compiler using ".obj" or else - no? Note: $COB_OBJECT_EXT
is available in the testuite so a $SED
operation should be possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should work now even with .obj, using $SED on compiler output...
Friendly ping @lefessan |
@lefessan I've did a quick browser-only merge, can you please review, adjust as needed and check the review comment above? |
029378b
to
0d408ba
Compare
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:
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. |
136592b
to
8dc9eed
Compare
bea01c0
to
98c078f
Compare
So, in this version, I am using the |
There was a problem hiding this 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.
@@ -134,6 +134,9 @@ CB_FLAG (cb_flag_stack_extended, 1, "stack-extended", | |||
CB_FLAG_ON (cb_flag_fast_compare, 0, "fast-compare", | |||
_(" -fno-fast-compare disables inline comparisions")) | |||
|
|||
CB_FLAG (cb_flag_copybook_deps, 0, "copybook-deps", | |||
_(" -fcopybook-deps output copybook names as dependencies")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The M...
options should already have some docs in gnucobol.texi and may should be extended (it is fine to reference GCC documentation for detail, it is also fine to copy its documentation over - both documents have the same license and copyright owner).
The option to getting a grasp how/why one should use them in the manual would be very useful.
The -fcopybook-deps
is something new and "special", there definitely should be at least one sentence in the manual on which case/why to use that.
The currently missing NEWS entry can then also reference the manual for details. :-)
AT_CHECK([$GREP 'sub\\copy\\PROC.cpy:' prog.d], [0], [ignore]) | ||
AT_CHECK([$GREP 'sub\\PROCE.cpy:' prog.d], [0], [ignore]) | ||
], [ | ||
AT_CHECK([$GREP ' sub/copy/PROC.cpy \\' prog.d], [0], [ignore]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we still need that? I've thought the point of slashify is to not need that any more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it's probably not useful anymore, but without a Windows computer, it's painful to modify all these tests and then wait for Github CI for feedback...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the pain, but please check that with either Github CI (that's still much faster than Appveyor) or otherwise, when adding the cob_slashify
- which should be in a separate PR. Instead this PR should use the same approach that's used here or a simple tr
of the test data for output.
tests/testsuite.src/used_binaries.at
Outdated
AT_CHECK([$COMPILE -MD prog.cob]) | ||
|
||
AT_CHECK([cat prog.d], [0], | ||
[prog.o: \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That still fails with a compiler using ".obj" or else - no? Note: $COB_OBJECT_EXT
is available in the testuite so a $SED
operation should be possible.
PROCEDURE DIVISION. | ||
CALL "f" USING "Hello" BY VALUE long RETURNING NOTHING. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has, by design a BY VALUE long
in there and ignores the compiler output; is there a reason to change that?
What is that "rename" stuff about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, under Windows, the function has to be available. f
was not a real function, so it was failing with an "undefined function 'f'". I solved it by calling an existing function (rename
is part of stdio.h
, which is not included by default in common.h
). My understanding was that the test was mostly testing the arity of the function, not the exact types, so I chose a function with two char*
because I couldn't find an existing function with the same prototype as former f
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rechecking:
The first test is a simple non-static call, so no problem.
The second one does a static call, and that may need to be resolved to not raise an error, so yes, it would be reasonable to adjust this - but please put that to another (separate! PR) and leave this out here.
AT_CHECK([echo "$PWD/prog.cob:7: error: CRUD.CPY: No such file or directory" > expected.output]) | ||
AT_CHECK([echo "$PWD/prog.cob:6: warning: numeric value is expected" >> expected.output]) | ||
AT_CHECK([echo "$PWD/prog.cob:14: warning: ignoring redundant ." >> expected.output]) | ||
AT_CAPTURE_FILE([expected.output]) | ||
|
||
AT_CHECK([[cat compiler.output | tr '[:upper:]' '[:lower:]' | tr -d ':/\\' > compiler.output2]]) | ||
AT_CHECK([[cat expected.output | tr '[:upper:]' '[:lower:]' | tr -d ':/\\' > expected.output2]]) | ||
AT_CHECK([diff compiler.output2 expected.output2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a HEREDOC here instead of AT_CHECK
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familar with HEREDOC notations. This version is not the most elegant one, but it does the job :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all unrelated to the actual PR changes, please move this out to a separate PR for later review.
tests/testsuite.src/used_binaries.at
Outdated
AT_CHECK([TMPDIR="" TMP="notthere" TEMP="" $COMPILE prog.cob], [0], [], | ||
[libcob: warning: Temporary directory TMP is invalid, adjust TMPDIR! | ||
AT_CHECK([TMPDIR="" TMP="notthere" TEMP="" $COMPILE prog.cob 2> compiler.output], [0], [], | ||
[],[ | ||
# On Windows, we get a failure from gcc, so the binary is not created, the stderr is mixed and exit code is 1. | ||
AT_CHECK([grep libcob: compiler.output], [0], [libcob: warning: Temporary directory TMP is invalid, adjust TMPDIR! | ||
]) | ||
AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [OK], []) | ||
AT_CHECK([TMPDIR="" TMP="" TEMP="./prog.cob" $COMPILE prog.cob], [0], [], | ||
[libcob: warning: Temporary directory TEMP is invalid, adjust TMPDIR! | ||
], | ||
[ | ||
AT_CHECK([cat compiler.output], [0], [libcob: warning: Temporary directory TMP is invalid, adjust TMPDIR! | ||
]) | ||
AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [OK], []) | ||
]) | ||
|
||
AT_CHECK([TMPDIR="" TMP="" TEMP="./prog.cob" $COMPILE prog.cob 2> compiler.output], [0], [], | ||
[],[ | ||
AT_CHECK([grep libcob: compiler.output], [0], [libcob: warning: Temporary directory TEMP is invalid, adjust TMPDIR! | ||
]) | ||
], | ||
[ | ||
AT_CHECK([cat compiler.output], [0], [libcob: warning: Temporary directory TEMP is invalid, adjust TMPDIR! | ||
]) | ||
]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's an ... interesting approach, but please move that out to a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with moving that elsewhere is that the test will keep failing under Windows, which means that I might make changes in this PR and not notice that the failures under Windows have changed. I would prefer to have a working CI under Windows and find another fix in another PR later...
98c078f
to
d7be103
Compare
I don't think it is worth it. Though they are easy to implement (by modifying the |
This version has a |
7cf30b0
to
68c30e6
Compare
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.
68c30e6
to
75646da
Compare
@GitMensch I think I have replied and/or fixed all your points, is it for merge ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, "review pending" - I haven't clicked on send.
But this let me recheck another time now and after thinking "what do we want to achieve" I concluded that it is not the Win32 test working fine afterwards.
I therefore added some review comments asking for moving those changes out to separate PR(s) to be reviewed separately (and definitely later), allowing to merge this R hopefully next week.
Thank you and Sorry for the postponed review!
static char *cb_depend_target; /* -MT <target>... */ | ||
|
||
static char *cb_depend_target; /* -MT <target>... */ | ||
static const char *cb_depend_filename; /* -MF <file> */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those are all pointer to chars, so the old space line after seems more reasonable (but it's enough to handle that on commit and no problem if you forget, other than people possibly stumbling over this later).
Actually, because they don't follow the "size" couple that the others have, I'd suggest to moving them up front with an extra space line after.
static int string_is_dash (const char*s){ | ||
return ( strcmp (s, COB_DASH) == 0 ); | ||
} | ||
|
||
static void add_depend_target (const char* s){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor formatting:
- first the type
- next line the name and its arguments
- next line the starting
{
@@ -3001,6 +3018,74 @@ remove_trailing_slash (char *data) | |||
} | |||
} | |||
|
|||
static int string_is_dash (const char*s){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please force-inline this function
|
||
AT_CLEANUP | ||
|
||
AT_SETUP([output dependencies]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add an extra empty line before that
AT_CHECK([$GREP 'sub\\copy\\PROC.cpy:' prog.d], [0], [ignore]) | ||
AT_CHECK([$GREP 'sub\\PROCE.cpy:' prog.d], [0], [ignore]) | ||
], [ | ||
AT_CHECK([$GREP ' sub/copy/PROC.cpy \\' prog.d], [0], [ignore]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the pain, but please check that with either Github CI (that's still much faster than Appveyor) or otherwise, when adding the cob_slashify
- which should be in a separate PR. Instead this PR should use the same approach that's used here or a simple tr
of the test data for output.
PROCEDURE DIVISION. | ||
CALL "f" USING "Hello" BY VALUE long RETURNING NOTHING. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rechecking:
The first test is a simple non-static call, so no problem.
The second one does a static call, and that may need to be resolved to not raise an error, so yes, it would be reasonable to adjust this - but please put that to another (separate! PR) and leave this out here.
AT_CHECK([echo "$PWD/prog.cob:7: error: CRUD.CPY: No such file or directory" > expected.output]) | ||
AT_CHECK([echo "$PWD/prog.cob:6: warning: numeric value is expected" >> expected.output]) | ||
AT_CHECK([echo "$PWD/prog.cob:14: warning: ignoring redundant ." >> expected.output]) | ||
AT_CAPTURE_FILE([expected.output]) | ||
|
||
AT_CHECK([[cat compiler.output | tr '[:upper:]' '[:lower:]' | tr -d ':/\\' > compiler.output2]]) | ||
AT_CHECK([[cat expected.output | tr '[:upper:]' '[:lower:]' | tr -d ':/\\' > expected.output2]]) | ||
AT_CHECK([diff compiler.output2 expected.output2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all unrelated to the actual PR changes, please move this out to a separate PR for later review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's well done. Please add a ChangeLog entry for it.
the test of outputs, as they will be similar on Unix and Windows. | ||
*/ | ||
char * | ||
cobc_slashify (const char *src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. But cob_slashify()
and its related testsuite changes are far from the original PR. Please move that out to a separate one, then revert the related parts in this one.
- name: check | ||
continue-on-error: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about moving this to two separate steps? One "check" with continue-on-error
and another test
that should never fail? After all these run as separate checks for win32 in any case.
-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.