|
132 | 132 | "JavaScript code executed in nodejs. This feature is only available " |
133 | 133 | "for x32, x86, and x64 architectures.") |
134 | 134 |
|
| 135 | +parser.add_option("--enable-pgo-generate", |
| 136 | + action="store_true", |
| 137 | + dest="enable_pgo_generate", |
| 138 | + help="Enable profiling with pgo of a binary. This feature is only available " |
| 139 | + "on linux with gcc and g++ 5.4.1 or newer.") |
| 140 | + |
| 141 | +parser.add_option("--enable-pgo-use", |
| 142 | + action="store_true", |
| 143 | + dest="enable_pgo_use", |
| 144 | + help="Enable use of the profile generated with --enable-pgo-generate. This " |
| 145 | + "feature is only available on linux with gcc and g++ 5.4.1 or newer.") |
| 146 | + |
135 | 147 | parser.add_option("--enable-lto", |
136 | 148 | action="store_true", |
137 | 149 | dest="enable_lto", |
138 | 150 | help="Enable compiling with lto of a binary. This feature is only available " |
139 | | - "on linux with gcc and g++.") |
| 151 | + "on linux with gcc and g++ 5.4.1 or newer.") |
140 | 152 |
|
141 | 153 | parser.add_option("--link-module", |
142 | 154 | action="append", |
@@ -887,6 +899,16 @@ def configure_mips(o): |
887 | 899 | o['variables']['mips_fpu_mode'] = options.mips_fpu_mode |
888 | 900 |
|
889 | 901 |
|
| 902 | +def gcc_version_ge(version_checked): |
| 903 | + for compiler in [(CC, 'c'), (CXX, 'c++')]: |
| 904 | + ok, is_clang, clang_version, compiler_version = \ |
| 905 | + try_check_compiler(compiler[0], compiler[1]) |
| 906 | + compiler_version_num = tuple(map(int, compiler_version)) |
| 907 | + if is_clang or compiler_version_num < version_checked: |
| 908 | + return False |
| 909 | + return True |
| 910 | + |
| 911 | + |
890 | 912 | def configure_node(o): |
891 | 913 | if options.dest_os == 'android': |
892 | 914 | o['variables']['OS'] = 'android' |
@@ -931,22 +953,41 @@ def configure_node(o): |
931 | 953 | else: |
932 | 954 | o['variables']['node_enable_v8_vtunejit'] = 'false' |
933 | 955 |
|
| 956 | + if flavor != 'linux' and (options.enable_pgo_generate or options.enable_pgo_use): |
| 957 | + raise Exception( |
| 958 | + 'The pgo option is supported only on linux.') |
| 959 | + |
| 960 | + if flavor == 'linux': |
| 961 | + if options.enable_pgo_generate or options.enable_pgo_use: |
| 962 | + version_checked = (5, 4, 1) |
| 963 | + if not gcc_version_ge(version_checked): |
| 964 | + version_checked_str = ".".join(map(str, version_checked)) |
| 965 | + raise Exception( |
| 966 | + 'The options --enable-pgo-generate and --enable-pgo-use ' |
| 967 | + 'are supported for gcc and gxx %s or newer only.' % (version_checked_str)) |
| 968 | + |
| 969 | + if options.enable_pgo_generate and options.enable_pgo_use: |
| 970 | + raise Exception( |
| 971 | + 'Only one of the --enable-pgo-generate or --enable-pgo-use options ' |
| 972 | + 'can be specified at a time. You would like to use ' |
| 973 | + '--enable-pgo-generate first, profile node, and then recompile ' |
| 974 | + 'with --enable-pgo-use') |
| 975 | + |
| 976 | + o['variables']['enable_pgo_generate'] = b(options.enable_pgo_generate) |
| 977 | + o['variables']['enable_pgo_use'] = b(options.enable_pgo_use) |
| 978 | + |
934 | 979 | if flavor != 'linux' and (options.enable_lto): |
935 | 980 | raise Exception( |
936 | 981 | 'The lto option is supported only on linux.') |
937 | 982 |
|
938 | 983 | if flavor == 'linux': |
939 | 984 | if options.enable_lto: |
940 | 985 | version_checked = (5, 4, 1) |
941 | | - for compiler in [(CC, 'c'), (CXX, 'c++')]: |
942 | | - ok, is_clang, clang_version, compiler_version = \ |
943 | | - try_check_compiler(compiler[0], compiler[1]) |
944 | | - compiler_version_num = tuple(map(int, compiler_version)) |
945 | | - if is_clang or compiler_version_num < version_checked: |
946 | | - version_checked_str = ".".join(map(str, version_checked)) |
947 | | - raise Exception( |
948 | | - 'The option --enable-lto is supported for gcc and gxx %s' |
949 | | - ' or newer only.' % (version_checked_str)) |
| 986 | + if not gcc_version_ge(version_checked): |
| 987 | + version_checked_str = ".".join(map(str, version_checked)) |
| 988 | + raise Exception( |
| 989 | + 'The option --enable-lto is supported for gcc and gxx %s' |
| 990 | + ' or newer only.' % (version_checked_str)) |
950 | 991 |
|
951 | 992 | o['variables']['enable_lto'] = b(options.enable_lto) |
952 | 993 |
|
|
0 commit comments