Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: make debug doesn't produce a debug build #287

Closed
ee7 opened this issue May 6, 2024 · 2 comments · Fixed by #286
Closed

build: make debug doesn't produce a debug build #287

ee7 opened this issue May 6, 2024 · 2 comments · Fixed by #286

Comments

@ee7
Copy link
Contributor

ee7 commented May 6, 2024

The README.md for the pytest-based testing says that make debug is the way to produce a debug build of chalk:

For a debug build:
```sh
# root of the repo
make debug
```
The second command should drop a `chalk` binary that is usable by tests. You can also manually build with `nimble build`, but this is not recommended as it doesn't guarantee that the architecture will be compatible with the `tests` container.
WARNING: Debug builds are very slow, so it is not recommended to run the entire test suite on a debug build.

but that doesn't seem to work:

$ git clone --depth 1 https://github.com/crashappsec/chalk /tmp/chalk
$ cd /tmp/chalk
$ git log -1 --oneline
ca217bd (grafted, HEAD -> main, origin/main, origin/HEAD) test(fd_cache): make tests self-contained, and enable in CI (#276)
$ make debug
rm -f chalk chalk.bck
make chalk
make[1]: Entering directory '/tmp/chalk'
cp CHANGELOG.md src/docs/CHANGELOG.md
docker compose run --rm  chalk nimble -y build
[...]
+ strip chalk
+ ./chalk --debug --no-use-external-config --skip-command-report load default
[...]
make[1]: Leaving directory '/tmp/chalk'
$ file chalk
chalk: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

The fact that strip runs above shows that -d:debug isn't passed to nimble build:

chalk/chalk.nimble

Lines 78 to 81 in 46ffecd

after build:
when not defined(debug):
exec "set -x && strip " & bin[0]
exec "set -x && ./" & bin[0] & " --debug --no-use-external-config --skip-command-report load default"

In the Makefile:

chalk/Makefile

Lines 47 to 52 in ca217bd

.PHONY: debug release
debug: CHALK_BUILD=build --define:debug
release: CHALK_BUILD=build
debug release:
-rm -f $(BINARY) $(BINARY).bck
$(MAKE) $(BINARY)

@miki725
Copy link
Contributor

miki725 commented May 6, 2024

fixed in 5b825df (#286)

@ee7
Copy link
Contributor Author

ee7 commented May 6, 2024

Thanks. That does cause make debug to pass --define:debug to the build command, with the output containing:

docker compose run --rm  chalk nimble -y build --define:debug

However, strip still runs. Unfortunately, it turns out that nimble still doesn't support checking a custom define in the nimble file (see upstream ticket).

I'll fix that. Edit: created PR #289

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants