From a6d795365257855f9bd2979ba99bdfb4863b1490 Mon Sep 17 00:00:00 2001 From: Rebekah Rowe Date: Mon, 29 May 2023 19:28:54 -0400 Subject: [PATCH] Fix build issues due to multiple definitions during linking Issue is the title, alot of multiple definition errors and some other misc ones. The changes allow phunix to be built with modern compilers. --- bin/pax/extern.h | 1 - bin/pax/pax.c | 1 + .../llvm/dist/llvm/include/llvm/IR/ValueMap.h | 2 +- sbin/newfs_udf/newfs_udf.c | 4 +- sbin/newfs_udf/newfs_udf.h | 4 +- usr.bin/make/make.c | 2 + usr.bin/make/make.h | 2 +- usr.sbin/installboot/machines.c | 101 ++++++++++++++---- usr.sbin/makefs/udf.c | 3 + 9 files changed, 93 insertions(+), 27 deletions(-) diff --git a/bin/pax/extern.h b/bin/pax/extern.h index 298600c2d..94ee13911 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -204,7 +204,6 @@ void options(int, char **); OPLIST * opt_next(void); int bad_opt(void); int mkpath(char *); -char *chdname; #if !HAVE_NBTOOL_CONFIG_H int do_chroot; #endif diff --git a/bin/pax/pax.c b/bin/pax/pax.c index 253d5fc94..24c1112e8 100644 --- a/bin/pax/pax.c +++ b/bin/pax/pax.c @@ -116,6 +116,7 @@ int forcelocal; /* force local operation even if the name * contains a : */ int secure = 1; /* don't extract names that contain .. */ +char *chdname; /* * PAX - Portable Archive Interchange diff --git a/external/bsd/llvm/dist/llvm/include/llvm/IR/ValueMap.h b/external/bsd/llvm/dist/llvm/include/llvm/IR/ValueMap.h index f2ea405f1..45ae7e784 100644 --- a/external/bsd/llvm/dist/llvm/include/llvm/IR/ValueMap.h +++ b/external/bsd/llvm/dist/llvm/include/llvm/IR/ValueMap.h @@ -101,7 +101,7 @@ public: ~ValueMap() {} - bool hasMD() const { return MDMap; } + bool hasMD() const { return (bool)MDMap; } MDMapT &MD() { if (!MDMap) MDMap.reset(new MDMapT); diff --git a/sbin/newfs_udf/newfs_udf.c b/sbin/newfs_udf/newfs_udf.c index eaab2b144..10cb32523 100644 --- a/sbin/newfs_udf/newfs_udf.c +++ b/sbin/newfs_udf/newfs_udf.c @@ -72,6 +72,9 @@ int newfs_udf(int argc, char **argv); static void usage(void) __attribute__((__noreturn__)); +/* shared structure between udf_create.c users */ +struct udf_create_context context; +struct udf_disclayout layout; /* queue for temporary storage of sectors to be written out */ struct wrsect { @@ -100,7 +103,6 @@ int wrtrack_skew; int meta_perc = UDF_META_PERC; float meta_fract = (float) UDF_META_PERC / 100.0; - /* --------------------------------------------------------------------- */ /* diff --git a/sbin/newfs_udf/newfs_udf.h b/sbin/newfs_udf/newfs_udf.h index 1c21a0b48..e9ff149a5 100644 --- a/sbin/newfs_udf/newfs_udf.h +++ b/sbin/newfs_udf/newfs_udf.h @@ -53,8 +53,8 @@ extern float meta_fract; /* shared structure between udf_create.c users */ -struct udf_create_context context; -struct udf_disclayout layout; +extern struct udf_create_context context; +extern struct udf_disclayout layout; /* prototypes */ int udf_write_sector(void *sector, uint64_t location); diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index fde185065..a505fd5d0 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -120,6 +120,8 @@ __RCSID("$NetBSD: make.c,v 1.91 2014/10/18 08:33:30 snj Exp $"); #include "dir.h" #include "job.h" +FILE *debug_file; + static unsigned int checked = 1;/* Sequence # to detect recursion */ static Lst toBeMade; /* The current fringe of the graph. These * are nodes which await examination by diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index f162ef670..e07bba3cc 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -440,7 +440,7 @@ extern pid_t myPid; * There is one bit per module. It is up to the module what debug * information to print. */ -FILE *debug_file; /* Output written here - default stdout */ +extern FILE *debug_file; /* Output written here - default stdout */ extern int debug; #define DEBUG_ARCH 0x00001 #define DEBUG_COND 0x00002 diff --git a/usr.sbin/installboot/machines.c b/usr.sbin/installboot/machines.c index 357652b83..508aae92c 100644 --- a/usr.sbin/installboot/machines.c +++ b/usr.sbin/installboot/machines.c @@ -46,27 +46,86 @@ __RCSID("$NetBSD: machines.c,v 1.39 2014/02/24 07:23:44 skrll Exp $"); * isn't built with all the architectures defined. * A lot simpler that conditionally including the definitions themselves. */ -struct ib_mach - ib_mach_alpha, - ib_mach_amd64, - ib_mach_amiga, - ib_mach_emips, - ib_mach_ews4800mips, - ib_mach_hp300, - ib_mach_hppa, - ib_mach_i386, - ib_mach_landisk, - ib_mach_macppc, - ib_mach_news68k, - ib_mach_newsmips, - ib_mach_next68k, - ib_mach_pmax, - ib_mach_sparc, - ib_mach_sparc64, - ib_mach_sun2, - ib_mach_sun3, - ib_mach_vax, - ib_mach_x68k; +// commented out due to modern c not allowing multiple definitions. This will simply throw not defined errors. +#ifndef __alpha__ +struct ib_mach ib_mach_alpha; +#endif + +#ifndef __amd64__ +struct ib_mach ib_mach_amd64; +#endif + +#ifndef __amiga__ +struct ib_mach ib_mach_amiga; +#endif + +#ifndef __emips__ +struct ib_mach ib_mach_emips; +#endif + +#ifndef __ews4800mips__ +struct ib_mach ib_mach_ews4800mips; +#endif + +#ifndef __hp300__ +struct ib_mach ib_mach_hp300; +#endif + +#ifndef __hppa__ +struct ib_mach ib_mach_hppa; +#endif + +#if !defined(__i386__) && !defined(__amd64__) +struct ib_mach ib_mach_i386; +#endif + +#ifndef __landisk__ +struct ib_mach ib_mach_landisk; +#endif + +#ifndef __macppc__ +struct ib_mach ib_mach_macppc; +#endif + +#ifndef __news68k__ +struct ib_mach ib_mach_news68k; +#endif + +#ifndef __newsmips__ +struct ib_mach ib_mach_newsmips; +#endif + +#ifndef __next68k__ +struct ib_mach ib_mach_next68k; +#endif + +#ifndef __pmax__ +struct ib_mach ib_mach_pmax; +#endif + +#ifndef __sparc__ +struct ib_mach ib_mach_sparc; +#endif + +#ifndef __sparc64__ +struct ib_mach ib_mach_sparc64; +#endif + +#ifndef __sun2__ +struct ib_mach ib_mach_sun2; +#endif + +#ifndef __sun3__ +struct ib_mach ib_mach_sun3; +#endif + +#ifndef __vax__ +struct ib_mach ib_mach_vax; +#endif + +#ifndef __x68k__ +struct ib_mach ib_mach_x68k; +#endif struct ib_mach * const machines[] = { &ib_mach_alpha, diff --git a/usr.sbin/makefs/udf.c b/usr.sbin/makefs/udf.c index 1ff612ff9..055bd2880 100644 --- a/usr.sbin/makefs/udf.c +++ b/usr.sbin/makefs/udf.c @@ -90,6 +90,9 @@ float meta_fract = (float) UDF_META_PERC / 100.0; int mmc_profile; /* emulated profile */ int req_enable, req_disable; +/* shared structure between udf_create.c users, from sbin/newfs_udf/newfs_udf.h */ +struct udf_create_context context; +struct udf_disclayout layout; /* --------------------------------------------------------------------- */