Skip to content

Commit 8d602cc

Browse files
committed
enable debug native binaries on windows
1 parent a3843bb commit 8d602cc

17 files changed

+73
-189
lines changed

.gitignore

-77
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,9 @@ Generated\ Files/
4747
*.VisualState.xml
4848
TestResult.xml
4949

50-
# Build Results of an ATL Project
51-
[Dd]ebugPS/
52-
[Rr]eleasePS/
53-
dlldata.c
54-
5550
# Benchmark Results
5651
BenchmarkDotNet.Artifacts/
5752

58-
# .NET Core
59-
project.lock.json
60-
project.fragment.lock.json
61-
artifacts/
62-
**/Properties/launchSettings.json
63-
6453
# StyleCop
6554
StyleCopReport.xml
6655

@@ -209,11 +198,6 @@ Package.StoreAssociation.xml
209198
_pkginfo.txt
210199
*.appx
211200

212-
# Visual Studio cache files
213-
# files ending in .cache can be ignored
214-
*.[Cc]ache
215-
# but keep track of directories ending in .cache
216-
!*.[Cc]ache/
217201

218202
# Others
219203
ClientBin/
@@ -226,16 +210,6 @@ ClientBin/
226210
*.publishsettings
227211
orleans.codegen.cs
228212

229-
# Including strong name files can present a security risk
230-
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
231-
#*.snk
232-
233-
# Since there are multiple workflows, uncomment next line to ignore bower_components
234-
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
235-
#bower_components/
236-
237-
# RIA/Silverlight projects
238-
Generated_Code/
239213

240214
# Backup & report files from converting an old project file
241215
# to a newer Visual Studio version. Backup files are not needed,
@@ -246,57 +220,6 @@ UpgradeLog*.XML
246220
UpgradeLog*.htm
247221
ServiceFabricBackup/
248222

