Skip to content

Commit

Permalink
package: check for changes in $CC, etc. earlier (re: 48e6dd9)
Browse files Browse the repository at this point in the history
The check if $CC was changed did not work because it came after
code that stored $CC in the generated bin/cc script and then set
the CC variable to 'cc'. The fix is to check before that. The
corresponding code block is moved accordingly. Some tweaks for
robustness are also applied.

Unfortunately, after this commit, if you are using a build
directory where you had set CC to a custom compiler path, you'll
now get a spurious error that it has changed from 'cc' because the
bug caused it to remmeber that value. To fix this, remove the file
arch/*/lib/package/gen/CC.
  • Loading branch information
McDutchie committed Jan 14, 2024
1 parent 76c6bdc commit 5e6c421
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 72 deletions.
73 changes: 37 additions & 36 deletions bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ command=${0##*/}
case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
0123) USAGE=$'
[-?
@(#)$Id: '$command$' (ksh 93u+m) 2024-01-02 $
@(#)$Id: '$command$' (ksh 93u+m) 2024-01-14 $
]
[-author?Glenn Fowler <[email protected]>]
[-author?Contributors to https://github.com/ksh93/ksh]
Expand Down Expand Up @@ -543,7 +543,7 @@ SEE ALSO
pkgadd(1), pkgmk(1), rpm(1), sh(1), tar(1), optget(3)

IMPLEMENTATION
version package (ksh 93u+m) 2024-01-02
version package (ksh 93u+m) 2024-01-14
author Glenn Fowler <[email protected]>
author Contributors to https://github.com/ksh93/ksh
copyright (c) 1994-2012 AT&T Intellectual Property
Expand Down Expand Up @@ -2819,6 +2819,41 @@ make|view)
;;
esac

# check against previous compiler and flags

err=
for var in CC CCFLAGS CCLDFLAGS LDFLAGS
do store=$INSTALLROOT/lib/package/gen/$var
eval "new=\$$var"
if test -e "$store"
then old=$(cat "$store") || exit
case $old in
"$new") ;;
*) case $old in
'') old="(none)" ;;
*) old="'$old'" ;;
esac
case $new in
'') new="(none)" ;;
*) new="'$new'" ;;
esac
note "$var changed from $old to $new"
err=y ;;
esac
elif test -d "$INSTALLROOT/lib/package/gen" # does not exist if 'bin/package debug make'
then case $new in
'') ;;
*) echo "$new" ;;
esac > $store || exit
fi
done
case $err,${FORCE_FLAGS+f} in
y,) err_out "This would likely break the build. Restore the flag(s)," \
"or delete the build directory and rebuild from scratch."
;;
esac
unset err var store old new

# remember the default $CC

case $CC in
Expand Down Expand Up @@ -2894,40 +2929,6 @@ make|view)
view) exit 0 ;;
esac

# check against previous compiler and flags

err=
for var in CC CCFLAGS CCLDFLAGS LDFLAGS
do store=$INSTALLROOT/lib/package/gen/$var
eval "new=\$$var"
if test -f $store
then old=$(cat $store)
case $old in
"$new") ;;
*) case $old in
'') old="(none)" ;;
*) old="'$old'" ;;
esac
case $new in
'') new="(none)" ;;
*) new="'$new'" ;;
esac
note "$var changed from $old to $new"
err=y ;;
esac
else test -d $INSTALLROOT/lib/package/gen && case $new in
'') ;;
*) echo "$new" ;;
esac > $store
fi
done
case $err,${FORCE_FLAGS+f} in
y,) err_out "This would likely break the build. Restore the flag(s)," \
"or delete the build directory and rebuild from scratch."
;;
esac
unset err var store old new

# all work under $INSTALLROOT/src

$make cd $INSTALLROOT/src
Expand Down
73 changes: 37 additions & 36 deletions src/cmd/INIT/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ command=${0##*/}
case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in
0123) USAGE=$'
[-?
@(#)$Id: '$command$' (ksh 93u+m) 2024-01-02 $
@(#)$Id: '$command$' (ksh 93u+m) 2024-01-14 $
]
[-author?Glenn Fowler <[email protected]>]
[-author?Contributors to https://github.com/ksh93/ksh]
Expand Down Expand Up @@ -543,7 +543,7 @@ SEE ALSO
pkgadd(1), pkgmk(1), rpm(1), sh(1), tar(1), optget(3)
IMPLEMENTATION
version package (ksh 93u+m) 2024-01-02
version package (ksh 93u+m) 2024-01-14
author Glenn Fowler <[email protected]>
author Contributors to https://github.com/ksh93/ksh
copyright (c) 1994-2012 AT&T Intellectual Property
Expand Down Expand Up @@ -2819,6 +2819,41 @@ make|view)
;;
esac

# check against previous compiler and flags

err=
for var in CC CCFLAGS CCLDFLAGS LDFLAGS
do store=$INSTALLROOT/lib/package/gen/$var
eval "new=\$$var"
if test -e "$store"
then old=$(cat "$store") || exit
case $old in
"$new") ;;
*) case $old in
'') old="(none)" ;;
*) old="'$old'" ;;
esac
case $new in
'') new="(none)" ;;
*) new="'$new'" ;;
esac
note "$var changed from $old to $new"
err=y ;;
esac
elif test -d "$INSTALLROOT/lib/package/gen" # does not exist if 'bin/package debug make'
then case $new in
'') ;;
*) echo "$new" ;;
esac > $store || exit
fi
done
case $err,${FORCE_FLAGS+f} in
y,) err_out "This would likely break the build. Restore the flag(s)," \
"or delete the build directory and rebuild from scratch."
;;
esac
unset err var store old new

# remember the default $CC

case $CC in
Expand Down Expand Up @@ -2894,40 +2929,6 @@ make|view)
view) exit 0 ;;
esac

# check against previous compiler and flags

err=
for var in CC CCFLAGS CCLDFLAGS LDFLAGS
do store=$INSTALLROOT/lib/package/gen/$var
eval "new=\$$var"
if test -f $store
then old=$(cat $store)
case $old in
"$new") ;;
*) case $old in
'') old="(none)" ;;
*) old="'$old'" ;;
esac
case $new in
'') new="(none)" ;;
*) new="'$new'" ;;
esac
note "$var changed from $old to $new"
err=y ;;
esac
else test -d $INSTALLROOT/lib/package/gen && case $new in
'') ;;
*) echo "$new" ;;
esac > $store
fi
done
case $err,${FORCE_FLAGS+f} in
y,) err_out "This would likely break the build. Restore the flag(s)," \
"or delete the build directory and rebuild from scratch."
;;
esac
unset err var store old new

# all work under $INSTALLROOT/src

$make cd $INSTALLROOT/src
Expand Down

0 comments on commit 5e6c421

Please sign in to comment.