1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix release and standards build flags (re: 35672208, aa4669ad)

bin/package, src/cmd/INIT/package.sh:
- CCFLAGS overwrites the autodetected optimisation flags (e.g. -Os)
  if set. Unfortunately, that also happened when we added something
  to CCFLAGS for a release build or to add an extra flag needed by
  Solaris. The fix is to use a new flags variable (KSH_RELFLAGS)
  instead. This needs to be done in a different place as it needs
  to be added to the mamake command as an assignment argument.
- Remove the Solaris CCFLAGS hack; see features/common below.

src/*/*/Mamfile:
- Add ${KSH_RELFLAGS} to all the compiler commands.

src/lib/libast/features/common:
- Enable POSIX standard on Solaris (i.e.: if __sun is defined) by
  defining _XPG6 directly in the feature test that generates
  ast_std.h, which is indirectly included by everything. This
  removes the need to pass -D_XPG6 via CCFLAGS. (Doing so
  automatically with gcc was not otherwise possible.)

src/cmd/INIT/cc.sol11.*:
- No longer pass -D_XPG6, as per above.
This commit is contained in:
Martijn Dekker 2021-01-18 01:07:45 +00:00
parent e25d9f4190
commit 580ff61617
14 changed files with 925 additions and 922 deletions

View file

@ -7,6 +7,7 @@ setv AS as
setv ASFLAGS
setv CC cc
setv mam_cc_FLAGS
setv KSH_RELFLAGS
setv CCFLAGS ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?}
setv CCLDFLAGS ${-strip-symbols?1?${mam_cc_LD_STRIP}??}
setv COTEMP $$
@ -532,9 +533,9 @@ done ast.h dontcare virtual
done mamake.c
meta mamake.o %.c>%.o mamake.c mamake
prev mamake.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -DUSAGE_LICENSE=\""[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyright (c) 1994-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html]"\" -c mamake.c
exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} -DUSAGE_LICENSE=\""[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyright (c) 1994-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html]"\" -c mamake.c
done mamake.o generated
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} -o mamake mamake.o
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -o mamake mamake.o
done mamake generated
make proto
make proto.o
@ -542,9 +543,9 @@ make proto.c
done proto.c
meta proto.o %.c>%.o proto.c proto
prev proto.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -c proto.c
exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} -c proto.c
done proto.o generated
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} -o proto proto.o
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -o proto proto.o
done proto generated
make ratz
make ratz.o
@ -567,9 +568,9 @@ prev ast.h implicit
done ratz.c
meta ratz.o %.c>%.o ratz.c ratz
prev ratz.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -c ratz.c
exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} -c ratz.c
done ratz.o generated
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} -o ratz ratz.o
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -o ratz ratz.o
done ratz generated
make release
make release.o
@ -578,9 +579,9 @@ prev ast.h implicit
done release.c
meta release.o %.c>%.o release.c release
prev release.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -DUSAGE_LICENSE=\""[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyright (c) 1994-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html]"\" -c release.c
exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} -DUSAGE_LICENSE=\""[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyright (c) 1994-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html]"\" -c release.c
done release.o generated
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} -o release release.o
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -o release release.o
done release generated
make mprobe
make mprobe.sh

View file

@ -1,4 +1,4 @@
: solaris.i386 cc wrapper for reasonable ansi C defaults and 32 bit : 2021-01-16 :
: solaris.i386 cc wrapper for reasonable ansi C defaults and 32 bit : 2021-01-17 :
HOSTTYPE=sol11.i386
@ -13,4 +13,6 @@ case ${CC_EXPLICIT:=$CC} in
CC_EXPLICIT=cc
esac
$CC_EXPLICIT -m32 -xc99 -D_XPG6 "$@"
# Note: the _XPG6 macro is now defined in src/lib/libast/features/common
$CC_EXPLICIT -m32 -xc99 "$@"

View file

@ -1,4 +1,4 @@
: solaris.i386-64 cc wrapper for reasonable ansi C defaults and 64 bit : 2021-01-16 :
: solaris.i386-64 cc wrapper for reasonable ansi C defaults and 64 bit : 2021-01-17 :
HOSTTYPE=sol11.i386-64
@ -13,4 +13,6 @@ case ${CC_EXPLICIT:=$CC} in
CC_EXPLICIT=cc
esac
$CC_EXPLICIT -m64 -xc99 -D_XPG6 "$@"
# Note: the _XPG6 macro is now defined in src/lib/libast/features/common
$CC_EXPLICIT -m64 -xc99 "$@"

View file

