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

package: fix code for detecting 64-bit compiler

bin/package, src/cmd/INIT/package.sh:
- The code for detecting a 64-bit object file was seriously broken:
  the temporary file name could contain '64' because it included $$,
  the current PID, and 64-bit was detected if the output of 'file'
  (which includes the complete file name) contained '64'. Fix by
  removing the file name from 'file' output before testing.
- Also refactor that code a bit and remove the nonsensical test if
  /bin/sh is a 64-bit binary, which is neither here nor there. It's
  what the compiler produces that we need to care about.
This commit is contained in:
Martijn Dekker 2021-01-16 22:53:35 +00:00
parent 6025c8125e
commit 9a48ba1557
2 changed files with 14 additions and 32 deletions

View file

@ -2491,24 +2491,15 @@ int b() { return 0; }
esac
;;
*) case $bits in
'') case `file /bin/sh 2>/dev/null` in
*universal*64* | *64-bit* | *x86[_-]64*)
pwd=`pwd`
cd "$TMPDIR"
'') bits=` cd "$TMPDIR"
tmp=hi$$
trap 'rm -f $tmp.*' 0 1 2
cat > $tmp.a.c <<!
int main() { return 0; }
!
if $cc -o $tmp.a.exe $tmp.a.c
then case `file $tmp.a.exe` in
*64*) bits=64 ;;
esac
fi </dev/null >/dev/null 2>&1
rm -f $tmp.*
trap - 0 1 2
cd $pwd
;;
echo 'int main() { return 0; }' > $tmp.a.c
$cc -o $tmp.a.exe $tmp.a.c </dev/null >/dev/null 2>&1
file $tmp.a.exe 2>/dev/null | sed "s/$tmp\.a\.exe//g" `
case $bits in
*64*) bits=64 ;;
*) bits= ;;
esac
;;
esac

View file

@ -2490,24 +2490,15 @@ int b() { return 0; }
esac
;;
*) case $bits in
'') case `file /bin/sh 2>/dev/null` in
*universal*64* | *64-bit* | *x86[_-]64*)
pwd=`pwd`
cd "$TMPDIR"
'') bits=` cd "$TMPDIR"
tmp=hi$$
trap 'rm -f $tmp.*' 0 1 2
cat > $tmp.a.c <<!
int main() { return 0; }
!
if $cc -o $tmp.a.exe $tmp.a.c
then case `file $tmp.a.exe` in
*64*) bits=64 ;;
esac
fi </dev/null >/dev/null 2>&1
rm -f $tmp.*
trap - 0 1 2
cd $pwd
;;
echo 'int main() { return 0; }' > $tmp.a.c
$cc -o $tmp.a.exe $tmp.a.c </dev/null >/dev/null 2>&1
file $tmp.a.exe 2>/dev/null | sed "s/$tmp\.a\.exe//g" `
case $bits in
*64*) bits=64 ;;
*) bits= ;;
esac
;;
esac