Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions src/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,39 @@ endif
QUOTE_NATIVE = $(call QUOTE_ARG,$(call NATIVEPATH,$1))
ROOT_DIR := $(dir $(realpath $(call NATIVEPATH,$(lastword $(MAKEFILE_LIST)))))

EZCFLAGS := -S -fno-autolink -fno-addrsig -fno-math-errno -ffunction-sections -fdata-sections -ffreestanding
EZCFLAGS += -Wall -Wextra -Wimplicit-float-conversion -Wimplicit-int-float-conversion -Oz
EZCFLAGS += -D_EZ80 -D__TICE__=1
EZCFLAGS += -isystem $(call NATIVEPATH,$(ROOT_DIR)libc/include) -I$(call NATIVEPATH,$(ROOT_DIR)ce/include) -I$(call NATIVEPATH,$(ROOT_DIR)fileioc)
EZCFLAGS += -mllvm -profile-guided-section-prefix=false -mllvm -z80-gas-style
EZCXXFLAGS := $(EZCFLAGS) -fno-exceptions -fno-rtti
EZCXXFLAGS += -isystem $(call NATIVEPATH,$(ROOT_DIR)libcxx/include)
EZLLVMFLAGS :=
EZLLVMFLAGS += -fno-autolink
EZLLVMFLAGS += -fno-addrsig
EZLLVMFLAGS += -fno-threadsafe-statics
EZLLVMFLAGS += -mllvm -profile-guided-section-prefix=false
EZLLVMFLAGS += -mllvm -z80-gas-style
EZLLVMFLAGS += -ffunction-sections
EZLLVMFLAGS += -fdata-sections
EZLLVMFLAGS += -fno-math-errno

EZCOMMONFLAGS := -S
EZCOMMONFLAGS += -ffreestanding
EZCOMMONFLAGS += $(EZLLVMFLAGS)
EZCOMMONFLAGS += -Oz
EZCOMMONFLAGS += -Wall -Wextra -Wshadow
EZCOMMONFLAGS += -Wimplicit-float-conversion -Wimplicit-int-float-conversion
EZCOMMONFLAGS += -Wimplicit-int-conversion
EZCOMMONFLAGS += -D_EZ80 -D__TICE__=1

EZLIBCINCLUDE := -isystem $(call NATIVEPATH,$(ROOT_DIR)libc/include)
EZLIBCINCLUDE += -I$(call NATIVEPATH,$(ROOT_DIR)ce/include)
EZLIBCINCLUDE += -I$(call NATIVEPATH,$(ROOT_DIR)fileioc)

EZLIBCXXINCLUDE := -isystem $(call NATIVEPATH,$(ROOT_DIR)libcxx/include)

EZCFLAGS := $(EZCOMMONFLAGS) $(EZLIBCINCLUDE)

# The C++ standard requires libcxx headers to be searched before libc headers
# this means include/c++/math.h must be included before include/math.h
EZCXXFLAGS := $(EZCOMMONFLAGS) $(EZLIBCXXINCLUDE) $(EZLIBCINCLUDE)
EZCXXFLAGS += -fno-exceptions
EZCXXFLAGS += -fno-rtti

EZASFLAGS := -march=ez80+full
EZASFLAGS += --defsym __TICE__=1

Expand Down
2 changes: 1 addition & 1 deletion src/crt/lltof.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

