facil-io / cstl

facil.io C STL - a Server Toolbox Library for C, including JSON processing, hash maps, dynamic arrays, binary strings and more.
https://facil.io
MIT License
68 stars 6 forks source link

According to `make -n`, the `db/` prefix isn't quite working as expected #19

Closed michaellenaghan closed 12 months ago

michaellenaghan commented 12 months ago

I'm looking into another issue, but while testing I noticed that using a db/ prefix isn't quite working as expected.

The makefile says:

#   Run tests (i.e., the test file `foo.c`) with:       `make tests/foo`
#   Run tests with DEBUG mode (no optimizations) with:  `make db/tests/foo`

But here's the output of make db/tests/array -n:

* Building single-file header: fio-stl.h
* Building documentation: fio-stl.md
* Detected the OpenSSL library, setting HAVE_OPENSSL
* Detected the zlib library, setting HAVE_ZLIB
rm -f tmp/app 2> /dev/null || echo "" >> /dev/null
rm -R -f tmp 2> /dev/null || echo "" >> /dev/null
rm -R -f tmp 2> /dev/null || echo "" >> /dev/null
mkdir -p tmp tmp/tests tmp/examples  tmp/lib  tmp/src  tmp/tests 2> /dev/null
echo "* Set debug flags."
mkdir -p tmp tmp/tests tmp/examples  tmp/lib  tmp/src  tmp/tests 2> /dev/null
echo "* Set testing flags (array)"
echo "* Compiling tests/array.c"
time cc -c tests/array.c -o tmp/tests/array.o -MT tmp/tests/array.o -MMD -MP -I/opt/local/libexec/openssl3/include -g -std=gnu11 -fpic -DFIO_LEAK_COUNTER -DNDEBUG -DNODEBUG -DHAVE_OPENSSL -DFIO_TLS_FOUND -DHAVE_ZLIB -Wshadow -Wall -Wextra -Wpedantic -Wno-missing-field-initializers -Wformat-security -I. -Ilib -Isrc -Itests  -DDEBUG=1 -fno-builtin -DTEST=1 -DFIO_WEAK_TLS -O0 -g -coverage -fsanitize=address -fno-omit-frame-pointer -fno-builtin
otool -dtVGX tmp/tests/array.o >> tmp/tests/array.s
echo "* Linking... (tmp/array)"
time cc -o tmp/array tmp/tests/array.o -O0 -g -coverage -fsanitize=address -fno-omit-frame-pointer -fno-builtin -g -DDEBUG=1 -L/opt/local/libexec/openssl3/lib -lssl -lcrypto -lpthread -lm -lz
echo "* Finished build (tmp/array)"
tmp/array

Notice that the compile line has ... -DNDEBUG -DNODEBUG ... -DDEBUG=1 ..., a mixture of "no debug" and "debug" flags.

(Notice too that there are CFLAGS on the link line.)

This probably doesn't matter too much, because facil itself doesn't use NDEBUG at all, and only uses NODEBUG in one spot:

https://github.com/facil-io/cstl/blob/9a04d28d3a8c16c6eef593c0a3870e99cd86ee0d/fio-stl/902%20string%20core.h#L466

This is, in the grand scheme of things, not very important; I'll offer a fix next week when I have a chance to take a closer look.

boazsegev commented 12 months ago

fixed in commit https://github.com/facil-io/cstl/commit/5d7f09f53a19190f665fee8d4901008d4388b0ca