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

Optimize server code #5456

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added enable_asan option
  • Loading branch information
matyhtf committed Aug 22, 2024
commit e0b3ccf07fe9c69ee2c5288e221821d4fd4aef7e
3 changes: 3 additions & 0 deletions .github/WORKFLOW-PARAMETERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ Setting this parameter will cause the test program to be run with `valgrind`.
```shell
git commit -m "commit message --filter=[core][unit] --valgrind"
```

## --asan
Setting this parameter will cause the test program to be run with `ASAN`.
5 changes: 5 additions & 0 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
sudo apt install -y valgrind
cd core-tests && SWOOLE_VALGRIND=1 ./run.sh

- name: make test with asan
if: "contains(github.event.head_commit.message, '--asan')"
run: |
cd core-tests && SWOOLE_ENABLE_ASAN=1 ./run.sh

- name: make test
run:
cd core-tests && ./run.sh
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ if (DEFINED enable_trace_log)
add_definitions(-DSW_LOG_TRACE_OPEN)
endif()

if (DEFINED enable_asan)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()

execute_process(COMMAND php-config --includes OUTPUT_VARIABLE PHP_INCLUDES OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND php-config --extension-dir OUTPUT_VARIABLE PHP_EXTENSION_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PHP_INCLUDES}")
Expand Down
4 changes: 4 additions & 0 deletions core-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ if (DEFINED enable_asan)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()

if (DEFINED enable_thread)
add_definitions(-DSW_THREAD)
endif()

# should execute before the add_executable command
link_directories(${core_tests_link_directories})

Expand Down
6 changes: 5 additions & 1 deletion core-tests/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash
cmake . -DSW_THREAD=1
if [ "${SWOOLE_ENABLE_ASAN}" = 1 ]; then
cmake . -D enable_thread=1 -D enable_asan=1
else
cmake . -D enable_thread=1
fi
make -j8
ipcs -q

Expand Down
Loading