Skip to content

Commit

Permalink
Fix -fno-strict-aliasing when passing optim. flags (re: 27ece9f)
Browse files Browse the repository at this point in the history
-fno-strict-aliasing is a flag that turns off a specific compiler
optimisation. Passing this through ${mam_cc_FLAGS} is only
effective as long as no compiler optimisation flags are passed
through ${CCFLAGS}, because the latter follows the former.

There is only one way to be sure: add ${mam_cc_NOSTRICTALIASING}
separately to each compiler invocation.
  • Loading branch information
McDutchie committed Mar 23, 2024
1 parent 27ece9f commit 1dc39bc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/cmd/builtin/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setv MAMAKE_STRICT 3
setv INSTALLROOT ../../..
setv PACKAGE_ast_INCLUDE ${INSTALLROOT}/include/ast
setv CC cc
setv mam_cc_FLAGS ${mam_cc_TARGET} ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?} ${mam_cc_NOSTRICTALIASING}
setv mam_cc_FLAGS ${mam_cc_TARGET} ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?}
setv CCFLAGS
setv CCLDFLAGS ${-strip-symbols?1?${mam_cc_LD_STRIP}??}
setv IFFEFLAGS
Expand Down Expand Up @@ -134,7 +134,7 @@ make install virtual
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} \
exec - -DERROR_CATALOG=\""builtin"\" -DCMD_STANDALONE=b_pty -c ${<}
done pty.o
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} \
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} ${LDFLAGS} ${mam_cc_L+-L.} \
exec - ${mam_cc_L+-L${INSTALLROOT}/lib} -o pty pty.o ${mam_libutil} ${mam_libast} ${mam_libcmd}
done pty

Expand Down
8 changes: 4 additions & 4 deletions src/cmd/ksh93/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setv INSTALLROOT ../../..
setv PACKAGE_ast_INCLUDE ${INSTALLROOT}/include/ast
setv CC cc
setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS}
setv mam_cc_FLAGS ${mam_cc_TARGET} ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?} ${mam_cc_NOSTRICTALIASING}
setv mam_cc_FLAGS ${mam_cc_TARGET} ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?}
setv CCFLAGS
setv CCLDFLAGS ${-strip-symbols?1?${mam_cc_LD_STRIP}??}
setv IFFEFLAGS
Expand Down Expand Up @@ -167,15 +167,15 @@ make install virtual

make shell.req
prev ${INSTALLROOT}/bin/mkreq
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} : ${LDFLAGS} : \
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} : ${LDFLAGS} : \
exec - shell dll cmd ast m jobs i socket nsl secdb network
done

note *
note * Feature tests
note *

setv iffe_run iffe ${IFFEFLAGS} -v -c '${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}' ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run
setv iffe_run iffe ${IFFEFLAGS} -v -c '${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} ${LDFLAGS}' ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdll} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libnsl} : run

make features/time
prev ${PACKAGE_ast_INCLUDE}/times.h
Expand Down Expand Up @@ -1157,7 +1157,7 @@ make install virtual
note * Set common compiler invocation arguments
note *

setv compile ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${DEBUG+-DDEBUG=${DEBUG}} -DSH_DICT=${SH_DICT} ${SH_CMDLIB_DIR+-DSH_CMDLIB_DIR=${SH_CMDLIB_DIR}} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -D_API_ast=20100309 -DERROR_CONTEXT_T=Error_context_t -c
setv compile ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} ${DEBUG+-DDEBUG=${DEBUG}} -DSH_DICT=${SH_DICT} ${SH_CMDLIB_DIR+-DSH_CMDLIB_DIR=${SH_CMDLIB_DIR}} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -D_API_ast=20100309 -DERROR_CONTEXT_T=Error_context_t -c

note *
note * Build the library
Expand Down
16 changes: 8 additions & 8 deletions src/lib/libast/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setv INSTALLROOT ../../..
setv PACKAGEROOT ../../../../..
setv CC cc
setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS}
setv mam_cc_FLAGS ${mam_cc_TARGET} ${mam_cc_DLL} -D_BLD_ast ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?} ${mam_cc_NOSTRICTALIASING}
setv mam_cc_FLAGS ${mam_cc_TARGET} ${mam_cc_DLL} -D_BLD_ast ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?}
setv CCFLAGS
setv CCLDFLAGS ${-strip-symbols?1?${mam_cc_LD_STRIP}??}
setv IFFEFLAGS
Expand All @@ -23,15 +23,15 @@ shim - invoke_iffe()
shim - {
shim - s=$1
shim - shift
shim - set -- ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} "$@"
shim - set -- ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} ${LDFLAGS} "$@"
shim - iffe ${IFFEFLAGS} -v -X ast -X std -c "$*" run "$s"
shim - }
shim -
shim - compile()
shim - {
shim - s=$1
shim - shift
shim - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Icomp "$@" -Iinclude -Istd -c "$s"
shim - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} -I. -Icomp "$@" -Iinclude -Istd -c "$s"
shim - }

make install virtual
Expand Down Expand Up @@ -287,15 +287,15 @@ make install virtual
note *
prev ${INSTALLROOT}/bin/mkreq
exec - set -o errexit
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} : ${LDFLAGS} : ast iconv w
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} : ${LDFLAGS} : ast iconv w
note *
note * some systems move -lc routines to -lm; see astmath.c for details
note *
make astmath.out
make port/astmath.c
prev std/endian.h
done
setv _math_test ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} -DN=$N -DIS -o astmath.exe ${<}
setv _math_test ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} ${LDFLAGS} -DN=$N -DIS -o astmath.exe ${<}
exec - X=1
exec - for N in 1 2 3 4 5 6 7 8
exec - do if ${_math_test} 2>/dev/null
Expand Down Expand Up @@ -353,7 +353,7 @@ make install virtual
exec - EOF
done
prev comp/conf.tab
exec - conf -v ${<} ${CC} ${mam_cc_FLAGS} ${CCFLAGS}
exec - conf -v ${<} ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING}
done
done features/limits.c
exec - invoke_iffe ${<} -I. -Icomp -Iinclude -Istd
Expand Down Expand Up @@ -521,7 +521,7 @@ make install virtual
make port/lcgen.c
prev std/stdio.h
done
exec - ${CC} ${CCLDFLAGS} ${CCFLAGS} ${LDFLAGS} -o lcgen port/lcgen.c
exec - ${CC} ${CCLDFLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} ${LDFLAGS} -o lcgen port/lcgen.c
done
exec - lcgen lc.h lctab.c < port/lc.tab
done
Expand Down Expand Up @@ -5043,7 +5043,7 @@ make install virtual
exec - compile ${<} -D_PACKAGE_ast
done
bind -last
exec - ${CC} ${CCLDFLAGS} ${CCFLAGS} ${LDFLAGS} -o ${@} ${<} ${mam_libast} || exit
exec - ${CC} ${CCLDFLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} ${LDFLAGS} -o ${@} ${<} ${mam_libast} || exit
note *
note * We purposely do not have a make target of ${INSTALLROOT}/bin/mamake here;
note * this helps to ensure that the package.sh-built version gets overwritten.
Expand Down
6 changes: 3 additions & 3 deletions src/lib/libcmd/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ make install virtual
bind -lsum
make cmd.req
prev ${INSTALLROOT}/bin/mkreq
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} : ${LDFLAGS} : cmd fsg md util ast
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} : ${LDFLAGS} : cmd fsg md util ast
done

note *
note * Header dependencies and feature tests
note *

setv run_iffe iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libutil} ${mam_libast} : run
setv run_iffe iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} ${LDFLAGS}" ref ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libutil} ${mam_libast} : run

make deps virtual
make cmdinit.c
Expand Down Expand Up @@ -468,7 +468,7 @@ make install virtual
loop OBJ cmdinit basename cat chgrp chmod chown cksum cmp comm cp cut dirname date expr fds fmt fold getconf head id join ln logname md5sum mkdir mkfifo mktemp mv paste pathchk pids rev rm rmdir stty sum sync tail tee tty uname uniq vmstate wc revlib wclib lib
make ${OBJ}.o
prev ${OBJ}.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DHOSTTYPE=\""${mam_cc_HOSTTYPE}"\" -D_BLD_cmd -c ${<}
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DHOSTTYPE=\""${mam_cc_HOSTTYPE}"\" -D_BLD_cmd -c ${<}
done
done
make sumlib.o
Expand Down
9 changes: 5 additions & 4 deletions src/lib/libdll/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setv INSTALLROOT ../../..
setv PACKAGE_ast_INCLUDE ${INSTALLROOT}/include/ast
setv CC cc
setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS}
setv mam_cc_FLAGS ${mam_cc_TARGET} ${mam_cc_DLL} ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?} ${mam_cc_NOSTRICTALIASING}
setv mam_cc_FLAGS ${mam_cc_TARGET} ${mam_cc_DLL} ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?}
setv CCFLAGS
setv IFFEFLAGS
setv LDFLAGS
Expand Down Expand Up @@ -103,7 +103,7 @@ make install virtual
bind -last
make dll.req
prev ${INSTALLROOT}/bin/mkreq
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} : ${LDFLAGS} : dll dl dld ast
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} : ${LDFLAGS} : dll dl dld ast
done

note *
Expand All @@ -115,7 +115,8 @@ make install virtual
make dlldefs.h implicit
make FEATURE/dll
prev features/dll
exec - iffe ${IFFEFLAGS} -v -c '${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}' \
exec - iffe ${IFFEFLAGS} -v -c '${CC} ${mam_cc_FLAGS} ${CCFLAGS} \
exec - ${mam_cc_NOSTRICTALIASING} ${LDFLAGS}' \
exec - ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} \
exec - -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include \
exec - ${mam_libdl} ${mam_libast} : run ${<}
Expand Down Expand Up @@ -175,7 +176,7 @@ make install virtual
loop OBJ dlfcn dllopen dllfind dllplug dll_lib dllnext dlllook dllscan dllcheck dllerror
make ${OBJ}.o
prev ${OBJ}.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -D_BLD_dll -c ${<}
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} -I. -I${PACKAGE_ast_INCLUDE} -D_BLD_dll -c ${<}
done
done
exec - if test -f ${@}
Expand Down
9 changes: 5 additions & 4 deletions src/lib/libsum/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setv INSTALLROOT ../../..
setv PACKAGE_ast_INCLUDE ${INSTALLROOT}/include/ast
setv CC cc
setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS}
setv mam_cc_FLAGS ${mam_cc_TARGET} ${mam_cc_PIC} ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?} ${mam_cc_NOSTRICTALIASING}
setv mam_cc_FLAGS ${mam_cc_TARGET} ${mam_cc_PIC} ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?}
setv CCFLAGS
setv IFFEFLAGS
setv LDFLAGS
Expand Down Expand Up @@ -94,7 +94,7 @@ make install virtual
bind -last
make sum.req
prev ${INSTALLROOT}/bin/mkreq
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} : ${LDFLAGS} : sum md ast
exec - mkreq ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} : ${LDFLAGS} : sum md ast
done

note *
Expand All @@ -117,7 +117,8 @@ make install virtual
prev sum-ast4.c implicit
make FEATURE/sum implicit
prev features/sum
exec - iffe ${IFFEFLAGS} -v -c '${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}' \
exec - iffe ${IFFEFLAGS} -v -c '${CC} ${mam_cc_FLAGS} ${CCFLAGS} \
exec - ${mam_cc_NOSTRICTALIASING} ${LDFLAGS}' \
exec - ref ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} \
exec - -I${INSTALLROOT}/include ${mam_libast} : run ${<}
done
Expand All @@ -134,7 +135,7 @@ make install virtual
prev ${PACKAGE_ast_INCLUDE}/ast.h
done
done
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -c ${<}
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${mam_cc_NOSTRICTALIASING} -I. -I${PACKAGE_ast_INCLUDE} -c ${<}
done sumlib.o
exec - ${AR} rc ${@} ${<} || exit
exec - ranlib ${@} >/dev/null 2>&1 || true
Expand Down

0 comments on commit 1dc39bc

Please sign in to comment.