Skip to content

Commit b9d6e6e

Browse files
committed
Standardize on -fsigned-char
MaGuess on Discord pointed out the fact that cosmocc contradicts itself on the signedness of `char`. It's up to each platform to choose one, so the cosmo platform shall choose signed. The rationale is it makes the C language syntax more internally similar. `char` should be `signed char` for the same reason `int` means `signed int`. It's recommended that you still assume `char` could go either way since that's portable thinking. But if you want to assume we'll always have signed char, that's ok too.
1 parent b431ca4 commit b9d6e6e

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

build/definitions.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ ifeq ($(ARCH), aarch64)
127127
DEFAULT_COPTS += \
128128
-ffixed-x18 \
129129
-ffixed-x28 \
130+
-fsigned-char \
130131
-mno-outline-atomics
131132
endif
132133

tool/cosmocc/bin/cosmocc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ LDFLAGS_X86_64="$LDFLAGS -L$BIN/../x86_64-linux-cosmo/lib -Wl,-T,$BIN/../x86_64-
265265
LDLIBS_X86_64="-lcosmo"
266266

267267
CRT_AARCH64="$BIN/../aarch64-linux-cosmo/lib/crt.o"
268-
CPPFLAGS_AARCH64="$CPPFLAGS"
268+
CPPFLAGS_AARCH64="$CPPFLAGS -fsigned-char"
269269
CFLAGS_AARCH64="$CFLAGS -ffixed-x18 -ffixed-x28 -mno-outline-atomics"
270270
LDFLAGS_AARCH64="$LDFLAGS -L$BIN/../aarch64-linux-cosmo/lib -Wl,-T,$BIN/../aarch64-linux-cosmo/lib/aarch64.lds -Wl,-z,common-page-size=16384 -Wl,-z,max-page-size=16384"
271271
LDLIBS_AARCH64="-lcosmo"

tool/cosmocc/bin/cosmocross

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ if [ x"$ARCH" = x"x86_64" ]; then
8484
elif [ x"$ARCH" = x"aarch64" ]; then
8585
OBJCOPYFLAGS="-S"
8686
PAGESZ=16384
87+
CPPFLAGS="$CPPFLAGS -fsigned-char"
8788
CFLAGS="$CFLAGS -ffixed-x18 -ffixed-x28 -mno-outline-atomics"
8889
LDFLAGS="$LDFLAGS -Wl,-T,$BIN/../$ARCH-linux-cosmo/lib/aarch64.lds"
8990
else

0 commit comments

Comments
 (0)