1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

crunchgen(8): fix crunched application build with WARNS=6

This was revealed by the rescue build with a patch I'm working on to default
WARNS=6 everywhere. The issues resolved were:

- Missing prototype for _crunched_${ident}_stub in the *_stub.c generated
  bits
- Missing prototype for crunched_main
- Incomplete prototype for _crunched_${ident}_stub in the generated parts of
  crunched_main
- Literal strings in the stub table must drop const qualifier, unless we
  const'ify name
- f field in struct stub didn't have a proper prototype

Most of these issues are minor formalities and easily addressed.

I note that if my patch to eventually raise WARNS for the rescue build
lands, we'll need to bump the __FreeBSD_version requirement for
bootstrapping crunchgen and wipe out the rescue .OBJDIR if it's stale, which
we should be able to detect pretty easily from a couple of the issues that
have been fixed here.

Reviewed by:	arichardson
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26363
This commit is contained in:
Kyle Evans 2020-09-10 18:19:45 +00:00
parent 4d6265e3e4
commit fc90521002
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=365605
2 changed files with 11 additions and 4 deletions

View File

@ -76,9 +76,11 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
typedef int crunched_stub_t(int, char **, char **);
struct stub {
char *name;
int (*f)();
const char *name;
crunched_stub_t *f;
};
extern const char *__progname;
@ -86,6 +88,8 @@ extern struct stub entry_points[];
static void crunched_usage(void);
crunched_stub_t crunched_main;
static struct stub *
find_entry_point(const char *basename)
{

View File

@ -934,7 +934,9 @@ gen_output_cfile(void)
fprintf(outcf, "%s\n", *cp);
for (p = progs; p != NULL; p = p->next)
fprintf(outcf, "extern int _crunched_%s_stub();\n", p->ident);
fprintf(outcf,
"extern crunched_stub_t _crunched_%s_stub;\n",
p->ident);
fprintf(outcf, "\nstruct stub entry_points[] = {\n");
for (p = progs; p != NULL; p = p->next) {
@ -1122,9 +1124,10 @@ prog_makefile_rules(FILE *outmk, prog_t *p)
fprintf(outmk, "%s_stub.c:\n", p->name);
fprintf(outmk, "\techo \""
"extern int main(int argc, char **argv, char **envp); "
"int _crunched_%s_stub(int argc, char **argv, char **envp);"
"int _crunched_%s_stub(int argc, char **argv, char **envp)"
"{return main(argc,argv,envp);}\" >%s_stub.c\n",
p->ident, p->name);
p->ident, p->ident, p->name);
fprintf(outmk, "%s.lo: %s_stub.o $(%s_OBJPATHS)",
p->name, p->name, p->ident);
if (p->libs)