File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 'msvs_multi_core_compile' : '0' , # we do enable multicore compiles, but not using the V8 way
1313 'enable_pgo_generate%' : '0' ,
1414 'enable_pgo_use%' : '0' ,
15+ 'clang_profile_lib%' : '' ,
1516 'python%' : 'python' ,
1617
1718 'node_shared%' : 'false' ,
270271 },
271272 },
272273 },],
273- ['enable_pgo_generate=="true"' , {
274- 'msvs_settings' : {
275- 'VCCLCompilerTool' : {
276- 'AdditionalOptions' : ['-fprofile-generate' ],
277- },
278- 'VCLinkerTool' : {
279- 'AdditionalOptions' : ['-fprofile-generate' ],
280- },
281- },
282- },],
283- ['enable_pgo_use=="true"' , {
284- 'msvs_settings' : {
285- 'VCCLCompilerTool' : {
286- 'AdditionalOptions' : ['-fprofile-use=$(SolutionDir)node.profdata' ],
287- },
288- 'VCLinkerTool' : {
289- 'AdditionalOptions' : ['-fprofile-use=$(SolutionDir)node.profdata' ],
290- },
291- },
274+ ],
275+ 'target_conditions' : [
276+ ['_toolset=="target"' , {
277+ 'conditions' : [
278+ ['enable_pgo_generate=="true"' , {
279+ 'msvs_settings' : {
280+ 'VCCLCompilerTool' : {
281+ 'AdditionalOptions' : ['-fprofile-generate' ],
282+ },
283+ 'VCLinkerTool' : {
284+ 'AdditionalOptions' : [
285+ '/NODEFAULTLIB:clang_rt.profile.lib' ,
286+ '"<(clang_profile_lib)"' ,
287+ ],
288+ },
289+ },
290+ },],
291+ ['enable_pgo_use=="true"' , {
292+ 'msvs_settings' : {
293+ 'VCCLCompilerTool' : {
294+ 'AdditionalOptions' : ['-fprofile-use=$(SolutionDir)node.profdata' ],
295+ },
296+ 'VCLinkerTool' : {
297+ 'AdditionalOptions' : ['-fprofile-use=$(SolutionDir)node.profdata' ],
298+ },
299+ },
300+ },],
301+ ],
292302 },],
293303 ],
294304 },],
Original file line number Diff line number Diff line change @@ -1940,6 +1940,24 @@ def configure_node(o):
19401940 o ['variables' ]['enable_pgo_generate' ] = b (options .enable_pgo_generate )
19411941 o ['variables' ]['enable_pgo_use' ] = b (options .enable_pgo_use )
19421942
1943+ if flavor == 'win' and (options .enable_pgo_generate or options .enable_pgo_use ):
1944+ lib_suffix = 'aarch64' if target_arch == 'arm64' else 'x86_64'
1945+ lib_name = f'clang_rt.profile-{ lib_suffix } .lib'
1946+ msvc_dir = target_arch # 'x64' or 'arm64'
1947+
1948+ vc_tools_dir = os .environ .get ('VCToolsInstallDir' , '' )
1949+ if vc_tools_dir :
1950+ clang_profile_lib = os .path .join (vc_tools_dir , 'lib' , msvc_dir , lib_name )
1951+ if os .path .isfile (clang_profile_lib ):
1952+ o ['variables' ]['clang_profile_lib' ] = clang_profile_lib
1953+ else :
1954+ raise Exception (
1955+ f'PGO profile runtime library not found at { clang_profile_lib } . '
1956+ 'Ensure the ClangCL toolset is installed.' )
1957+ else :
1958+ raise Exception (
1959+ 'VCToolsInstallDir not set. Run from a Visual Studio command prompt.' )
1960+
19431961 if flavor != 'win' and options .enable_thin_lto :
19441962 raise Exception (
19451963 'Use --enable-lto instead.' )
You can’t perform that action at this time.
0 commit comments