float _lltof_c(long long x)
{
uint8_t exponent = x ? __builtin_clrsbll(x) : LLONG_WIDTH - 1;
uint8_t exponent = x ? ((uint8_t)__builtin_clrsbll(x)) : LLONG_WIDTH - 1;
if (exponent >= LLONG_WIDTH - LONG_WIDTH) {
return (float)((long)x);
}
Expand Down
2 changes: 1 addition & 1 deletion src/crt/ulltof.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

float _ulltof_c(unsigned long long x)
{
uint8_t exponent = x ? __builtin_clzll(x) : ULLONG_WIDTH;
uint8_t exponent = x ? ((uint8_t)__builtin_clzll(x)) : ULLONG_WIDTH;
if (exponent >= ULLONG_WIDTH - ULONG_WIDTH) {
return (float)((unsigned long)x);
}
Expand Down
9 changes: 6 additions & 3 deletions src/libc/fgetc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ int __attribute__((weak)) fgetc(FILE *stream)
{
int c;

if (stream == NULL ||
stream == stdout ||
stream == stderr)
if (stream == NULL)
{
return EOF;
}

if (stream == stdout || stream == stderr)
{
c = EOF;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libc/fgets.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ char* __attribute__((weak)) fgets(char *__restrict str, int num, FILE *__restric
{
break;
}
*p++ = c;
*p++ = (char)c;
if (c == '\n')
{
break;
Expand Down
2 changes: 1 addition & 1 deletion src/libc/float64_rounding.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ long long llroundl(long double x) {
FE_UPWARD == softfloat_round_max)

// assumes fenv.h macros match softfloat_roundingModes
#define GET_FENV_SOFTFLOAT_ROUNDING() (fegetround())
#define GET_FENV_SOFTFLOAT_ROUNDING() ((uint_fast8_t)fegetround())

#else
static uint_fast8_t GET_FENV_SOFTFLOAT_ROUNDING(void) {
Expand Down
7 changes: 6 additions & 1 deletion src/libc/fputc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ int __attribute__((weak)) fputc(int c, FILE *stream)
{
int ret;

if (stream == NULL || stream == stdin)
if (stream == NULL)
{
return EOF;
}

if (stream == stdin)
{
ret = EOF;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libc/fread.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ size_t __attribute__((weak)) fread(void *ptr, size_t size, size_t count, FILE *_
{
break;
}
*p++ = c;
*p++ = (char)c;
}

return count;
Expand Down
2 changes: 1 addition & 1 deletion src/libc/gmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct tm *gmtime(const time_t *tp)
tm2.tm_min++;
}

tm2.tm_sec = t;
tm2.tm_sec = (int)t;

return &tm2;
}
2 changes: 1 addition & 1 deletion src/libc/printf/nanoprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

static void npf_putc_std(int c, void *ctx) {
(void)ctx;
outchar(c);
outchar((char)c);
}

static void npf_fputc_std(int c, void *ctx) {
Expand Down
6 changes: 3 additions & 3 deletions src/libc/printf/nanoprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,9 @@ static npf_cnt_putc_ctx_t pc_cnt;
#endif

static void npf_putc_cnt(int c, void *ctx) {
npf_cnt_putc_ctx_t *pc_cnt = (npf_cnt_putc_ctx_t *)ctx;
++pc_cnt->n;
pc_cnt->pc(c, pc_cnt->ctx); // sibling-call optimization
npf_cnt_putc_ctx_t *pc_putc_cnt = (npf_cnt_putc_ctx_t *)ctx;
++pc_putc_cnt->n;
pc_putc_cnt->pc(c, pc_putc_cnt->ctx); // sibling-call optimization
}

#ifdef NANOPRINTF_STATIC_GLOBALS
Expand Down
2 changes: 1 addition & 1 deletion src/libc/strftime.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ size_t strftime(char *__restrict s, size_t n, const char *__restrict f, const st

while (s + 1 < e && *f)
{
int c = *f++;
char c = *f++;
int val;

if (c != '%')
Expand Down
37 changes: 33 additions & 4 deletions src/makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,39 @@ MATH_ERRNO = -fno-math-errno
endif

# define the compiler/assembler flags
EZLLVMFLAGS = -mllvm -profile-guided-section-prefix=false -mllvm -z80-gas-style -ffunction-sections -fdata-sections -fno-addrsig -fno-autolink -fno-threadsafe-statics $(MATH_ERRNO)
EZCOMMONFLAGS = -nostdinc -isystem $(call QUOTE_ARG,$(call FORWARD_PATH,$(CEDEV_TOOLCHAIN)/include)) -I$(SRCDIR) -Xclang -fforce-mangle-main-argc-argv $(EZLLVMFLAGS) -D__TICE__=1 $(CC_CUSTOMFILE)
EZCFLAGS = $(EZCOMMONFLAGS) $(CFLAGS) $(CC_DEBUG)
EZCXXFLAGS = $(EZCOMMONFLAGS) -isystem $(call QUOTE_ARG,$(call FORWARD_PATH,$(CEDEV_TOOLCHAIN)/include/c++)) -fno-exceptions -fno-use-cxa-atexit $(CXXFLAGS) $(CC_DEBUG)

EZLLVMFLAGS =
EZLLVMFLAGS += -fno-autolink
EZLLVMFLAGS += -fno-addrsig
EZLLVMFLAGS += -fno-threadsafe-statics
EZLLVMFLAGS += -mllvm -profile-guided-section-prefix=false
EZLLVMFLAGS += -mllvm -z80-gas-style
EZLLVMFLAGS += -ffunction-sections
EZLLVMFLAGS += -fdata-sections
EZLLVMFLAGS += $(MATH_ERRNO)

EZCOMMONFLAGS =
EZCOMMONFLAGS += -nostdinc
EZCOMMONFLAGS += -Xclang -fforce-mangle-main-argc-argv
EZCOMMONFLAGS += $(EZLLVMFLAGS)
EZCOMMONFLAGS += -D__TICE__=1
EZCOMMONFLAGS += $(CC_CUSTOMFILE)

EZLIBCINCLUDE = -isystem $(call QUOTE_ARG,$(call FORWARD_PATH,$(CEDEV_TOOLCHAIN)/include))
EZLIBCINCLUDE += -I$(SRCDIR)

EZLIBCXXINCLUDE = -isystem $(call QUOTE_ARG,$(call FORWARD_PATH,$(CEDEV_TOOLCHAIN)/include/c++))

EZCFLAGS = $(EZCOMMONFLAGS) $(EZLIBCINCLUDE)
EZCFLAGS += $(CFLAGS) $(CC_DEBUG)

# The C++ standard requires libcxx headers to be searched before libc headers
# this means include/c++/math.h must be included before include/math.h
EZCXXFLAGS = $(EZCOMMONFLAGS) $(EZLIBCXXINCLUDE) $(EZLIBCINCLUDE)
EZCXXFLAGS += -fno-exceptions
EZCXXFLAGS += -fno-use-cxa-atexit
EZCXXFLAGS += $(CXXFLAGS) $(CC_DEBUG)

EZLTOFLAGS = $(EZLLVMFLAGS) $(LTOFLAGS)
EZASFLAGS = -march=ez80+full $(ASFLAGS)

Expand Down
Loading