nodejs-20.1.0-support-clang-pgo.patch 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. diff -urp node-v20.1.0.orig/common.gypi node-v20.1.0/common.gypi
  2. --- node-v20.1.0.orig/common.gypi 2023-05-05 13:14:38.026479514 -0700
  3. +++ node-v20.1.0/common.gypi 2023-05-05 13:23:42.166490607 -0700
  4. @@ -165,8 +165,12 @@
  5. 'Release': {
  6. 'variables': {
  7. 'v8_enable_handle_zapping': 0,
  8. - 'pgo_generate': ' -fprofile-generate ',
  9. - 'pgo_use': ' -fprofile-use -fprofile-correction ',
  10. + 'pgo_generate_gcc': ' -fprofile-generate ',
  11. + 'pgo_use_gcc': ' -fprofile-use -fprofile-correction ',
  12. + 'pgo_generate_clang': ' -fprofile-generate=<(pgo_profile_dir) -mllvm -vp-counters-per-site=3 ',
  13. + 'pgo_generate_clang_ldflags': ' -fprofile-generate=<(pgo_profile_dir) ',
  14. + 'pgo_use_clang': ' -fprofile-use=<(pgo_profile_profdata) -mllvm -vp-counters-per-site=3 ',
  15. + 'pgo_use_clang_ldflags': ' -fprofile-use=<(pgo_profile_profdata) ',
  16. 'conditions': [
  17. ['node_shared != "true"', {
  18. 'MSVC_runtimeType': 0 # MultiThreaded (/MT)
  19. @@ -241,15 +245,27 @@
  20. # frames otherwise, even with --call-graph dwarf.
  21. 'cflags': [ '-fno-omit-frame-pointer' ],
  22. }],
  23. - ['OS=="linux"', {
  24. + ['OS=="linux" and llvm_version=="0.0"', {
  25. + 'conditions': [
  26. + ['enable_pgo_generate=="true"', {
  27. + 'cflags': ['<(pgo_generate_gcc)'],
  28. + 'ldflags': ['<(pgo_generate_gcc)'],
  29. + },],
  30. + ['enable_pgo_use=="true"', {
  31. + 'cflags': ['<(pgo_use_gcc)'],
  32. + 'ldflags': ['<(pgo_use_gcc)'],
  33. + },],
  34. + ],
  35. + },],
  36. + ['OS=="linux" and llvm_version!="0.0"', {
  37. 'conditions': [
  38. ['enable_pgo_generate=="true"', {
  39. - 'cflags': ['<(pgo_generate)'],
  40. - 'ldflags': ['<(pgo_generate)'],
  41. + 'cflags': ['<(pgo_generate_clang)'],
  42. + 'ldflags': ['<(pgo_generate_clang_ldflags)'],
  43. },],
  44. ['enable_pgo_use=="true"', {
  45. - 'cflags': ['<(pgo_use)'],
  46. - 'ldflags': ['<(pgo_use)'],
  47. + 'cflags': ['<(pgo_use_clang)'],
  48. + 'ldflags': ['<(pgo_use_clang_ldflags)'],
  49. },],
  50. ],
  51. },],
  52. Only in node-v20.1.0: common.gypi.orig
  53. diff -urp node-v20.1.0.orig/configure.py node-v20.1.0/configure.py
  54. --- node-v20.1.0.orig/configure.py 2023-05-05 13:14:38.026479514 -0700
  55. +++ node-v20.1.0/configure.py 2023-05-05 13:28:24.870496371 -0700
  56. @@ -1331,14 +1331,22 @@ def configure_node(o):
  57. raise Exception(
  58. 'The pgo option is supported only on linux.')
  59. + o['variables']['pgo_profile_dir'] = ""
  60. + o['variables']['pgo_profile_profdata'] = ""
  61. if flavor == 'linux':
  62. if options.enable_pgo_generate or options.enable_pgo_use:
  63. - version_checked = (5, 4, 1)
  64. - if not gcc_version_ge(version_checked):
  65. - version_checked_str = ".".join(map(str, version_checked))
  66. + gcc_version_checked = (5, 4, 1)
  67. + clang_version_checked = (3, 9, 1)
  68. + if not gcc_version_ge(gcc_version_checked) and not clang_version_ge(clang_version_checked):
  69. + gcc_version_checked_str = ".".join(map(str, gcc_version_checked))
  70. + clang_version_checked_str = ".".join(map(str, clang_version_checked))
  71. raise Exception(
  72. 'The options --enable-pgo-generate and --enable-pgo-use '
  73. - f'are supported for gcc and gxx {version_checked_str} or newer only.')
  74. + f'are supported for gcc and gxx {gcc_version_checked_str} or newer only'
  75. + f'or for clang and clang++ {clang_version_checked_str} or newer only.')
  76. + if clang_version_ge(clang_version_checked):
  77. + o['variables']['pgo_profile_dir'] = os.environ.get('PGO_PROFILE_DIR')
  78. + o['variables']['pgo_profile_profdata'] = os.environ.get('PGO_PROFILE_PROFDATA')
  79. if options.enable_pgo_generate and options.enable_pgo_use:
  80. raise Exception(
  81. Only in node-v20.1.0: configure.py.orig
  82. Only in node-v20.1.0: configure.py.rej