Basil L. Contovounesios wrote:
> When compiling my project with Clang, ASan, and Gnulib's stdint-h,
> I find that PTRDIFF_MAX and SIZE_MAX expand to 1.
> ...
> I am reproducing the issue in a dummy project as follows:
> 0. git clone 'https://git.sr.ht/~blc/foo' && cd foo
> 4. ./test clang --enable-asan
This code contains:
foo_libasan="libclang_rt.asan-$(uname -m).so"
foo_ldflags=-shared-libasan
foo_preload="$(${foo_cc} -print-file-name="${foo_libasan}")"
...
./configure \
CC="${foo_cc}" \
CFLAGS="${foo_cflags}" \
${foo_ldflags:+LDFLAGS="${foo_ldflags}"} \
and this is not the right way to set configure with clang and ASAN.
The right way to do so is:
# Cf. https://clang.llvm.org/docs/AddressSanitizer.html
CC="clang -Wl,-rpath,$CLANG_INSTALLATION_DIR/lib -fsanitize=address"
export CC
CFLAGS="-O0 -fno-omit-frame-pointer -ggdb"
export CFLAGS
You are getting nonsense results because
1) you are not passing the documented option '-fsanitize=address'
but instead playing with libclang_rt in undocumented ways,
2) the environment variables LD_PRELOAD and ASAN_OPTIONS are not
active during the 'configure' step.
Both of these mistakes are fatal.
Bruno