Skip to content

Commit c6018b8

Browse files
authored
Add additional debug configuration for a better debugging experience + CI update (#1893)
* Add additional debug configuration I've added the DebugOpt config for a better debugging experience. This version enables some optimizations and uses `_ITERATOR_DEBUG_LEVEL=0` to remove many of the slowdowns of traditional debugging while still keeping the debuggability of the app intact. It uses the release versions of llvm and crt. * Enable native debugging when running *.Gen test projects from vs2022 * Move msvc specific define to msc toolset filter * Update CI to build all configurations * Ignore crashing unit test in debug builds * Attempt to fix upload-artifact CI step * Use msclr string marshallers * Fix two bugs in Driver.cs * Update parser bindings * Add debug mode parser bindings * Disable CI test step in windows debug
1 parent c25c7df commit c6018b8

File tree

34 files changed

+87210
-255
lines changed

34 files changed

+87210
-255
lines changed

Diff for: .github/workflows/main.yml

+41-26
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,34 @@ name: CI
22

33
on: [push, pull_request]
44

5+
# Cancel any previous workflows if the pull request was updated
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
8+
cancel-in-progress: true
9+
510
jobs:
611
build:
712
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
813
strategy:
914
fail-fast: false
1015
matrix:
11-
config:
12-
- { os: ubuntu-22.04, platform: x64, cxx: g++-11, cc: gcc-11 }
13-
- { os: macos-12, platform: x64, cxx: clang++, cc: clang }
14-
- { os: windows-2022, platform: x64, vs: "Program Files/Microsoft Visual Studio/2022" }
16+
os: [ubuntu-22.04, macos-12, windows-2022]
17+
platform: [x64]
18+
build-cfg: [DebugOpt, Release]
19+
#build-cfg: [Debug, DebugOpt, Release] # our local copy of clang isn't build for debug on linux/macos currently
20+
include:
21+
- os: windows-2022
22+
platform: x64
23+
build-cfg: Debug
1524

16-
runs-on: ${{ matrix.config.os }}
25+
runs-on: ${{ matrix.os }}
1726

1827
env:
19-
CC: ${{ matrix.config.cc }}
20-
CXX: ${{ matrix.config.cxx }}
21-
VS_VERSION: ${{ matrix.config.vs }}
22-
PLATFORM: ${{ matrix.config.platform }}
28+
CC: ${{ startsWith(matrix.os, 'ubuntu') && 'gcc-11' || 'clang' }}
29+
CXX: ${{ startsWith(matrix.os, 'ubuntu') && 'g++-11' || 'clang++' }}
30+
VS_VERSION: "Program Files/Microsoft Visual Studio/2022"
31+
PLATFORM: ${{ matrix.platform }}
32+
BUILD_CONFIGURATION: ${{ matrix.build-cfg }}
2333
DOTNET_NOLOGO: true
2434
DOTNET_CLI_TELEMETRY_OPTOUT: true
2535
EMSCRIPTEN_VERSION: 3.1.65
@@ -41,59 +51,63 @@ jobs:
4151
cmake-version: '3.30.x'
4252

4353
- name: Install nbgv
44-
if: startsWith(matrix.config.os, 'macos')
54+
if: startsWith(matrix.os, 'macos')
4555
run: |
4656
dotnet tool install -g nbgv
4757
4858
- name: Set version
4959
run: nbgv cloud --all-vars
5060

5161
- name: Environment
52-
if: matrix.config.vs
62+
if: startsWith(matrix.os, 'windows')
5363
shell: bash
5464
run: echo "/c/$VS_VERSION/Enterprise/MSBuild/Current/Bin" >> $GITHUB_PATH
5565

5666
- name: Setup
5767
shell: bash
5868
run: |
59-
build/build.sh generate -platform $PLATFORM
60-
build/build.sh download_llvm -platform $PLATFORM
69+
build/build.sh generate -platform $PLATFORM -configuration $BUILD_CONFIGURATION
70+
build/build.sh download_llvm -platform $PLATFORM -configuration $BUILD_CONFIGURATION
6171
6272
- name: Restore
6373
shell: bash
64-
run: build/build.sh restore -platform $PLATFORM
74+
run: build/build.sh restore -platform $PLATFORM -configuration $BUILD_CONFIGURATION
6575

6676
- name: Build
6777
shell: bash
68-
run: build/build.sh -platform $PLATFORM -build_only
78+
run: build/build.sh -platform $PLATFORM -build_only -configuration $BUILD_CONFIGURATION
6979

7080
- name: Test (.NET)
81+
# Disable test for debug configs, since they take over 6 hours to complete
82+
if: matrix.build-cfg != 'Debug'
7183
shell: bash
72-
run: build/test.sh -platform $PLATFORM
84+
run: build/test.sh -platform $PLATFORM -configuration $BUILD_CONFIGURATION
7385

7486
- name: Build (QuickJS runtime)
87+
if: runner.os != 'Windows'
7588
shell: bash
7689
run: tests/quickjs/bootstrap.sh
77-
if: runner.os != 'Windows'
7890

7991
- name: Test (QuickJS)
80-
shell: bash
81-
run: tests/quickjs/test.sh
8292
if: runner.os != 'Windows'
93+
shell: bash
94+
run: tests/quickjs/test.sh -dotnet_configuration $BUILD_CONFIGURATION
8395

8496
- name: Test (Emscripten)
85-
shell: bash
86-
run: tests/emscripten/test.sh
8797
if: runner.os != 'Windows'
98+
shell: bash
99+
run: tests/emscripten/test.sh -dotnet_configuration $BUILD_CONFIGURATION
88100

89101
- name: Pack
90102
shell: bash
91-
run: build/build.sh prepack -platform $PLATFORM
103+
run: build/build.sh prepack -platform $PLATFORM -configuration $BUILD_CONFIGURATION
92104

93105
- name: Upload Artifacts
106+
# We only need a release version of this in the create_package job
107+
if: matrix.build-cfg == 'Release'
94108
uses: actions/upload-artifact@v4
95109
with:
96-
name: intermediate
110+
name: intermediate-${{ matrix.build-cfg }}-${{ matrix.platform }}
97111
retention-days: 7
98112
overwrite: true
99113
path: |
@@ -110,6 +124,7 @@ jobs:
110124
env:
111125
DOTNET_NOLOGO: true
112126
DOTNET_CLI_TELEMETRY_OPTOUT: true
127+
BUILD_CONFIGURATION: Release
113128

114129
steps:
115130
- uses: actions/checkout@v4
@@ -121,15 +136,15 @@ jobs:
121136

122137
- uses: actions/download-artifact@v4
123138
with:
124-
name: intermediate
139+
name: intermediate-Release-x64
125140

126141
- name: Setup
127142
shell: bash
128-
run: build/build.sh generate_config
143+
run: build/build.sh generate_config -configuration $BUILD_CONFIGURATION
129144

130145
- name: Create package
131146
shell: bash
132-
run: build/build.sh pack
147+
run: build/build.sh pack -configuration $BUILD_CONFIGURATION
133148

134149
- name: Upload package
135150
uses: actions/upload-artifact@v4

Diff for: Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<PropertyGroup>
55
<RootDir>$(MSBuildThisFileDirectory)</RootDir>
66
<Platforms>x86;x64</Platforms>
7+
<Configurations>Debug;DebugOpt;Release</Configurations>
78
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
89
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
910
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Diff for: build/Helpers.lua

+16-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ newoption {
3636
allowed = {
3737
{ "Release", "Release" },
3838
{ "Debug", "Debug" },
39+
{ "DebugOpt", "DebugOpt" },
3940
}
4041
}
4142

@@ -104,13 +105,21 @@ function SetupNativeProject()
104105

105106
filter { "configurations:Debug" }
106107
defines { "DEBUG" }
108+
109+
filter { "configurations:DebugOpt" }
110+
defines { "DEBUG" }
111+
optimize "Debug"
112+
runtime "Release"
107113

108114
filter { "configurations:Release" }
109115
defines { "NDEBUG" }
110-
optimize "On"
116+
optimize "Full"
111117

112118
-- Compiler-specific options
113119

120+
filter { "toolset:msc*", "configurations:DebugOpt" }
121+
defines { "_ITERATOR_DEBUG_LEVEL=0" }
122+
114123
filter { "toolset:msc*" }
115124
buildoptions { msvc_buildflags }
116125
defines { msvc_cpp_defines }
@@ -247,9 +256,13 @@ end
247256
function AddPlatformSpecificFiles(folder, filename)
248257

249258
if os.istarget("windows") then
250-
filter { "toolset:msc*", "architecture:x86_64" }
259+
filter { "toolset:msc*", "architecture:x86_64", "configurations:Debug" }
260+
files { path.join(folder, "x86_64-pc-win32-msvc-d", filename) }
261+
filter { "toolset:msc*", "architecture:x86", "configurations:Debug" }
262+
files { path.join(folder, "i686-pc-win32-msvc-d", filename) }
263+
filter { "toolset:msc*", "architecture:x86_64", "configurations:not Debug" }
251264
files { path.join(folder, "x86_64-pc-win32-msvc", filename) }
252-
filter { "toolset:msc*", "architecture:x86" }
265+
filter { "toolset:msc*", "architecture:x86", "configurations:not Debug" }
253266
files { path.join(folder, "i686-pc-win32-msvc", filename) }
254267
elseif os.istarget("macosx") then
255268
filter { "architecture:arm64" }

Diff for: build/LLVM.lua

+18
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ function SetupLLVMIncludes()
3838
local c = filter()
3939

4040
if LLVMDirPerConfiguration then
41+
filter { "configurations:DebugOpt" }
42+
includedirs
43+
{
44+
path.join(LLVMRootDirRelease, "include"),
45+
path.join(LLVMRootDirRelease, "llvm/include"),
46+
path.join(LLVMRootDirRelease, "lld/include"),
47+
path.join(LLVMRootDirRelease, "clang/include"),
48+
path.join(LLVMRootDirRelease, "clang/lib"),
49+
path.join(LLVMRootDirRelease, "build/include"),
50+
path.join(LLVMRootDirRelease, "build/clang/include"),
51+
}
52+
4153
filter { "configurations:Debug" }
4254
includedirs
4355
{
@@ -121,6 +133,9 @@ function SetupLLVMLibs()
121133
filter {}
122134

123135
if LLVMDirPerConfiguration then
136+
filter { "configurations:DebugOpt" }
137+
libdirs { path.join(LLVMRootDirRelease, "build/lib") }
138+
124139
filter { "configurations:Debug" }
125140
libdirs { path.join(LLVMRootDirDebug, "build/lib") }
126141

@@ -129,6 +144,9 @@ function SetupLLVMLibs()
129144
else
130145
local LLVMBuildDir = get_llvm_build_dir()
131146
libdirs { path.join(LLVMBuildDir, "lib") }
147+
148+
filter { "configurations:DebugOpt", "toolset:msc*" }
149+
libdirs { path.join(LLVMBuildDir, "RelWithDebInfo/lib") }
132150

133151
filter { "configurations:Debug", "toolset:msc*" }
134152
libdirs { path.join(LLVMBuildDir, "Debug/lib") }

Diff for: build/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33
builddir=$(cd "$(dirname "$0")"; pwd)
44
platform=x64
55
vs=vs2022
6-
configuration=Release
6+
configuration=DebugOpt
77
build_only=false
88
ci=false
99
target_framework=

Diff for: build/llvm/LLVM.lua

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ function get_llvm_package_name(rev, conf, arch)
137137
end
138138

139139
function get_llvm_configuration_name(debug)
140+
if string.find(_OPTIONS["configuration"], "DebugOpt") then
141+
return os.istarget("windows") and "RelWithDebInfo" or "Release"
142+
end
140143
if string.find(_OPTIONS["configuration"], "Debug") then
141144
return "Debug"
142145
end

0 commit comments

Comments
 (0)