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

Change Makefile to generate/extract symbols files at src/symbols during post-compilation (last step of project build) (only macOS) #12711

Closed
2 tasks done
Tracked by #9910
jnasselle opened this issue Mar 14, 2022 · 1 comment · Fixed by #12853
Assignees
Labels
module/agent Issues related to the agent daemon module/building Compilation of the core product platform/macos

Comments

@jnasselle
Copy link
Member

jnasselle commented Mar 14, 2022

Epic
#9913

Description

This issue aims to extract the symbols (strip) once the generation of the binaries is done, this task is done as long as the variable STRIP_SYMBOLS is true, the output directory of this is wazuh/src/symbols

The default extension for symbols bundle should be .dSYM

Execute this task, based on the result of this spike: #9910 (comment)

DoD

  • Execute dsymutil against binaries that will be part of the agent as post generation task
  • Strip debug information of those binaries if STRIP_SYMBOLS is true
@jnasselle jnasselle added module/agent Issues related to the agent daemon platform/macos module/building Compilation of the core product labels Mar 14, 2022
@RamiroRD RamiroRD self-assigned this Mar 21, 2022
@RamiroRD
Copy link
Contributor

RamiroRD commented Mar 23, 2022

Currently updating the makefile to use a static pattern rule that automatically generates the .dSYM folders in symbols/ from a list of executables and shared libraries that need to be stripped.
The following commands should be able to find all executables and shared libraries on macOS (they are meant to be run on <repo root>/src:

find . -maxdepth 1 -type f -not -path "./external/*"  -exec /bin/sh -c "file {} | grep 'bit executable' > /dev/null" \; -print 
find . -type f -not -path "./external/*" -name  "*.dylib" -print 

The only executable excluded here would be the sysinfo test tool, which should be fine.


BUILD_AGENT=$(shell find . -maxdepth 1 -type f -not -path "./external/*"  -exec /bin/sh -c "file {} | grep 'bit executable' > /dev/null" \; -print)
BUILD_AGENT+=$(shell find . -type f -not -path "./external/*" -name  "*.dylib" -print)


SYMBOLS_AGENT=$(BUILD_AGENT:./%=symbols/%.dSYM)

all: $(SYMBOLS_AGENT)

# This will extract symbols and then strip the binaries
$(SYMBOLS_AGENT): symbols/%.dSYM:%
	@echo $(SYMBOLS_AGENT)
	@echo "$@ <- $?"
	dsymutil -o $@ $?
	strip $?


clean:
	rm -rvf symbols/*.dSYM
	rm $(BUILD_AGENT)

prep:
	cp backup/* .

@jnasselle jnasselle linked a pull request Mar 29, 2022 that will close this issue
28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/agent Issues related to the agent daemon module/building Compilation of the core product platform/macos
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants