Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit c4bca8f

Browse files
author
Trung Lê
committed
Support linux ppc64le
1 parent fcf04ce commit c4bca8f

File tree

4 files changed

+105
-7
lines changed

4 files changed

+105
-7
lines changed

.travis.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
dist: xenial
1+
dist: bionic
22
compiler: clang
33
language: ruby
44
rvm:
5-
- 2.7
65
- 2.6
7-
- 2.5
86
matrix:
97
include:
108
- rvm: 2.6
11-
os: osx
12-
osx_image: xcode9.4.1
9+
arch: ppc64le
1310
fast_finish: true
1411
addons:
1512
apt:
1613
packages:
1714
- clang
1815
- pkg-config
16+
- python3.8
17+
- python2.7
1918
bundler_args: --jobs=4 --retry=3
2019
before_install:
2120
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then gem update bundler; fi

ext/libv8/arch.rb

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module Arch
66

77
def libv8_arch
88
case Gem::Platform.local.cpu
9+
when /^powerpc64/ then 'ppc64'
910
when /^arm(v6.*|v7.*)*$/ then 'arm'
1011
when /^a(rm|arch)64$/ then 'arm64'
1112
when /^x86$/ then 'ia32'

ext/libv8/builder.rb

+76-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
unless $:.include? File.expand_path("../../../lib", __FILE__)
22
$:.unshift File.expand_path("../../../lib", __FILE__)
33
end
4+
require 'fileutils'
45
require 'mkmf'
56
require 'rbconfig'
67
require 'shellwords'
@@ -35,8 +36,11 @@ def debug_build?
3536
end
3637

3738
def build_libv8!
39+
setup_depot_tools!
3840
setup_python!
3941
setup_build_deps!
42+
setup_ninja!
43+
setup_gn!
4044
Dir.chdir(File.expand_path('../../../vendor/v8', __FILE__)) do
4145
puts 'Beginning compilation. This will take some time.'
4246
generate_gn_args
@@ -46,6 +50,10 @@ def build_libv8!
4650
return $?.exitstatus
4751
end
4852

53+
def setup_depot_tools!
54+
ENV['PATH'] = "#{File.expand_path('../../../vendor/depot_tools', __FILE__)}:#{ENV['PATH']}"
55+
end
56+
4957
def setup_python!
5058
# If python v2 cannot be found in PATH,
5159
# create a symbolic link to python2 the current directory and put it
@@ -58,6 +66,19 @@ def setup_python!
5866
`ln -fs #{`which python2`.chomp} python`
5967
ENV['PATH'] = "#{File.expand_path '.'}:#{ENV['PATH']}"
6068
end
69+
70+
if arch_ppc64?
71+
unless system 'which python3 2>&1 > /dev/null'
72+
fail "libv8 requires python 3 to be installed in order to build"
73+
end
74+
75+
# Because infra/3pp/tools/cpython3/linux-ppc64le@version:3.8.0.chromium.8 CIPD is not yet available
76+
# fallback to host's python3
77+
ENV['VPYTHON_BYPASS'] = 'manually managed python not supported by chrome operations'
78+
79+
# stub the CIPD cpython3 with host's python3
80+
FileUtils.symlink(`which python3`.chomp, File.expand_path("../../../vendor/depot_tools/python3", __FILE__), force: true)
81+
end
6182
end
6283

6384
##
@@ -75,8 +96,6 @@ def source_version
7596
# https://chromium.googlesource.com/v8/v8.git#Getting-the-Code
7697
#
7798
def setup_build_deps!
78-
ENV['PATH'] = "#{File.expand_path('../../../vendor/depot_tools', __FILE__)}:#{ENV['PATH']}"
79-
8099
Dir.chdir(File.expand_path('../../../vendor', __FILE__)) do
81100
unless Dir.exists?('v8') || File.exists?('.gclient')
82101
system "fetch v8" or fail "unable to fetch v8 source"
@@ -92,8 +111,63 @@ def setup_build_deps!
92111
end
93112
end
94113

