Allow -c to be specified with -E in cosmocc

This commit is contained in:
Justine Tunney 2024-07-31 02:09:15 -07:00
parent 4ed4a1095a
commit f8cfc89eba
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
10 changed files with 41 additions and 4 deletions

View file

@ -139,7 +139,9 @@ for x; do
elif [ x"$x" != x"${x#-O}" ]; then # startswith(x, "-O")
OPT=$x
elif [ x"$x" = x"-c" ]; then
INTENT=cc
if [ x"$INTENT" != x"cpp" ]; then
INTENT=cc
fi
elif [ x"$x" = x"-E" ] ||
[ x"$x" = x"-M" ] ||
[ x"$x" = x"-MM" ]; then
@ -266,7 +268,9 @@ CC_AARCH64="$BIN/aarch64-linux-cosmo-gcc"
if [ x"$PROG" != x"${PROG%++}" ]; then
CC_X86_64="$BIN/x86_64-linux-cosmo-g++"
CC_AARCH64="$BIN/aarch64-linux-cosmo-g++"
CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -fuse-cxa-atexit"
if [ x"$INTENT" != x"cpp" ]; then
CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -fuse-cxa-atexit"
fi
CPPFLAGS="-isystem $BIN/../include/third_party/libcxx $CPPFLAGS"
else
CFLAGS="$CFLAGS -Wno-implicit-int"
@ -325,6 +329,9 @@ if [ $INTENT = cpp ]; then
if [ -n "$OUTPUT" ]; then
ARGS="$ARGS -o$OUTPUT"
fi
# undefine cpu-specific and linux-specific defines
# we get rid of long double too to not lead astray
# we shall leave behind unix, __unix, and __unix__
set -- \
"$CC_X86_64" \
-U__k8 \
@ -333,10 +340,21 @@ if [ $INTENT = cpp ]; then
-U__amd64__ \
-U__x86_64 \
-U__x86_64__ \
-U__MMX__ \
-U__MMX_WITH_SSE__ \
-U__SSE_MATH__ \
-U__SEG_FS \
-U__SEG_GS \
-U__SSE__ \
-U__FXSR__ \
-U__SSE2__ \
-U__SSE2_MATH__ \
-Ulinux \
-U__linux \
-U__linux__ \
-U__gnu_linux__ \
-mno-red-zone \
-mlong-double-64 \
$PLATFORM \
$CPPFLAGS \
$ARGS

View file

@ -17,6 +17,7 @@
"__GNUC__"
"__APPLE__"
"__linux__"
"__gnu_linux__"
"__HAIKU__"
"__CYGWIN__"
"__EMSCRIPTEN__"
@ -25,10 +26,13 @@
"__NetBSD__"
"__NetBSD_Version__"
"__OpenBSD__"
"__Fuchsia__"
"__COSMOPOLITAN__"
"__COSMOCC__"
"__FATCOSMOCC__"
"__GLIBC__"
"__ELF__"
"__GNU__"
"__linux"
"__MACH__"
"__GNUG__"
@ -128,6 +132,8 @@
"__ARM_FP16_IEEE"
"__ARM_FP_FAST"
"__powerpc__"
"__POWERPC__"
"__ppc__"
"__powerpc64__"
"__POWER9_VECTOR__"
"__wasm_simd128__"

View file

@ -5,7 +5,6 @@
'("__cplusplus"
"__OBJC__"
"__STRICT_ANSI__"
"__ELF__"
"__VERSION__"
"__OPTIMIZE__"
"__OPTIMIZE_SIZE__"
@ -29,6 +28,7 @@
"__LP64__"
"__SSP__"
"__SSP_ALL__"
"__unix"
"__unix__"
"__vax__"
"__ns16000__"