macOS build with latest clang from Xcode

A bunch of new warnings appeared by default on macOS compiler provided with Xcode,
including on every usage of sprintf(). Suppress those for now.

The issues with utilizing WANT_ASAN=1 on the make command line with macOS seem
to be resolved in this latest version, so allow it to be specified. Don't specify
it if using a problematic clang version.
This commit is contained in:
nhmall
2023-04-21 11:33:15 -04:00
parent b26ec2f677
commit 9fd719cbf2
4 changed files with 22 additions and 20 deletions

View File

@@ -60,10 +60,6 @@
#endif #endif
#endif #endif
#if __APPLE__
#include "config.h"
#endif
/* /*
* uudecode [input] * uudecode [input]
* *
@@ -85,7 +81,9 @@
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#include "warnings.h" /* #include "warnings.h" */
#define DISABLE_WARNING_UNREACHABLE_CODE
#define RESTORE_WARNINGS
static void decode(FILE *, FILE *); static void decode(FILE *, FILE *);
static void outdec(char *, FILE *, int); static void outdec(char *, FILE *, int);
@@ -130,7 +128,7 @@ main(int argc, char **argv)
} }
(void) sscanf(buf, "begin %o %s", &mode, dest); (void) sscanf(buf, "begin %o %s", &mode, dest);
#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32) && !defined(MACOS) #if !defined(MSDOS) && !defined(VMS) && !defined(WIN32) && !defined(__APPLE__)
/* handle ~user/file format */ /* handle ~user/file format */
if (dest[0] == '~') { if (dest[0] == '~') {
char *sl; char *sl;
@@ -154,7 +152,7 @@ main(int argc, char **argv)
strcat(dnbuf, sl); strcat(dnbuf, sl);
strcpy(dest, dnbuf); strcpy(dest, dnbuf);
} }
#endif /* !defined(MSDOS) && !defined(VMS) */ #endif /* !MSDOS && !VMS && !WIN32 && !__APPLE__ */
/* create output file */ /* create output file */
#if defined(MSDOS) || defined(WIN32) #if defined(MSDOS) || defined(WIN32)
@@ -239,7 +237,8 @@ outdec(char *p, FILE *f, int n)
putc(c3, f); putc(c3, f);
} }
#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32) && !defined(MACOS) #if !defined(MSDOS) && !defined(VMS) && !defined(WIN32) && !defined(__APPLE__)
/* /*
* Return the ptr in sp at which the character c appears; * Return the ptr in sp at which the character c appears;
* NULL if not found * NULL if not found

View File

@@ -29,9 +29,9 @@ CCFLAGS = -g
# CPLUSPLUS_NEED_DEPSUPPRESS = 1 C++ -Wno-deprecated-copy, # CPLUSPLUS_NEED_DEPSUPPRESS = 1 C++ -Wno-deprecated-copy,
# -Wno-deprecated-declarations # -Wno-deprecated-declarations
#ifeq "$(WANT_ASAN)" "1" ifeq "$(WANT_ASAN)" "1"
#NEED_ASAN=1 USE_ASAN=1
#endif endif
# If you want to override the compiler detection just carried out # If you want to override the compiler detection just carried out
# uncomment one of the following pairs. Note, however, that # uncomment one of the following pairs. Note, however, that
@@ -63,10 +63,6 @@ CFLAGS+=-Wmissing-prototypes
CFLAGS+=-Wold-style-definition CFLAGS+=-Wold-style-definition
CFLAGS+=-Wstrict-prototypes CFLAGS+=-Wstrict-prototypes
#ifeq "$(NEED_ASAN)" "1"
#CFLAGS+=-fsanitize=address
#endif
#detection of clang vs gcc #detection of clang vs gcc
CCISCLANG := $(shell echo `$(CC) --version` | grep clang) CCISCLANG := $(shell echo `$(CC) --version` | grep clang)
ifeq "$(CCISCLANG)" "" ifeq "$(CCISCLANG)" ""
@@ -89,6 +85,10 @@ endif # GCC greater than or equal to 9
else # gcc or clang? else # gcc or clang?
CXX=clang++ -std=gnu++11 CXX=clang++ -std=gnu++11
# clang-specific follows # clang-specific follows
CLANGGTEQ14 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 14)
ifeq "$(CLANGGTEQ14)" "1"
CFLAGS+=-Wno-deprecated-declarations
endif
# none # none
endif # clang-specific ends here endif # clang-specific ends here
@@ -139,6 +139,9 @@ CLANGPPGTEQ14 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 14)
ifeq "$(CLANGPPGTEQ9)" "1" ifeq "$(CLANGPPGTEQ9)" "1"
#CCXXFLAGS+=-Wformat-overflow #CCXXFLAGS+=-Wformat-overflow
endif endif
ifeq "$(CLANGPPGTEQ14)" "1"
CPLUSPLUS_NEED_DEPSUPPRESS=1
endif
ifdef CPLUSPLUS_NEED_DEPSUPPRESS ifdef CPLUSPLUS_NEED_DEPSUPPRESS
CCXXFLAGS+=-Wno-deprecated CCXXFLAGS+=-Wno-deprecated
CCXXFLAGS+=-Wno-deprecated-declarations CCXXFLAGS+=-Wno-deprecated-declarations

View File

@@ -56,7 +56,8 @@ endif # WANT_WIN_QT
# #
#-INCLUDE multiw-3.370 #-INCLUDE multiw-3.370
ifeq "$(NEED_ASAN)" "1" ifeq "$(USE_ASAN)" "1"
CFLAGS+=-fsanitize=address
LFLAGS+=-fsanitize=address LFLAGS+=-fsanitize=address
endif endif

View File

@@ -72,10 +72,9 @@ endif # WANT_WIN_QT
#-INCLUDE multiw-3.370 #-INCLUDE multiw-3.370
ifdef NEED_ASAN ifeq "$(USE_ASAN)" "1"
ifeq "$(NEED_ASAN)" "1" CFLAGS +=-fsanitize=address
#LFLAGS +=-fsanitize=address LFLAGS +=-fsanitize=address
endif
endif endif
# NetHack sources control # NetHack sources control