114+
##
115+
# Build ninja for linux ppc64le
116+
#
117+
def setup_ninja!
118+
return unless arch_ppc64?
119+
120+
ninja_filepath = File.expand_path("../../../vendor/depot_tools/ninja-linux-ppc64le", __FILE__)
121+
return if File.exists?(ninja_filepath)
122+
123+
Dir.chdir("/tmp") do
124+
FileUtils.rm_rf("ninja")
125+
system "git clone https://github.com/ninja-build/ninja.git -b v1.8.2" or fail "unable to git clone ninja repository"
126+
end
127+
128+
Dir.chdir("/tmp/ninja") do
129+
system "python2 ./configure.py --bootstrap" or fail "unable to build ninja"
130+
FileUtils.mv(File.expand_path("#{Dir.pwd}/ninja"), ninja_filepath)
131+
end
132+
133+
patch_filepath = File.expand_path("../../../vendor/patches/0001-support-ninja-ppc64le.patch", __FILE__)
134+
Dir.chdir(File.expand_path('../../../vendor/depot_tools', __FILE__)) do
135+
system "patch -p1 < #{patch_filepath}" or fail "unable to patch depot_tools/ninja"
136+
end
137+
end
138+
139+
##
140+
# Build gn for linux ppc64le
141+
# Upstream issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1076455
142+
# TODO: Remove once upstream has supported ppc64le
143+
#
144+
def setup_gn!
145+
return unless arch_ppc64?
146+
147+
gn_filepath = File.expand_path("../../../vendor/depot_tools/gn-linux-ppc64le", __FILE__)
148+
return if File.exists?(gn_filepath)
149+
150+
Dir.chdir("/tmp") do
151+
FileUtils.rm_rf("gn")
152+
system "git clone https://gn.googlesource.com/gn" or fail "unable to git clone gn repository"
153+
end
154+
155+
Dir.chdir("/tmp/gn") do
156+
system "python2 build/gen.py"
157+
fail "unable to prepare gn for compilation" unless File.exists?(File.expand_path("#{Dir.pwd}/out/build.ninja"))
158+
system "ninja -C out" or fail "unable to build gn"
159+
FileUtils.mv(File.expand_path("#{Dir.pwd}/out/gn"), gn_filepath)
160+
FileUtils.rm_f(File.expand_path("../../../vendor/depot_tools/gn", __FILE__))
161+
FileUtils.symlink(gn_filepath, File.expand_path("../../../vendor/depot_tools/gn", __FILE__), force: true)
162+
end
163+
end
164+
95165
private
96166

167+
def arch_ppc64?
168+
libv8_arch == "ppc64"
169+
end
170+
97171
def python_version
98172
if system 'which python 2>&1 > /dev/null'
99173
`python -c 'import platform; print(platform.python_version())'`.chomp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
From 88070442df48a857460a68d065957d0f7efc5468 Mon Sep 17 00:00:00 2001
2+
From: Trung LE <[email protected]>
3+
Date: Sun, 8 Mar 2020 07:46:10 +0000
4+
Subject: [PATCH] Support ninja ppc64le
5+
6+
---
7+
ninja | 2 ++
8+
1 file changed, 2 insertions(+)
9+
10+
diff --git a/ninja b/ninja
11+
index 1a650b54..eb146a4b 100755
12+
--- a/ninja
13+
+++ b/ninja
14+
@@ -28,6 +28,8 @@ case "$OS" in
15+
# bittage of the userspace install (e.g. when running 32-bit userspace
16+
# on x86_64 kernel)
17+
exec "${THIS_DIR}/ninja-linux${LONG_BIT}" "$@";;
18+
+ ppc64le)
19+
+ exec "${THIS_DIR}/ninja-linux-ppc64le" "$@";;
20+
*)
21+
echo Unknown architecture \($MACHINE\) -- unable to run ninja.
22+
print_help
23+
--
24+
2.17.1

0 commit comments

Comments
 (0)