From b45c03ab429ae417ed77232750d2d8ac2666aacf Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin (Intel)" Date: Wed, 27 Jun 2018 21:03:38 -0700 Subject: [PATCH] asm: add a default-off warning for phase error in pass 1 Add a default-off warning for phase error in pass 1. This is default off because of the lateness in the release cycle, but cases where we have such instability should be investigated further. For now, the warning is here so we can debug these problems in the field. Signed-off-by: H. Peter Anvin (Intel) --- asm/error.c | 1 + asm/nasm.c | 20 +++++++++++++++++--- include/error.h | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/asm/error.c b/asm/error.c index 3fdaa027..73db7443 100644 --- a/asm/error.c +++ b/asm/error.c @@ -69,6 +69,7 @@ const struct warning warnings[ERR_WARN_ALL+1] = { {"not-my-pragma", "%pragma not applicable to this compilation", false}, {"unknown-warning", "unknown warning in -W/-w or warning directive", false}, {"negative-rep", "regative %rep count", true}, + {"phase", "phase error during stabilization", false}, /* THIS ENTRY MUST COME LAST */ {"all", "all possible warnings", false} diff --git a/asm/nasm.c b/asm/nasm.c index 5290b078..55e4a8cf 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -1613,9 +1613,23 @@ static void assemble_file(const char *fname, StrList **depend_ptr) nasm_free(line); } /* end while (line = preproc->getline... */ - if (pass0 == 2 && global_offset_changed && !terminate_after_phase) - nasm_error(ERR_NONFATAL, - "phase error detected at end of assembly."); + if (global_offset_changed && !terminate_after_phase) { + switch (pass0) { + case 1: + nasm_error(ERR_WARNING|ERR_WARN_PHASE, + "phase error during stabilization pass, hoping for the best"); + break; + + case 2: + nasm_error(ERR_NONFATAL, + "phase error during code generation pass"); + break; + + default: + /* This is normal, we'll keep going... */ + break; + } + } if (pass1 == 1) preproc->cleanup(1); diff --git a/include/error.h b/include/error.h index 83b28da0..139400db 100644 --- a/include/error.h +++ b/include/error.h @@ -113,9 +113,10 @@ static inline vefunc nasm_set_verror(vefunc ve) #define ERR_WARN_NOTMY_PRAGMA WARN(19) /* pragma inapplicable */ #define ERR_WARN_UNK_WARNING WARN(20) /* unknown warning */ #define ERR_WARN_NEG_REP WARN(21) /* negative repeat count */ +#define ERR_WARN_PHASE WARN(22) /* phase error in pass 1 */ /* The "all" warning acts as a global switch, it must come last */ -#define ERR_WARN_ALL 22 /* Do not use WARN() here */ +#define ERR_WARN_ALL 23 /* Do not use WARN() here */ struct warning { const char *name;