Skip to content

Commit 3f554ee

Browse files
danakjAravind Vasudevan
authored andcommitted
Pull OpenSSL pre-built libraries from 3pp for the Rust toolchain
Do this on Linux as well, to match what we'll do on Mac even though OpenSSL is already available. Windows binaries are needed before we can avoid using the OpenSSL library that is passively present on the system. Bug: 1271215, 1386212 Change-Id: Ieaac749a9516c56b9da98c9b921fcb689b57fd6d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4234717 Reviewed-by: Hans Wennborg <[email protected]> Commit-Queue: danakj <[email protected]> Cr-Commit-Position: refs/heads/main@{#1103332} NOKEYCHECK=True GitOrigin-RevId: 6f327868359dd670cb670ccc83bdffb61069ddff
1 parent 23db868 commit 3f554ee

File tree

1 file changed

+50
-6
lines changed

1 file changed

+50
-6
lines changed

build_rust.py

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@
5353
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'clang',
5454
'scripts'))
5555

56-
from build import (AddCMakeToPath, AddOpenSSLToEnv, AddZlibToPath,
57-
CheckoutGitRepo, GetLibXml2Dirs, LLVM_BUILD_TOOLS_DIR,
58-
RunCommand)
56+
from build import (AddCMakeToPath, AddZlibToPath, CheckoutGitRepo,
57+
GetLibXml2Dirs, LLVM_BUILD_TOOLS_DIR, RunCommand)
5958
from update import (CLANG_REVISION, CLANG_SUB_REVISION, DownloadAndUnpack,
6059
LLVM_BUILD_DIR, GetDefaultHostOs, RmTree, UpdatePackage)
6160
import build
@@ -100,6 +99,24 @@
10099
os.path.dirname(os.path.abspath(__file__)), 'cargo-config.toml.template')
101100
RUST_SRC_VENDOR_DIR = os.path.join(RUST_SRC_DIR, 'vendor')
102101

102+
# CIPD Versions from:
103+
# - List all platforms
104+
# cipd ls infra/3pp/static_libs/openssl/
105+
# - Find all versions for a platform
106+
# cipd instances infra/3pp/static_libs/openssl/linux-amd64
107+
# - Find the version tag for a version
108+
# cipd desc infra/3pp/static_libs/openssl/linux-amd64 --version <instance id>
109+
# - A version tag looks like: `version:[email protected]` and we
110+
# store the part after the `2@` here.
111+
CIPD_DOWNLOAD_URL = f'https://chrome-infra-packages.appspot.com/dl'
112+
OPENSSL_CIPD_LINUX_AMD_PATH = 'infra/3pp/static_libs/openssl/linux-amd64'
113+
OPENSSL_CIPD_LINUX_AMD_VERSION = '1.1.1j.chromium.2'
114+
OPENSSL_CIPD_MAC_AMD_PATH = 'infra/3pp/static_libs/openssl/mac-amd64'
115+
OPENSSL_CIPD_MAC_AMD_VERSION = '1.1.1j.chromium.2'
116+
OPENSSL_CIPD_MAC_ARM_PATH = 'infra/3pp/static_libs/openssl/mac-amd64'
117+
OPENSSL_CIPD_MAC_ARM_VERSION = '1.1.1j.chromium.2'
118+
# TODO(crbug.com/1271215): Pull Windows OpenSSL from 3pp when it exists.
119+
103120
if sys.platform == 'win32':
104121
LD_PATH_FLAG = '/LIBPATH:'
105122
else:
@@ -119,6 +136,31 @@
119136
]
120137

121138

139+
def AddOpenSSLToEnv(build_mac_arm):
140+
"""Download OpenSSL, and add to OPENSSL_DIR."""
141+
ssl_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'openssl')
142+
143+
if sys.platform == 'darwin':
144+
if platform.machine() == 'arm64' or build_mac_arm:
145+
ssl_url = (f'{CIPD_DOWNLOAD_URL}/{OPENSSL_CIPD_MAC_ARM_PATH}'
146+
f'/+/version:2@{OPENSSL_CIPD_MAC_ARM_VERSION}')
147+
else:
148+
ssl_url = (f'{CIPD_DOWNLOAD_URL}/{OPENSSL_CIPD_MAC_AMD_PATH}'
149+
f'/+/version:2@{OPENSSL_CIPD_MAC_AMD_VERSION}')
150+
elif sys.platform == 'win32':
151+
ssl_url = (f'{CIPD_DOWNLOAD_URL}/{OPENSSL_CIPD_WIN_AMD_PATH}'
152+
f'/+/version:2@{OPENSSL_CIPD_WIN_AMD_VERSION}')
153+
else:
154+
ssl_url = (f'{CIPD_DOWNLOAD_URL}/{OPENSSL_CIPD_LINUX_AMD_PATH}'
155+
f'/+/version:2@{OPENSSL_CIPD_LINUX_AMD_VERSION}')
156+
157+
if os.path.exists(ssl_dir):
158+
RmTree(ssl_dir)
159+
DownloadAndUnpack(ssl_url, ssl_dir, is_known_zip=True)
160+
os.environ['OPENSSL_DIR'] = ssl_dir
161+
return ssl_dir
162+
163+
122164
def VerifyStage0JsonHash():
123165
hasher = hashlib.sha256()
124166
with open(STAGE0_JSON_PATH, 'rb') as input:
@@ -486,9 +528,11 @@ def main():
486528
else:
487529
libxml2_dirs = None
488530

489-
# Cargo requires OpenSSL to build, and it's not already present on Mac
490-
# builders.
491-
if sys.platform == 'darwin':
531+
# TODO(crbug.com/1271215): OpenSSL is somehow already present on the Windows
532+
# builder, but we should change to using a package from 3pp when it is
533+
# available.
534+
if sys.platform != 'win32':
535+
# Cargo depends on OpenSSL.
492536
AddOpenSSLToEnv(args.build_mac_arm)
493537

494538
if args.run_xpy:

0 commit comments

Comments
 (0)