Skip to content

Commit

Permalink
Add initial build support for ppc64le (OpenPOWER) systems
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
  • Loading branch information
madscientist159 authored and Raptor Engineering Development Team committed Apr 21, 2023
1 parent 014b74b commit 6023660
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 10 deletions.
8 changes: 8 additions & 0 deletions README.OPENPOWER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Due to unilateral tooling decisions at Google, building on a fully open source platform requires a few extra packages:

* For Debian:
- ninja-build
- generate-ninja
- clang
- llvm
- lld
8 changes: 7 additions & 1 deletion build.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ core_windows {
desktop:CONFIG += core_and_multimedia
}
core_linux {
desktop:CONFIG += core_and_multimedia
linux-g++:contains(QMAKE_HOST.arch, ppc64le): {
CONFIG += no_use_htmlfileinternal
CONFIG += no_desktop_apps
}
else {
CONFIG += core_and_multimedia
}
}
core_mac {
CONFIG += no_desktop_apps
Expand Down
13 changes: 13 additions & 0 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
import deploy
import make_common
import develop
import os
import platform

# set up environment
if "ppc64" in platform.machine():
# PhantomJS has been ignoring requests to support non-Intel machines upstream,
# (issues #15432, #14421, #13708) so we have to use the distro version. The
# distro version in turn fails if there is no X server available and this
# environment variable is not set, so set it here...
os.environ["QT_QPA_PLATFORM"] = "offscreen"

# Debian builds libpng without VSX support for some reason (bug #959487)
os.environ["CFLAGS"] = "-DPNG_POWERPC_VSX_OPT=0"

# parse configuration
config.parse()
Expand Down
2 changes: 1 addition & 1 deletion scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def parse():

if check_option("platform", "native"):
bits = "32"
if platform.machine().endswith('64'):
if platform.machine().endswith('64') or platform.machine().endswith('64le'):
bits = "64"
if ("windows" == host_platform):
options["platform"] += (" win_" + bits)
Expand Down
5 changes: 4 additions & 1 deletion scripts/core_common/make_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import base
import glob

import platform

import boost
import cef
import icu
Expand Down Expand Up @@ -35,7 +37,8 @@ def make():
check_android_ndk_macos_arm(toolchain + "/prebuilt")

boost.make()
cef.make()
if "ppc64" not in platform.machine():
cef.make()
icu.make()
openssl.make()
v8.make()
Expand Down
34 changes: 34 additions & 0 deletions scripts/core_common/modules/v8.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import base
import os
import subprocess
import platform
import v8_89

def clean():
Expand Down Expand Up @@ -100,6 +101,9 @@ def make():

os.environ["PATH"] = base_dir + "/depot_tools" + os.pathsep + os.environ["PATH"]

if "ppc64" in platform.machine():
os.environ["VPYTHON_BYPASS"] = "manually managed python not supported by chrome operations"

if not base.is_dir("v8/out.gn"):
base.cmd("gclient")

Expand Down Expand Up @@ -130,6 +134,8 @@ def make():
if ("linux" == base.host_platform()):
if base.is_dir("v8/third_party/binutils/Linux_x64/Release"):
base.delete_dir("v8/third_party/binutils/Linux_x64/Release")
if base.is_dir("v8/third_party/binutils/Linux_ppc64/Release"):
base.delete_dir("v8/third_party/binutils/Linux_ppc64/Release")
if base.is_dir("v8/third_party/binutils/Linux_ia32/Release"):
base.delete_dir("v8/third_party/binutils/Linux_ia32/Release")

Expand All @@ -142,6 +148,13 @@ def make():
base.cmd("mv", ["v8/third_party/binutils/Linux_x64/Release/bin/" + name, "v8/third_party/binutils/Linux_x64/Release/bin/old_" + name])
base.cmd("ln", ["-s", "/usr/bin/" + name, "v8/third_party/binutils/Linux_x64/Release/bin/" + name])

if base.is_dir("v8/third_party/binutils/Linux_ppc64/Release/bin"):
for file in os.listdir("v8/third_party/binutils/Linux_ppc64/Release/bin"):
name = file.split("/")[-1]
if ("ld.gold" != name):
base.cmd("mv", ["v8/third_party/binutils/Linux_ppc64/Release/bin/" + name, "v8/third_party/binutils/Linux_ppc64/Release/bin/old_" + name])
base.cmd("ln", ["-s", "/usr/bin/" + name, "v8/third_party/binutils/Linux_ppc64/Release/bin/" + name])

if base.is_dir("v8/third_party/binutils/Linux_ia32/Release/bin"):
for file in os.listdir("v8/third_party/binutils/Linux_ia32/Release/bin"):
name = file.split("/")[-1]
Expand All @@ -160,11 +173,32 @@ def make():
base.delete_dir("v8/third_party/llvm-build/Release+Asserts/include")
base.replaceInFile("v8/build/config/mac/BUILD.gn", "\"-mmacosx-version-min=$mac_deployment_target\",", "\"-mmacosx-version-min=$mac_deployment_target\",\n \"-Wno-deprecated-declarations\",")

if "ppc64" in platform.machine():
# Google's gn and ninja binaries won't work, they're x86 only by Google fiat.
# Remove them and use the system binaries...
try:
os.remove(base_dir + "/depot_tools/gn")
except:
pass
try:
os.remove(base_dir + "/depot_tools/ninja")
except:
pass

# Apply ppc64-specific build system patches
base.cmd_in_dir("./v8", "git", ["reset", "--hard", "HEAD"])
base.cmd_in_dir("./v8/build", "git", ["reset", "--hard", "HEAD"])
base.cmd_in_dir("./v8", "patch", ["-p1", "-i", "../v8_ppc64/add_clang_target.diff"])

# --------------------------------------------------------------------------
# build
os.chdir("v8")

base_args64 = "target_cpu=\\\"x64\\\" v8_target_cpu=\\\"x64\\\" v8_static_library=true is_component_build=false v8_use_snapshot=false"
if "ppc64le" in platform.machine():
base_args64 = "target_cpu=\\\"ppc64\\\" v8_target_cpu=\\\"ppc64\\\" v8_static_library=true v8_enable_pointer_compression=true is_component_build=false v8_use_snapshot=false clang_base_path=\\\"/usr\\\" clang_use_chrome_plugins=false"
else:
base_args64 = "target_cpu=\\\"x64\\\" v8_target_cpu=\\\"x64\\\" v8_static_library=true is_component_build=false v8_use_snapshot=false"
base_args32 = "target_cpu=\\\"x86\\\" v8_target_cpu=\\\"x86\\\" v8_static_library=true is_component_build=false v8_use_snapshot=false"

if config.check_option("platform", "linux_64"):
Expand Down
35 changes: 29 additions & 6 deletions scripts/core_common/modules/v8_89.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,41 @@
import base
import os
import subprocess
import platform

def make_args(args, platform, is_64=True, is_debug=False):
def make_args(args, os_platform, is_64=True, is_debug=False):
args_copy = args[:]
if is_64:
if "ppc64le" in platform.machine():
args_copy.append("target_cpu=\\\"ppc64\\\"")
args_copy.append("v8_target_cpu=\\\"ppc64\\\"")
args_copy.append("v8_static_library=true")
args_copy.append("v8_enable_pointer_compression=true")
args_copy.append("is_component_build=false")
args_copy.append("clang_base_path=\\\"/usr\\\" clang_use_chrome_plugins=false")
elif is_64:
args_copy.append("target_cpu=\\\"x64\\\"")
args_copy.append("v8_target_cpu=\\\"x64\\\"")
else:
args_copy.append("target_cpu=\\\"x86\\\"")
args_copy.append("v8_target_cpu=\\\"x86\\\"")

if (platform == "linux_arm64"):
if (os_platform == "linux_arm64"):
args_copy = args[:]
args_copy.append("target_cpu=\\\"arm64\\\"")
args_copy.append("v8_target_cpu=\\\"arm64\\\"")
args_copy.append("use_sysroot=true")

if is_debug:
args_copy.append("is_debug=true")
if (platform == "windows"):
if (os_platform == "windows"):
args_copy.append("enable_iterator_debugging=true")
else:
args_copy.append("is_debug=false")

if (platform == "linux"):
if (os_platform == "linux"):
args_copy.append("is_clang=true")
args_copy.append("use_sysroot=false")
if (platform == "windows"):
if (os_platform == "windows"):
args_copy.append("is_clang=false")

return "--args=\"" + " ".join(args_copy) + "\""
Expand Down Expand Up @@ -88,6 +96,9 @@ def make():

os.environ["PATH"] = base_dir + "/depot_tools" + os.pathsep + os.environ["PATH"]

if "ppc64" in platform.machine():
os.environ["VPYTHON_BYPASS"] = "manually managed python not supported by chrome operations"

if ("windows" == base.host_platform()):
base.set_env("DEPOT_TOOLS_WIN_TOOLCHAIN", "0")
base.set_env("GYP_MSVS_VERSION", config.option("vs-version"))
Expand All @@ -109,6 +120,18 @@ def make():
if not base.is_file("v8/src/base/platform/wrappers.cc"):
base.writeFile("v8/src/base/platform/wrappers.cc", "#include \"src/base/platform/wrappers.h\"\n")

if "ppc64" in platform.machine():
# Google's gn and ninja binaries won't work, they're x86 only by Google fiat.
# Remove them and use the system binaries...
try:
os.remove(base_dir + "/depot_tools/gn")
except:
pass
try:
os.remove(base_dir + "/depot_tools/ninja")
except:
pass

os.chdir("v8")

gn_args = ["v8_static_library=true",
Expand Down
4 changes: 3 additions & 1 deletion tools/linux/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import base
import os
import subprocess
import platform

def install_deps():
if base.is_file("./packages_complete"):
Expand Down Expand Up @@ -60,7 +61,8 @@ def install_deps():
if (base.is_dir("./node_js_setup_10.x")):
base.delete_dir("./node_js_setup_10.x")
base.cmd("sudo", ["apt-get", "remove", "--purge", "-y", "nodejs"])
base.download("https://deb.nodesource.com/setup_10.x", "./node_js_setup_10.x")
if "ppc64le" not in platform.machine():
base.download("https://deb.nodesource.com/setup_10.x", "./node_js_setup_10.x")
base.cmd('curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -')
base.cmd("sudo", ["bash", "./node_js_setup_10.x"])
base.cmd("sudo", ["apt-get", "install", "-y", "nodejs"])
Expand Down

0 comments on commit 6023660

Please sign in to comment.