Skip to content

Commit 20d4c6b

Browse files
authored
Merge pull request #539 from PatKamin/ci-libbacktrace
[ci] Test tracing using libbacktrace
2 parents 2ed1735 + bd7f33b commit 20d4c6b

File tree

7 files changed

+65
-36
lines changed

7 files changed

+65
-36
lines changed

.github/workflows/cmake.yml

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1-
name: CMake
1+
name: Build and test
22

33
on: [push, pull_request]
44

5-
env:
6-
BUILD_TYPE: Release
7-
85
jobs:
96
ubuntu-build:
107
name: Build - Ubuntu
118
strategy:
129
matrix:
13-
config:
14-
- {os: 'ubuntu-20.04', compiler: {c: gcc, cxx: g++}}
15-
- {os: 'ubuntu-22.04', compiler: {c: gcc, cxx: g++}}
16-
- {os: 'ubuntu-22.04', compiler: {c: clang, cxx: clang++}}
17-
runs-on: ${{matrix.config.os}}
10+
os: ['ubuntu-20.04', 'ubuntu-22.04']
11+
build_type: [Debug, Release]
12+
compiler: [{c: gcc, cxx: g++}]
13+
libbacktrace: ['-DVAL_USE_LIBBACKTRACE_BACKTRACE=OFF']
14+
include:
15+
- os: 'ubuntu-22.04'
16+
build_type: Release
17+
compiler: {c: clang, cxx: clang++}
18+
libbacktrace: '-DVAL_USE_LIBBACKTRACE_BACKTRACE=OFF'
19+
- os: 'ubuntu-22.04'
20+
build_type: Release
21+
compiler: {c: gcc, cxx: g++}
22+
libbacktrace: '-DVAL_USE_LIBBACKTRACE_BACKTRACE=ON'
23+
- os: 'ubuntu-22.04'
24+
build_type: Release
25+
compiler: {c: clang, cxx: clang++}
26+
libbacktrace: '-DVAL_USE_LIBBACKTRACE_BACKTRACE=ON'
27+
28+
runs-on: ${{matrix.os}}
1829

1930
steps:
2031
- uses: actions/checkout@v3
@@ -27,37 +38,47 @@ jobs:
2738
- name: Install pip packages
2839
run: pip install -r third_party/requirements.txt
2940

41+
- name: Install libbacktrace
42+
if: matrix.libbacktrace == '-DVAL_USE_LIBBACKTRACE_BACKTRACE=ON'
43+
run: |
44+
git clone https://github.com/ianlancetaylor/libbacktrace.git
45+
cd libbacktrace
46+
./configure
47+
make
48+
sudo make install
49+
cd ..
50+
3051
- name: Configure CMake
3152
run: >
3253
cmake
3354
-B${{github.workspace}}/build
34-
-DCMAKE_C_COMPILER=${{matrix.config.compiler.c}}
35-
-DCMAKE_CXX_COMPILER=${{matrix.config.compiler.cxx}}
55+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
56+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
3657
-DUR_ENABLE_TRACING=ON
3758
-DUR_DEVELOPER_MODE=ON
38-
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
59+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
3960
-DUR_BUILD_TESTS=ON
4061
-DUR_FORMAT_CPP_STYLE=ON
62+
${{matrix.libbacktrace}}
4163
4264
- name: Generate source from spec, check for uncommitted diff
43-
if: matrix.config.os == 'ubuntu-22.04'
65+
if: matrix.os == 'ubuntu-22.04'
4466
run: cmake --build ${{github.workspace}}/build --target check-generated
4567

4668
- name: Build
47-
run: cmake --build ${{github.workspace}}/build
69+
run: cmake --build ${{github.workspace}}/build -j $(nproc)
4870

4971
- name: Test
5072
working-directory: ${{github.workspace}}/build
51-
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure -L "python|uma|loader|validation|tracing|unit|urtrace"
73+
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|uma|loader|validation|tracing|unit|urtrace"
5274

5375
windows-build:
5476
name: Build - Windows
5577
strategy:
5678
matrix:
57-
config:
58-
- {os: 'windows-2019'}
59-
- {os: 'windows-2022'}
60-
runs-on: ${{matrix.config.os}}
79+
os: ['windows-2019', 'windows-2022']
80+
build_type: [Debug, Release]
81+
runs-on: ${{matrix.os}}
6182

6283
steps:
6384
- uses: actions/checkout@v3
@@ -80,12 +101,12 @@ jobs:
80101
-DUR_FORMAT_CPP_STYLE=ON
81102
82103
- name: Generate source from spec, check for uncommitted diff
83-
if: matrix.config.os == 'windows-2022'
84-
run: cmake --build ${{github.workspace}}/build --target check-generated --config ${{env.BUILD_TYPE}}
104+
if: matrix.os == 'windows-2022'
105+
run: cmake --build ${{github.workspace}}/build --target check-generated --config ${{matrix.build_type}}
85106

86107
- name: Build all
87-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
108+
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j 2
88109

89110
- name: Test
90111
working-directory: ${{github.workspace}}/build
91-
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure -L "python|uma|loader|validation|tracing|unit|urtrace"
112+
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|uma|loader|validation|tracing|unit|urtrace"

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2022-2023 Intel Corporation
22
# SPDX-License-Identifier: MIT
33