249-
# SQL Server files
250-
*.mdf
251-
*.ldf
252-
*.ndf
253-
254-
# Business Intelligence projects
255-
*.rdl.data
256-
*.bim.layout
257-
*.bim_*.settings
258-
259-
# Microsoft Fakes
260-
FakesAssemblies/
261-
262-
# GhostDoc plugin setting file
263-
*.GhostDoc.xml
264-
265-
# Node.js Tools for Visual Studio
266-
.ntvs_analysis.dat
267-
node_modules/
268-
269-
# TypeScript v1 declaration files
270-
typings/
271-
272-
# Visual Studio 6 build log
273-
*.plg
274-
275-
# Visual Studio 6 workspace options file
276-
*.opt
277-
278-
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
279-
*.vbw
280-
281-
# Visual Studio LightSwitch build output
282-
**/*.HTMLClient/GeneratedArtifacts
283-
**/*.DesktopClient/GeneratedArtifacts
284-
**/*.DesktopClient/ModelManifest.xml
285-
**/*.Server/GeneratedArtifacts
286-
**/*.Server/ModelManifest.xml
287-
_Pvt_Extensions
288-
289-
# Paket dependency manager
290-
.paket/paket.exe
291-
paket-files/
292-
293-
# FAKE - F# Make
294-
.fake/
295-
296-
# JetBrains Rider
297-
.idea/
298-
*.sln.iml
299-
300223
# CodeRush
301224
.cr/
302225

Directory.Build.props

+12-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PropertyGroup>
88
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
99
<Configurations>Debug;Release</Configurations>
10-
<Platform Condition="'$(Platform)'==''">AnyCPU</Platform>
10+
<Platform Condition="'$(Platform)'==''">x64</Platform>
1111
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
1212
<NativeTargetArchitecture Condition="'$(NativeTargetArchitecture)' == ''">$(TargetArchitecture)</NativeTargetArchitecture>
1313
<PlatformConfig>$(Platform).$(Configuration)</PlatformConfig>
@@ -45,9 +45,16 @@
4545
<PackageOutputPath Condition="'$(PackageOutputPath)'=='' and '$(NonShippingPackage)' == 'true'">$(BinDir)packages_noship/</PackageOutputPath>
4646
<PackageOutputPath Condition="'$(PackageOutputPath)'==''">$(BinDir)packages/</PackageOutputPath>
4747

48-
<!-- Note that Release is hard coded because LibTorchSharp needs to be built in Release
49-
because LibTorch itself is in release. -->
50-
<NativeOutputPath>$(BaseOutputPath)$(NativeTargetArchitecture).Release\Native\</NativeOutputPath>
48+
<!-- On Unix we currently hard code LibTorchSharp as Release - there is a (possibly flawed) assumption -->
49+
<!-- that it needs to be built in Release because LibTorch itself is in release. -->
50+
<!-- On windows a debug version of LibTorch is available for download-->
51+
<NativeConfiguration>Release</NativeConfiguration>
52+
<NativeConfiguration Condition="'$(OS)' == 'Windows_NT' OR '$(AssumeOS)' == 'windows'">$(Configuration)</NativeConfiguration>
53+
54+
<!-- on windows separate debug binaries are available-->
55+
<LibTorchDebug Condition="('$(NativeConfiguration)' == 'Debug') AND ('$(OS)' == 'Windows_NT' OR '$(AssumeOS)' == 'windows')">-debug</LibTorchDebug>
56+
57+
<NativeOutputPath>$(BaseOutputPath)$(NativeTargetArchitecture).$(NativeConfiguration)\Native\</NativeOutputPath>
5158

5259
<!-- Input Directories -->
5360
<PackagesDir>$(DotNetRestorePackagesPath)</PackagesDir>
@@ -96,11 +103,7 @@
96103
<LangVersion>latest</LangVersion> <!-- default to allowing all language features -->
97104
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
98105
</PropertyGroup>
99-
100-
<PropertyGroup>
101-
<RunningOnUnix Condition="'$(OS)'!='Windows_NT'">true</RunningOnUnix>
102-
</PropertyGroup>
103-
106+
104107
<!-- Signing properties -->
105108
<PropertyGroup>
106109
<AssemblyOriginatorKeyFile Condition="'$(AssemblyOriginatorKeyFile)' == ''">$(ToolsDir)Open.snk</AssemblyOriginatorKeyFile>

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Then run these to test downloads and update SHA hashes for LibTorch downloads:
119119
You must also update the "FilesFromArchive= ..." entries under src\Redist projects. Check the contents
120120
of the unzip of the archive, e.g.
121121

122-
bin\obj\AnyCPU.Debug\LibTorch.Redist\libtorch-shared-with-deps-1.5.0%2Bcpu\libtorch\lib
122+
bin\obj\x86.Debug\LibTorch.Redist\libtorch-shared-with-deps-1.5.0%2Bcpu\libtorch\lib
123123

124124

125125
Updating package version for new release

TorchSharp.sln

+1-46
Original file line numberDiff line numberDiff line change
@@ -36,77 +36,32 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TorchSharp", "TorchSharp",
3636
pkg\TorchSharp\TorchSharp.symbols.nupkgproj = pkg\TorchSharp\TorchSharp.symbols.nupkgproj
3737
EndProjectSection
3838
EndProject
39-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibTorchSharp", "bin\obj\x64.Release\Native\LibTorchSharp\LibTorchSharp.vcxproj", "{912E4543-FB5A-3172-BAFE-B3F15EE0A723}"
39+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibTorchSharp", "bin\obj\x64.Debug\Native\LibTorchSharp\LibTorchSharp.vcxproj", "{912E4543-FB5A-3172-BAFE-B3F15EE0A723}"
4040
EndProject
4141
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Native", "Native", "{CF2C1A9E-3A8A-4329-8A6E-7880C15AAC3D}"
4242
EndProject
4343
Global
4444
GlobalSection(SolutionConfigurationPlatforms) = preSolution
45-
Debug|Any CPU = Debug|Any CPU
4645
Debug|x64 = Debug|x64
47-
Release|Any CPU = Release|Any CPU
4846
Release|x64 = Release|x64
49-
RelWithDebInfo|Any CPU = RelWithDebInfo|Any CPU
50-
RelWithDebInfo|x64 = RelWithDebInfo|x64
5147
EndGlobalSection
5248
GlobalSection(ProjectConfigurationPlatforms) = postSolution
53-
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54-
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.Debug|Any CPU.Build.0 = Debug|Any CPU
5549
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.Debug|x64.ActiveCfg = Debug|Any CPU
5650
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.Debug|x64.Build.0 = Debug|Any CPU
57-
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.Release|Any CPU.ActiveCfg = Release|Any CPU
58-
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.Release|Any CPU.Build.0 = Release|Any CPU
5951
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.Release|x64.ActiveCfg = Release|Any CPU
6052
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.Release|x64.Build.0 = Release|Any CPU
61-
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
62-
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
63-
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
64-
{B4E55B2D-2A92-46E7-B72F-E76D6FD83440}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
65-
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66-
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.Debug|Any CPU.Build.0 = Debug|Any CPU
6753
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.Debug|x64.ActiveCfg = Debug|Any CPU
6854
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.Debug|x64.Build.0 = Debug|Any CPU
69-
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.Release|Any CPU.ActiveCfg = Release|Any CPU
70-
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.Release|Any CPU.Build.0 = Release|Any CPU
7155
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.Release|x64.ActiveCfg = Release|Any CPU
7256
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.Release|x64.Build.0 = Release|Any CPU
73-
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
74-
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
75-
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
76-
{061CCBA1-A859-4392-8F45-249E5DAF1C88}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
77-
{6C323B05-9028-4B09-911C-3C03AE058BEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
78-
{6C323B05-9028-4B09-911C-3C03AE058BEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
7957
{6C323B05-9028-4B09-911C-3C03AE058BEE}.Debug|x64.ActiveCfg = Debug|Any CPU
8058
{6C323B05-9028-4B09-911C-3C03AE058BEE}.Debug|x64.Build.0 = Debug|Any CPU
81-
{6C323B05-9028-4B09-911C-3C03AE058BEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
82-
{6C323B05-9028-4B09-911C-3C03AE058BEE}.Release|Any CPU.Build.0 = Release|Any CPU
8359
{6C323B05-9028-4B09-911C-3C03AE058BEE}.Release|x64.ActiveCfg = Release|Any CPU
8460
{6C323B05-9028-4B09-911C-3C03AE058BEE}.Release|x64.Build.0 = Release|Any CPU
85-
{6C323B05-9028-4B09-911C-3C03AE058BEE}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
86-
{6C323B05-9028-4B09-911C-3C03AE058BEE}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
87-
{6C323B05-9028-4B09-911C-3C03AE058BEE}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
88-
{6C323B05-9028-4B09-911C-3C03AE058BEE}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
89-
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
90-
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
9161
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Debug|x64.ActiveCfg = Debug|Any CPU
9262
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Debug|x64.Build.0 = Debug|Any CPU
93-
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
94-
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Release|Any CPU.Build.0 = Release|Any CPU
9563
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Release|x64.ActiveCfg = Release|Any CPU
9664
{42B45168-476D-4BFA-87B8-81A34E6295CD}.Release|x64.Build.0 = Release|Any CPU
97-
{42B45168-476D-4BFA-87B8-81A34E6295CD}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
98-
{42B45168-476D-4BFA-87B8-81A34E6295CD}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
99-
{42B45168-476D-4BFA-87B8-81A34E6295CD}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
100-
{42B45168-476D-4BFA-87B8-81A34E6295CD}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
101-
{912E4543-FB5A-3172-BAFE-B3F15EE0A723}.Debug|Any CPU.ActiveCfg = Debug|x64
102-
{912E4543-FB5A-3172-BAFE-B3F15EE0A723}.Debug|x64.ActiveCfg = Debug|x64
103-
{912E4543-FB5A-3172-BAFE-B3F15EE0A723}.Debug|x64.Build.0 = Debug|x64
104-
{912E4543-FB5A-3172-BAFE-B3F15EE0A723}.Release|Any CPU.ActiveCfg = Release|x64
105-
{912E4543-FB5A-3172-BAFE-B3F15EE0A723}.Release|x64.ActiveCfg = Release|x64
106-
{912E4543-FB5A-3172-BAFE-B3F15EE0A723}.Release|x64.Build.0 = Release|x64
107-
{912E4543-FB5A-3172-BAFE-B3F15EE0A723}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
108-
{912E4543-FB5A-3172-BAFE-B3F15EE0A723}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
109-
{912E4543-FB5A-3172-BAFE-B3F15EE0A723}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
11065
EndGlobalSection
11166
GlobalSection(SolutionProperties) = preSolution
11267
HideSolutionNode = FALSE

src/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<!-- Note that Release is hard coded because LibTorchSharp needs to be built in Release
1717
because LibTorch itself is in release. -->
18-
<NativeAssetsBuiltPath>$(BaseOutputPath)$(TargetArchitecture).Release\Native</NativeAssetsBuiltPath>
18+
<NativeAssetsBuiltPath>$(BaseOutputPath)$(TargetArchitecture).$(NativeConfiguration)\Native</NativeAssetsBuiltPath>
1919

2020
<PackageRid Condition="'$(OS)' == 'Windows_NT' OR '$(AssumeOS)' == 'windows'">win</PackageRid>
2121
<PackageRid Condition="'$(OS)' != 'Windows_NT' OR '$(AssumeOS)' == 'linux'">linux</PackageRid>

src/Examples/Examples.csproj

+32-13
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,49 @@
1616
<NativeAssemblyReference Include="LibTorchSharp" />
1717
</ItemGroup>
1818

19-
<!-- Torch is 64-bit only? REVIEW check if true, do we need all these? -->
20-
<ItemGroup Condition="'$(NativeTargetArchitecture)' == 'x64'">
21-
<NativeAssemblyReference Include="torch" />
19+
<ItemGroup Condition="'$(NativeTargetArchitecture)' == 'x64' and '$(OS)' == 'Windows_NT'">
20+
<NativeAssemblyReference Include="c10" />
21+
<NativeAssemblyReference Include="asmjit" />
2222
<NativeAssemblyReference Include="caffe2_detectron_ops" />
2323
<NativeAssemblyReference Include="caffe2_module_test_dynamic" />
24-
<NativeAssemblyReference Include="c10" />
25-
</ItemGroup>
26-
27-
<ItemGroup Condition="'$(NativeTargetArchitecture)' == 'x64' and ('$(OS)' == 'Windows_NT' OR '$(AssumeOS)' == 'windows')">
24+
<NativeAssemblyReference Include="fbgemm" />
2825
<NativeAssemblyReference Include="libiomp5md" />
2926
<NativeAssemblyReference Include="libiompstubs5md" />
27+
<NativeAssemblyReference Include="torch" />
28+
<NativeAssemblyReference Include="torch_cpu" />
29+
<NativeAssemblyReference Include="torch_global_deps" />
3030
</ItemGroup>
3131

32-
<!-- Torch is 64-bit only? REVIEW check if true do we need all these? -->
33-
<ItemGroup Condition="'$(NativeTargetArchitecture)' == 'x64'and ($([MSBuild]::IsOSPlatform('osx')) OR '$(AssumeOS)' == 'mac')">
34-
<NativeAssemblyReference Include="torch_python" />
35-
<NativeAssemblyReference Include="shm" />
32+
<!-- Torch is 64-bit only? REVIEW check if true do we need all these? -->
33+
<ItemGroup Condition="'$(NativeTargetArchitecture)' == 'x64'and $([MSBuild]::IsOSPlatform('osx'))">
34+
<NativeAssemblyReference Include="c10" />
35+
<NativeAssemblyReference Include="caffe2_detectron_ops" />
36+
<NativeAssemblyReference Include="caffe2_module_test_dynamic" />
3637
<NativeAssemblyReference Include="caffe2_observers" />
38+
<NativeAssemblyReference Include="fbjni" />
39+
<NativeAssemblyReference Include="pytorch_jni" />
40+
<NativeAssemblyReference Include="shm" />
41+
<NativeAssemblyReference Include="torch" />
42+
<NativeAssemblyReference Include="torch_cpu" />
43+
<NativeAssemblyReference Include="torch_global_deps" />
44+
<NativeAssemblyReference Include="torch_python" />
3745
<NativeAssemblyReference Include="mklml" />
3846
<NativeAssemblyReference Include="iomp5" />
3947
</ItemGroup>
4048

41-
<ItemGroup Condition="'$(NativeTargetArchitecture)' == 'x64' and ($([MSBuild]::IsOSPlatform('linux')) OR '$(AssumeOS)' == 'linux')">
42-
<NativeAssemblyReference Include="gomp-4f651535" ExtraExtension=".1" />
49+
<ItemGroup Condition="'$(NativeTargetArchitecture)' == 'x64' and $([MSBuild]::IsOSPlatform('linux'))">
50+
<NativeAssemblyReference Include="c10" />
51+
<NativeAssemblyReference Include="caffe2_detectron_ops" />
52+
<NativeAssemblyReference Include="caffe2_module_test_dynamic" />
53+
<NativeAssemblyReference Include="caffe2_observers" />
54+
<NativeAssemblyReference Include="fbjni" />
55+
<NativeAssemblyReference Include="pytorch_jni" />
56+
<NativeAssemblyReference Include="shm" />
57+
<NativeAssemblyReference Include="torch" />
58+
<NativeAssemblyReference Include="torch_cpu" />
59+
<NativeAssemblyReference Include="torch_global_deps" />
60+
<NativeAssemblyReference Include="torch_python" />
61+
<NativeAssemblyReference Include="gomp-7c85b1e2" ExtraExtension=".1" />
4362
</ItemGroup>
4463

4564
</Project>

src/Native/CMakeLists.txt

-8
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ if(WIN32)
1616
endif()
1717
add_compile_options($<$<CONFIG:Debug>:-DDEBUG>)
1818
add_compile_options($<$<CONFIG:Release>:-DNDEBUG>)
19-
add_compile_options($<$<CONFIG:RelWithDebInfo>:-DNDEBUG>)
2019
add_compile_options($<$<CONFIG:Debug>:/Od>)
2120
add_compile_options($<$<CONFIG:Debug>:/MTd>) # /MT will static link the VC runtime library, so it doesn't need to be installed on the target machine
2221
add_compile_options($<$<CONFIG:Release>:/MT>)
23-
add_compile_options($<$<CONFIG:RelWithDebInfo>:/MT>)
2422
add_compile_options(/guard:cf)
2523
add_compile_options(/d2Zi+) # make optimized builds debugging easier
2624
add_compile_options(/nologo) # Suppress Startup Banner
@@ -71,12 +69,6 @@ if(WIN32)
7169
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
7270
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
7371

74-
# RelWithDebInfo specific flags
75-
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /OPT:REF /OPT:ICF")
76-
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /OPT:REF /OPT:ICF")
77-
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /OPT:REF /OPT:ICF")
78-
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
79-
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
8072
list(APPEND RESOURCES ${CMAKE_SOURCE_DIR}/../../Tools/NativeVersion.rc)
8173
else()
8274
add_definitions(-Werror) # treat warnings as errors

src/Native/build.proj

+6-11
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
<!-- Use this flag to ensure native assets take stable version -->
66
<UseStableVersionForNativeAssets>true</UseStableVersionForNativeAssets>
77

8-
<!-- Note that Release is hard coded because LibTorchSharp needs to be built in Release
9-
because LibTorch itself is in release. -->
10-
<StripNativeSymbols Condition="'$(StripNativeSymbols)' == ''">True</StripNativeSymbols>
8+
<!-- Do we split unix symbols into separate files -->
9+
<StripNativeSymbols Condition="'$(Configuration)' == ''">True</StripNativeSymbols>
1110
</PropertyGroup>
1211

1312
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />
@@ -44,7 +43,7 @@
4443
<LibName Condition="'$(OS)' != 'Windows_NT' OR '$(AssumeOS)' == 'linux'">libtorch-shared-with-deps</LibName>
4544
<LibName Condition="$([MSBuild]::IsOSPlatform('osx')) OR '$(AssumeOS)' == 'mac'">libtorch-macos</LibName>
4645

47-
<LibtorchPath Condition="'$(LibtorchPath)'==''">$(IntermediateOutputRootPath)LibTorch.Redist\$(LibName)-$(LibtorchVersion)\libtorch\share\cmake\Torch</LibtorchPath>
46+
<LibtorchPath Condition="'$(LibtorchPath)'==''">$(IntermediateOutputRootPath)LibTorch.Redist\$(LibName)-$(LibtorchVersion)$(LibTorchDebug)\libtorch\share\cmake\Torch</LibtorchPath>
4847
</PropertyGroup>
4948

5049
<Target Name="BuildNativeUnix"
@@ -53,10 +52,8 @@
5352

5453
<PropertyGroup>
5554

56-
<!-- Note that Release is hard coded because LibTorchSharp needs to be built in Release
57-
because LibTorch itself is in release. -->
58-
<StripArgs Condition="'$(StripNativeSymbols)' == 'True'">--stripSymbols</StripArgs>
59-
<BuildArgs>--configuration Release --arch $(TargetArchitecture) $(StripArgs) --libtorchpath $(LibtorchPath)</BuildArgs>
55+
<StripArgs Condition="'$(StripNativeSymbols)' == 'True'">--stripsymbols</StripArgs>
56+
<BuildArgs>--configuration $(NativeConfiguration) --arch $(TargetArchitecture) $(StripArgs) --libtorchpath $(LibtorchPath)</BuildArgs>
6057
</PropertyGroup>
6158

6259
<Message Text="$(MSBuildProjectDirectory)/build.sh $(BuildArgs)" Importance="High"/>
@@ -69,9 +66,7 @@
6966
DependsOnTargets="GenerateVersionHeader">
7067

7168
<PropertyGroup>
72-
<!-- Note that Release is hard coded because LibTorchSharp needs to be built in Release
73-
because LibTorch itself is in release. -->
74-
<BuildArgs>Release $(TargetArchitecture) --libtorchpath $(LibtorchPath)</BuildArgs>
69+
<BuildArgs>$(NativeConfiguration) $(TargetArchitecture) --libtorchpath $(LibtorchPath)</BuildArgs>
7570
</PropertyGroup>
7671

7772
<!-- Run script that invokes Cmake to create VS files, and then calls msbuild to compile them -->

src/Native/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ usage()
88
echo "Options:"
99
echo " --arch <Architecture> Target Architecture (x64, x86)"
1010
echo " --configuration <Configuration> Build Configuration (Debug, Release)"
11-
echo " --stripSymbols Enable symbol stripping (to external file)"
11+
echo " --stripsymbols Enable symbol stripping (to external file)"
1212
echo " --libtorchpath <PathToLibtorch> Path to libtorch TorchConfig.cmake"
1313
exit 1
1414
}

0 commit comments

Comments
 (0)