@ -1,4 +1,4 @@
: solaris.sparc cc wrapper for reasonable ansi C defaults and 32 bit : 2021-01-16 :
: solaris.sparc cc wrapper for reasonable ansi C defaults and 32 bit : 2021-01-17 :
HOSTTYPE=sol11.sparc
@ -13,4 +13,6 @@ case ${CC_EXPLICIT:=$CC} in
CC_EXPLICIT=cc
esac
$CC_EXPLICIT -m32 -xc99 -D_XPG6 "$@"
# Note: the _XPG6 macro is now defined in src/lib/libast/features/common
$CC_EXPLICIT -m32 -xc99 "$@"

View file

@ -1,4 +1,4 @@
: solaris.sparc-64 cc wrapper for reasonable ansi C defaults and 64 bit : 2021-01-16 :
: solaris.sparc-64 cc wrapper for reasonable ansi C defaults and 64 bit : 2021-01-17 :
HOSTTYPE=sol11.sparc-64
@ -13,4 +13,6 @@ case ${CC_EXPLICIT:=$CC} in
CC_EXPLICIT=cc
esac
$CC_EXPLICIT -m64 -xc99 -D_XPG6 "$@"
# Note: the _XPG6 macro is now defined in src/lib/libast/features/common
$CC_EXPLICIT -m64 -xc99 "$@"

View file

@ -1383,6 +1383,40 @@ case $CC in
*) export CC ;;
esac
# Add build type flags via KSH_RELFLAGS, which is used in src/cmd/ksh93/Mamfile.
# (Avoid using CCFLAGS; setting it would overwrite autodetected optimization flags.)
ksh_relflags=
case `git branch 2>/dev/null` in
'' | *\*\ [0-9]*.[0-9]*)
# If we're not on a git branch (tarball) or on a branch that starts
# with a number (release branch), then compile as a release version
ksh_relflags="${ksh_relflags:+$ksh_relflags }-D_AST_ksh_release" ;;
*) # Otherwise, add 8-character git commit hash if available, and if the working dir is clean
git_commit=`git status >/dev/null 2>&1 && git diff-index --quiet HEAD && git rev-parse --short=8 HEAD`
case $git_commit in
????????)
ksh_relflags="${ksh_relflags:+$ksh_relflags }-D_AST_git_commit=\\\"$git_commit\\\"" ;;
esac
unset git_commit ;;
esac
case $ksh_relflags in
?*) # add the extra flags as an argument to mamake
assign="${assign:+$assign }KSH_RELFLAGS=\"\$ksh_relflags\"" ;;
esac
# Hack to build on some systems that need an explicit link with libm due to a bug in the build system
case `uname` in
NetBSD | SunOS)
case " $LDFLAGS " in
*" -m "*)
;;
*) LDFLAGS="-lm${LDFLAGS:+ $LDFLAGS}"
export LDFLAGS
;;
esac
;;
esac
# grab action specific args
case $action in
@ -5401,49 +5435,6 @@ license)# all work in $PACKAGESRC/LICENSES
;;
make|view)
# Add flags for build type
case `git branch 2>/dev/null` in
'' | *\*\ [0-9]*.[0-9]*)
# If we're not on a git branch (tarball) or on a branch that starts
# with a number (release branch), then compile as a release version
CCFLAGS="-D_AST_ksh_release${CCFLAGS:+ $CCFLAGS}" # prefix it to allow override with -U
export CCFLAGS
;;
*) # Otherwise, add 8-character git commit hash if available, and if the working dir is clean
git_commit=`git status >/dev/null 2>&1 && git diff-index --quiet HEAD && git rev-parse --short=8 HEAD`
case $git_commit in
????????)
CCFLAGS="-D_AST_git_commit=\\\"$git_commit\\\"${CCFLAGS:+ $CCFLAGS}"
export CCFLAGS
;;
esac
unset git_commit
;;
esac
# Hack to build on some systems that need an explicit link with libm due to a bug in the build system
case `uname` in
NetBSD | SunOS)
case " $LDFLAGS " in
*" -m "*)
;;
*) LDFLAGS="-lm${LDFLAGS:+ $LDFLAGS}"
export LDFLAGS
;;
esac
;;
esac
# Hack for Solaris gcc, which needs -D_XPG6 in C flags to not segfault
case `uname` in
SunOS) case "$CC, $CCFLAGS " in
*" -D_XPG6 "*)
;;
*gcc,*) CCFLAGS="-D_XPG6${CCFLAGS:+ $CCFLAGS}"
export CCFLAGS
;;
esac
;;
esac
cd $PACKAGEROOT
case $package in
'') lic="lib/package/*.lic"