4-
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
4+
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
55
project(unified-runtime VERSION 0.6.0)
66

77
include(GNUInstallDirs)
@@ -70,7 +70,7 @@ if(NOT MSVC)
7070
link_libraries(stdc++fs)
7171
endif()
7272
elseif(MSVC)
73-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
73+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
7474
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
7575
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
7676
add_compile_options(/MP /W3)
@@ -103,8 +103,12 @@ if(UR_ENABLE_TRACING)
103103
if (MSVC)
104104
set_property(TARGET xpti PROPERTY MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}")
105105
set_property(TARGET xptifw PROPERTY MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}")
106+
set(TARGET_XPTI $<IF:$<CONFIG:Release>,xpti,xptid>)
107+
106108
# disable warning C4267: The compiler detected a conversion from size_t to a smaller type.
107109
target_compile_options(xptifw PRIVATE /wd4267)
110+
else()
111+
set(TARGET_XPTI xpti)
108112
endif()
109113
endif()
110114

examples/collector/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(${TARGET_NAME} PRIVATE
1111
${CMAKE_SOURCE_DIR}/include
1212
)
1313

14-
target_link_libraries(${TARGET_NAME} PRIVATE xpti ${CMAKE_DL_LIBS})
14+
target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_XPTI})
1515
target_include_directories(${TARGET_NAME} PRIVATE ${xpti_SOURCE_DIR}/include)
1616

1717
if(MSVC)

source/loader/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ target_link_libraries(ur_loader PRIVATE
3636
)
3737

3838
if(UR_ENABLE_TRACING)
39-
target_link_libraries(ur_loader PRIVATE xpti)
39+
target_link_libraries(ur_loader PRIVATE ${TARGET_XPTI})
4040
target_include_directories(ur_loader PRIVATE ${xpti_SOURCE_DIR}/include)
4141
target_compile_definitions(ur_loader PRIVATE XPTI_STATIC_LIBRARY)
4242
endif()
@@ -92,8 +92,10 @@ endif()
9292

9393

9494
# link validation backtrace dependencies
95-
find_package(Libbacktrace)
96-
if (VAL_USE_LIBBACKTRACE_BACKTRACE AND LIBBACKTRACE_FOUND AND UNIX)
95+
if(UNIX)
96+
find_package(Libbacktrace)
97+
endif()
98+
if (VAL_USE_LIBBACKTRACE_BACKTRACE AND LIBBACKTRACE_FOUND)
9799
message(STATUS "Using libbacktrace backtrace for validation")
98100

99101
target_sources(ur_loader PRIVATE

source/loader/layers/validation/backtrace_libbacktrace.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ int backtrace_cb(void *data, uintptr_t pc, const char *filename, int lineno,
4242
} else if (function != NULL) {
4343
backtraceLine << "(" << function << ") ";
4444
} else {
45-
backtraceLine << "(????????) ";
45+
// Note: Escaping the last '?' character to avoid creation of a trigraph character
46+
backtraceLine << "(???????\?) ";
4647
}
4748

4849
char filepath[PATH_MAX];
4950
if (realpath(filename, filepath) != NULL) {
5051
backtraceLine << "(" << filepath << ":" << std::dec << lineno << ")";
5152
} else {
52-
backtraceLine << "(????????)";
53+
// Note: Escaping the last '?' character to avoid creation of a trigraph character
54+
backtraceLine << "(???????\?)";
5355
}
5456

5557
std::vector<std::string> *backtrace =

tools/urtrace/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(${TARGET_NAME} PRIVATE
1111
${CMAKE_SOURCE_DIR}/include
1212
)
1313

14-
target_link_libraries(${TARGET_NAME} PRIVATE xpti ${PROJECT_NAME}::common ${CMAKE_DL_LIBS})
14+
target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_XPTI} ${PROJECT_NAME}::common ${CMAKE_DL_LIBS})
1515
target_include_directories(${TARGET_NAME} PRIVATE ${xpti_SOURCE_DIR}/include)
1616

1717
if(MSVC)

tools/urtrace/urtrace

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ if args.debug:
6262
print(config)
6363
env = dict()
6464

65-
env['UR_LOG_COLLECTOR']="level:info;output:stderr;flush:info"
6665
collector_args = ""
6766
if args.print_begin:
6867
collector_args += "print_begin;"
@@ -81,15 +80,16 @@ env['UR_COLLECTOR_ARGS'] = collector_args
8180
log_collector = ""
8281
if args.debug:
8382
log_collector += "level:debug;"
83+
log_collector += "flush:debug;"
8484
else:
8585
log_collector += "level:info;"
86+
log_collector += "flush:info;"
8687
if args.file:
8788
log_collector += "output:file," + args.file + ";"
8889
elif args.stdout:
89-
log_collector += "output:stdout;"
90+
log_collector += "output:stdout"
9091
else:
91-
log_collector += "output:stderr;"
92-
log_collector += "flush:error"
92+
log_collector += "output:stderr"
9393
env['UR_LOG_COLLECTOR'] = log_collector
9494

9595
env['XPTI_TRACE_ENABLE'] = "1"

0 commit comments

Comments
 (0)