On Sat, Nov 10, 2007 at 12:53:09 +0100, Pierre Habouzit wrote:
> for some reason when building on a biarch machine you have to tell him you
> want the 64bits API. Run:
>
> cgcc -m64 .... yourtest.c
>
> and it will work as expected.
Thanks for that hint; it does indeed.
> cgcc is a tiny wrapper, and I believe it's the place where you have to
> fix that -m64 for sparse. I'll have a deeper look.
I don't think it's really a bug in the wrapper.
Here's what I did, using a simplified test file, test2.c:
1 /* Build with `cgcc -Wall test.c' */
2
3 #include <stdio.h>
4
5 int main(int argc, char **argv) {
6 long int li;
7 long long int lli;
8
9 li = (11644473600UL);
10 /* sparse outputs
11 warning: constant 11644473600UL is so big it is unsigned
12 long long
13 warning: cast truncates bits from constant value
(2b6109100
14 becomes b6109100)
15 */
16
17 return 0;
18 }
I've been testing with the current git version of sparse.
Using strace, I could identify the "sparse" invocation as
/home/ray/devel/sparse/sparse-git/sparse -c test2.c -Dx86_64=1
-D__x86_64=1 -D__x86_64__=1 -D__CHAR_BIT__=8 -D__SCHAR_MAX__=127
-D__SHRT_MAX__=32767 -D__INT_MAX__=2147483647
-D__LONG_MAX__=9223372036854775807L -D__LONG_LONG_MAX__=9223372036854775807LL
-D__FLT_RADIX__=2 -D__FINITE_MATH_ONLY__=0 -D__DECIMAL_DIG__=33
-D__FLT_MANT_DIG__=24 -D__FLT_DIG__=6 -D__FLT_MIN_EXP__='(-125)'
-D__FLT_MAX_EXP__=128 -D__FLT_MIN_10_EXP__='(-37)' -D__FLT_MAX_10_EXP__=38
-D__FLT_HAS_INFINITY__=1 -D__FLT_HAS_QUIET_NAN__=1
-D__FLT_DENORM_MIN__=1.40129846e-45F -D__FLT_EPSILON__=1.19209290e-7F
-D__FLT_MAX__=3.40282347e+38F -D__FLT_MIN__=1.17549435e-38F
-D__DBL_MANT_DIG__=53 -D__DBL_DIG__=15 -D__DBL_MIN_EXP__='(-1021)'
-D__DBL_MAX_EXP__=1024 -D__DBL_MIN_10_EXP__='(-307)' -D__DBL_MAX_10_EXP__=308
-D__DBL_HAS_INFINITY__=1 -D__DBL_HAS_QUIET_NAN__=1
-D__DBL_DENORM_MIN__=4.9406564584124654e-324
-D__DBL_EPSILON__=2.2204460492503131e-16 -D__DBL_MAX__=1.7976931348623157e+308
-D__DBL_MIN__=2.2250738585072014e-308 -D__LDBL_MANT_DIG__=113 -D__LDBL_DIG__=33
-D__LDBL_MIN_EXP__='(-16381)' -D__LDBL_MAX_EXP__=16384
-D__LDBL_MIN_10_EXP__='(-4931)' -D__LDBL_MAX_10_EXP__=4932
-D__LDBL_HAS_INFINITY__=1 -D__LDBL_HAS_QUIET_NAN__=1
-D__LDBL_DENORM_MIN__=6.47517511943802511092443895822764655e-4966L
-D__LDBL_EPSILON__=1.92592994438723585305597794258492732e-34L
-D__LDBL_MAX__=1.18973149535723176508575932662800702e+4932L
-D__LDBL_MIN__=3.36210314311209350626267781732175260e-4932L -U__SIZE_TYPE__
-D__SIZE_TYPE__=long\ unsigned\ int -Dunix=1 -D__unix=1 -D__unix__=1
-D__linux__=1 -D__linux=1 -Dlinux=linux
Regarding the line
li = (11644473600UL);
When sparse is invoked as above, so without -m64 or -m32:
cast_value() is called for this expression/line, and the Int: block in it is
reached. The "cast truncates bits from constant value" is output (the middle
condition of the if around it evaluates to true).
Here are the various values and conditions (obtained by adding some debug
lines to expand.c):
test2.c:9:8: warning: value: 2b6109100; dropped: ffffffff00000000;
value & dropped: 200000000
test2.c:9:8: warning: dropped: ffffffff00000000; oldsignmask:
8000000000000000; signmask: 80000000
test2.c:9:8: warning: value: 2b6109100; oldsignmask: 8000000000000000;
!(value & oldsignmask): 1
test2.c:9:8: warning: value: 2b6109100; signmask: 80000000; !(value &
signmask): 0
test2.c:9:8: warning: value: 2b6109100; dropped: ffffffff00000000;
(value & dropped) != dropped: 1
test2.c:9:8: warning: cast truncates bits from constant value
11644473600 (2b6109100 becomes b6109100)
When -m64 is added to the invocation above:
cast_value() in expand.c is called for this expression/line, but the Int:
block in it is not reached for it, as old_size == new_size.
So the "sparse" command itself behaves differently on amd64 when "-m64" is
specified than when neither "-m32" nor "-m64" is specified; that seems buggy
to me.
HTH,
Ray
--
THEY planted The Lone Gunmen to MIND CONTROL the public into seeing TRUTH
SEEKERS as CONSPIRACY NUTS.