commit 5eedaa9f030481f63ab828c89c0623068fd2b7a7
parent 3ef4da68f555260111abb67615a28885bf57a7b5
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Wed, 11 Feb 2026 14:38:41 +0100
make: Change default CFLAGS and FFLAGS
This is a very weird situation, because classical cc accepted -O to
enable optimizations, but POSIX 2004 specified -O level for c99, but it
specified -O for default value of CFLAGS in make. This conjuction made
that gcc accepts -O1 but not -O 1, because -O 1 is interpreted like
the -O option and the source file 1. That makes that the default CFLAGS
of POSIX make cannot work with gcc (and clang), but GNU make uses -O1
instead of the -O 1 specified in POSIX. Seems both values should be
accepted by compliant POSIX tools, in order to avoid problems the best
option is to follow GNU make here and use -O1 instead of -O 1, even
when it is not strictly POSIX compliant.
Diffstat:
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/cmd/scc-make/defaults.c b/src/cmd/scc-make/defaults.c
@@ -4,9 +4,9 @@ char defaults[] =
"AR = ar\n"
"ARFLAGS = -rv\n"
"CC = c99\n"
- "CFLAGS = -O\n"
+ "CFLAGS = -O1\n"
"FC = fort77\n"
- "FFLAGS = -O 1\n"
+ "FFLAGS = -O1\n"
"LDFLAGS =\n"
"LEX = lex\n"
"LFLAGS =\n"
diff --git a/tests/make/execute/0015-pflag.sh b/tests/make/execute/0015-pflag.sh
@@ -18,13 +18,13 @@ YFLAGS =
ARFLAGS = -rv
LDFLAGS =
LEX = lex
-CFLAGS = -O
+CFLAGS = -O1
YACC = yacc
CC = c99
LFLAGS =
AR = ar
SHELL = /bin/sh
-FFLAGS = -O 1
+FFLAGS = -O1
.f.a:
${FC} -c ${FFLAGS} $<
${AR} ${ARFLAGS} $@ $*.o
diff --git a/tests/make/execute/0093-inference.sh b/tests/make/execute/0093-inference.sh
@@ -18,5 +18,5 @@ touch f.c
scc make -f $tmp1) > $tmp2
diff $tmp2 - <<EOF
-c99 -O -c f.c
+c99 -O1 -c f.c
EOF
diff --git a/tests/make/execute/0106-inference.sh b/tests/make/execute/0106-inference.sh
@@ -15,5 +15,5 @@ all: f.o
EOF
diff $tmp1 - <<EOF
-c99 -O -c f.c
+c99 -O1 -c f.c
EOF
diff --git a/tests/make/execute/0107-inference.sh b/tests/make/execute/0107-inference.sh
@@ -25,5 +25,5 @@ f.h:
EOF
diff $tmp1 - <<EOF
-c99 -O -o f f.c
+c99 -O1 -o f f.c
EOF