Skip to content

Commit

Permalink
build: mamake: rm include <assert.h> (re: ced499a)
Browse files Browse the repository at this point in the history
On 32-bit Linux systems, as soon as mamake was relinked against
libast, the libast version of fseeko(3) was displaying some really
weird undefined behaviour, breaking the 'loop' command. The culprit
was the <assert.h> include. The problem went away as soon as that
was removed.

assert.h was included before libast to avoid a compilation failure
on some other systems, but including it before libast evidently
breaks libast -- it looks like it may pull in parts of Stdio that
libast (which reimplements Stdio in terms of Sfio) does not have a
chance to override, so the two get mixed in breaking ways.

I'd never seen assert.h combined with libast code before I used it
in mamake; now I know why :-/

src/cmd/INIT/mamake.c:
- Remove the <assert.h> include.
- Define assert(c) as a simplistic 'if (!(c)) abort()'. There won't
  be a message if it goes wrong, but that's no big deal; we'll just
  have to follow the stack trace.
  • Loading branch information
McDutchie committed Aug 2, 2024
1 parent 616bc8d commit 4467eaf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cmd/INIT/mamake.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#define RELEASE_DATE "2024-08-01"
static char id[] = "\n@(#)$Id: mamake (ksh 93u+m) " RELEASE_DATE " $\0\n";

#include <assert.h>

#if _PACKAGE_ast

#include <ast.h>
Expand Down Expand Up @@ -165,6 +163,9 @@ static const char usage[] =
#include <string.h>
#endif

/* standard assert.h does not play well with libast headers on too many systems */
#define assert(c) if(!(c)) abort()

/* backward compat for file offsets */
#if _POSIX_VERSION < 200112L
#define off_t long
Expand Down

0 comments on commit 4467eaf

Please sign in to comment.