aboutsummaryrefslogtreecommitdiff
path: root/ports/v8/build.patch
diff options
context:
space:
mode:
Diffstat (limited to 'ports/v8/build.patch')
-rw-r--r--ports/v8/build.patch179
1 files changed, 179 insertions, 0 deletions
diff --git a/ports/v8/build.patch b/ports/v8/build.patch
new file mode 100644
index 000000000..7394c6591
--- /dev/null
+++ b/ports/v8/build.patch
@@ -0,0 +1,179 @@
+diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn
+index 5a0984f54..4f301517b 100644
+--- a/config/compiler/BUILD.gn
++++ b/config/compiler/BUILD.gn
+@@ -1473,6 +1473,8 @@ config("default_warnings") {
+ # Disables.
+ "-Wno-missing-field-initializers", # "struct foo f = {0};"
+ "-Wno-unused-parameter", # Unused function parameters.
++ "-Wno-invalid-offsetof", # Use of "conditionally-supported" offsetof in c++17
++ "-Wno-range-loop-construct",
+ ]
+ }
+
+@@ -1887,11 +1889,21 @@ config("no_incompatible_pointer_warnings") {
+ # Shared settings for both "optimize" and "optimize_max" configs.
+ # IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
+ if (is_win) {
+- common_optimize_on_cflags = [
++ common_optimize_on_cflags = []
++ if(is_clang) {
++ common_optimize_on_cflags += [
+ "/Ob2", # Both explicit and auto inlining.
++ ]
++ } else {
++ common_optimize_on_cflags += [
++ "/Ob3", # Both explicit and auto inlining.
++ ]
++ }
++ common_optimize_on_cflags += [
+ "/Oy-", # Disable omitting frame pointers, must be after /O2.
+ "/Zc:inline", # Remove unreferenced COMDAT (faster links).
+ ]
++
+ if (!is_asan) {
+ common_optimize_on_cflags += [
+ # Put data in separate COMDATs. This allows the linker
+diff --git a/config/linux/pkg-config.py b/config/linux/pkg-config.py
+index 5adf70cc3..1438c365b 100644
+--- a/config/linux/pkg-config.py
++++ b/config/linux/pkg-config.py
+@@ -41,7 +41,11 @@ from optparse import OptionParser
+ # Additionally, you can specify the option --atleast-version. This will skip
+ # the normal outputting of a dictionary and instead print true or false,
+ # depending on the return value of pkg-config for the given package.
+-
++#
++# --pkg_config_libdir=<path> allows direct override
++# of the PKG_CONFIG_LIBDIR environment library.
++#
++# --full-path-libs causes lib names to include their full path.
+
+ def SetConfigPath(options):
+ """Set the PKG_CONFIG_LIBDIR environment variable.
+@@ -105,11 +109,29 @@ def RewritePath(path, strip_prefix, sysroot):
+ return path
+
+
++flag_regex = re.compile("(-.)(.+)")
++
++def FlagReplace(matchobj):
++ if matchobj.group(1) == '-I':
++ return matchobj.group(1) + subprocess.check_output([u'cygpath',u'-w',matchobj.group(2)]).strip().decode("utf-8")
++ if matchobj.group(1) == '-L':
++ return matchobj.group(1) + subprocess.check_output([u'cygpath',u'-w',matchobj.group(2)]).strip().decode("utf-8")
++ if matchobj.group(1) == '-l':
++ return matchobj.group(1) + matchobj.group(2) + '.lib'
++ return matchobj.group(0)
++
++def ConvertGCCToMSVC(flags):
++ """Rewrites GCC flags into MSVC flags."""
++ if 'win32' not in sys.platform:
++ return flags
++ return [ flag_regex.sub(FlagReplace,flag) for flag in flags]
++
++
+ def main():
+ # If this is run on non-Linux platforms, just return nothing and indicate
+ # success. This allows us to "kind of emulate" a Linux build from other
+ # platforms.
+- if "linux" not in sys.platform:
++ if "linux" not in sys.platform and 'win32' not in sys.platform:
+ print("[[],[],[],[],[]]")
+ return 0
+
+@@ -122,12 +144,15 @@ def main():
+ parser.add_option('-a', action='store', dest='arch', type='string')
+ parser.add_option('--system_libdir', action='store', dest='system_libdir',
+ type='string', default='lib')
++ parser.add_option('--pkg_config_libdir', action='store', dest='pkg_config_libdir',
++ type='string')
+ parser.add_option('--atleast-version', action='store',
+ dest='atleast_version', type='string')
+ parser.add_option('--libdir', action='store_true', dest='libdir')
+ parser.add_option('--dridriverdir', action='store_true', dest='dridriverdir')
+ parser.add_option('--version-as-components', action='store_true',
+ dest='version_as_components')
++ parser.add_option('--full-path-libs', action='store_true', dest='full_path_libs')
+ (options, args) = parser.parse_args()
+
+ # Make a list of regular expressions to strip out.
+@@ -144,6 +169,10 @@ def main():
+ else:
+ prefix = ''
+
++ # Override PKG_CONFIG_LIBDIR
++ if options.pkg_config_libdir:
++ os.environ['PKG_CONFIG_LIBDIR'] = options.pkg_config_libdir
++
+ if options.atleast_version:
+ # When asking for the return value, just run pkg-config and print the return
+ # value, no need to do other work.
+@@ -203,7 +232,7 @@ def main():
+ # For now just split on spaces to get the args out. This will break if
+ # pkgconfig returns quoted things with spaces in them, but that doesn't seem
+ # to happen in practice.
+- all_flags = flag_string.strip().split(' ')
++ all_flags = ConvertGCCToMSVC(flag_string.strip().split(' '))
+
+
+ sysroot = options.sysroot
+@@ -220,7 +249,10 @@ def main():
+ continue;
+
+ if flag[:2] == '-l':
+- libs.append(RewritePath(flag[2:], prefix, sysroot))
++ library = RewritePath(flag[2:], prefix, sysroot)
++ # Skip math library on MSVC
++ if library != 'm.lib':
++ libs.append(library)
+ elif flag[:2] == '-L':
+ lib_dirs.append(RewritePath(flag[2:], prefix, sysroot))
+ elif flag[:2] == '-I':
+@@ -237,6 +269,14 @@ def main():
+ else:
+ cflags.append(flag)
+
++ if options.full_path_libs:
++ full_path_libs = []
++ for lib_dir in lib_dirs:
++ for lib in libs:
++ if os.path.isfile(lib_dir+"/"+lib):
++ full_path_libs.append(lib_dir+"/"+lib)
++ libs = full_path_libs
++
+ # Output a GN array, the first one is the cflags, the second are the libs. The
+ # JSON formatter prints GN compatible lists when everything is a list of
+ # strings.
+diff --git a/config/linux/pkg_config.gni b/config/linux/pkg_config.gni
+index 428e44ac0..a0d2175ee 100644
+--- a/config/linux/pkg_config.gni
++++ b/config/linux/pkg_config.gni
+@@ -45,6 +45,9 @@ declare_args() {
+ # in similar fashion by setting the `system_libdir` variable in the build's
+ # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture.
+ system_libdir = "lib"
++
++ # Allow directly overriding the PKG_CONFIG_LIBDIR enviroment variable
++ pkg_config_libdir = ""
+ }
+
+ pkg_config_script = "//build/config/linux/pkg-config.py"
+@@ -87,6 +90,17 @@ if (host_pkg_config != "") {
+ host_pkg_config_args = pkg_config_args
+ }
+
++if (pkg_config_libdir != "") {
++ pkg_config_args += [
++ "--pkg_config_libdir",
++ pkg_config_libdir,
++ ]
++ host_pkg_config_args += [
++ "--pkg_config_libdir",
++ pkg_config_libdir,
++ ]
++}
++
+ template("pkg_config") {
+ assert(defined(invoker.packages),
+ "Variable |packages| must be defined to be a list in pkg_config.")