Skip to content

Commit

Permalink
Linux arm64 support (#6927)
Browse files Browse the repository at this point in the history
* linux arm64 support
  • Loading branch information
mihaiplesa authored Mar 14, 2021
1 parent 0f6cfbf commit 5a76a8c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
11 changes: 9 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ hooks = [
'action': ['vpython3', 'script/download_rust_deps.py', '--platform', 'ios'],
},
{
# Download rust deps if necessary for Linux, macOS, Windows
# Download rust deps if necessary for Linux
'name': 'download_rust_deps',
'pattern': '.',
'condition': 'not checkout_android and not checkout_ios',
'condition': 'checkout_linux',
'action': ['vpython3', 'script/download_rust_deps.py', '--platform', 'linux'],
},
{
# Download rust deps if necessary for the other platforms (macOS and Windows)
'name': 'download_rust_deps',
'pattern': '.',
'condition': 'not checkout_android and not checkout_ios and not checkout_linux',
'action': ['vpython3', 'script/download_rust_deps.py'],
},
{
Expand Down
8 changes: 8 additions & 0 deletions build/rust/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ if (is_win) {
rust_flags += " -C link-arg=--sysroot=$target_sysroot "
rust_flags += " -C link-arg=-Wl,-rpath=\$ORIGIN "
}
} else if (current_cpu == "arm64") {
rustc_target = "aarch64-unknown-linux-gnu"
rustc_toolchain = "arm64"
rust_flags += " -C linker=aarch64-linux-gnu-gcc "
if (use_sysroot) {
rust_flags += " -C link-arg=--sysroot=$target_sysroot "
rust_flags += " -C link-arg=-Wl,-rpath=\$ORIGIN "
}
}
} else if (is_android) {
if (current_cpu == "arm") {
Expand Down
25 changes: 25 additions & 0 deletions script/download_rust_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@ def make_standalone_toolchain_for_android():
fp.close()


def get_linux_target(target_arch):
return {
'arm64': 'aarch64-linux',
'x86_64': 'x86_64-linux',
}[target_arch]


def get_linux_linker(target_arch):
return get_linux_target(target_arch) + "-gnu-gcc"


def make_rustup_config_for_linux():
config_path = os.path.join(RUSTUP_HOME, 'config')
fp = open(config_path, "w+")

for target_arch in ['arm64', 'x86_64']:
# Add target to rustup config
fp.write("[target." + get_linux_target(target_arch) + "]\r\n")
fp.write("linker = \"" + get_linux_linker(target_arch) + "\"\r\n")

fp.close()


def parse_args():
parser = argparse.ArgumentParser(description='Download rust deps')

Expand Down Expand Up @@ -171,6 +194,8 @@ def main():

if args.platform == 'android':
make_standalone_toolchain_for_android()
elif args.platform == 'linux':
make_rustup_config_for_linux()

tools = [
{
Expand Down

0 comments on commit 5a76a8c

Please sign in to comment.