Skip to content

Commit e9e749b

Browse files
committed
Fix cmake option for tests
1 parent 49722c8 commit e9e749b

File tree

8 files changed

+28
-15
lines changed

8 files changed

+28
-15
lines changed

.ci/scripts/setup-windows.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
param (
2-
[string]$editable = $false
2+
[string]$editable = "false"
33
)
44

55
conda create --yes --quiet -n et python=3.12

.ci/scripts/unittest-windows.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
param (
2-
[string]$editable = $false
2+
[string]$buildMode = "Release"
33
)
44

55
Set-PSDebug -Trace 1
@@ -17,13 +17,13 @@ if ($LASTEXITCODE -ne 0) {
1717
New-Item -Path "test-build" -ItemType Directory
1818
cd "test-build"
1919

20-
cmake .. --preset windows -B . -DCMAKE_BUILD_TESTS=ON
20+
cmake .. --preset windows -B . -DEXECUTORCH_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=$buildMode
2121
if ($LASTEXITCODE -ne 0) {
2222
Write-Host "CMake configuration was unsuccessful. Exit code: $LASTEXITCODE."
2323
exit $LASTEXITCODE
2424
}
2525

26-
cmake --build . -j8 --config Release
26+
cmake --build . -j8 --config $buildMode --verbose
2727
if ($LASTEXITCODE -ne 0) {
2828
Write-Host "CMake build was unsuccessful. Exit code: $LASTEXITCODE."
2929
exit $LASTEXITCODE

.github/workflows/_unittest.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ jobs:
6969
\$ErrorActionPreference = 'Stop'
7070
\$PSNativeCommandUseErrorActionPreference = \$true
7171
72-
.ci/scripts/setup-windows.ps1
72+
.ci/scripts/setup-windows.ps1 -editable "${{ inputs.editable }}"
73+
if (\$LASTEXITCODE -ne 0) {
74+
Write-Host "Setup failed. Exit code: \$LASTEXITCODE."
75+
exit \$LASTEXITCODE
76+
}
7377
74-
.ci/scripts/unittest-windows.ps1 -editable "${{ inputs.editable }}"
78+
.ci/scripts/unittest-windows.ps1 -buildMode "${{ inputs.build-mode }}"
79+
if (\$LASTEXITCODE -ne 0) {
80+
Write-Host "Unit tests failed. Exit code: \$LASTEXITCODE."
81+
exit \$LASTEXITCODE
82+
}
7583
}"

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,13 @@ endif()
143143

144144
# -ffunction-sections -fdata-sections: breaks function and data into sections so
145145
# they can be properly gc'd. -s: strip symbol.
146-
set(CMAKE_CXX_FLAGS_RELEASE
147-
"-ffunction-sections -fdata-sections ${CMAKE_CXX_FLAGS_RELEASE}"
148-
)
146+
if(WIN32)
147+
set(CMAKE_CXX_FLAGS_RELEASE "/Gy /Gw ${CMAKE_CXX_FLAGS_RELEASE}")
148+
else()
149+
set(CMAKE_CXX_FLAGS_RELEASE
150+
"-ffunction-sections -fdata-sections ${CMAKE_CXX_FLAGS_RELEASE}"
151+
)
152+
endif()
149153
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
150154
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
151155
endif()

runtime/executor/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ add_custom_command(
3939
COMMAND
4040
${PYTHON_EXECUTABLE} -m test.models.export_delegated_program --modules
4141
"ModuleAddMul" --backend_id "StubBackend" --outdir
42-
"${CMAKE_CURRENT_BINARY_DIR}/delegated/" || true
42+
"${CMAKE_CURRENT_BINARY_DIR}/delegated/"
4343
WORKING_DIRECTORY ${EXECUTORCH_ROOT}
4444
)
4545

test/end2end/exported_module.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ def __init__(self, method):
187187
if method_name_to_dynamic_shapes
188188
else None
189189
),
190-
strict=True,
191190
)
192191

193192
exec_prog = to_edge(

test/models/export_delegated_program.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ def forward(self, *args, **kwargs):
155155

156156
if method_name != "forward":
157157
# Only require wrapper module if we're exporting a specific method other than forward.
158-
exported_program = export(WrapperModule(eager_module), args=inputs, strict=True)
158+
exported_program = export(WrapperModule(eager_module), args=inputs)
159159
else:
160-
exported_program = export(eager_module, args=inputs, strict=True)
160+
exported_program = export(eager_module, args=inputs)
161161

162162
edge_config = EdgeCompileConfig(_check_ir_validity=False)
163163
et_config = exir.ExecutorchBackendConfig(
@@ -178,7 +178,7 @@ def forward(self, *args, **kwargs):
178178
module=tagged_module,
179179
gen_tag_fn=lambda x: module_class.__name__,
180180
)
181-
exported_program = export(tagged_module, args=inputs, strict=True)
181+
exported_program = export(tagged_module, args=inputs)
182182
executorch_program = to_edge_transform_and_lower(
183183
exported_program,
184184
compile_config=edge_config,
@@ -205,7 +205,7 @@ def forward(self, *args, **kwargs):
205205
composite_module(*inputs)
206206

207207
executorch_program = to_edge(
208-
export(composite_module, args=inputs, strict=True)
208+
export(composite_module, args=inputs)
209209
).to_executorch(config=et_config)
210210

211211
return executorch_program

tools/cmake/Utils.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ endfunction()
6262
function(target_link_options_gc_sections target_name)
6363
if(APPLE)
6464
target_link_options(${target_name} PRIVATE "LINKER:-dead_strip")
65+
elseif(WIN32)
66+
target_link_options(${target_name} PRIVATE "LINKER:/OPT:REF")
6567
else()
6668
target_link_options(${target_name} PRIVATE "LINKER:--gc-sections")
6769
endif()

0 commit comments

Comments
 (0)