Skip to content

Commit

Permalink
Fix -save-temps=DIR with -E and -c
Browse files Browse the repository at this point in the history
Do not move object files and preprocess files when they were specified
as an explicit target on the command line (-E, -c) with -save-temps=DIR
  • Loading branch information
lefessan committed Nov 29, 2023
1 parent c0d64ad commit 36bf864
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

2023-11-29 Fabrice Le Fessant <[email protected]>

* cobc.c (cobc_clean_up): when save-temps specifies a directory,
do not move object files and preprocess files when they were
specified as an explicit target on the command line (-E, -c)

2023-07-26 Simon Sobisch <[email protected]>

* typeck.c (search_set_keys): improving SEARCH ALL syntax checks
Expand Down
6 changes: 4 additions & 2 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,8 @@ clean_up_intermediates (struct filename *fn, const int status)
if (fn->need_preprocess
&& (status
|| cb_compile_level > CB_LEVEL_PREPROCESS
|| (cb_compile_level == CB_LEVEL_PREPROCESS && save_temps))) {
|| (cb_compile_level == CB_LEVEL_PREPROCESS
&& save_temps && !save_temps_dir))) {
cobc_check_action (fn->preprocess);
}
/* CHECKME: we had reports of unexpected intermediate
Expand Down Expand Up @@ -2287,7 +2288,8 @@ cobc_clean_up (const int status)
if (fn->need_assemble
&& (status
|| cb_compile_level > CB_LEVEL_ASSEMBLE
|| (cb_compile_level == CB_LEVEL_ASSEMBLE && save_temps))) {
|| (cb_compile_level == CB_LEVEL_ASSEMBLE
&& save_temps && !save_temps_dir))) {
cobc_check_action (fn->object);
}
clean_up_intermediates (fn, status);
Expand Down
5 changes: 5 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

2023-11-29 Fabrice Le Fessant <[email protected]>

* common.h/common.c: export "cob_get_strerror" as a public function
* coblocal.h: include "config.h"

2023-07-28 Simon Sobisch <[email protected]>

* screenio.c, common.c: replace use of NCURSES_MOUSE_VERSION by
Expand Down
3 changes: 3 additions & 0 deletions libcob/coblocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef COB_LOCAL_H
#define COB_LOCAL_H

#include "config.h"

/* We use this file to define/prototype things that should not be
exported to user space
*/
Expand Down Expand Up @@ -487,6 +489,7 @@ COB_HIDDEN int cob_check_env_true (char*);
COB_HIDDEN int cob_check_env_false (char*);
COB_HIDDEN const char *cob_get_last_exception_name (void);
COB_HIDDEN void cob_parameter_check (const char *, const int);
COB_HIDDEN char* cob_get_strerror (void);

enum cob_case_modifier {
CCM_NONE,
Expand Down
2 changes: 1 addition & 1 deletion libcob/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ cob_get_source_line ()
}

/* reentrant version of strerror */
static char *
char *
cob_get_strerror (void)
{
size_t size;
Expand Down
62 changes: 62 additions & 0 deletions tests/testsuite.src/used_binaries.at
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,68 @@ AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [OK], [])
AT_CLEANUP


AT_SETUP([save-temps in sub-directory])
AT_KEYWORDS([runmisc])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
PROCEDURE DIVISION.
DISPLAY "OK" NO ADVANCING
END-DISPLAY.
EXIT PROGRAM.
])

AT_CHECK([mkdir debug])

AT_CHECK([$COMPILE -save-temps=debug -o prog.exe prog.cob])
AT_CHECK([$COBCRUN_DIRECT ./prog.exe], [0], [OK])
AT_CHECK([test -f debug/prog.$COB_OBJECT_EXT])
AT_CHECK([test -f debug/prog.c])
AT_CHECK([test -f debug/prog.s], [1])
AT_CHECK([test -f debug/prog.i])
AT_CHECK([test -f debug/prog.c.h])
AT_CHECK([test -f debug/prog.c.l.h])

# Check with -c

AT_CHECK([test -f prog.$COB_OBJECT_EXT], [1])
AT_CHECK([$COMPILE -save-temps=debug -c prog.cob])
AT_CHECK([test -f prog.$COB_OBJECT_EXT])
AT_CHECK([$COMPILE -save-temps=debug -c -o program.$COB_OBJECT_EXT prog.cob])
AT_CHECK([test -f program.$COB_OBJECT_EXT])

# Check with -S

AT_CHECK([test -f prog.s], [1])
AT_CHECK([$COMPILE -save-temps=debug -S prog.cob])
AT_CHECK([test -f prog.s])
AT_CHECK([$COMPILE -save-temps=debug -S -o program.s prog.cob])
AT_CHECK([test -f program.s])

# Check with -C

AT_CHECK([test -f prog.c], [1])
AT_CHECK([$COMPILE -save-temps=debug -C prog.cob])
AT_CHECK([test -f prog.c])
AT_CHECK([test -f prog.c.h])
AT_CHECK([test -f prog.c.l.h])
AT_CHECK([$COMPILE -save-temps=debug -C -o program.c prog.cob])
AT_CHECK([test -f program.c])
AT_CHECK([test -f program.c.h])
AT_CHECK([test -f program.c.l.h])

# Check with -E

AT_CHECK([test -f prog.i], [1])
AT_CHECK([$COMPILE -save-temps=debug -E -o prog.i prog.cob])
AT_CHECK([test -f prog.i])
AT_CHECK([$COMPILE -save-temps=debug -E -o program.i prog.cob])
AT_CHECK([test -f program.i])

AT_CLEANUP


AT_SETUP([C Compiler optimizations])
AT_KEYWORDS([runmisc cobc optimization])

Expand Down

0 comments on commit 36bf864

Please sign in to comment.