Skip to content

Commit 9681989

Browse files
authored
Add missing compilation flags for vcpkg ports (microsoft#5587)
microsoft#5567 didn't actually fix the crash we were seeing. The actual cause of the crash seems to be that I missed adding some compilation flags that we had added to the `.vcxproj` for cpprestsdk when I moved the dependencies to vcpkg (which does not use the `.vcxproj`). Specifically, I didn't set a flag to compile it without async support, so the library used async but winget wasn't prepared for that. This PR adds the missing compilation flags for all ports, taken from the project files before the migration to vcpkg. I added the flags to the triplet files (conditionally) so that it applies the same regardless of whether a port comes from the official registry or a local overlay. I noticed that for `libyaml` and `jsoncpp` I missed the flags to prepare for fuzzing, so I added a new triplet for those. This PR also updates the pipeline to publish the compilation logs from vcpkg for easier debugging in the future. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/5587)
1 parent da80018 commit 9681989

File tree

8 files changed

+53
-2
lines changed

8 files changed

+53
-2
lines changed

.github/actions/spelling/expect.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Browsable
6868
BSODs
6969
Buf
7070
buildtransitive
71+
buildtrees
7172
cancelledbyuser
7273
casemap
7374
casemappings
@@ -113,6 +114,7 @@ dacl
113114
datetimeoffset
114115
Dbg
115116
Dcom
117+
DCPPREST
116118
debian
117119
decompressor
118120
dedupe
@@ -126,6 +128,7 @@ desktopappinstaller
126128
devblogs
127129
devhome
128130
DFX
131+
DHAVE
129132
dic
130133
diskfull
131134
DISPLAYCATALOG
@@ -139,6 +142,7 @@ dustojnikhummer
139142
dvinns
140143
dwgs
141144
dwrite
145+
DYAML
142146
ecfr
143147
ecfrbrowse
144148
EFGH
@@ -468,6 +472,7 @@ rwgch
468472
rwgs
469473
ryfu
470474
sacl
475+
sancov
471476
SARL
472477
savepoint
473478
sawgc

azure-pipelines.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ jobs:
148148
/p:AppxPackageSigningEnabled=false'
149149
maximumCpuCount: true
150150

151+
- task: CopyFiles@2
152+
displayName: Copy vcpkg logs
153+
inputs:
154+
SourceFolder: $(VCPKG_INSTALLATION_ROOT)\buildtrees
155+
Contents: '**\*.log'
156+
TargetFolder: '$(artifactsDir)\vcpkgLogs'
157+
condition: succeededOrFailed()
158+
151159
- task: CopyFiles@2
152160
displayName: 'Copy specific build artifacts'
153161
inputs:
@@ -285,6 +293,7 @@ jobs:
285293
inputs:
286294
targetPath: '$(artifactsDir)'
287295
artifact: 'Build.$(artifactIdentifier)'
296+
condition: succeededOrFailed()
288297

289298
- task: ComponentGovernanceComponentDetection@0
290299
displayName: Component Governance
@@ -639,6 +648,14 @@ jobs:
639648
msbuildArgs: '/bl:$(artifactsDir)\msbuild.binlog'
640649
maximumCpuCount: true
641650

651+
- task: CopyFiles@2
652+
displayName: Copy vcpkg logs
653+
inputs:
654+
SourceFolder: $(VCPKG_INSTALLATION_ROOT)\buildtrees
655+
Contents: '**\*.log'
656+
TargetFolder: '$(artifactsDir)\vcpkgLogs'
657+
condition: succeededOrFailed()
658+
642659
- task: CopyFiles@2
643660
displayName: Copy Fuzzing Artifacts for Publishing
644661
inputs:
@@ -650,6 +667,7 @@ jobs:
650667
displayName: Publish Fuzzing Artifacts
651668
inputs:
652669
targetPath: '$(artifactsDir)'
670+
condition: succeededOrFailed()
653671

654672
- task: onefuzz-task@0
655673
inputs:

src/AppInstallerCLI.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VcpkgCustomTriplets", "Vcpk
183183
VcpkgCustomTriplets\arm64-release.cmake = VcpkgCustomTriplets\arm64-release.cmake
184184
VcpkgCustomTriplets\arm64.cmake = VcpkgCustomTriplets\arm64.cmake
185185
VcpkgCustomTriplets\common.cmake = VcpkgCustomTriplets\common.cmake
186+
VcpkgCustomTriplets\fuzzing.cmake = VcpkgCustomTriplets\fuzzing.cmake
187+
VcpkgCustomTriplets\x64-fuzzing.cmake = VcpkgCustomTriplets\x64-fuzzing.cmake
186188
VcpkgCustomTriplets\x64-release-static.cmake = VcpkgCustomTriplets\x64-release-static.cmake
187189
VcpkgCustomTriplets\x64-release.cmake = VcpkgCustomTriplets\x64-release.cmake
188190
VcpkgCustomTriplets\x64.cmake = VcpkgCustomTriplets\x64.cmake
191+
VcpkgCustomTriplets\x86-fuzzing.cmake = VcpkgCustomTriplets\x86-fuzzing.cmake
189192
VcpkgCustomTriplets\x86-release-static.cmake = VcpkgCustomTriplets\x86-release-static.cmake
190193
VcpkgCustomTriplets\x86-release.cmake = VcpkgCustomTriplets\x86-release.cmake
191194
VcpkgCustomTriplets\x86.cmake = VcpkgCustomTriplets\x86.cmake

src/VcpkgCustomTriplets/common.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,19 @@ set(VCPKG_LIBRARY_LINKAGE static)
22
set(VCPKG_C_FLAGS "/Qspectre /W3 /guard:cf")
33
set(VCPKG_CXX_FLAGS "/Qspectre /W3 /guard:cf")
44
set(VCPKG_INSTALL_OPTIONS, "--debug")
5+
6+
if(PORT MATCHES "cpprestsdk")
7+
set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} /D_NO_ASYNCRTIMP /DCPPREST_EXCLUDE_WEBSOCKETS")
8+
set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} /D_NO_ASYNCRTIMP /DCPPREST_EXCLUDE_WEBSOCKETS")
9+
elseif(PORT MATCHES "detours")
10+
set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} /D_LIB")
11+
set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} /D_LIB")
12+
elseif(PORT MATCHES "jsoncpp")
13+
set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} /D_DISABLE_VECTOR_ANNOTATION /D_DISABLE_STRING_ANNOTATION")
14+
set(VCPKG_CXX_FLAGS "${VCPKG_C_FLAGS} /D_DISABLE_VECTOR_ANNOTATION /D_DISABLE_STRING_ANNOTATION")
15+
elseif(PORT MATCHES "libyaml")
16+
set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} /DYAML_DECLARE_STATIC /DHAVE_CONFIG_H")
17+
set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} /DYAML_DECLARE_STATIC /DHAVE_CONFIG_H")
18+
endif()
19+
20+
message("Compilation flags for ${PORT}: ${VCPKG_CXX_FLAGS}")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if(PORT MATCHES "jsoncpp|libyaml")
2+
set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} /fsanitize=address /fsanitize-coverage=inline-8bit-counters /fsanitize-coverage=edge /fsanitize-coverage=trace-cmp /fsanitize-coverage=trace-div")
3+
set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} /fsanitize=address /fsanitize-coverage=inline-8bit-counters /fsanitize-coverage=edge /fsanitize-coverage=trace-cmp /fsanitize-coverage=trace-div")
4+
set(VCPKG_LINKER_FLAGS libsancov.lib)
5+
endif()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include("${CMAKE_CURRENT_LIST_DIR}/x64-release-static.cmake")
2+
include("${CMAKE_CURRENT_LIST_DIR}/fuzzing.cmake")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include("${CMAKE_CURRENT_LIST_DIR}/x86-release-static.cmake")
2+
include("${CMAKE_CURRENT_LIST_DIR}/fuzzing.cmake")

src/vcpkg.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
<VcpkgConfiguration>Release</VcpkgConfiguration>
4242
</PropertyGroup>
4343
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'">
44-
<VcpkgTriplet>x64-release-static</VcpkgTriplet>
44+
<VcpkgTriplet>x64-fuzzing</VcpkgTriplet>
4545
<VcpkgConfiguration>Release</VcpkgConfiguration>
4646
</PropertyGroup>
4747
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Fuzzing|Win32'">
48-
<VcpkgTriplet>x86-release-static</VcpkgTriplet>
48+
<VcpkgTriplet>x86-fuzzing</VcpkgTriplet>
4949
<VcpkgConfiguration>Release</VcpkgConfiguration>
5050
</PropertyGroup>
5151
</Project>

0 commit comments

Comments
 (0)